YuLab-SMU / ChIPseeker

:dart: ChIP peak Annotation, Comparison and Visualization
https://onlinelibrary.wiley.com/share/author/GYJGUBYCTRMYJFN2JFZZ?target=10.1002/cpz1.585
224 stars 74 forks source link

bug fix #112 #121 #139 #148

Closed MingLi-929 closed 3 years ago

MingLi-929 commented 3 years ago

This pull request is to fix #112, #121, #139, which reflects the same problem having two parts.

The first part is that when change the options(ChIPseeker.downstreamDistance = 500), the marker in the picture change but the ratio of Downstream(<=N) do not change.The reason is because https://github.com/YuLab-SMU/ChIPseeker/issues/112#issuecomment-818660296.

library(ChIPseeker)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene

files <- getSampleFiles()
peak <- readPeakFile(files[[4]])

options(ChIPseeker.downstreamDistance = 3000)
getOption('ChIPseeker.downstreamDistance')
x <- annotatePeak(peak,
                  tssRegion = c(-1000,1000),
                  TxDb = txdb)
plotAnnoPie(x,cex = 0.7)

distance3000

options(ChIPseeker.downstreamDistance = 500)
getOption('ChIPseeker.downstreamDistance')
x1 <- annotatePeak(peak,
                  tssRegion = c(-1000,1000),
                  TxDb = txdb)
plotAnnoPie(x1,cex = 0.7)

distance500 As it shows above the marker is changed, but the ratio do not change.

The second part is the misuse of precede(), which reported in #139. This problem causes the different between the result of annotatePeak and peakAnno@detailGenomicAnnotation$downstream.

# issue139
library(ChIPseeker)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
TxDb <- TxDb.Hsapiens.UCSC.hg19.knownGene

files <- getSampleFiles()
peakAnno <- annotatePeak(files[[2]], tssRegion=c(-500, 0),
                         TxDb=TxDb, 
                         level = "gene")

# According to the peakAnno result, there will be about 20 peaks in the downstream. 
> peakAnno
Annotated peaks generated by ChIPseeker
2296/2296  peaks were annotated
Genomic Annotation Summary:
             Feature  Frequency
9           Promoter  0.7404181
4             5' UTR  0.6533101
3             3' UTR  1.5243902
1           1st Exon  0.4355401
7         Other Exon  2.6567944
2         1st Intron 14.5905923
8       Other Intron 31.6637631
6 Downstream (<=300)  0.8710801
5  Distal Intergenic 46.8641115

# But according to the result below, it seems no peak locating downstream
> sum(peakAnno@detailGenomicAnnotation$downstream)
[1] 0

the reason is because https://github.com/YuLab-SMU/ChIPseeker/issues/139#issuecomment-818673319.

After doing the changing, the two parts are corrected.

options(ChIPseeker.downstreamDistance = 3000)
getOption('ChIPseeker.downstreamDistance')
x <- annotatePeak(peak,
                  tssRegion = c(-1000,1000),
                  TxDb = txdb)
plotAnnoPie(x,cex = 0.7)

4 The reason that ratio changes from 1.13% to 1.05% is that I use follow() to replace precede(). Different functions get different result.

options(ChIPseeker.downstreamDistance = 500)
getOption('ChIPseeker.downstreamDistance')
x1 <- annotatePeak(peak,
                   tssRegion = c(-1000,1000),
                   TxDb = txdb)
plotAnnoPie(x1,cex = 0.7)

3

All that above is what the PR do.