Question: Ggbio Issues: How To Align Tracks & Where Are Figure Legends?
gravatar for sndrtj
7.1 years ago by
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:

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 • 3.1k views
ADD COMMENTlink modified 4.2 years ago by Alastair Kerr5.2k • written 7.1 years ago by sndrtj180
gravatar for Alastair Kerr
4.2 years ago by
Alastair Kerr5.2k
Manchester/UK/Cancer Biomarker Centre at CRUK-MI
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)))


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 11 weeks ago by RamRS26k • written 4.2 years ago by Alastair Kerr5.2k
Please log in to add an answer.


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