I have used the excellent package DMRcate and I am trying to extract the CpG names included in each DMR from my results.ranges. I have found this question many times over online forums but I think they are outdated as when I do this code that the creators of the package recommended:
locs <- IlluminaHumanMethylationEPICanno.ilm10b2.hg19::Locations
locs.ranges <- GRanges(locs$chr, IRanges(locs$pos, locs$pos))
names(locs.ranges) <- rownames(locs)
DMR.IDs <- lapply(results.ranges, function (x) names(locs.ranges[locs.ranges %over% x]))
I get this error on the last line of code: Error in getListElement(x, i, ...) : GRanges objects don't support [[, as.list(), lapply(), or unlist() at the moment
Found on other forums that a "for loop" can be used on granges objects instead of lapply. But I don't know how to convert this lapply function to a for loop in this context for it to work.
Can anyone help with converting this last line of code to a for loop, or anything else that would extract the CpG names from a DMR?
Thank you, Shanie