Keeps the transcripts that reach a TPM threshold and, optionally, a share
of the most expressed transcript of the same gene, or only the most
expressed transcript of each gene. The rules follow Trinity's
filter_low_expr_transcripts.pl (--min_expr_any, --min_pct_dom_iso,
--highest_iso_only); as there, the share rule and the "most expressed
only" rule cannot be combined.
Usage
rsem_select_isoforms(
x,
tx2gene = attr(x, "tx2gene", exact = TRUE),
min_tpm = 1,
min_fraction = NULL,
highest_only = FALSE,
rule = "any",
prevalence = 0.5
)Arguments
- x
Transcript TPM, as returned by
rsem_read(level = "isoform", expr = "tpm").- tx2gene
Transcript-to-gene table with the columns
transcript_idandgene_id. Default: the attribute"tx2gene"ofx.- min_tpm
TPM a transcript must reach. Default 1.
- min_fraction
Optional share (0 to 1) of the gene's highest TPM.
- highest_only
Keep only the most expressed transcript of each gene.
- rule
"any","all","prevalence"or"mean".- prevalence
For
rule = "prevalence": share of samples. Default 0.5.
Value
The kept transcripts, in the layout and order of x, with the
matching rows of tx2gene in the attribute "tx2gene".
How samples are combined
In each sample, a transcript passes when its TPM is at least min_tpm
and, with min_fraction, its TPM is at least min_fraction times the
highest TPM among the transcripts of its gene in that sample (with
highest_only, when it is that highest transcript). The per-sample results
are then combined by rule:
"any"(the default): passes in at least one sample;"all": passes in every sample;"prevalence": passes in at least the shareprevalenceof samples;"mean": the rule is applied once to the mean TPM over samples.
The most expressed transcript can differ between samples, so "any" with
highest_only may keep several transcripts of a gene, while "mean"
keeps exactly one per expressed gene.
Caution
Removing transcripts by expression can remove biologically important ones, and keeping one transcript per gene is not a general preprocessing step for differential expression. The values of the kept transcripts are the original estimates: they were not re-quantified without the removed transcripts. To use the selection as a new reference, build the reference again and rerun RSEM.
Examples
x <- data.frame(S1 = c(10, 1, 0.5), S2 = c(8, 3, 0), row.names = c("T1", "T2", "T3"))
t2g <- data.frame(transcript_id = c("T1", "T2", "T3"), gene_id = "G1")
rsem_select_isoforms(x, t2g, min_tpm = 1, min_fraction = 0.2)
#> rsem_select_isoforms: kept 2 of 3 transcripts (1 of 1 genes); TPM >= 1, >= 0.2 of the gene's top transcript, rule = any. Values are the original estimates, not re-quantified.
#> S1 S2
#> T1 10 8
#> T2 1 3
rsem_select_isoforms(x, t2g, highest_only = TRUE, rule = "mean")
#> rsem_select_isoforms: kept 1 of 3 transcripts (1 of 1 genes); TPM >= 1, top transcript only, rule = mean. Values are the original estimates, not re-quantified.
#> S1 S2
#> T1 10 8