I used the following code to try and run an EWAS:
ewas <- cpg.assoc (betas, phenotype_final$independent_var, covariates)
And keep getting these error messages where it says all of the CpG sites were not able to be analyzed.
Warning messages:
1: In rm(non.m.beta, sser, ssef, beta0, r.ressq) : object 'sser' not found
2: In rm(non.m.beta, sser, ssef, beta0, r.ressq) : object 'ssef' not found
3: In rm(non.m.beta, sser, ssef, beta0, r.ressq) :
object 'beta0' not found
4: In rm(non.m.beta, sser, ssef, beta0, r.ressq) :
object 'r.ressq' not found
5: In
cpg.work(beta.val, indep, covariates, data, logit.transform, :
7207 sites were not able to be analysed.
Test statistics for these were set to NA
6: In min(test.stat$P.value, na.rm = TRUE) :
no non-missing arguments to min; returning Inf
From the source code of CpG assoc for #5, where levin is the independent variable as a factor:
if(!levin) {
test.stat[nonmissing,1]<-sqrt(test.stat[nonmissing,1])*sign(beta[2,])
if(beta.col>1) {
e.s[nonmissing,]<-cbind(colSums(colMeans(r.design)*matrix(beta[-2,],ncol(r.design))),beta[2,])
}
else {
e.s[nonmissing,]<-cbind(colSums(as.matrix(colMeans(r.design)*matrix(beta[-2,],ncol(r.design)))),beta[2,])
}
stderror[nonmissing,]<-abs(e.s[nonmissing,2]/test.stat[nonmissing,1])
}}
if(callarge) {
rm(beta)
gc()}
if(sum(is.na(test.stat[,1]))>0) {
warning(sum(is.na(test.stat[,1]))," sites were not able to be analysed.\n",
"Test statistics for these were set to NA")
}
}
Can someone explain the source code to me and what the problem is?