Question: Ggbio Issues: How To Align Tracks & Where Are Figure Legends?
3
gravatar for sndrtj
6.1 years ago by
sndrtj180
Netherlands
sndrtj180 wrote:

Dear Biostar users,

I am using ggbio to add a chromosome ideogram over data along the length of a chromosome. See the code beneath here for some sample code:

library(GenomicRanges)
library(ggbio)
data(hg19IdeogramCyto, package = "biovizBase")
x <- seq(from=1,to=8e+07,by=100)
x <- sample(x,7000)
x <- append(x,x)
y_ <- seq(from=-1,to=1,by=0.00001)
y <- sample(y_,7000)
y2 <- sample(y,7000)
y <- append(y,y2)
z <- NULL
z[1:7000] <- 'one'
z[7001:14000] <- 'two'
df <- data.frame(x,y,z)
p <- plotSingleChrom(hg19IdeogramCyto, "chr17",xlabel=TRUE,zoom.region=c(min(df$x),max(df$x)))
p2 <- qplot(x,y,data=df,colour=z,geom='line')
tracks(p, p2 = p2, heights = c(1.2, 5))

Which results in:

enter image description here

Issue one: the ideogram x axis seems out of place with the data x axis. How do I align these two, in such a way that the cytobands actually corresprond to x axis below?

Issue two: Where have my legends gone? In normal ggplot/qplot I would nicely get a legend with "one" and "two" on the right. Somehow this vanished?

Thanks a lot for any suggestions!

R • 2.8k views
ADD COMMENTlink modified 3.1 years ago by Alastair Kerr5.2k • written 6.1 years ago by sndrtj180
0
gravatar for Alastair Kerr
3.1 years ago by
Alastair Kerr5.2k
The University of Edinburgh, UK
Alastair Kerr5.2k wrote:

I just tried this code using BioC 3.2

> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS

...

other attached packages:

[1] ggbio_1.18.3         ggplot2_2.0.0        GenomicRanges_1.22.4
[4] GenomeInfoDb_1.6.3   IRanges_2.4.6        S4Vectors_0.8.11    
[7] BiocGenerics_0.16.1 

 

I had to change 

p <- plotSingleChrom(hg19IdeogramCyto, "chr17",xlabel=TRUE,zoom.region=c(min(df$x),max(df$x)))

to 

p <- Ideogram(hg19IdeogramCyto, "chr17",xlabel=TRUE,zoom.region=c(min(df$x),max(df$x)))

It did give the error  

`axis.ticks.margin` is deprecated. Please set `margin` property  of `axis.text` instead 

but produced the graph as expected (?)

 

ADD COMMENTlink modified 3.1 years ago • written 3.1 years ago by Alastair Kerr5.2k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1144 users visited in the last hour