I am following a published workflow on methylation analysis and am currently looking at differentially methylated regions with dmrcate. My results come back ordered by chromosomal region, but I understand that by default they should be ordered by the Stouffer p-value? I have tried to sort the data by p-value using order() but I can't get it right (I am an R newbie). When I write it to excel and sort it there, it matches up with the results in the paper, so I know that the results are correct, they are just ranked incorrectly in R. Does anyone know why this is happening and how I can change it? Code below (from Maksimovic et al. 2016). Thank you!
myAnnotation <- cpg.annotate(object = mVals, datatype = "array", what = "M", analysis.type = "differential", design = design, contrasts = TRUE, cont.matrix = contMatrix, coef = "naive - rTreg", arraytype = "450K") DMRs <- dmrcate(myAnnotation, lambda=1000, C=2) head(DMRs$results)
What I get:
## coord no.cpgs minfdr Stouffer maxbetafc meanbetafc ## 1 chr1:1149501-1150936 6 5.984538e-56 0.001088019 0.2693474 0.11443808 ## 2 chr1:2003577-2004636 9 2.742863e-42 0.762659787 0.3441610 0.09161004 ## 3 chr1:2058941-2059086 2 5.902550e-18 0.032585707 -0.2040435 -0.15183179 ## 4 chr1:2228160-2229113 4 8.885648e-78 0.038966222 -0.4400900 -0.17788349 ## 5 chr1:2516401-2516516 2 1.285306e-17 0.181109097 0.2476914 0.13585802 ## 6 chr1:3289798-3289994 3 3.012113e-18 0.057362507 0.1991512 0.10041011
What the authors get:
## coord no.cpgs minfdr Stouffer maxbetafc
## 457 chr17:57915665-57918682 12 4.957890e-91 6.639928e-10 0.3982862
## 733 chr3:114012316-114012912 5 1.622885e-180 1.515378e-07 0.5434277
## 469 chr17:74639731-74640078 6 9.516873e-90 1.527961e-07 -0.2528645
## 1069 chrX:49121205-49122718 6 6.753751e-84 2.936984e-07 0.4529088
## 492 chr18:21452730-21453131 7 5.702319e-115 7.674943e-07 -0.3867474
## 186 chr10:135202522-135203200 6 1.465070e-65 7.918224e-07 0.2803157
## meanbetafc
## 457 0.3131611
## 733 0.4251622
## 469 -0.1951904
## 1069 0.3006242
## 492 -0.2546089
## 186 0.2293419
Thanks very much, Tim!