Prepare splicejam data environment from a TxDb annotation package
Source:R/splicejam-shiny-data.R
splicejamDataFromTxDb.RdPrepare splicejam data environment from a TxDb annotation package
Usage
splicejamDataFromTxDb(
txdb,
ann_lib = NULL,
tx2geneDF = NULL,
detectedTx = NULL,
detectedGenes = NULL,
filesDF = NULL,
color_sub = NULL,
verbose = FALSE,
...
)Arguments
- txdb
TxDbobject, typically loaded from a Bioconductor annotation package such asTxDb.Mmusculus.UCSC.mm10.knownGene.- ann_lib
characterstring naming an installed Bioconductor organism annotation package (e.g."org.Mm.eg.db"). Must correspond to the same organism astxdb. No cross-validation is performed.When NULL as default, it will try to generate a suitable annotation name using the txdb metadata 'Organism', using the first letter of the first two words in the organism name. This process works for most common species, but will fail for things like E. coli K12.
- tx2geneDF
data.frame, default NULL.When NULL,
ann_libis used to derivetx2geneDF.When provided, it is used and
ann_libis ignored.The 'gene_id' values must exactly match:
names(GenomicFeatures::genes(txdb, single.strand.genes.only=FALSE)).The 'gene_name' column will be used to name gene data.
The 'transcript_id' values must exactly match values 'tx_name' from:
GenomicFeatures::transcripts(txdb).
- detectedTx
charactervector oftranscript_idvalues representing detected (expressed) transcripts. WhenNULL(default), all transcripts in theTxDbare used. Values not found intx2geneDF$transcript_idare silently dropped.- detectedGenes
charactervector ofgene_name(SYMBOL) values representing genes of interest. WhenNULL(default), genes are derived fromdetectedTxviatx2geneDF. Values not found intx2geneDF$gene_nameare silently dropped.- filesDF
optional
data.framewith at minimum colnames"sample_id","url","type". Stored in the returned environment unchanged.- color_sub
optional named
charactervector of R colors, whose names should matchfilesDF$sample_id. WhenfilesDFis provided butcolor_subisNULL, colors are derived automatically usingcolorjam::group2colors().- verbose
logicalwhether to print verbose output.- ...
additional arguments are ignored.
Value
environment containing:
flatExonsByGene—GRangesListwith non-overlapping exons per gene, named bygene_name.flatExonsByTx—GRangesListwith non-overlapping exons per transcript, named bytranscript_id.tx2geneDF—data.framewith colnames"transcript_id","gene_id","gene_name", subset to detected transcripts and genes.detectedTx—charactervector of retained transcript IDs.detectedGenes—charactervector of retained gene names.filesDF— included when provided (otherwise absent).color_sub— included when provided or derived fromfilesDF.
Details
This function is an alternative to sashimiDataConstants() for users who
prefer to supply a Bioconductor TxDb annotation package such as
'TxDb.Mmusculus.UCSC.mm10.knownGene', rather than a GTF file.
It calls makeTx2geneFromTxdb() to build the transcript-to-gene
data.frame 'tx2geneDF',
then derives exonsByTx, cdsByTx, flatExonsByTx, and flatExonsByGene
from the TxDb using the same flattenExonsBy() machinery as the
GTF-based workflow.
Subsetting logic
When detectedTx and/or detectedGenes are provided, they are used to
subset the full annotation:
detectedTxis intersected withtx2geneDF$transcript_id. ProvidingdetectedTxalso limits the available genes viatx2geneDF.detectedGenesis intersected withtx2geneDF$gene_name. ProvidingdetectedGenesalso limits the available transcripts viatx2geneDF.Both filters are applied simultaneously; the resulting
tx2geneDFis the source of truth from whichdetectedTxanddetectedGenesare re-derived.When neither is provided, all transcripts and genes in the
TxDbare used.
See also
sashimiDataConstants() for the GTF-based equivalent,
makeTx2geneFromTxdb() for the helper that builds tx2geneDF.
Other Splicejam core functions:
launchSashimiApp(),
sashimiDataConstants(),
splicejamFigure()
Examples
if (FALSE) { # \dontrun{
# Prepare TxDb for mouse mm10 genome
system.time({
sjenv_txdb <- splicejamDataFromTxDb(
txdb=TxDb.Mmusculus.UCSC.mm10.knownGene::TxDb.Mmusculus.UCSC.mm10.knownGene,
detectedGenes=unique(sjenvtest$tx2geneDF$gene_name),
filesDF=sjenvtest$filesDF,
ann_lib="org.Mm.eg.db")
})
# 8 to 12 seconds to prep the environment
# optionally display progress bar
progressr::handlers(global=TRUE)
system.time({
splicejamFigure(sjenv_txdb,
gene="Gria1",
geneAxisSize=8,
use_memoise=TRUE)
})
# Use subset of transcript_id which happen
# to be compatible with sjenvtest on mm10.
# Note the flat gene exons still used all
# transcripts. Rebuild from TxDb to resolve.
use_detectedTx <- subset(sjenvtest$tx2geneDF,
gene_name %in% 'Gria1')$transcript_id
system.time({
splicejamFigure(sjenv_txdb,
gene="Gria1",
geneAxisSize=8,
minJunctionScore=100,
detectedTx=use_detectedTx,
use_exon_range=c("exon17", "exon20"),
use_memoise=TRUE)
})
} # }