View source: R/adders_samples.R
add_spike_ratio | R Documentation |
add_spike_ratio
adds a new variable showing the ratio total abundance
to spike abundance to the samples tibble of a tidyamplicons object.
add_spike_ratio(ta, spike_taxon)
ta |
A tidyamplicons object. |
spike_taxon |
The taxon_id of the spike. |
This function calculates the spike ratio defined as the total sample abundance to the spike abundance and adds this as a new variable "spike_ratio" to the samples tibble of a tidyamplicons object. This function is useful if a DNA spike was added prior to sequencing and is based on the method described by Smets et al., 2016.
Credits to Wenke Smets for the idea of spiking samples prior to 16S sequencing and the initial implementation of this function.
# Initiate abundance matrix
x <- matrix(
c(1500, 1300, 280, 356),
ncol = 2
)
rownames(x) <- c("taxon1", "taxon2")
colnames(x) <- c("sample1", "sample2")
# Convert to tidyamplicons object
data <- create_tidyamplicons(x,
taxa_are_columns = FALSE
)
# Add total abundance
data <- data %>%
add_spike_ratio(spike_taxon = "t1")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.