Sums the values of each gene type (from a GTF file) per sample and divides
by the sample total, for example to see how much of the TPM goes to rRNA,
mitochondrial genes or lncRNA. Genes that the annotation does not know are
counted as "unannotated", and genes whose name has several types as
"multiple".
Usage
rsem_biotype_profile(
x,
annotation,
types = NULL,
ids = attr(x, "gene_ids", exact = TRUE)
)Arguments
- x
The gene by sample table (TPM or counts), as returned by
rsem_read().- annotation
Path to a GTF file (plain or
.gz; GENCODE, Ensembl or NCBI, withgene_typeorgene_biotype), or a data frame with the columnsgene_id,gene_typeand optionallygene_name. It should be the annotation the RSEM reference was built from.- types
Gene types to report (values of
gene_type, such as"rRNA"or"protein_coding"). Default: every type found inx.- ids
The attribute
"gene_ids"of the tablersem_read()returned (default: that attribute ofx, when present). Rows are then matched to the annotation through their original gene IDs, which avoids losing genes whose OrgDb symbol differs from the GTF gene name. Without it, rows are matched by Ensembl ID or by gene name.
Value
A data frame with one row per sample and type: sample_id,
type, genes (genes of that type in x), value (sum) and share
(value / sample total).
Details
A type that the annotation does not contain cannot be measured: if a
requested type has no gene in the annotation, its share is NA, not 0, and
a message says so. For example, an annotation without rRNA genes says
nothing about rRNA contamination. Reads from genes outside the annotation
were never quantified by RSEM and are not in any share.
Examples
ann <- data.frame(gene_id = c("ENSG01", "ENSG02", "ENSG03"),
gene_name = c("A", "B", "C"),
gene_type = c("protein_coding", "rRNA", "lncRNA"))
x <- data.frame(S1 = c(10, 5, 1), S2 = c(20, 0, 2), row.names = c("A", "B", "C"))
rsem_biotype_profile(x, ann)
#> rsem_biotype_profile: 3 genes x 2 samples; 0 of the genes not in the annotation
#> sample_id type genes value share
#> 1 S1 lncRNA 1 1 0.06250000
#> 2 S2 lncRNA 1 2 0.09090909
#> 3 S1 protein_coding 1 10 0.62500000
#> 4 S2 protein_coding 1 20 0.90909091
#> 5 S1 rRNA 1 5 0.31250000
#> 6 S2 rRNA 1 0 0.00000000