geom_gene {gggenomes} | R Documentation |
Draw gene models
Description
Draw coding sequences, mRNAs and other non-coding features. Supports
multi-exon features. CDS and mRNAs in the same group are plotted together.
They can therefore also be positioned as a single unit using the position
argument.
Usage
geom_gene(
mapping = NULL,
data = genes(),
stat = "identity",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
size = 2,
rna_size = size,
shape = size,
rna_shape = shape,
intron_shape = size,
intron_types = c("CDS", "mRNA", "tRNA", "tmRNA", "ncRNA", "rRNA"),
cds_aes = NULL,
rna_aes = NULL,
intron_aes = NULL,
...
)
Arguments
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
na.rm |
remove na values |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
size , rna_size |
the size of the gene model, aka the height of the
polygons. |
shape , rna_shape |
vector of height and width of the arrow tip, defaults
to size. If only one value is provided it is recycled. Set '0' to
deactivates arrow-shaped tips. |
intron_shape |
single value controlling the kink of the intron line. Defaults to size. Set 0 for straight lines between exons. |
intron_types |
introns will only be computed/drawn for features with types listed here. Set to "CDS" to plot mRNAs as continous features, and set to NA to completely ignore introns. |
cds_aes , rna_aes , intron_aes |
overwrite aesthetics for different model
parts. Need to be wrapped in |
... |
passed to layer params |
Value
A ggplot2 layer with genes.
Aesthetics
geom_gene()
understands the following aesthetics (required aesthetics are in bold):
Learn more about setting these aesthetics in vignette("ggplot2-specs")
.
'type' and 'group' (mapped to 'type' and 'geom_id' by default) power the proper recognition of CDS and their corresponding mRNAs so that they can be drawn as one composite object. Overwrite 'group' to plot CDS and mRNAs independently.
'introns' (mapped to 'introns') is used to compute intron/exon boundaries.
Use the parameter intron_types
if you want to disable introns.
Examples
gggenomes(genes = emale_genes) +
geom_gene()
gggenomes(genes = emale_genes) +
geom_gene(aes(fill = as.numeric(gc_content)), position = "strand") +
scale_fill_viridis_b()
g0 <- read_gff3(ex("eden-utr.gff"))
gggenomes(genes = g0) +
# all features in the "genes" regardless of type
geom_feat(data = feats(genes)) +
annotate("text", label = "geom_feat", x = -15, y = .9) + xlim(-20, NA) +
# only features in the "genes" of geneish type (implicit `data=genes()`)
geom_gene() +
geom_gene_tag(aes(label = ifelse(is.na(type), "<NA>", type)), data = genes(.gene_types = NULL)) +
annotate("text", label = "geom_gene", x = -15, y = 1) +
# control which types are returned from the track
geom_gene(aes(y = 1.1), data = genes(.gene_types = c("CDS", "misc_RNA"))) +
annotate("text", label = "gene_types", x = -15, y = 1.1) +
# control which types can have introns
geom_gene(
aes(y = 1.2, yend = 1.2),
data = genes(.gene_types = c("CDS", "misc_RNA")),
intron_types = "misc_RNA"
) +
annotate("text", label = "intron_types", x = -15, y = 1.2)
# spliced genes
library(patchwork)
gg <- gggenomes(genes = g0)
gg + geom_gene(position = "pile") +
gg + geom_gene(aes(fill = type),
position = "pile",
shape = 0, intron_shape = 0, color = "white"
) +
# some fine-control on cds/rna/intron after_scale aesthetics
gg + geom_gene(aes(fill = geom_id),
position = "pile",
size = 2, shape = c(4, 3), rna_size = 2, intron_shape = 4, stroke = 0,
cds_aes = aes(fill = "black"), rna_aes = aes(fill = fill),
intron_aes = aes(colour = fill, stroke = 2)
) +
scale_fill_viridis_d() +
# fun with introns
gg + geom_gene(aes(fill = geom_id), position = "pile", size = 3, shape = c(4, 4)) +
gg + geom_gene(aes(fill = geom_id),
position = "pile", size = 3, shape = c(4, 4),
intron_types = c()
) +
gg + geom_gene(aes(fill = geom_id),
position = "pile", size = 3, shape = c(4, 4),
intron_types = "CDS"
)