View source: R/misc_analyses.R
calc_prop_shared_taxa | R Documentation |
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.
calc_prop_shared_taxa(input, type_header, sample_types, within_cat)
input |
The input dataset as loaded by |
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 |
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. |
If only input
is provided, the proportion is calculated
across all samples.
calc_prop_taxa_from_sample_type
# 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' )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.