Renders a nucleotide sequence track using one of two visual styles. Colors follow UCSC Genome Browser conventions by default (A = green, C = blue, G = gold, T = red, N = grey).
Usage
geom_sequence(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
style = c("text", "tile"),
show_labels = TRUE,
label_size = 3,
label_color = "white",
tile_height = 0.8,
tile_width = 1,
na.rm = TRUE,
show.legend = NA,
inherit.aes = TRUE
)Arguments
- mapping
Aesthetic mappings. Required:
x(genomic position),label(nucleotide character). Optional:fill(nucleotide color),colour(tile border color, only used whenstyle = "tile").- data
Dataset (default: NULL).
- stat
Statistic to use (default:
"identity").- position
Position adjustment (default:
"identity").- ...
Other arguments passed on to
ggplot2::layer().- style
Character. Visual style for the sequence track:
"text"(default): bold, colored nucleotide letters with no background or border. Letter color is taken from thefillaesthetic."tile": colored background tiles with letters on top (controlled byshow_labelsandlabel_color).
- show_labels
Logical. Whether to draw nucleotide letter labels. For
style = "text", labels are always drawn whenshow_labels = TRUE. Forstyle = "tile", labels are drawn on top of the colored tiles. Default:TRUE.- label_size
Numeric. Font size for nucleotide letters (in pt). Default:
3.- label_color
Character. Color of the nucleotide letter text, used only when
style = "tile". Forstyle = "text", letter color is taken from thefillaesthetic. Default:"white".- tile_height
Numeric (0–1). Height of each nucleotide tile as a proportion of the y-axis range. Only used when
style = "tile". Default:0.8.- tile_width
Numeric. Width of each nucleotide tile in data (genomic) units. Only used when
style = "tile". Default:1(one base pair per tile).- na.rm
Logical. Silently remove
NAvalues. Default:TRUE.- show.legend
logical. Should this layer be included in the legends?
NA, the default, includes if any aesthetics are mapped.FALSEnever includes, andTRUEalways includes. It can also be a named logical vector to finely select the aesthetics to display. To include legend keys for all levels, even when no data exists, useTRUE. IfNA, all levels are shown in legend, but unobserved levels are omitted.- inherit.aes
If
FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g.annotation_borders().
Examples
if (FALSE) { # \dontrun{
library(ggplot2)
df <- data.frame(
position = 1:10,
nucleotide = c("A", "T", "G", "C", "A", "T", "G", "C", "N", "A"),
fill = c("#00A800", "#CC0000", "#CC9900", "#0000CC",
"#00A800", "#CC0000", "#CC9900", "#0000CC", "#999999", "#00A800")
)
ggplot(df, aes(x = position, label = nucleotide, fill = fill)) +
geom_sequence() +
ggplot2::scale_fill_identity()
} # }