Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing genes on exome level zoom #11

Open
mmoisse opened this issue Mar 16, 2018 · 1 comment
Open

Missing genes on exome level zoom #11

mmoisse opened this issue Mar 16, 2018 · 1 comment

Comments

@mmoisse
Copy link

mmoisse commented Mar 16, 2018

We you want to zoom into a gene at exon level you don't see the exon anymore. As shown by the following figure:
org

I believe this has to do with a transcriptinfo filtering step in plotGenes:

transcriptinfo = transcriptinfo[which(
    (transcriptinfo[, 2] > chromstart & transcriptinfo[, 2] < chromend) | 
    (transcriptinfo[, 3] > chromstart & transcriptinfo[, 3] < chromend)
), ]

I believe you should add the situation where the zoom window falls completely inside a gene:

transcriptinfo = transcriptinfo[which(
    (transcriptinfo[, 2] > chromstart & transcriptinfo[, 2] < chromend) | 
    (transcriptinfo[, 3] > chromstart & transcriptinfo[, 3] < chromend) |
    (transcriptinfo[, 2] <= chromstart & transcriptinfo[, 3] >= chromend)
), ]

Which gives the figure I expected:
new

Here is the code to reproduce the plot

library(Sushi)
## Get data
Sushi_data = data(package = 'Sushi')
data(list = Sushi_data$results[,3])

## Setup position
chrom = "chr11"
chromstart = 1945000
chromend = 1960000

## Get genes
mart = useMart(biomart = "ensembl", dataset = "hsapiens_gene_ensembl")
geneinfo = getBM(attributes = c("chromosome_name", "exon_chrom_start","exon_chrom_end", "external_gene_name", "strand"), filters = c("chromosome_name", "start", "end"), values = list(gsub("chr","",chrom), chromstart, chromend), mart = mart)
names(geneinfo) = c("chrom", "start", "stop", "gene","strand")
geneinfo$score = "."
geneinfo = geneinfo[, c(1, 2, 3, 4, 6, 5)]
geneinfo$chrom = paste0("chr", sub("chr","",geneinfo$chrom))

## Set graphic parameters
par(mar=c(3,4,1,1))
layout(matrix(c(1,2,3,4), 4, 1, byrow = TRUE))

## Plot coverage
plotBedgraph(Sushi_ChIPSeq_CTCF.bedgraph,
   chrom,chromstart,chromend, 
   transparency=.50,color=SushiColors(2)(2)[1]
)                                                                                                                                                                                       
axis(side=2,las=2,tcl=.2)
labelgenome(chrom,chromstart,chromend, n=5,scale="bp")

## Plot gene
plotGenes(geneinfo, chrom,chromstart,chromend)

## Create zoom box
chrom = "chr11"
chromstart = 1956000
chromend = 1958000
zoomsregion(c(chromstart,chromend), extend=c(0.01,0.13), wideextend=0.05, offsets=c(0,0))

## Plot coverage
plotBedgraph(Sushi_ChIPSeq_CTCF.bedgraph,
   chrom,chromstart,chromend, 
   transparency=.50,color=SushiColors(2)(2)[1]
)                                                                                                                                                                                       
axis(side=2,las=2,tcl=.2)
labelgenome(chrom,chromstart,chromend, n=5,scale="bp")

## Plot gene
plotGenes(geneinfo, chrom,chromstart,chromend)
mmoisse added a commit to mmoisse/Sushi that referenced this issue Mar 16, 2018
Fix for PhanstielLab#11, adding the situation where the zoom window falls completely inside a gene.
@lucapandolfini
Copy link

lucapandolfini commented May 16, 2020

In my opinion the test

transcriptinfo = transcriptinfo[which((transcriptinfo[, 2] > 
        chromstart & transcriptinfo[, 2] < chromend) | (transcriptinfo[, 
        3] > chromstart & transcriptinfo[, 3] < chromend)), ]

should be modified into:

transcriptinfo = transcriptinfo[which((transcriptinfo[, 2] >=
        chromstart & transcriptinfo[, 2] <= chromend) | (transcriptinfo[, 
        3] >= chromstart & transcriptinfo[, 3] <= chromend)), ]

in order to account for transcripts starting exactly at the chromstart AND ending exactly at chromend. Optionally, it would be nice the part of a certain transcript spanning the chromstart/chromend selection were visualized instead of dropping it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants