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

Dear all,

please could I have some (introductory) information about the CIRCULAR DISPLAY in GGBIO is setup; especially function on 1) seqlength and 2) radius;

the following 2 examples give very different displays; thanks !

<> example 1 :

gr <- GRanges("chr21", strand="+", IRanges(start = c(1, 100), end = c(10, 200)), score = c(10,20))

seqlengths(gr) <- c("chr21"=100000)

ggplot() + layout_circle(gr, geom = "bar", radius = 100, trackWidth = 4, aes(fill = factor(score), y = score))

<> example 2 :

gr <- GRanges("chr21", strand="+", IRanges(start = c(1, 100), end = c(10, 200)), score = c(10,20))

seqlengths(gr) <- max(end(gr))-min(start(gr))

ggplot() + layout_circle(gr, geom = "bar", radius = 100, trackWidth = 4, aes(fill = factor(score), y = score))

 

 

ggbio • 1.4k views
ADD COMMENT
1
Entering edit mode
@james-w-macdonald-5106
Last seen 5 hours ago
United States

When you make a plot of a 200 bp region on a circular chromosome that is 100,000 bp long (e.g., you are plotting 0.2% of the genome), it's like you zoomed in on a very small region of a big circle. At that point it looks linear because the curvature is so slight (just like the earth looks flat to us when on the surface). But if the region you are plotting is a large portion of the (circular) genome, then it's as if you zoomed out, and can now see the circularity.

gr <- GRanges("chr21", strand="+", IRanges(start = c(1, 100), end = c(10, 200)), score = c(10,20))

fun <- function(gr, sq){
 seqlengths(gr) <- sq
 ggplot() + layout_circle(gr, geom = "bar", radius = 100, trackWidth = 4, aes(fill = factor(score), y = score))
 }

sqlst <- c(200, 500, 800, 1000, 2000, 5000)

pdf("tmp.pdf")

lapply(sqlst, function(x) fun(gr, x))

dev.off()

And look at the pdf.

 

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

Thank you James for time and prompt help, really appreciate it ! It is a beautiful piece of R code ...  I may have some additional questions, as I am trying to plot also some gene tracks in the CIRCULAR format, together with interaction links ;) will get back to you later, shall you find 5 minutes ;) thanks a lot !

 

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

Oh, well, it looks that we would need to set up the seqlengths specifically for each GRanges object depending on the segment we would like to represent in order to scale everything accordingly :

for example :

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

gr2 <- GRanges("chr21", strand="+", IRanges(start = c(1, 400), end = c(300, 600)), score = c(0,2000))

min_start_gr1 <- min(start(gr1))
min_start_gr2 <- min(start(gr2))

min_start_gr1_gr2 <- min(min_start_gr1, min_start_gr2)

max_end_gr1 <- max(end(gr1))
max_end_gr2 <- max(end(gr2))

max_end_gr1_gr2 <- max(max_end_gr1, max_end_gr2)

#####################################

seqlengths(gr1) <- max_end_gr1_gr2 - min_start_gr1_gr2
seqlengths(gr2) <- max_end_gr1_gr2 - min_start_gr1_gr2

 

ggplot() + layout_circle(gr2, geom = "bar", radius = 100, trackWidth = 4, aes(fill = score, y = score)) +
           layout_circle(gr2, geom = "point", color = "red", radius = 110, trackWidth = 3, grid = TRUE, aes(y = score)) +
           layout_circle(gr1, geom = "bar", radius = 120, trackWidth = 4, aes(fill = score, y = score)) +
           layout_circle(gr1, geom = "point", color = "red", radius = 130, trackWidth = 3, grid = TRUE, aes(y = score))

ADD COMMENT

Login before adding your answer.

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