make_prev_df: Make dataframe of taxa prevalence, abundance, and...

Description Usage Arguments Value Examples

Description

Using the resultant OTU table biom file produced by QIIME, find the relative abundance and sample prevalence of all OTUs and store results in dataframe. Resultant dataframe will show taxonomic classification, abundance, and prevalence for all OTUs.

Usage

1
make_prev_df(biom_file)

Arguments

biom_file

Full path name of OTU table biom file

Value

Returns dataframe combining sample prevalence, abundance, and taxonomic classification for all OTUs.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(biom_file){
  phylo <- import_biom(biom_file)
  prevdf = apply(X = otu_table(phylo),MARGIN = ifelse(taxa_are_rows(ps), yes=1, no=2), FUN=function(x){sum(x>0)}) #find prevalence of each taxa per sample
  #bind together taxonomic information and prevalence and total abundance of each taxa into one dataframe
  prevdf = data.frame(Prevalence = prevdf, TotalAbundance = taxa_sums(phylo), tax_table(phylo))
  prevdf <- prevdf[prevdf$Prevalence > 0,] #remove taxa not present in samples
  return(prevdf)
}

ConesaLab/MDM documentation built on Aug. 1, 2020, 11:47 a.m.