wilkox / gggenes

➡️️➡️️⬅️️➡️️ Draw gene arrow maps in ggplot2
http://wilkox.org/gggenes
477 stars 49 forks source link

Gene length issue #76

Open chantisakee opened 3 months ago

chantisakee commented 3 months ago

Hi @wilkox , Thank you for this amazing package. It's really helpful :) I have a problem with the visualization of gene length (group_506) as I have attached the files. Pic_01 is the plot that i need, and Pic_02 is what i got. I'm quite not sure whether anything i can do to increase the length of group_506. 01 02

this is the code i used:

ggplot(input, 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()

this is my dataset:

 molecule      gene  start    end orientation

1 NC_006142.1 group_506 906635 906880 TRUE 2 NC_006142.1 group_505 841537 841782 TRUE 3 B9991CWPP group_506 908080 908325 TRUE 4 B9991CWPP group_505 842201 842446 TRUE 5 TH1527 group_506 907512 907757 TRUE 6 TH1527 group_505 841633 841878 TRUE

And when i tried to use dummies to align by group_505, Pic_03 is the plot i got 03

`dummies <- make_alignment_dummies( input, aes(xmin = start, xmax = end, y = molecule, id = gene), on = "group_505" )

ggplot(input, aes(xmin = start, xmax = end, y = molecule, fill = gene, label = gene)) + geom_gene_arrow(arrowhead_height = unit(3, "mm"), arrowhead_width = unit(1, "mm")) + geom_gene_label(align = "left") + geom_blank(data = dummies) + facet_wrap(~ molecule, scales = "free", ncol = 1) + scale_fill_brewer(palette = "Set3") + theme_genes()`

Thank you

wilkox commented 3 months ago

Hi @chantisakee,

Thanks for your kind words about the package. The gene map in Pic_01 is not drawn to scale. For example, in molecule NC_006142.1, the distance between the two genes based on their locations is about 65,000 bp, but the space between them in the image is only about 1.5 times the width of the genes which are 246 bp in length. ggplot2 draws the genes with an accurate x-axis scale, which is why they are (correctly) drawn so small and far apart in Pic_02.

It is possible to draw something like Pic_01 with ggplot2 (you don't even need gggenes), but it would probably be easier to use vector graphics software like Inkscape or Adobe Illustrator instead, as the image is more of a schematic illustration than a plot.