thackl / gggenomes

A grammar of graphics for comparative genomics
https://thackl.github.io/gggenomes/
Other
579 stars 64 forks source link

Fill by gene rather than CDS #100

Closed andreaniml closed 2 years ago

andreaniml commented 2 years ago

Hi! This is probably really silly, I have a gff3 reformated from augustus output that looks like this:

Mockdata1   AUGUSTUS    gene    803 1108    1   -   .   ID=g1Mockdata1;
Mockdata1   AUGUSTUS    mRNA    803 1108    .   -   .   ID=g1Mockdata1.t1;Parent=g1;Name=Gen1;biotype=protein_coding;
Mockdata1   AUGUSTUS    stop_codon  800 803 .   -   0   ID=g1Mockdata1.t1.stop1;Parent=g1.t1;
Mockdata1   AUGUSTUS    start_codon 1108    1106    .   -   0   ID=g1Mockdata1.t1.start1;Parent=g1.t1;
Mockdata1   AUGUSTUS    gene    5082    1281    1   +   .   ID=g2Mockdata1;
Mockdata1   AUGUSTUS    mRNA    5082    1281    .   +   .   ID=g2Mockdata1.t1;Parent=g2;Name=Gen2;biotype=protein_coding;
Mockdata1   AUGUSTUS    start_codon 5082    5084    .   +   0   ID=g2Mockdata1.t1.start1;Parent=g2.t1;
Mockdata1   AUGUSTUS    stop_codon  1279    1281    .   +   0   ID=g2Mockdata1.t1.stop1;Parent=g2.t1;
Mockdata2   AUGUSTUS    gene    1   305 1   +   .   ID=g1Mockdata2;
Mockdata2   AUGUSTUS    mRNA    1   305 .   +   .   ID=g1Mockdata2.t1;Parent=g1;Name=Gen2;biotype=protein_coding;
Mockdata2   AUGUSTUS    stop_codon  303 305 .   +   0   ID=g1Mockdata2.t1.stop1;Parent=g1.t1;
Mockdata2   AUGUSTUS    gene    699 492 1   +   .   ID=g2Mockdata2;
Mockdata2   AUGUSTUS    mRNA    699 492 .   +   .   ID=g2Mockdata2.t1;Parent=g2;Name=Gen1;biotype=protein_coding;
Mockdata2   AUGUSTUS    start_codon 699 701 .   +   0   ID=g2Mockdata2.t1.start1;Parent=g2.t1;
Mockdata2   AUGUSTUS    stop_codon  490 492 .   +   0   ID=g2Mockdata2.t1.stop1;Parent=g2.t1;

When passed to gggnomes with this code: `` g1 <- read_feats("Reproductible.gff3") cbPalette <- c("#D55E00", "#E69F00", "#009E73", "#56B4E9", "#F0E442","#999999", "#0042B2", "#CC79A7","#00000","#05555") MyImage= gggenomes(genes=g1) + geom_seq() + geom_seq_label()+ geom_bin_label()+ geom_gene(aes(fill=name, stroke = 1,linetype=biotype),size = 8) + scale_fill_manual(values= cbPalette) I get this result: image

I think I figured it out that this is coloring by mRNA column and then it gets remapped to be a little lighter. I know if I change the identifier from mRNA to CDS it fixes it, however, is there anyway to tell gggnomes that I want to color by gene or mRNA without lightening? I couldn't figure it out by seing the imported gffs from example data. If I delete the mRNA column then the genes disappear.

Thanks for any help!

thackl commented 2 years ago

Try geom_gene(…, rna_aes=aes(fill=fill colour=colour))

That should overwrite the defaut lightening for mrnas, trnas etc (rna_aes=aes(fill=colorspace::lighten(fill, .5), colour=colorspace::lighten(colour, .5)))

andreaniml commented 2 years ago

It worked! Thanks!