calc_prop_shared_taxa: Calculate mean proportions of shared taxa between paired...

View source: R/misc_analyses.R

calc_prop_shared_taxaR Documentation

Calculate mean proportions of shared taxa between paired samples

Description

This function will calculate the mean proportion of taxa (i.e. OTUs) that are shared between pairs of samples in a given data set. It has the option to calculate this value for only pairs where each sample is of a different, specified type. For example, this is useful if you want to calculate proportion of taxa that are shared between red and blue samples only and not red and red or red and green, etc.

Usage

calc_prop_shared_taxa(input, type_header, sample_types, within_cat)

Arguments

input

The input dataset as loaded by load_taxa_table.

type_header

[OPTIONAL] The header label from the metadata map that has the labels which indicate the types of samples you want to calculate proportions for.

sample_types

[OPTIONAL] Use with type_header to indicate which two sample types for which you want to calculate proportions. Supply a character vector of length 2.

within_cat

[OPTIONAL] Specify a header label from the metadata map that tells the function to restrict pairs to within levels of this factor. If included, will return a data frame instead of a vector.

Details

If only input is provided, the proportion is calculated across all samples.

See Also

calc_prop_taxa_from_sample_type

Examples

# proportion of taxa shared between spinach and strawberries
calc_prop_shared_taxa(
  fruits_veggies, type_header = 'Sample_type',
  sample_types = c('Spinach', 'Strawberries')
)
# proportion of taxa shared between spinach and mushrooms
calc_prop_shared_taxa(
  fruits_veggies, type_header = 'Sample_type', 
  sample_types = c('Strawberries', 'Mushrooms')
)
# proportion of taxa shared between spinach and strawberries within each
# farming type (greater overlap within conventional)
calc_prop_shared_taxa(
  fruits_veggies, type_header = 'Sample_type', 
  sample_types = c('Spinach', 'Strawberries'), within_cat = 'Farm_type'
)

leffj/mctoolsr documentation built on Aug. 5, 2022, 1:27 a.m.