View source: R/amp_filter_samples.R
amp_filter_samples | R Documentation |
Subsets the data in ampvis2 objects based on metadata and returns the subsetted object.
amp_filter_samples(
data,
...,
minreads = 0,
rarefy = NULL,
normalise = FALSE,
removeAbsentOTUs = TRUE
)
amp_subset_samples(
data,
...,
minreads = 0,
rarefy = NULL,
normalise = FALSE,
removeAbsentOTUs = TRUE
)
data |
(required) Data list as loaded with |
... |
Logical expression indicating elements or rows to keep in the metadata. Missing values are treated as |
minreads |
Minimum number of reads pr. sample. Samples below this value will be removed initially. (default: |
rarefy |
Rarefy species richness to this value by using |
normalise |
(logical) Normalise the OTU read counts to 100 (ie percent) per sample BEFORE the subset. (default: |
removeAbsentOTUs |
(logical) Whether to remove OTU's that may have 0 read abundance in all samples after the subset. (default: |
The subset is performed on the metadata by subset()
and the abundance- and taxonomy tables are then adjusted accordingly.
A modifed ampvis2 object
By default the raw read counts in the abundance matrix are normalised (transformed to percentages) by some plotting functions automatically (for example amp_heatmap
, amp_timeseries
, and more). This means that the relative abundances shown will be calculated based on the remaining taxa after the subset, not including the removed taxa, if any. To circumvent this, set normalise = TRUE
when subsetting with the amp_filter_taxa
and amp_filter_samples
functions, and then set normalise = FALSE
in the plotting function. This will transform the OTU counts to relative abundances BEFORE the subset, and setting normalise = FALSE
will skip the transformation in the plotting function, see the example below.
data("MiDAS") subsettedData <- amp_filter_samples(MiDAS, Plant %in% c("Aalborg West", "Aalborg East"), normalise = TRUE ) amp_heatmap(subsettedData, group_by = "Plant", tax_aggregate = "Phylum", tax_add = "Genus", normalise = FALSE )
Kasper Skytte Andersen ksa@bio.aau.dk
Mads Albertsen MadsAlbertsen85@gmail.com
McMurdie, P.J. & Holmes, S. (2014). Waste not, want not: Why
rarefying microbiome data is inadmissible. PLoS Comput Biol
10(4): e1003531. DOI:10.1371/journal.pcbi.1003531
amp_load
, amp_filter_taxa
# Load example data
data("MiDAS")
# Show a short summary about the data by simply typing the name of the object in the console
MiDAS
# Keep only samples containing Aalborg West or East in the Plant column
MiDASsubset <- amp_filter_samples(MiDAS, Plant %in% c("Aalborg West", "Aalborg East"))
# Summary
MiDASsubset
# Keep only samples containing Aalborg West or East in the Plant column
# and remove the sample "16SAMP-749". Remove any sample(s) with less than 20000 total reads
MiDASsubset2 <- amp_filter_samples(MiDAS,
Plant %in% c("Aalborg West", "Aalborg East") & !SampleID %in% c("16SAMP-749"),
minreads = 20000
)
# Summary
MiDASsubset2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.