View source: R/geom_junction.R
geom_junction | R Documentation |
geom_junction()
draws curves that are designed to represent junction reads
from RNA-sequencing data. It can be useful to overlay junction data on
transcript annotation (plotted using geom_range()
/geom_half_range()
and
geom_intron()
) to understand which splicing events or transcripts have
support from RNA-sequencing data.
geom_junction(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
junction.orientation = "alternating",
junction.y.max = 1,
angle = 90,
ncp = 15,
na.rm = FALSE,
orientation = NA,
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
|
junction.orientation |
|
junction.y.max |
|
angle |
A numeric value between 0 and 180, giving an amount to skew the control points of the curve. Values less than 90 skew the curve towards the start point and values greater than 90 skew the curve towards the end point. |
ncp |
The number of control points used to draw the curve. More control points creates a smoother curve. |
na.rm |
If |
orientation |
The orientation of the layer. The default ( |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
... |
Other arguments passed on to
|
geom_junction()
requires the following aes()
; xstart
, xend
and y
(e.g. transcript name). geom_junction()
curves can be modified using
junction.y.max
, which can be useful when junctions overlap one
another/other transcripts or extend beyond the plot margins. By default,
junction curves will alternate between being plotted on the top and bottom of
each transcript (y
), however this can be modified via
junction.orientation
.
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
sod1_annotation %>% head()
# as well as a set of example (unannotated) junctions
# originating from GTEx and downloaded via the Bioconductor package snapcount
sod1_junctions
# extract exons
sod1_exons <- sod1_annotation %>% dplyr::filter(
type == "exon",
transcript_name == "SOD1-201"
)
sod1_exons %>% head()
# add transcript_name to junctions for plotting
sod1_junctions <- sod1_junctions %>%
dplyr::mutate(transcript_name = "SOD1-201")
# junctions can be plotted as curves using geom_junction()
base <- sod1_junctions %>%
ggplot2::ggplot(ggplot2::aes(
xstart = start,
xend = end,
y = transcript_name
))
# sometimes, depending on the number and widths of transcripts and junctions
# junctions will go overlap one another or extend beyond the plot margin
base + geom_junction()
# in such cases, junction.y.max can be adjusted to modify the max y of curves
base + geom_junction(junction.y.max = 0.5)
# ncp can be used improve the smoothness of curves
base + geom_junction(junction.y.max = 0.5, ncp = 30)
# junction.orientation controls where the junction are plotted
# with respect to each transcript
# either alternating (default), or on the top or bottom
base + geom_junction(junction.orientation = "top", junction.y.max = 0.5)
base + geom_junction(junction.orientation = "bottom", junction.y.max = 0.5)
# it can be useful useful to overlay junction curves onto existing annotation
# plotted using geom_range() and geom_intron()
base <- sod1_exons %>%
ggplot(aes(
xstart = start,
xend = end,
y = transcript_name
)) +
geom_range() +
geom_intron(
data = to_intron(sod1_exons, "transcript_name")
)
base + geom_junction(
data = sod1_junctions,
junction.y.max = 0.5
)
# as a ggplot2 extension, ggtranscript geoms inherit the
# the functionality from the parameters and aesthetics in ggplot2
# this can be useful when mapping junction thickness to their counts
base + geom_junction(
data = sod1_junctions,
aes(linewidth = mean_count),
junction.y.max = 0.5,
colour = "purple"
) +
scale_linewidth(range = c(0.1, 1))
# it can be useful to combine geom_junction() with geom_half_range()
sod1_exons %>%
ggplot(aes(
xstart = start,
xend = end,
y = transcript_name
)) +
geom_half_range() +
geom_intron(
data = to_intron(sod1_exons, "transcript_name")
) +
geom_junction(
data = sod1_junctions,
aes(linewidth = mean_count),
junction.y.max = 0.5,
junction.orientation = "top",
colour = "purple"
) +
scale_linewidth(range = c(0.1, 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.