Problems with parsing of geom_alignment()'s type column (from ggbio)
1
0
Entering edit mode
@kristoffervittingseerup-7310
Last seen 6.5 years ago
European Union

I'm currently trying to plotting a gene model using ggbio's geom_alignment() function and I'm interested in annotating the coding sequence (cds) as a thicker part of the track. I'm taking the GRangesList approach described in the into document ( http://www.bioconductor.org/packages/release/bioc/vignettes/ggbio/inst/doc/ggbio.pdf ) section 2.2.4 (page 5).

Here it says that "this object must has a column contains following key word: cds, exon, intron, and it’s not case senstitive. use type to map this column"

My problem is that this does not always work - and not as expected either. (btw in case the author sees this post: the code for the non-autoplot method has a typo, it says: ggplot() + geom_alignment(grl, type = "model"), but should be ggplot() + geom_alignment(grl, aes(type = model)) .

 

Let's look at a quick example where the mapping goes wrong:

### Make GRangesList with a type column called "col"

test <- GRangesList( A=GRanges("chr1", IRanges(c(3,15), end = c(8,20)), stand='+', col=c('utr','cds')) )

### Plot it without specifying type column as sanity check

ggplot() + geom_alignment(test)

 

This works fine as can be seen from: https://www.dropbox.com/s/dh0gb2tjv9268f0/single_transcript_plot.png?dl=0 

If I then map the col names to type - they are for some reason removed and an error is produced:

> ggplot() + geom_alignment(test, aes(type=col))
"" is not matching to following arbitrary model terms"cds CDS Cds exon EXON Exon utr UTR Utr"
Constructing graphics...
Error in approx(c(x.s, x.e), rep(0, 2), n = N) : 
  negative length vectors are not allowed

 

The strange thing is that if I include another exon it sort-of works:

test <- GRangesList( A=GRanges("chr1", IRanges(c(3,15,30), end = c(8,20,40)), stand='+', col=c('utr','utr','cds')) )

> ggplot() + geom_alignment(test, aes(type=col))
"" is not matching to following arbitrary model terms"cds CDS Cds exon EXON Exon utr UTR Utr"
Constructing graphics...

And it produce a plot : https://www.dropbox.com/s/qxxa1lg8euknm4c/3_exon_transcript.png?dl=0 

But now the y-axis have been removed and instead an (very) small label have appeared over the transcript. Furthermore I still get the error message about "" not matching the following ...

Furthermore the example from section 2.2.4 in the guide also plots empty transcripts...

 

Hope somebody can help me out.

In advance - thanks

Kristoffer

 

ggbio geom_alignment • 1.3k views
ADD COMMENT
1
Entering edit mode
@michael-lawrence-3846
Last seen 3.0 years ago
United States

Sorry to answer so late. I guess Tengfei is off the map. I fixed a couple of issues, including the harmless message about matching the model terms. At this point, I would try to avoid using the "type" aesthetic directly but instead pass a TxDb object, or perhaps something loaded from GTF/GFF3. Otherwise, the type column (as in your test case) is not going to match the expectations of the fragile ggbio code, and the result is undefined.

ADD COMMENT

Login before adding your answer.

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