add_spike_ratio: Add spike ratio

View source: R/adders_samples.R

add_spike_ratioR Documentation

Add spike ratio

Description

add_spike_ratio adds a new variable showing the ratio total abundance to spike abundance to the samples tibble of a tidyamplicons object.

Usage

add_spike_ratio(ta, spike_taxon)

Arguments

ta

A tidyamplicons object.

spike_taxon

The taxon_id of the spike.

Details

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.

Examples

# 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")

SWittouck/tidyamplicons documentation built on Aug. 15, 2023, 3:14 a.m.