Thank Basti, I already did this, could you please above posted full code?
Many thanks,
Hi,
Could you please also help me how to arrange samples in the same order in rows (targests2) and columns in (betaval2) in R?
head(betaval2, 10) [,1:5]
DC541 DC485 DC490 DC131
1 cg26928153 0.869022470 0.87365220 0.911936463 0.6590429
2 cg16269199 0.625793206 0.78426522 0.805430832 0.5539671
3 cg13869341 0.862986903 0.88750760 0.789204281 0.7218103
4 cg24669183 0.751976011 0.86801138 0.889076957 0.6721988
5 cg26679879 0.379529937 0.34471486 0.383734472 0.4459295
6 cg22519184 0.394488319 0.38111739 0.381072524 0.4119580
7 cg15560884 0.613115675 0.68987661 0.713836687 0.5976042
8 cg01014490 0.009082822 0.01586443 0.006567706 0.1453065
9 cg10692041 0.908627024 0.92327421 0.902507690 0.8106531
10 cg02339369 0.915374608 0.87147961 0.902443744 0.7101839
> head(targets2)
Sentrix_ID Sentrix_Position Batch Category Gender eGFR
DC541 2.03e+11 R06C01 Batch 15 Control Male 141.3943
DC485 2.03e+11 R04C01 Batch 8 Control Male 133.6376
DC490 2.03e+11 R08C01 Batch 8 Control Male 133.1413
DC131 2.03e+11 R08C01 Batch 7 Control Female 131.9288
DC574 2.03e+11 R03C01 Batch 16 Control Female 130.6548
DC411 2.03e+11 R02C01 Batch 18 Control Male 127.5505
> fit<-lmFit(betaval2,var)
Error in lmFit(betaval2, var) :
row dimension of design doesn't match column dimension of data object
The issue comes from the presence of your cg....... column so you might put it into rownames to keep the information and then remove the column :
rownames(betaval2)=betaval2[,1]
betaval2=betaval2[,-1]
Thank Basti, I already did this, could you please above posted full code?
Many thanks,
Could you provide the output of dim(betaval2), dim(mval)and dim(var)? Thanks
Thank you very much Basti, after correcting same number of samples in phenotype and methylation file, this code works very well.
#model matrix
var<-model.matrix(~logeGFR + as.factor(Gender) + Age +CD8T +CD4T +NK + Bcell +Mono ,data=targets2)
fit<-lmFit(mval,var)
fit2<-eBayes(fit,trend=TRUE, robust=TRUE)
probe<-topTable(fit2,adjust="BH",coef=2,num=Inf)
sig.probe<-probe[which(probe$adj.P.Val<=0.05),]
write.table(sig.probe,file="Result.eGFR.associated.probe.txt",sep="\t",quote=TRUE)
Just few more queries;
Could you please let me know how I can confirm that coef =2 is logeGFR and what else information I can get from this model?
Many thanks,
Normally yes, you can check that your design matrix second column refer to your logeGFR variable. For the second question, I do not know what would be interesting, it depends on your biological questions.
Thanks Basti, could you please also help me how I can understand this regression analysis data (significant eGFR ASSOCIATED CpG); what is t and B?
logFC AveExpr t P.Value adj.P.Val B
cg03546163 0.410187762 -0.801321796 7.851041916 1.13E-12 8.65E-07 12.30512906
cg17944885 -0.48848589 2.319742786 -5.731964548 6.33E-08 0.024313494 5.152371088
Specific questions on functions output should be adressed by reading function documentations : https://www.rdocumentation.org/packages/limma/versions/3.28.14/topics/toptable
Dear Basti, thanks I wanted to understand that in above regression result sheet log fold change positive for cg03546163 so can I say cg03546163 methylation is positively associated to eGFR means if eGFR increase, methylation is also increased at cg03546163 and cg17944885 methylation is negatively associated with eGFR.
Many thanks,
Log in to answer this question.
What is contained in the
varvariable?First, the probe names (first column of betaval2) should be set as rownames, and then you need to remove that column from the data:
You then also probably need to try:
Please ensure --double- and treble-check-- that your metadata and expression data are aligned.
Thank you so much for quick response, but here is the more complete code and I already put CpG as row name and in sampleInfo file (targets2) samples names as rows but still I am getting this error? Is there any way in R to make sure rows in targets2 and columns in mval are in same order?
You probably just need:
In your model, you are also attempting to adjust for a lot of covariates- is that necessary? The model will 'overfit' with that many parameters (covariates), unless you have a very large sample size.
This also shows error, Is there any way in R to arrange samples in same rows/column?
fit <- lmFit(t(mval), var)
Error in lmFit(t(mval), var) :
row dimension of design doesn't match column dimension of data object
I'm not convinced the M-values matrix should be transposed, the way the code is presented is correct but there may be samples that are missing in the data or the metadata. this could be easily checked with
dim(var),dim(targets2). I agree that the number of covariables could be high, because often proportions of CD8T, CD4T, NK, Bcell and Mono are often highly correlated. A singular value decomposition might help to choose the best covariates to adjust for.Thanks!
It seems like here is some problem. I will have a look and get back to you.
Many thanks, Yogesh