Reads the *.cnt file that rsem-calculate-expression writes (in
<name>.stat/<name>.cnt) for every sample and returns one row per sample
with the read counts and fractions that describe how the reads were
assigned. The numbers come from the alignments RSEM was given, not from the
abundance estimates.
Value
A data frame with one row per sample: sample_id, the counts
n_total, n_unalignable, n_alignable, n_filtered, n_unique,
n_multi, n_uncertain, n_hits, read_type, and the fractions
alignable_fraction (N1 / N_tot), unalignable_fraction
(N0 / N_tot), filtered_fraction (N2 / N_tot), unique_gene_fraction
(nUnique / N1), multi_gene_fraction (nMulti / N1),
uncertain_fraction (nUncertain / N1) and alignments_per_read
(nHits / N1). Fractions are NA where the denominator is 0.
What the file contains
Following RSEM's cnt_file_description.txt: N0 reads that could not be
aligned, N1 alignable reads, N2 reads filtered because they have too
many alignments, and N_tot = N0 + N1 + N2; nUnique reads aligned
uniquely to one gene and nMulti reads aligned to several genes
(nUnique + nMulti = N1); nUncertain reads aligned to several places in
the reference, which includes ambiguity between isoforms of the same gene,
so it is not a subset of nMulti; nHits, the total number of alignments;
and the read type (0 single-end without quality, 1 single-end with quality,
2 paired-end without quality, 3 paired-end with quality). The histogram of
alignments per read that follows in the file is not used.
A file that breaks these identities (N_tot is not N0 + N1 + N2, or
nUnique + nMulti is not N1) stops the function instead of returning
numbers that cannot be right.
Files
As in rsem_read(): metadata = NULL finds every *.cnt file under
data (the sample is named after the file, or with sample_from = "parent_dir" after its folder without the .stat suffix), or a metadata
CSV with sample_id and ref names the files.
Examples
f <- tempfile(fileext = ".cnt")
writeLines(c("100 850 50 1000", "800 50 120", "1500 2", "0\t100", "1\t700", "Inf\t50"), f)
rsem_mapping_qc(dirname(f), metadata = NULL)[, c("sample_id", "n_total", "alignable_fraction")]
#> rsem_mapping_qc: found 1 files under '/tmp/RtmpUP3OoN' (sample ID from the file name):
#> file18e6b5b92c <- file18e6b5b92c.cnt
#> rsem_mapping_qc: 1 samples; alignable fraction 0.85 to 0.85; unique-gene fraction of alignable reads 0.941 to 0.941
#> sample_id n_total alignable_fraction
#> 1 file18e6b5b92c 1000 0.85