predict_metagenomes: Produce the actual metagenome functional predictions.

View source: R/predict_metagenomes.R

predict_metagenomesR Documentation

Produce the actual metagenome functional predictions.

Description

Produce the actual metagenome functional predictions.

Usage

predict_metagenomes(
  otu_tab,
  func_tab,
  NSTI_present = TRUE,
  rel_abund = TRUE,
  add_sub_tabs = FALSE
)

Arguments

otu_tab

Data frame with OTU abundances (rows = OTUs, columns = Samples, first column = OTU names)

func_tab

Data frame with precalculated function predictions on per OTU basis (rows = OTUs, columns = feature counts, first column = OTU names)

NSTI_present

Logical; idnicating weather NSTI values are present in the last column of func_tab

rel_abund

Logical; if TRUE, OTU counts will be transformed to relative abundances

add_sub_tabs

Logical; if TRUE, subsetted OTU and functional tables will be added to the results

Details

This function is analogous to the 'predict_metagenomes.py' from PICRUSt. It will produce the actual metagenome functional predictions for a given OTU table and table with feature counts, e.g. count number of gene copies for each feature (e.g., KEGG) in each sample. Feature counts for each OTU will be multiplied by the abundance of that OTU in each each sample and summed across all OTUs.

Value

Data frame with samples as rows and features as columns.

References

https://picrust.github.io/picrust/scripts/predict_metagenomes.html

Examples

## Create dummy data
set.seed(111)
NSAMP=10    # number of samples
NSPEC=30    # number of species/OTUs
NGENES=8   # number of features

dummy_name <- function(len = 5){ paste(sample(letters, size = len, replace = T), collapse = "") }

# Table with precalculated number of gene copies per OTU
func_tab <- data.frame(
  OTU_ID = replicate(n = 100, expr = dummy_name()),
  matrix(data = sample(1:100, size = 100*NGENES, replace = T), nrow = 100),
  stringsAsFactors = F)
colnames(func_tab)[-1] <- paste("Gene", 1:NGENES, sep="")

# Table with OTU abundance
otu_tab <- data.frame(
  OTU = sample(func_tab$OTU_ID, size = NSPEC),
  matrix(data = sample(0:200, size = NSPEC*NSAMP, replace = T), nrow = NSPEC),
  stringsAsFactors = F)
colnames(otu_tab)[-1] <- paste("Sample", 1:NSAMP, sep="")

## Predict metagenomes
predict_metagenomes(otu_tab, func_tab, NSTI_present = FALSE, rel_abund = FALSE, add_sub_tabs = FALSE)


vmikk/metagMisc documentation built on June 20, 2024, 7:20 a.m.