Giter Site home page Giter Site logo

gggenes's Issues

Legend element border

Hello,
is there a way to make the legend element borders white instead of black? With "legend element" I mean the square containing the gene/subgene colour.

Thank you,
M

make_alignment_dummies undefined columns selected

Hi there,

Great package! Thanks!

I'm trying to create a dummy variable using 'make_alignment_dummies` as follows

dummies <- make_alignment_dummies(
  genes_to_plot_curated,
  aes(xmin = start, xmax = end, y = genome_split, id = Gene),
  on = "geneA"
)

This trows the following error:

Error in `[.data.frame`(data, as.character(unlist(mapping))) : 
  undefined columns selected

geneA is definitely present in column Gene as I use almost the exact same aes call in the plot version (replacing 'id' with 'fill'). Would you be able to give me some insights in what's happening here?

Sorry about not providing a reproducible example.

Thanks!

Cut off the useless position of the map

Hi,
Thanks for the wonderful visualisation tool for gene arrow map. I have a 5 genome and I pick up the target genes, they are quite far from each other which make the plot unreadable. I wondering if there a way to cut off part off the location that not contain genes.
Thanks for your warm assisstance.

Best.
Screen Shot 2021-05-06 at 3 51 39 pm

true_min not found

> library(gggenes)
>
> dummies <- make_alignment_dummies(
+   gggenes_example_genes,
+   aes(xmin = start, xmax = end, y = molecule, id = gene),
+   on = "genE"
+ )
Error in ifelse(side == "left", true_min, true_max) :
  object 'true_min' not found

This may due to the upgrade of dplyr.

> packageVersion("dplyr")
[1] ‘0.7.2’

R 3.6 requirement

Hi! This looks to be a perfect match for us, but we are restricted to R 3.5.1. May I ask what functionality it is that requires 3.6? Looking at the commits it doesn't seem like there would be anything after you bumped the requirement from 3.3 to 3.6. Thanks!

[feature request] arrow shape - aesthetics strand or direction

Hi,

I don't know if I missed an option, but I suggest an aesthetics to create an arrow according to the strand feature.
geom_gene_arrow(aes(direction = strand))

The effect of this aesthetics must be the direction of the arrow, this way it may support non-overlapping genes in the same y axis.

I don't know how to represent when it has overlap.

Another suggestion, to better fit the name of the molecule, is an option where the text might be placed below to arrow representation.

'>>gen1>>##>>>>>>gen2>>>>>>###<<<<<<<gen3<<<<<<<##>>>>>gen4>>>>>>'
'Melecule name or text'

Plot virus genome with overlapping genes

Hi David,
I am plotting gene regions on the Sars-CoV-2 genome, and several regions overlap. Is there any way that gggenes can offset the overlapping areas? This is often done in other visualizations. I have an example of the problem below. Orf1ab-LP is contained within Orf1a which is contained within Orf1ab. If these were offset vertically it would work well.

molecule gene start end strand orientation
Sars-CoV-2 5UTR 1 265 forward 1
Sars-CoV-2 Orf1ab-LP 266 805 forward 1
Sars-CoV-2 Orf1a 266 13483 forward 1
Sars-CoV-2 Orf1ab 266 21555 forward 1
Sars-CoV-2 Nsp2 806 2719 forward 1
Sars-CoV-2 Nsp3 2720 8554 forward 1
Sars-CoV-2 Nsp4 8555 10054 forward 1

I can separate the overlapping areas and put them in different genomes as in your example, but this is not ideal because they are too far apart. I think your plots are beautiful and I would love to use gggenes to visualize this genome.
Thanks for your help!
Julia

Equal scaling between different figures

Hi @wilkox,

Firstly thank you for the wonderful tool! I am not exaggerating when I say that gggenes has saved me hours of drawing arrows on Illustrator...

I am making several figures and would like the scale to be the same between them. Currently, the figures are all made to be the same length so that 10kb on one figure could be the length of 20kb on another. Is there a way of scaling all axes so that 10kb is a specific length in all figures?

Thank you again!

Dina

extract polygons from plot

Is it possible to extract the coordinates of the underlying polygons from the ggplot object?

p <- ggplot(example_genes, aes(xmin = start, xmax = end, y = molecule, fill = gene)) +
  geom_gene_arrow() +
  facet_wrap(~ molecule, scales = "free", ncol = 1)
layer_data(p)

only contains the original start/stop position.
thanks!

Issue with dummy gene alignment

Hi there,

I'm trying to construct the dummy gene alignment but I seem unable to.

I have got all the other plotting features working. I've compared my data types to the example types and they appear to be identical. Adding in the geom_blank(data = dummies) doesn't change the plot, nor does it throw up an error. It just produces the same plot as without it.

I'm wondering if this is a known bug? Any help would be much appreciated.

Best,
Sean

Getting involved with gggenomes development

Hi David
It tried to contact you by email a few days ago (via [email protected]). But I'm not sure if my message came through. So I'm just trying this channel.

My name is Thomas, I'm a postdoc working on microbial and viral genomics. I'm a big fan of ggplot and your gggenes package. It inspired me to put together my own package, which at the beginning I thought would just become an extension to gggenes, adding some features I was missing. But I think I went down the rabbit hole a bit too deep, and it has now grown somewhat beyond that. You can find a draft version of its documentation and a show case here: https://thackl.github.io/gggenomes/

The main features of the package are:

  • an arbitrary amount of data tracks (seqs, genes, features, links...) that geom_* calls can access
  • links between genomes (synteny)
  • manipulation of the "layout"
    • flip
    • reorder/select seqs (not shown in example)
    • zoom in on regions of interest (not shown in example)
  • multiple contigs (not shown in example)
  • multi-exon genes (not shown in example)

I wanted to get in touch to see if you'd be interested to get involved in this project in any way. I've learned a lot from your code, and this would not have happened without your work. I'm planning to get this package out in the near future, ideally accompanied by a preprint/manuscript. But of course, there's still quite some things to do. If you'd be interested to get involved, let me know. Maybe we can set up a video chat to talk some more.

How to specify the color of some genes

Hi Wilkox,

I'm now using a palette to colour the genes. But I hope to specify the colour of genes with the name 'na' and keep other genes using the colour from the palette. I can't achieve this by adding a second colour layer. Could you please tell me how can I make this using gggenes? Thank you in advance!

Forward and reverse genes on the same line

Hi thanks for this great way to visualize contigs!

Would it be possible to have the forward and reverse genes on the same strand rather than on separate forward and reverse strands?

May be useful to autoconvert `molecule` to character

This may be a rare problem, however I did experience it in my case where my genome ids (thus molecule) are numbers. So it would be useful to mention in the documentation that the molecule has to be character, or convert this automatically before plotting.

Let' s take the package example and change to numerical molecule ids:

example_genes_num <- example_genes %>% mutate(molecule = as.numeric(stringr::str_replace(molecule,'Genome','')))
ggplot(example_genes_num, aes(xmin = start, xmax = end, y = molecule, fill = gene)) +
  geom_gene_arrow() +
  facet_wrap(~ molecule, scales = "free", ncol = 1) +
  scale_fill_brewer(palette = "Set3")

When we then plot this (only a part shown):
image

This can be prevented when we convert the molecule to character:

example_genes_num <- example_genes_num %>% mutate(molecule = as.character(molecule))
ggplot(example_genes_num, aes(xmin = start, xmax = end, y = molecule, fill = gene)) +
  geom_gene_arrow() +
  facet_wrap(~ molecule, scales = "free", ncol = 1) +
  scale_fill_brewer(palette = "Set3")

image

Anyway, really nice and useful package!

Wrap genes to plot whole genome

We love your program! I was wondering if there is a way to plot a whole genome (~2000 genes), but have it wrap around to make multiple lines instead of it all being on one line? I guess we could do this manually by instead of making each line a genome just not labeling, but one line that wraps at a specified number of bases would be great.

Keep up the good work!

Combine gggenes with other ggplot?

Hi,

I have a sequence coverage plot for a region of several genes, i would like to combine with gggenes to show the gene arrangement overlayed or next to the coverage ggplot.

Is this possible at all?

thanks

order of the genome names

Hi,

Thanks for wonderful package.

I am trying to align according to a specific gene using make_alignment_dummies but the order of the genomes in the final figure are sorted by genome names. This results me a figure, where a few genomes on top are similar and a few genomes with the same gene contents due to different names are sorted by names are seen at the bottom.

Is there a way to sort the genomes based on the gene content? or else is there a way ggplot can plot the data exactly in the same order passed by dummies and example_genes if have sorted the contents?

Thanks much!

ggGenes - Increase Text Size?

I’m using ggGenes to build a simple gene illustration that I intend to pair with a metagene plot (see attached). I’m having trouble increasing the text size of the gene name, which should be controlled by geom_gene_label(). I’ve reviewed documentation for ggGenes and ggFitText, and haven’t been able to come up with any solutions. Have any advice?

I’ve tried:

  1. Setting geom_gene_label(grow=TRUE)
  2. Setting geom_gene_label(aes(size=10). Strangely, setting any value to size= results in a slight shrinkage of the text size.

Tried both of the above alone and in combination with:
3) Increasing the size of geom_gene_arrow() so that large text size can fit. Excessively large arrows still do not result in increased text size.

Code Sample

gene_arrows <- data.frame(
  start = c(24),
  end = c(72),
  molecule = c("BY4741"),
  gene = c("ADE5,7")
)

ggplot_genearrows <- ggplot(gene_arrows, aes(xmin = start, xmax = end, y = molecule, fill = gene)) +
  geom_gene_arrow(arrowhead_height = unit(12, "mm"), arrowhead_width = unit(6, "mm"), arrow_body_height = grid::unit(6, "mm")) +
  geom_gene_label(grow=TRUE, aes(label = gene)) +
  xlim(0,95) +
  scale_fill_brewer(palette = "Set3") +
  theme_genes() +
  theme(axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.line.x=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank(),
        axis.title.y=element_blank(),
        legend.position="none"
  )

Thank you for taking the time to create a package for visually displaying genes in ggplot - it’s something I’ve looked for in the past!

Label genes above gene boxes

Thanks for the great prog. I have some good illustrations, but I want to produce an illustration of a phage, so having the gene names inside the gene boxes doesn't work. I have tried without success to find an easy way to add the names above the boxes. I wondered if you had any suggestions. Here is an example of what I am trying to achieve.

image

Thank you for your help

error and empty plot

Hi,

I'm trying to plot many genes neighborhood.

This is my data

structure(list(nucleotide = c("NC_007484.1", "NC_007484.1", "NC_007484.1", 
"NC_007484.1", "NC_007484.1", "NC_007484.1", "NC_007484.1", "NC_007484.1", 
"NC_007484.1", "NC_007484.1", "NC_007484.1", "NC_007484.1", "NC_007484.1", 
"NC_007484.1", "NC_007484.1", "NC_007484.1", "NC_007484.1", "NC_007484.1", 
"NC_007484.1", "NC_007484.1", "NC_007484.1", "NC_007484.1", "NC_007484.1", 
"NC_007484.1", "NC_007484.1", "NC_007484.1", "NC_007484.1", "NC_007484.1", 
"NC_007484.1", "NC_007484.1", "NC_007484.1", "NC_007484.1", "NC_007484.1", 
"NC_007484.1", "NC_007484.1", "NC_007484.1", "NC_007484.1", "NC_007484.1", 
"NZ_CP024608.1", "NZ_CP024608.1", "NZ_CP024608.1", "NZ_CP024608.1", 
"NZ_CP024608.1", "NZ_CP024608.1", "NZ_CP024608.1", "NZ_CP024608.1", 
"NZ_CP024608.1", "NZ_CP024608.1", "NZ_CP024608.1", "NZ_CP024608.1", 
"NZ_CP024608.1", "NZ_CP024608.1", "NZ_CP024608.1", "NZ_CP024608.1", 
"NZ_CP024608.1", "NZ_CP024608.1", "NZ_CP024608.1", "NZ_CP024608.1", 
"NZ_CP024608.1", "NZ_CP024608.1", "NZ_CP024608.1", "NZ_CP024608.1"
), pid = c("WP_002809076.1", "WP_011330607.1", "WP_011330607.1", 
"WP_011330607.1", "WP_002808619.1", "WP_011330608.1", "WP_011330609.1", 
"WP_011330609.1", "WP_011330609.1", "WP_002809840.1", "WP_002809840.1", 
"WP_011330611.1", "WP_011330611.1", "WP_011330611.1", "WP_011330611.1", 
"WP_011330611.1", "WP_011330611.1", "WP_011330611.1", "WP_011330611.1", 
"WP_011330611.1", "WP_011330611.1", "WP_002810725.1", "WP_002810725.1", 
"WP_002810725.1", "WP_002810725.1", "WP_002810725.1", "WP_002810725.1", 
"WP_002810725.1", "WP_002810725.1", "WP_002810725.1", "WP_002810725.1", 
"WP_002809254.1", "WP_002810570.1", "WP_002810570.1", "WP_002810570.1", 
"WP_002808873.1", "WP_002808873.1", "WP_002808873.1", "WP_099879443.1", 
"WP_099879445.1", "WP_099879446.1", "WP_099879448.1", "WP_099879448.1", 
"WP_099882743.1", "WP_099882743.1", "WP_099879450.1", "WP_099879450.1", 
"WP_099879452.1", "WP_099879452.1", "WP_099879452.1", "WP_099879452.1", 
"WP_099879452.1", "WP_099879452.1", "WP_099879452.1", "WP_099879452.1", 
"WP_099879452.1", "WP_099879452.1", "WP_099879454.1", "WP_099879456.1", 
"WP_099879456.1", "WP_010398811.1", "WP_099879457.1"), start = c(-1396010L, 
1396521L, 1396521L, 1396521L, 1398326L, 1399173L, 1400009L, 1400009L, 
1400009L, 1402293L, 1402293L, 1403259L, 1403259L, 1403259L, 1403259L, 
1403259L, 1403259L, 1403259L, 1403259L, 1403259L, 1403259L, -1410361L, 
-1410361L, -1410361L, -1410361L, -1410361L, -1410361L, -1410361L, 
-1410361L, -1410361L, -1410361L, -1411047L, -1413567L, -1413567L, 
-1413567L, -1415337L, -1415337L, -1415337L, -5782921L, -5783429L, 
-5784229L, 5784257L, 5784257L, 5785239L, 5785239L, 5786369L, 
5786369L, 5787495L, 5787495L, 5787495L, 5787495L, 5787495L, 5787495L, 
5787495L, 5787495L, 5787495L, 5787495L, -5793659L, 5793823L, 
5793823L, -5795030L, -5795864L), end = c(-1395207L, 1398329L, 
1398329L, 1398329L, 1399126L, 1399973L, 1402141L, 1402141L, 1402141L, 
1403249L, 1403249L, 1407758L, 1407758L, 1407758L, 1407758L, 1407758L, 
1407758L, 1407758L, 1407758L, 1407758L, 1407758L, -1407809L, 
-1407809L, -1407809L, -1407809L, -1407809L, -1407809L, -1407809L, 
-1407809L, -1407809L, -1407809L, -1410358L, -1411795L, -1411795L, 
-1411795L, -1413676L, -1413676L, -1413676L, -5782217L, -5782992L, 
-5783456L, 5785054L, 5785054L, 5786237L, 5786237L, 5787490L, 
5787490L, 5791931L, 5791931L, 5791931L, 5791931L, 5791931L, 5791931L, 
5791931L, 5791931L, 5791931L, 5791931L, -5792070L, 5794725L, 
5794725L, -5794827L, -5795493L), strand = c("reverse", "forward", 
"forward", "forward", "forward", "forward", "forward", "forward", 
"forward", "forward", "forward", "forward", "forward", "forward", 
"forward", "forward", "forward", "forward", "forward", "forward", 
"forward", "reverse", "reverse", "reverse", "reverse", "reverse", 
"reverse", "reverse", "reverse", "reverse", "reverse", "reverse", 
"reverse", "reverse", "reverse", "reverse", "reverse", "reverse", 
"reverse", "reverse", "reverse", "forward", "forward", "forward", 
"forward", "forward", "forward", "forward", "forward", "forward", 
"forward", "forward", "forward", "forward", "forward", "forward", 
"forward", "reverse", "forward", "forward", "reverse", "reverse"
), domain = c("Phos_pyr_kin", "TPP_enzyme_N", "TPP_enzyme_M", 
"TPP_enzyme_C", NA, "Citrate_synt", "SP", "Plug", "TonB_dep_Rec", 
"SP", "ABC_sub_bind", "SP", "TM", "HisKA", "HATPase_c", "Response_reg", 
"Response_reg", "Hpt", "Response_reg", "GGDEF", "EAL", "SP", 
"TM", "TM", "TM", "TM", "TM", "TM", "TM", "TM", "TM", "ABC_tran", 
"SP", "OEP", "OEP", "TM", "HlyD_D23", "YtkA", "RNase_T", "RNase_H", 
"Methyltransf_11", "Lactamase_B", "HAGH_C", "SP", "ABC_sub_bind", 
"SP", "ABC_sub_bind", "TM", "DUF2222", "TM", "HisKA", "HATPase_c", 
"Response_reg", "Hpt", "Response_reg", "GGDEF", "EAL", "Malate_synthase", 
"HTH_1", "LysR_substrate", "CSD", "Hpt"), from = c(-1395978, 
1396581, 1397172, 1397808, NA, 1399224, 1400012, 1400168, 1400606, 
1402296, 1402452, 1403262, 1403817, 1404075, 1404411, 1404819, 
1405251, 1405722, 1406037, 1406421, 1406946, -1407917, -1408661, 
-1408790, -1408946, -1409084, -1409180, -1409324, -1410044, -1410194, 
-1410317, -1410877, -1411918, -1412641, -1413259, -1413769, -1414588, 
-1415248, -5782712, -5783415, -5783864, 5784311, 5784791, 5785242, 
5785698, 5786372, 5786690, 5787540, 5787615, 5788020, 5788299, 
5788635, 5789448, 5789937, 5790252, 5790636, 5791161, -5793657, 
5793835, 5794084, -5795028, -5795817), to = c(-1395243, 1397112, 
1397580, 1398264, NA, 1399908, 1400078, 1400501, 1402136, 1402389, 
1403223, 1403367, 1403886, 1404270, 1404759, 1405167, 1405590, 
1405989, 1406373, 1406892, 1407654, -1407812, -1408595, -1408721, 
-1408889, -1409030, -1409102, -1409264, -1409987, -1410107, -1410254, 
-1410430, -1411798, -1412068, -1412707, -1413712, -1413874, -1414993, 
-5782229, -5782995, -5783522, 5784788, 5785052, 5785350, 5786205, 
5786486, 5787464, 5787594, 5788017, 5788092, 5788494, 5788977, 
5789790, 5790186, 5790588, 5791104, 5791869, -5792097, 5794012, 
5794702, -5794833, -5795538), evalue = c(4e-87, 9.9e-49, 2e-19, 
2.9e-23, NA, 0.0017, 0, 2e-20, 4.8e-48, 0, 8.1e-05, 0, 0, 3.4e-15, 
1.4e-29, 3.4e-06, 1.4e-23, 3.8e-08, 9e-25, 5.3e-46, 2.3e-75, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.2e-30, 0, 9.8e-15, 2.9e-20, 0, 
2.5e-22, 1.9e-06, 1.6e-31, 4.9e-47, 1.2e-07, 1e-10, 5.6e-19, 
0, 4e-11, 0, 2.4e-10, 0, 0.003, 0, 2.6e-13, 8.5e-29, 5.7e-22, 
3e-08, 4.6e-25, 1.7e-42, 7.7e-76, 1.9e-200, 1.2e-12, 9.3e-41, 
1e-27, 5e-08)), row.names = c(NA, -62L), class = c("tbl_df", 
"tbl", "data.frame"), .internal.selfref = <pointer: 0x55a63b2e3230>)

Then I tried this code:

library(gggenes)
library(ggtree)
library(ggtreeExtra)
library(treeio)
library(tidyverse)

my_genes <- read_tsv("gene_ans_subgenes_example.tsv")
myset <- my_genes %>% filter(nucleotide %in% c("NC_007484.1", "NZ_CP024608.1"))

ggplot(
  (myset %>% select(nucleotide,pid,start,end,strand) %>% distinct()),
  aes(xmin = start, xmax = end, y = strand)
) +
  geom_gene_arrow() +
  geom_gene_label(aes(label = pid)) +
  geom_subgene_arrow(
    data = myset,
    aes(xsubmin = from, xsubmax = to, fill = domain)
  ) +
  geom_subgene_label(
    data = myset,
    aes(xsubmin = from, xsubmax = to, label = domain),
    min.size = 0
  )

And finally I got this plot
image

What do I'm doing wrong??

Also, this was just with a set of the data.
The complete data are attached. If I try the same code with the entire data (my_genes rather myset) I got this error

Error in grid.Call(C_convert, x, as.integer(whatfrom), as.integer(whatto), :
Viewport has zero dimension(s)
In addition: Warning messages:
1: Removed 37 rows containing missing values (geom_subgene_arrow).
2: Removed 37 rows containing missing values (geom_subgene_label).

Thanks for any help

Control green line

Hi,

I got a simple question, how do I suppose to control the gray line?

I know it is generated by the theme_genes() but I'd like to control its color and alpha, or even the thickness of the line.

Below I give my tries.

p <- ggplot(example_genes, aes(xmin = start, xmax = end, y = molecule, fill = gene)) +
  geom_gene_arrow() +
  facet_wrap(~ molecule, scales = "free", ncol = 1) +
  scale_fill_brewer(palette = "Set3") 
p +  theme_genes()
p + theme_classic() +
  theme(
    axis.title.x=element_blank(),
    axis.text.x=element_blank(),
    axis.ticks.x=element_blank(), 
    axis.line.x = element_blank(),
    axis.title.y=element_blank(),
    axis.ticks.y=element_blank(), 
    axis.line.y = element_blank()
  )
p + theme_genes() +
  theme(
    axis.title.x=element_blank(),
    axis.text.x=element_blank(),
    axis.ticks.x=element_blank(), 
    axis.line.x = element_blank(),
    axis.title.y=element_blank(),
    axis.ticks.y=element_blank(), 
    axis.line.y = element_blank()
  )

Give us this:
image
image
image

Thanks a lot in advance.

using make_alignment_dummies() and forward aesthetic

Hi,
Thank you for putting together this package. I'm having trouble when simultaneously using make_alignment_dummies() with the forward aesthetic option. Using the example data provided:

dummies <- make_alignment_dummies( example_genes,aes(xmin = start, xmax = end, y = molecule, id = gene, forward=direction),on = "genE")
ggplot(example_genes, aes(xmin = start, xmax = end, y = molecule, fill = gene,forward=direction)) +  geom_gene_arrow() + geom_blank(data = dummies) + facet_wrap(~ molecule, scales = "free", ncol = 1) + scale_fill_brewer(palette = "Set3") + theme_genes()
Error in FUN(X[[i]], ...) : object 'direction' not found

I'm not sure what's going on... am I missing anything? Thank you!

Error in grid.Call

Sorry for disturb you. But I've met trouble when I using gggenes.
here're my code:

library(ggplot2)
library(gggenes)
ggplot(example_genes, aes(xmin = start, xmax = end, y = molecule, fill = gene)) + geom_gene_arrow() + facet_wrap(~ molecule, scales = "free", ncol = 1) + scale_fill_brewer(palette = "Set3")
Then the screen shows : Error in grid.Call(C_convert, x, as.integer(whatfrom), as.integer(whatto), :
Viewport has zero dimension(s)

I've tried to update Rstudio and all the other packages, but the problem was still unsolved. Anybody can help me?
Thank you very much.

Arrow direction

A feature request/suggestion/question... It would be useful to be able to change the direction of the arrow (from pointing right to pointing left) in cases where the two separate DNA strands would need to be represented. Is this already possible? Would it be something that you think should/could be implemented?

Features without arrows

Is it possible to plot genes without arrows? I'd like to be able to plot some non-coding elements such as transposon ends, or a region of interest where the transcriptional direction is unknown.

Modify theme_genes

Hi, nice extension!
Just a question about theme_genes
I can modify everything in theme except for the grey central line, none of the line/axis code for ggplot themes seem to work?

README not rendering correctly

The presence of README.html seems to be confusing github so it's not rendering the .md on landing.

Great looking package BTW - I was just promoting it when the render issue was noted.

vertical gene arrows?

Hello,

I was wondering if anyone knew of a solution to rotate the gene arrows.

I am trying to make a dot plot with gene arrows on the x axis and y axis but am having trouble figuring out how to rotate the arrows to point vertically instead.

Any help would be greatly appreciated.

Thanks,
Pierre

conflicts between gggenomes and gggenes

Hi,

The following 2 commands work well when I only install gggenes, but after installed the gggenomes, the command didn't work and get errors:

p<-ggplot(da, aes(xmin = start, xmax = end, y =molecule, fill = gene, label = gene))
p+geom_gene_arrow(arrow_body_height = unit(10, "mm"),arrowhead_height = unit(10, "mm"),arrowhead_width = unit(2, "mm"),alpha=0.8,colour="white")+geom_gene_label(height = grid::unit(8, "mm"), grow = FALSE)+theme_genes()+scale_x_continuous(breaks=seq(0, 35000, 4000))
Error in UseMethod("pull_genes") :
no applicable method for 'pull_genes' applied to an object of class "data.frame"
In addition: Warning message:
Ignoring unknown parameters: height, grow

put gggenes x-axes on common scale

Hi @wilkox,

Thanks for a very nice package. Really helpful. However, I'm having trouble putting all my genomes on a common numerical axis starting from the gene on which they are centered (BRD2, in green). You can see from the plot image that I have 11 genomes aligned on BRD2 but they all start at different points. I could renumber all the genes in the data.frame, and I have tried all the "breaks" and "labels" options, but I often get the error "Error: Breaks and labels are different lengths". So I must be missing something. I have attached the image and the dataframe (=object "reversetab5" in code). The code I used was:

reversetab5<-read.table(file="11_hap_5_gene_tab2_genes_only.txt"

dummies <- make_alignment_dummies(
reversetab5,
aes(xmin = negstart03, xmax = negend03, y = molecule, id = gene),
on = "BRD2"
)
p<-ggplot(reversetab5,aes(xmin = negstart03, xmax = negend03, y = molecule, fill = gene, label = gene)) +
geom_gene_arrow(arrowhead_height = unit(3, "mm"), arrowhead_width = unit(1, "mm"),colour="blue",size=0) +
geom_blank(data = dummies) + facet_wrap(~ molecule, scales = "free", ncol = 1) +
scale_fill_brewer(palette = "Set3") + scale_x_continuous(labels = scales::comma) + theme_genes() +
theme(axis.text = element_text(size = 10))

ggsave("TEs_segment9.pdf",p, height = 20, width = 10,limitsize = FALSE)

11_hap_5_gene_tab2_genes_only.txt

TEs_segment9.pdf

Virus genome

Hello,
I am trying to use your package with viruses. I have encountered a problem, I do not know how to overcome.

Here the code:

library(ggplot2)
library(gggenes)

my <- data.frame(virus = c(rep("Example", 4), rep("Example2", 4)),
             ORF = rep(c("ORF1", "ORF2", "ORF2", "ORF3"), 2),
             start = rep(c(43, 150, 150, 250), 2),
             end = rep(c(146, 204, 204, 319), 2),
             strand = c("forward", "forward", "forward", "forward",
                        "forward", "forward", "forward", "reverse"),
             subgene= rep(c("RdRp", "Met", "Hel", "Unknown"), 2),
             from = rep(c(43, 155, 180, 260), 2),
             to = rep(c(146, 175, 204, 300), 2),
             direction = c(1, 1, 1, 1, 
                           1, 1, 1, -1))

ggplot(my, aes(xmin = start, xmax = end, y = virus, label = subgene,
               forward = direction)) +
    # facet_wrap(~ virus, scales = "free", ncol = 1) +
    geom_gene_arrow(fill = "white") +
    geom_subgene_arrow(data = my,
                       aes(xmin = start, xmax = end, y = virus, fill = subgene,
                           xsubmin = from, xsubmax = to), color="black", alpha=.7) +
    geom_subgene_label(aes(xsubmin = from, xsubmax = to)) +
    theme_genes()
#> Warning: Subgene 8 (260..300) breaks boundaries of gene (250..319), skipping

Created on 2020-04-16 by the reprex package (v0.3.0)

As you can see the subdomain in "Example2", ORF4 is not displayed. There is any way to overcome this behaviour.

Thank you,
Marco

Circular View of genome

Hi,

I love gggenes and would also like to use it for my publication, but therefore I would/need like to show some genomes in their circular view. Is it possible to do so with gggene?

Best

Kat

Scale showing the size of 1 kb

Hello!
Thanks for the great package to draw gene maps. Very helpful.
Is there a way to display a small scale showing the size of 1 kb?
Right now, the figure I got displays the scale from 0 to 15000, at the interval of 5000. I was wondering how to show the length of just 1 kb?
And is there a way to move the position of the scale line?

Also, right now I can display the gene name in or above the box.
Is there a way to display the gene name "geneA" in the box, and also other features like the NCBI gene locus number "APS_1234" or the gene function "MFS transporter" above or below the box?

Thanks for the help!
Best,
Mei

Perfect alignment of gene island

Hallo , first of all this is a absolutely wonderful visualisation tool for gene maps.
I want to draw gene maps with differing composition of genes due to mutations and frame shifts.
This means that in each line different genes are missing. Still, I want the maps to be aligned according to overlapping genes.

Screenshot from 2019-07-05 14-56-16

Here all lines are aligned to genE, like in the example, but not line 1. Which should aligned to protD. How it would be possible to extend this alignment feature ?

Default Color

Hi Wilkox,
I am try to set up a custom colour scheme using the default colours of gggenes.
Which are your default colours, which you use appart from ColorBrewer::Set3 ?

Gene cluster orientation reverse complements

Dear David,
I really appreciate the work you invested into this package, extremely useful!

I have one issue and maybe you know a smart solution, since you better know the possibilities of the package: In the exampe_genes, the genes always show the similar order. In real NCBI Datasets this is however rarely the case. Usually you end up with something like this:

sub_genomeA <- example_genes %>% filter(molecule == "Genome2")
sub_genomeB <- example_genes %>% filter(molecule == "Genome3")

sub_genomeA$start <- -sub_genomeA$start
sub_genomeA$end <- -sub_genomeA$end
baseval <- min(c(sub_genomeA$start,sub_genomeA$end))
sub_genomeA$start <- sub_genomeA$start - baseval
sub_genomeA$end<- sub_genomeA$end - baseval

sub_genome <- rbind(sub_genomeA,sub_genomeB)

ggplot(sub_genome, aes(xmin = start, xmax = end, y = molecule, fill = gene,forward = orientation)) +
  geom_gene_arrow() +
  facet_wrap(~ molecule, scales = "free", ncol = 1) +
  scale_fill_brewer(palette = "Set3") +
  theme_genes()

Can you imagine a function to identify such reverse complements and reverse them with a specific function ? Such that the target gene , like genE always points into same direction.

Best ,
Michael

Add scaffold length, sort them and display start-stop

Hello I write this message in order to ask you if this kind of figure can be done with gggenes :

Capture d’écran 2020-08-17 à 13 04 26

Indeed I wondered if it was possible to (1) add the information about the chr or scaffold length and (2) order the figure with the longest scaffold on the top and (3) add the start and stop coordinates of each scaffold?

It would be very usefull since all scaffold have different length and this information on a plot can be really usefull.

Thank you very much for you time and thank you for the package.

conflicts between "make_alignment_dummies()" and "forward" aesthetic

the gene cluster align with RDase_A

rdhA_center <- make_alignment_dummies(
rdhs_cluster,
aes(xmin = start, xmax = end, y = rdhs_tree.tip.label, id = gene),
on = "RDase_A")

rdhs_operon2 <- ggplot(rdhs_cluster, aes(xmin = start, xmax = end, y = rdhs_tree.tip.label,
fill = gene, forward = orientation)) +
geom_gene_arrow() +
geom_blank(data = rdhA_center) +
facet_wrap(~ rdhs_tree.tip.label, scales = "free", ncol = 1) +
scale_fill_brewer(palette = "Set3") +
theme_genes()

rdhs_operon2

##########
Error in FUN(X[[i]], ...) : object 'orientation' not found

gggenes works not with plotly

Hi, it would be absolutely a dream if the gggenes plot would be transformable to a plotly object.

library(ggplot2)
library(gggenes)
p <- ggplot(example_genes, aes(xmin = start, xmax = end, y = molecule, fill = gene)) +  geom_gene_arrow() +
  facet_wrap(~ molecule,scales="free", ncol = 1) +
  scale_fill_brewer(palette = "Set3") + theme_genes()

p <- ggplotly(p)

Error in convertUnit(x, unitTo, "y", "dimension", "y", "dimension", valueOnly = valueOnly) :
'x' argument must be a unit object

Gene orientation

First of all, great work!

I would like to make three suggestions for the visualization:

  • adding directionality to the arrows so that we could have for instance genB pointing to the right. The information could be added as an extra column in the data.
  • Draw genes as boxes, that is without arrows at all, for those situations when directionality is not important.
  • label the genes with their names directly or using a ggreppel-style approach.

I know it is a small and recent package and you probably already have this in your todo, so consider this as 👍 vote for enhanced features.

Cheers.

Forthcoming release of ggplot2 and gggenes

We are contacting you because you are the maintainer of gggenes, which imports ggplot2 and uses vdiffr to manage visual test cases. The upcoming release of ggplot2 includes several improvements to plot rendering, including the ability to specify lineend and linejoin in geom_rect() and geom_tile(), and improved rendering of text. These improvements will result in subtle changes to your vdiffr dopplegangers when the new version is released.

Because vdiffr test cases do not run on CRAN by default, your CRAN checks will still pass. However, we suggest updating your visual test cases with the new version of ggplot2 as soon as possible to avoid confusion. You can install the development version of ggplot2 using remotes::install_github("tidyverse/ggplot2").

If you have any questions, let me know!

Nudge overlapping feature labels

Hi, and thanks for a great tool! We're using this to show genetic variants in a gene region. Since those tend to be clustered, it's common that the labels overlap. It would be greatly appreciated if you could add the option to draw them without overlap and then use slanted lines to the correct point.

Cheers,
Rasmus

Legend Size

The font size of the legend is too large if many different genes are shown in the gggenes plot. Is it possible to change the size of the legend. I tried

theme(legend.text=element_text(size=9))
theme_genes(base_size=9)

None of them worked.

Place gene label above gene?

Hello,

I have been looking to an R package that does this for a very long time - this seems like a well done and highly useful package.

I have one question: is there a way to get the gene label placed above the gene? this would be especially helpful with short genes, as it would allow the label to extend past the gene end.

Thanks for any help.

Can't change color palette when filling by continuous variable

Hello, I'm finding the extension very useful, but I have a case where I'd like to fill the genes by a continuous variable. This seems to work fine, but only with the default continuous color scale. Attempts to change the palette give no error, but no change either.

For example, these produce the same plot:

# R v4.1.1
# gggenes v0.4.1.9004
# ggplot2 v3.3.5

ggplot(example_genes, aes(xmin = start, xmax = end, y = molecule, fill = start)) +
  geom_gene_arrow() +
  facet_wrap(~ molecule, scales = "free", ncol = 1)

ggplot(example_genes, aes(xmin = start, xmax = end, y = molecule, fill = start)) +
  geom_gene_arrow() +
  facet_wrap(~ molecule, scales = "free", ncol = 1) +
  scale_colour_gradient2()

ggplot(example_genes, aes(xmin = start, xmax = end, y = molecule, fill = start)) +
  geom_gene_arrow() +
  facet_wrap(~ molecule, scales = "free", ncol = 1) +
  scale_colour_brewer(palette = "Greens")

In the mean time I'll just bucket the variable, but I figured I bring it to your attention in case it's an easy fix.

Thanks for your help!
-Zach

error with subgene colours on reverse arrows

Plotting genes in forward direction with colouring of subgene segments the genes works, however fails when trying to plot the genes in reverse orientation with colouring of subgene segements

e.g.
ggplot(example, aes(xmin=example$start, xmax=example$end, y=example$molecule, forward=example$direction))+geom_gene_arrow(fill = "white") +geom_subgene_arrow(data = example,aes(xmin = example$start, xmax = example$end, y = example$molecule, fill = example$gene,xsubmin = example$submin, xsubmax = example$submax), color="black", alpha=.7) +theme_genes()

Warning message:
Subgene 1 (4492..4594) breaks boundaries of gene (4492..4594), skipping

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.