Subset mt objects based on sample metadata

mt_subset(data, ...)

Arguments

mmt

(required) Data list as loaded with mt_load.

sub_genes

(optional) A string specifying a logical row subset operation on the mtgene dataframe in the mt object parsed to subset.

sub_samples

(optional) A string specifying a logical row subset operation on the mtmeta dataframe in the mt object parsed to subset.

minreads

Minimum average number of reads pr. gene. Genes below this value will be removed. (default: 0)

frac0

Fraction of zeros allowed per gene. Genes with a higher fraction of zeros will be removed. (default: 1)

normalise

Normalise the read counts AFTER reads have been removed by the minreads argument but BEFORE any sample/gene subsetting. (default: "none")

  • "quantile": Quantile normalization. See normalize.quantiles for details.

  • "TPM": Normalise read counts to Transcripts Per Milion (TPM).

  • "abundance": Normalise read counts to relative abundance.

  • "libsize": Normalise the read counts to adjust for gene dispersion and total read counts per sample. See estimateSizeFactorsForMatrix for details.

  • "vst": Normalise as "libsize" and perform robust log2-transformation. See vst for details.

  • "log2": Normalise as "libsize" and perform log2(x + 1)-transformation.

  • "none": No normalisation.

Value

A modifed mt object

Details

The function mt_subset operates in three steps:

  • Filter - genes according to minreads and frac0.

  • Normalise - as specified in normalise.

  • Subset - according to sub_genes and sub_samples.

Subsetting are performed on the mtmeta/mtgene data by subset and the whole object is then adjusted accordingly.

Examples

# NOT RUN { # Get some data. data("example_mmt") # Let's subset to contig 1, 7675, and 69676. mt1 <- mt_subset(example_mmt,sub_genes = "contig %in% c(1,7675,69676)") mt1 # Let's subset to specific organism. mt2 <- mt_subset(example_mmt,sub_samples = "Organism == 'Brocadia'") mt2 # Let's do both and remove genes with less than 10000 reads in total. mt3 <- mt_subset(example_mmt, sub_samples = "Organism == 'Brocadia'", sub_genes = "contig %in% c(1,7675,69676)", minreads = 10000) mt3 # You can also normalise the data and subset. mt4 <- mt_subset(example_mmt, sub_samples = "Organism == 'Brocadia'", sub_genes = "contig %in% c(1,7675,69676)", minreads = 10000, normalise = "libsize") mt4 # Note "Normalised:" is now included. # }