Skip to contents

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.table of GTF rows.

target_gene

Gene symbol (matches gene_name, or gene_id if no gene_name is 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:

plot

A ggplot object.

info

A 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_order

The underlying tables used to build the plot, retained for advanced users.

Printing the object renders the plot and then prints info.

Required packages

Requires the ggplot2 package (declared in Suggests).

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
# }