How many genes each detection threshold keeps
Source:R/rsem_detection_curve.R
rsem_detection_curve.RdCounts the genes that reach each threshold in enough samples, for a grid of
thresholds and sample requirements, so that the effect of a threshold can
be seen before rsem_filter() removes genes. Nothing is removed.
Usage
rsem_detection_curve(x, expr, thresholds = NULL, min_samples = c(1, 0.2, 0.5))Arguments
- x
The gene by sample table, as returned by
rsem_read(): gene names as row names (or in the first column) and one numeric column per sample.- expr
"count"or"tpm": what the values are. Required.- thresholds
Values to try. Default
c(0.1, 0.5, 1, 2, 5, 10)for TPM andc(1, 5, 10, 20, 50, 100)for counts.- min_samples
Sample requirements to try; a number below 1 is a proportion of the samples, as in
rsem_filter(). Defaultc(1, 0.2, 0.5): at least one sample, 20% and half of the samples.
Value
A data frame with one row per threshold and sample requirement:
threshold, min_samples (as given), samples_needed, genes (genes
kept), share (of all genes in x) and genes_mean (genes whose mean
reaches the threshold; the same in every row of a threshold).
Details
For a threshold \(\tau\) and a required number of samples \(k\), the
count is the number of genes with a value of at least \(\tau\) in at
least \(k\) samples. This is exactly the rule of
rsem_filter(method = "detected", min_value = tau, min_samples = k), so
each row tells how many genes that call would keep. The column
genes_mean gives the number of genes whose mean over samples reaches the
threshold, the other rule often used in published scripts.
Examples
if (requireNamespace("org.Hs.eg.db", quietly = TRUE)) {
ex <- system.file("extdata", "example", package = "rsemverse")
tpm <- rsem_read(file.path(ex, "data"), file.path(ex, "metadata.csv"),
species = "human", expr = "tpm")
rsem_detection_curve(tpm, expr = "tpm")
}
#>
#> rsem_read: 3 samples, 44 genes -> 43 rows (species = human, expr = tpm, org.Hs.eg.db 3.23.1)
#> with symbol: 42 genes (1 symbols merged from several IDs); kept as original IDs: 2 genes
#> rsem_detection_curve: 43 genes x 3 samples; 6 thresholds x 3 sample requirements (TPM)
#> threshold min_samples samples_needed genes share genes_mean
#> 1 0.1 1.0 1 43 1 43
#> 2 0.1 0.2 1 43 1 43
#> 3 0.1 0.5 2 43 1 43
#> 4 0.5 1.0 1 43 1 43
#> 5 0.5 0.2 1 43 1 43
#> 6 0.5 0.5 2 43 1 43
#> 7 1.0 1.0 1 43 1 43
#> 8 1.0 0.2 1 43 1 43
#> 9 1.0 0.5 2 43 1 43
#> 10 2.0 1.0 1 43 1 43
#> 11 2.0 0.2 1 43 1 43
#> 12 2.0 0.5 2 43 1 43
#> 13 5.0 1.0 1 43 1 43
#> 14 5.0 0.2 1 43 1 43
#> 15 5.0 0.5 2 43 1 43
#> 16 10.0 1.0 1 43 1 43
#> 17 10.0 0.2 1 43 1 43
#> 18 10.0 0.5 2 43 1 43