## ---- echo = FALSE------------------------------------------------------------ knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 6, fig.height = 10 ) ## ----geom_gene_arrow, message = FALSE----------------------------------------- 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") ## ----theme_genes-------------------------------------------------------------- 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() ## ----make_alignment_dummies--------------------------------------------------- dummies <- make_alignment_dummies( example_genes, aes(xmin = start, xmax = end, y = molecule, id = gene), on = "genE" ) ggplot(example_genes, aes(xmin = start, xmax = end, y = molecule, fill = gene)) + geom_gene_arrow() + geom_blank(data = dummies) + facet_wrap(~ molecule, scales = "free", ncol = 1) + scale_fill_brewer(palette = "Set3") + theme_genes() ## ----labelled_genes----------------------------------------------------------- ggplot(example_genes, 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() ## ----reversing_direction------------------------------------------------------ ggplot(example_genes, 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() ## ----subgenes----------------------------------------------------------------- ggplot(example_genes, aes(xmin = start, xmax = end, y = molecule)) + facet_wrap(~ molecule, scales = "free", ncol = 1) + geom_gene_arrow(fill = "white") + geom_subgene_arrow(data = example_subgenes, aes(xmin = start, xmax = end, y = molecule, fill = gene, xsubmin = from, xsubmax = to), color="black", alpha=.7) + theme_genes() ## ----subgene labels, fig.height = 2------------------------------------------- ggplot(subset(example_genes, molecule == "Genome4" & gene == "genA"), aes(xmin = start, xmax = end, y = strand) ) + geom_gene_arrow() + geom_gene_label(aes(label = gene)) + geom_subgene_arrow( data = subset(example_subgenes, molecule == "Genome4" & gene == "genA"), aes(xsubmin = from, xsubmax = to, fill = subgene) ) + geom_subgene_label( data = subset(example_subgenes, molecule == "Genome4" & gene == "genA"), aes(xsubmin = from, xsubmax = to, label = subgene), min.size = 0 ) ## ----------------------------------------------------------------------------- ggplot(example_genes, aes(xmin = start, xmax = end, y = molecule, fill = gene)) + geom_feature( data = example_features, aes(x = position, y = molecule, forward = forward) ) + geom_feature_label( data = example_features, aes(x = position, y = molecule, label = name, forward = forward) ) + geom_gene_arrow() + geom_blank(data = example_dummies) + facet_wrap(~ molecule, scales = "free", ncol = 1) + scale_fill_brewer(palette = "Set3") + theme_genes()