geom_intron | R Documentation |
geom_intron()
draws horizontal lines with central arrows that are designed
to represent introns. In combination with geom_range()
/geom_half_range()
,
these geoms form the core components for visualizing transcript structures.
geom_intron(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
arrow = grid::arrow(ends = "last", length = grid::unit(0.1, "inches")),
arrow.fill = NULL,
lineend = "butt",
linejoin = "round",
na.rm = FALSE,
arrow.min.intron.length = 0,
show.legend = NA,
inherit.aes = TRUE
)
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
|
... |
Other arguments passed on to
|
arrow |
specification for arrow heads, as created by |
arrow.fill |
fill colour to use for the arrow head (if closed). |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
na.rm |
If |
arrow.min.intron.length |
|
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
geom_intron()
requires the following aes()
; xstart
, xend
and y
(e.g. transcript name). If users do not have intron co-ordinates, these can
be generated from the corresponding exons using to_intron()
. The strand
option (one of "+" or "-") adjusts the arrow direction to match the direction
of transcription. The arrow.min.intron.length
parameter can be useful to
remove strand arrows that overlap exons, which can be a problem if plotted
introns include those that are relatively short.
the return value of a geom_*
function is not intended to be
directly handled by users. Therefore, geom_*
functions should never be
executed in isolation, rather used in combination with a
ggplot2::ggplot()
call.
library(magrittr)
library(ggplot2)
# to illustrate the package's functionality
# ggtranscript includes example transcript annotation
pknox1_annotation %>% head()
# extract exons
pknox1_exons <- pknox1_annotation %>% dplyr::filter(type == "exon")
pknox1_exons %>% head()
# to_intron() is a helper function included in ggtranscript
# which is useful for converting exon co-ordinates to introns
pknox1_introns <- pknox1_exons %>% to_intron(group_var = "transcript_name")
pknox1_introns %>% head()
base <- pknox1_introns %>%
ggplot(aes(
xstart = start,
xend = end,
y = transcript_name
))
# by default, geom_intron() assumes introns originate from the "+" strand
base + geom_intron()
# however this can be modified using the strand option
base + geom_intron(strand = "-")
# strand can also be set as an aes()
base + geom_intron(aes(strand = strand))
# as a ggplot2 extension, ggtranscript geoms inherit the
# the functionality from the parameters and aesthetics in ggplot2
base + geom_intron(
aes(colour = transcript_name),
linewidth = 1
)
# together, geom_range() and geom_intron() are designed to visualize
# the core components of transcript annotation
pknox1_exons %>%
ggplot(aes(
xstart = start,
xend = end,
y = transcript_name
)) +
geom_range() +
geom_intron(
data = pknox1_introns
)
# for short introns, sometimes strand arrows will overlap exons
# to avoid this, users can set the arrow.min.intron.length parameter
pknox1_exons %>%
ggplot(aes(
xstart = start,
xend = end,
y = transcript_name
)) +
geom_range() +
geom_intron(
data = pknox1_introns,
arrow.min.intron.length = 3500
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.