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.
Usage
plot_exclusive_junctions(
gtf,
target_gene,
show_exclusive = TRUE,
transcript = NULL,
curvature = -0.2,
out_file = NULL
)Arguments
- gtf
Either a path to an Ensembl- or RefSeq-style GTF, or a pre-loaded
data.tableof GTF rows.- target_gene
Gene symbol (matches
gene_name, orgene_idif nogene_nameis present).- show_exclusive
Logical (default
TRUE). Restrict to transcripts that own >= 1 exclusive junction.- transcript
Optional character vector of transcript names to pin the plot to (overrides
show_exclusive).- curvature
Numeric, arc-height knob for
ggplot2::geom_curve().- out_file
Optional character. If given, the plot is also written to this file with
ggplot2::ggsave().
Value
An S3 object of class "splikit_junction_plot" (a list) with
components:
plotA
ggplotobject.infoA
data.tablewith one row per drawn (transcript, junction) pair and columnsgene_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 areNA.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.
Examples
# \donttest{
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
}
#> Key: <transcript_name>
#> gene_name gene_id transcript_name transcript_id chr strand j_start j_end
#> <char> <char> <char> <char> <char> <char> <num> <num>
#> 1: FOO <NA> tx1 tx1 chr1 + 201 299
#> 2: FOO <NA> tx1 tx1 chr1 + 401 499
#> 3: FOO <NA> tx2 tx2 chr1 + 201 499
#> j_width exclusive n_tx_with_junction observed_in_eventdata row_names_mtx
#> <num> <lgcl> <int> <lgcl> <char>
#> 1: 99 TRUE 1 NA <NA>
#> 2: 99 TRUE 1 NA <NA>
#> 3: 299 TRUE 1 NA <NA>
#> is_annot
#> <lgcl>
#> 1: NA
#> 2: NA
#> 3: NA
# }
