Chippeakanno Distance To Tss In Up And Downstream
1
0
Entering edit mode
10.7 years ago
antgomo ▴ 30

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

bioconductor r • 5.2k views
ADD COMMENT
1
Entering edit mode
10.7 years ago
seidel 11k

With ChIPpeakAnno it's easy to confuse NearestStart with the start site of a gene, rather than simply the beginning coordinate of the closest feature to the left or right of the current position.

One way to solve your problem would be to reduce your genes to a single point located at the start of the gene:

# use resize with a ranges object
foo <- resize(as(TSS.human.GRCh37, "GRanges"), fix="start", width=1)

# convert the result back to RangedData for use with ChipPeakAnno
tss <- as(foo,"RangedData")

However, once you're in GRanges space, it's easy to stay there. You might try:

tss.gr <- resize(as(TSS.human.GRCh37, "GRanges"), fix="start", width=1)

# create a Granges object with your DMRs
dmrs.gr <- GRanges(seqnames=Rle(space), ranges=IRanges(start_DMR,end_DMR,names=id), strand=Rle("*", length(space)))

# for each DMR get the nearest TSS
nearestdmrs.gr, tss.gr)

Edit: If you need to get the upstream and downstream TSS for each peak, you already mentioned the answer, you could stick with tss.gr and simply use precede() and follow(). (Read the documentation: ?nearest). You'd have to stitch the results together, but it should be fairly easy if you can get this far.

ADD COMMENT
0
Entering edit mode

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 ??

ADD REPLY
0
Entering edit mode

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?

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

Thanks! but I got problems subsetting TSS by strand, strand is not a metadata column

ADD REPLY
0
Entering edit mode

done it,

tss.upstream <- tss.gr[tss.gr@strand == "+"] tss.downstream <- tss.gr[tss.gr@strand == "-"]

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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.

ADD REPLY

Login before adding your answer.

Traffic: 1633 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6