นี่คือรหัสสำหรับรับ CIs สำหรับการวิเคราะห์เมตาใน PLINK:
getCI = function(mn1, se1, method){
remov = c(0, NA)
mn = mn1[! mn1 %in% remov]
se = se1[! mn1 %in% remov]
vars <- se^2
vwts <- 1/vars
fixedsumm <- sum(vwts * mn)/sum(vwts)
Q <- sum(((mn - fixedsumm)^2)/vars)
df <- length(mn) - 1
tau2 <- max(0, (Q - df)/(sum(vwts) - sum(vwts^2)/sum(vwts)) )
if (method == "fixed"){ wt <- 1/vars } else { wt <- 1/(vars + tau2) }
summ <- sum(wt * mn)/sum(wt)
if (method == "fixed")
varsum <- sum(wt * wt * vars)/(sum(wt)^2)
else varsum <- sum(wt * wt * (vars + tau2))/(sum(wt)^2)
summtest <- summ/sqrt(varsum)
df <- length(vars) - 1
se.summary <- sqrt(varsum)
pval = 1 - pchisq(summtest^2,1)
pvalhet = 1 - pchisq(Q, df)
L95 = summ - 1.96*se.summary
U95 = summ + 1.96*se.summary
# out = c(round(c(summ,L95,U95),2), format(pval,scientific=TRUE), pvalhet)
# c("OR","L95","U95","p","ph")
# return(out)
out = c(paste(round(summ,3), ' [', round(L95,3), ', ', round(U95,3), ']', sep=""),
format(pval, scientific=TRUE), round(pvalhet,3))
# c("OR","L95","U95","p","ph")
return(out)
}
ฟังก์ชั่นการโทร R:
getCI(log(plinkORs), plinkSEs)