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