RnBeads per sample methylation values

150 views
Skip to first unread message

bruce moran

unread,
Nov 1, 2016, 6:54:00 AM11/1/16
to Epigenomics forum
Hi,

apologies if this is obvious but I cannot see an option to output methylation values on a per sample level from RnBeads.

I run QC, exploratory, normalization, differential and get all expected outputs, but I cannot find per sample methylation, only per group as defined in the sample annotation file. I tried to work around this but need differential module to run, and making fake sample annotation would have taken ~16 runs to do. There has to be a better way!

For clarity, my desired output is the values that are used for 'mean.Sample_Group' output in the tiling, sites, probe output in the differential CSV reports.

Thanks,

Bruce.

Fabian

unread,
Nov 2, 2016, 6:05:53 AM11/2/16
to Epigenomics forum
Hi Bruce,
thanks for the hint. We will think about how to include such a feature in a future version of RnBeads. For now, you can accomplish this with a few lines of of R code. Let's say, that you have your RnBSet object stored in a variable called rnb.set (the objects are part of the RnBeads output) and that you want to average by the annotation column called ANNOT.COL. Then the following code should do the trick:

grps <- factor(pheno(rnb.set)[,ANNOT.COL])
methMatrix <- meth(rnb.set, "tiling")

meanMethMatrix <- do.call("cbind", lapply(levels(grps), FUN=function(gg){
rowMeans(methMatrix[, grps==gg, drop=FALSE], na.rm=TRUE)
}))
colnames(meanMethMatrix) <- levels(grps)

Hope that helps. Let us know if you have further questions.

Best,
Fabian

Fabian

unread,
Nov 2, 2016, 6:09:25 AM11/2/16
to Epigenomics forum
ah, forgot to mention that there is the "mergeSamples()" function, too. This will essentially let you do the same thing, but store the results in an RnBSet object instead of a matrix, so, its particularly useful if you want averages for more region types or want to further work with the objects.

bruce moran

unread,
Nov 3, 2016, 9:39:30 AM11/3/16
to Epigenomics forum
Great, thanks Fabian.

For anyone else using this I would specify that in rnb.options, disk.dump.big.matrices must be set to FALSE. It is then possible to load("./reports/rnbSet_preprocessed/rnb.set.RData"), which loads and object called 'object', which is the 'rnb.set' object used in Fabians example.

I only wanted the per-sample methylation values, the means are reported in 'differential' output.

Many thanks for the very quick response, always makes me prefer a tool when authors are on hand to answer and support the community!

Bruce.

sumanas...@gmail.com

unread,
Oct 23, 2018, 6:01:59 PM10/23/18
to Epigenomics forum
Hi,

I was trying to get per sample values too and came across this thread. I however had >100 samples and hence set disk.dump.big.matrices to TRUE. Is there any other way to get the per sample values?

Sorry I know this is an old thread and maybe I am missing something obvious in the latest version of RnBeads. Could I maybe use the score in the bed files as methylation values?

Thanks in advance.
Sumana

sumanas...@gmail.com

unread,
Oct 23, 2018, 6:01:59 PM10/23/18
to Epigenomics forum
Hi,

I would like to use the hyper and hypo methylated regions per sample and I am interested in getting methylation values for each sample too and came across this thread.

Unfortunately, I have >100 samples and need to set disk.dump.big.matrices to TRUE. Is there any other way of getting sample level values. Can I use the scores in the bed files for each sample in anyway?

Sorry, I know this thread is old and if I am missing a feature in RnBeads.

Thanks in advance.
Sumana

On Thursday, November 3, 2016 at 2:39:30 PM UTC+1, bruce moran wrote:
Reply all
Reply to author
Forward
0 new messages