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