| plot_exclusive_junctions | R Documentation |
Draws a gene-model view of a gene's transcripts (one row per transcript)
with splice junctions rendered as arcs above each row. Junctions used by a
single transcript of the gene ("transcript-exclusive") are drawn as solid
black arcs; shared junctions as thin grey arcs. Works with both
Ensembl-style and RefSeq-style GTFs: if a row has no gene_name
attribute, gene_id is used; if no transcript_name, transcript_id
is used.
plot_exclusive_junctions(
gtf,
target_gene,
show_exclusive = TRUE,
transcript = NULL,
curvature = -0.2,
out_file = NULL
)
gtf |
Either a path to an Ensembl- or RefSeq-style GTF, or a
pre-loaded |
target_gene |
Gene symbol (matches |
show_exclusive |
Logical (default |
transcript |
Optional character vector of transcript names to pin
the plot to (overrides |
curvature |
Numeric, arc-height knob for |
out_file |
Optional character. If given, the plot is also written
to this file with |
An S3 object of class "splikit_junction_plot" (a list) with
components:
plotA ggplot object.
infoA data.table with one row per drawn (transcript,
junction) pair and columns gene_name, gene_id,
transcript_name, transcript_id, chr,
strand, j_start, j_end, j_width,
exclusive, n_tx_with_junction,
observed_in_eventdata, row_names_mtx,
is_annot. For GTF-only calls the last three are NA.
exons, junctions, tx_orderThe underlying tables used to build the plot, retained for advanced users.
Printing the object renders the plot and then prints info.
Requires the ggplot2 package (declared in Suggests).
if (requireNamespace("ggplot2", quietly = TRUE)) {
# Build a tiny synthetic GTF as a data.table (no external file needed).
# tx1 has 3 exons (2 junctions); tx2 has 2 exons (1 junction).
gtf <- data.table::data.table(
seqname = "chr1",
source = "toy",
type = rep("exon", 5),
start = c(100, 300, 500, 100, 500),
end = c(200, 400, 600, 200, 600),
score = ".",
strand = "+",
frame = ".",
attr = c(
'gene_name "FOO"; transcript_id "tx1"; exon_number "1";',
'gene_name "FOO"; transcript_id "tx1"; exon_number "2";',
'gene_name "FOO"; transcript_id "tx1"; exon_number "3";',
'gene_name "FOO"; transcript_id "tx2"; exon_number "1";',
'gene_name "FOO"; transcript_id "tx2"; exon_number "2";'
)
)
res <- plot_exclusive_junctions(gtf, "FOO")
res$info
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.