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
What is contained in the
var
variable?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.
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
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