puzzling ggbio behaviour when plotting a detail of a track
1
0
Entering edit mode
@philip-lijnzaad-2499
Last seen 23 months ago
European Union

Dear all,

I'm new to ggbio and can't seem to find an solution. I have a GRanges object gr containing ChIP-seq  data (on all chromosomes, imported with rtracklayer0, and want to plot just a detail on one chromosome, using

autoplot(gr, geom="line", aes(y=score), zoom.region=GRanges(seqnames="chrI", IRanges(10000, 11000)))

i.e. gr is the GRanges object, and I want to see the peaks on chrI, from 10 to 11 kb.

Instead the plotter takes ages and produces peaks for *all* the chromosomes (and which appear to be wrong anyway). Using xlim=, or which=  (instead of zoom.region) doesn't solve it.

If I do it as follows:

   gr2 <- gr[seqnames(gr)=="chrI" & start(gr)> 10000 & end(gr)<11000]
   autoplot(gr2, geom="line", aes(y=score))

it works, but that defeats the whole purpose of xlim (or the similar other arguments)

What am I doing wrong? Cheers,

Philip

ggbio • 1.2k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen just now
United States

I don't see a 'zoom.region' argument for any of the autoplot methods, so it's not surprising that it doesn't do what you expect. In addition, I don't believe there is a 'which' nor an 'xlim' argument for a GRanges object:

 ## S4 method for signature 'GRanges'
     autoplot(object, ..., chr, xlab, ylab, main, truncate.gaps = FALSE,
                      truncate.fun = NULL, ratio = 0.0025, space.skip = 0.1,
                      legend = TRUE, geom = NULL, stat = NULL,
                      chr.weight = NULL,
                      coord = c("default", "genome", "truncate_gaps"),
                      layout = c("linear", "karyogram", "circle"))

There is an xlim function that will modify your plot,

gr <- GRanges("chr2", IRanges(1e5,1e6))

autoplot(gr) + xlim(GRanges("chr2", IRanges(1e5,3e5)))

But that just seems silly. Why wouldn't you just modify your GRanges, which is like, super easy to do?

ADD COMMENT
0
Entering edit mode

I guess I picked up the zoom.region, which and xlim arguments from other examples. In this context I find ggbio's lack of warnings about unused arguments a bit inconvenient.

> Why wouldn't you just modify your GRanges,

Because I would have thought that an xlim-like argument would (and should?) just work for a plot function, and not take ages and give (imho) wrong output.  It also avoids inelegantly copying things all over the place.

Cheers,

Philip

ADD REPLY

Login before adding your answer.

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