Hi All, i have a list of differentially methylated regions (DMRs) and I am trying to get the distance of these particular DMRs to known TSS, so I am using the ChIPpeakAnno package from Bioconductor, the question is: Is able this package to get the nearest start to up and downstream genes. From what I see, the package displays only one NearestStart, probably the downstream one, I tried setting the parameters up with both, but I got apart from Nearest if it is overlapping or not.
I add my script
library(GenomicFeatures)
library(ChIPpeakAnno)
data(TSS.human.GRCh37)
dmrs.ranges<-with(DMRs,RangedData(IRanges(start_DMR,end_DMR,names=id),space=space))
annotatedPeak <-annotatePeakInBatch(dmrs.ranges, AnnotationData =TSS.human.GRCh37,output="both")
annotatedPeak<-as.data.frame(annotatedPeak)
I read somewhere that using precede function in GenomicRanges, is the point, but I don't know how to get it, Could anybody help me with this point?
Thanks in advance
Many thanks!, but the question is, Will I get the distance of TSS for each DMR for upstream and downstream? I mean, one TSS nearest distance for up and once for down ??
I tried and I didn't get more than one TSS, and I a expecting both, one upstream DMR and one downstream. Maybe is a silly question what I am asking to, but it is possible?
I didn't realize you needed both the up and down stream sites. I edited my answer to include a scenario for that, but there may be more elegant ways.
Thanks! but I got problems subsetting TSS by strand, strand is not a metadata column
done it,
tss.upstream <- tss.gr[tss.gr@strand == "+"] tss.downstream <- tss.gr[tss.gr@strand == "-"]
Sorry again for the questions, but probably is a point important that I missed in all the conversation. When I was talking about downstream and upstream is not about the strand orientation but the TSS that are upstream and downstream for this particular DMR in positive strand and the same for the negative. For this I was talking about precede and follow
Sorry to confuse you, my suggestion about strand was not going to help (this is what I get for answering questions late at night), and I even coded it wrong (yet another option would have been: tss.gr[strandtss.gr) == "+"] ). So I deleted that part of my edit. Using precede() and follow() is the best and easiest way I can think of.