exonicParts {GenomicFeatures} | R Documentation |
exonicParts
and intronicParts
extract the non-overlapping
(a.k.a. disjoint) exonic or intronic parts from a TxDb-like object.
exonicParts(txdb, linked.to.single.gene.only=FALSE) intronicParts(txdb, linked.to.single.gene.only=FALSE)
txdb |
A TxDb object, or any TxDb-like object that supports the
|
linked.to.single.gene.only |
If If
|
exonicParts
returns a disjoint and strictly sorted
GRanges object with 1 range per exonic part
and with metadata columns tx_id
, tx_name
, gene_id
,
exon_id
, exon_name
, and exon_rank
.
intronicParts
returns a disjoint and strictly sorted
GRanges object with 1 range per intronic part
and with metadata columns tx_id
, tx_name
, and gene_id
.
exonicParts
is a replacement for disjointExons
with
the following differences/improvements:
Argument linked.to.single.gene.only
in exonicParts
replaces argument aggregateGenes
in disjointExons
,
but has opposite meaning i.e.
exonicParts(txdb, linked.to.single.gene.only=TRUE)
returns the same exonic parts as
disjointExons(txdb, aggregateGenes=FALSE)
.
Unlike disjointExons(txdb, aggregateGenes=TRUE)
,
exonicParts(txdb, linked.to.single.gene.only=FALSE)
does
NOT discard exon parts that are not linked to a gene.
exonicParts
is almost 2x more efficient than
disjointExons
.
exonicParts
works out-of-the-box on any TxDb-like
object that supports the transcripts()
and
exonsBy()
extractors (e.g. on an
EnsDb object).
Hervé Pagès
disjoin
in the IRanges package.
transcripts
, transcriptsBy
,
and transcriptsByOverlaps
, for extracting
genomic feature locations from a TxDb-like object.
transcriptLengths
for extracting the transcript
lengths (and other metrics) from a TxDb object.
extractTranscriptSeqs
for extracting transcript
(or CDS) sequences from chromosome sequences.
coverageByTranscript
for computing coverage by
transcript (or CDS) of a set of ranges.
The TxDb class.
library(TxDb.Hsapiens.UCSC.hg19.knownGene) txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene ## --------------------------------------------------------------------- ## exonicParts() ## --------------------------------------------------------------------- exonic_parts1 <- exonicParts(txdb) exonic_parts1 ## Mapping from exonic parts to genes is many-to-many: mcols(exonic_parts1)$gene_id table(lengths(mcols(exonic_parts1)$gene_id)) ## A Human exonic part can be linked to 0 to 22 known genes! exonic_parts2 <- exonicParts(txdb, linked.to.single.gene.only=TRUE) exonic_parts2 ## Mapping from exonic parts to genes now is many-to-one: class(mcols(exonic_parts2)$gene_id) ## Sanity checks: stopifnot(isDisjoint(exonic_parts1), isStrictlySorted(exonic_parts1)) stopifnot(isDisjoint(exonic_parts2), isStrictlySorted(exonic_parts2)) stopifnot(all(exonic_parts2 %within% reduce(exonic_parts1))) stopifnot(identical( lengths(mcols(exonic_parts1)$gene_id) == 1L, exonic_parts1 %within% exonic_parts2 )) ## --------------------------------------------------------------------- ## intronicParts() ## --------------------------------------------------------------------- intronic_parts1 <- intronicParts(txdb) intronic_parts1 ## Mapping from intronic parts to genes is many-to-many: mcols(intronic_parts1)$gene_id table(lengths(mcols(intronic_parts1)$gene_id)) ## A Human intronic part can be linked to 0 to 22 known genes! intronic_parts2 <- intronicParts(txdb, linked.to.single.gene.only=TRUE) intronic_parts2 ## Mapping from intronic parts to genes now is many-to-one: class(mcols(intronic_parts2)$gene_id) ## Sanity checks: stopifnot(isDisjoint(intronic_parts1), isStrictlySorted(intronic_parts1)) stopifnot(isDisjoint(intronic_parts2), isStrictlySorted(intronic_parts2)) stopifnot(all(intronic_parts2 %within% reduce(intronic_parts1))) stopifnot(identical( lengths(mcols(intronic_parts1)$gene_id) == 1L, intronic_parts1 %within% intronic_parts2 ))