circular display in ggbio for gene tracks
4
0
Entering edit mode
Bogdan ▴ 670
@bogdan-2367
Last seen 6 months ago
Palo Alto, CA, USA

Dear all,

somehow a related question about the CIRCULAR DISPLAY in ggbio of the gene tracks :

shall I start with the R code below, how could I do the same representation in CIRCULAR format ?

library(ggbio)
library(Gviz)
library(BSgenome)
library(Homo.sapiens) ## it uploads automatically the coordinates from HG19.

library(GenomicRanges)
library(GenomicFeatures)
library(biovizBase)
library(rtracklayer)

chr <- "chr21"
start <- 43760000
end <- 43810000    
gene <- "TFF1"

TFF1 <- GRanges(seqnames=chr,IRanges(start,end),strand="*")
region <- TFF1

autoplot(Homo.sapiens, which = region, color = "blue", fill = "blue", names.expr="SYMBOL")

 

ggbio • 1.7k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 16 hours ago
United States

You can simply add layout = "circular" to the autoplot() call. But I still don't think you understand the fundamental point I tried to make yesterday. If you plot some really small section of the genome, and say you want it to be circular, you won't get a circular plot!

The idea behind a circular plot is to lay out the entire genome as a circle and then plot things of interest. If you lay out the genome as a circle and then zoom way in to a tiny little section, it won't look circular any more! You seem fixated on the idea of doing a circular display, but you haven't said why this matters to you. Perhaps if you could elaborate on what you are trying to do and why, people might be able to help.
 

ADD COMMENT
0
Entering edit mode
Bogdan ▴ 670
@bogdan-2367
Last seen 6 months ago
Palo Alto, CA, USA

Hi James,

much thanks for your reply. If I may explain a little bit the overall goal of my project :

we do have a lot of gene interactions (by chromosome conformation capture, ie 3C) on chromosome 21, and some interactions could span 30-100kb, while some other interactions may span 1-10 MB. 

while a LINEAR layout is useful to visualize short-range interactions, a CIRCULAR layout would be needed in order to visualize the interactions that are >20MB apart (eg. between NRIP1 gene at position ~16MB, and TFF1 gene at position ~44MB) .

therefore what I would really need would be to separate the the CIRCLE format into 2 halfs :

-- on one side to display a region with the genes on the chromosome segment chr21: 15 000 000 - 16 000 000 (region A)

-- on the other side, to display the genes on the chromosome segment chr21 : 43 000 000 - 45 000 000 (region B)

and to show the interactions/links between these 2 regions in CIRCULAR format.

shall you have any insights, please let me know. we do not aim to picture the entire chromosome 21 (i.e. all 48MB), as it is too large, but only SPECIFIC REGIONS at both ENDS of the chromosome (eg region A and region B).

regarding the code with "layout = "circle" (below), it is not working on my PC.  please correct if I am wrong. thanks a lot !

region <- GRanges(seqnames= "chr21",IRanges(1,40000000),strand="*")

autoplot(Homo.sapiens, which = region, color = "blue", fill = "blue", names.expr="SYMBOL", layout="circle")

ADD COMMENT
0
Entering edit mode

Let's try this one more time. Do you see the difference between the following results? Can you see why they are different?

library(ggbio)
library(biovizBase)
data(CRC)
autoplot(hg19sub, layout = "circle")
autoplot(hg19sub[21,], layout = "circle")
hg19mini <- hg19sub[21,]
seqlevels(hg19mini) <- "21"
autoplot(hg19mini, layout = "circle")

If so, do you now understand why calling autoplot() on Homo.sapiens (which by default represents the entire genome) doesn't do what you expect? Have you read the ggbio vignette, specifically the part about circular plotting? Does this hopefully explain by example that you cannot do what you want using autoplot()?

You can probably do exactly what you want using ggbio, but you should understand going in that it will only be due to your own hard work. Like ggplot2, ggbio tries to 'do the right thing', and if you want it to do something else it is non-obvious how one would do that. There are quite a few examples in the vignette, and even more scattered around the internets, so that should be helpful. But the help pages are not super-helpful, and Tengfei doesn't answer many questions (last question answered was almost a year ago, and not even 1000 questions answered for what could hypothetically be a highly used package).

ADD REPLY
0
Entering edit mode
Bogdan ▴ 670
@bogdan-2367
Last seen 6 months ago
Palo Alto, CA, USA

HI James, thank for taking your time to help my question. I appreciate it ;) Yes, I think that we both understand the examples you provided. Thank you very much.

I would need your help with a more complex example of plotting the genes in a circular format. Will write to you soon ;)

 

ADD COMMENT
0
Entering edit mode
Bogdan ▴ 670
@bogdan-2367
Last seen 6 months ago
Palo Alto, CA, USA

Hi James, I think there is still something that I am missing in the circular display :

shall you follow my examples, I would appreciate your help on why these plots look so different ..

1) example 1:

library("ggbio")
library("GenomicFeatures")
library("GenomicRanges")

gr1 <- GRanges("chr21", strand="+", IRanges(start = c(1, 20), end = c(10, 30)), score = c(0,20))

values(gr1)$to.gr <- GRanges( "chr21", strand="+", IRanges(start = c(100, 200), end = c(110, 210)) )

seqlengths(gr1) <- 220

ggbio() + circle(gr1, geom = "bar", radius = 120, trackWidth = 4, aes(fill = score, y = score), direction = "anticlockwise") + circle(gr1, geom = "point", color = "red", radius = 130, trackWidth = 3, grid = TRUE, aes(y = score), direction = "anticlockwise") + circle(gr1, geom = "link", linked.to = "to.gr", radius = 100, trackWidth = 1, direction = "anticlockwise")

2) example 2 ; identical as example 1), except that we do modify the seqlengths() : i.e. seqlengths(gr1) <- 2200. 

library("ggbio")
library("GenomicFeatures")
library("GenomicRanges")

gr1 <- GRanges("chr21", strand="+", IRanges(start = c(1, 20), end = c(10, 30)), score = c(0,20))

values(gr1)$to.gr <- GRanges( "chr21", strand="+", IRanges(start = c(100, 200), end = c(110, 210)) )

seqlengths(gr1) <- 2200

ggbio() + circle(gr1, geom = "bar", radius = 120, trackWidth = 4, aes(fill = score, y = score), direction = "anticlockwise") + circle(gr1, geom = "point", color = "red", radius = 130, trackWidth = 3, grid = TRUE, aes(y = score), direction = "anticlockwise") + circle(gr1, geom = "link", linked.to = "to.gr", radius = 100, trackWidth = 1, direction = "anticlockwise")

 

 

 

 

 

ADD COMMENT

Login before adding your answer.

Traffic: 874 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