taxa_summary_by_sample_type: Further summarize output from summarize_taxonomy by sample...

View source: R/taxa_by_sample_type_functions.R

taxa_summary_by_sample_typeR Documentation

Further summarize output from summarize_taxonomy by sample type

Description

Function to show contributions of specific taxa to variation among communities using Mann-Whitney (2 factor levels), Kruskal-Wallis (more than 2) tests, or more complex models.

Usage

taxa_summary_by_sample_type(
  taxa_smry_df,
  metadata_map,
  type_header,
  filter_level,
  test_type,
  grouping_factor,
  custom_test_function,
  smry_fun = mean,
  out_fp
)

Arguments

taxa_smry_df

Taxa summary data frame.

metadata_map

The metadata mapping data frame.

type_header

Mapping file header (in quotation marks) of factor for which you are testing for differences.

filter_level

[OPTIONAL] The minimum mean value needed in at least one. of the factor levels for a taxon to be retained in the analysis.

test_type

[OPTIONAL]. If omitted, no test is performed and no p-values are reported. Otherwise, either 'MW', 'KW', or 'custom' (i.e. Wilcoxon/Mann-Whitney U for 2 factor levels or Kruskal-Wallis for more than two factor levels). See details for custom test/model implementation.

grouping_factor

[OPTIONAL] Used with 2-way tests.

custom_test_function

[OPTIONAL] Name of custom test function.

smry_fun

[OPTIONAL] The function to summarize values by (Default: mean).

out_fp

[OPTIONAL] Test results output filepath. Written as a csv file.

Examples

ts = summarize_taxonomy(fruits_veggies, level = 2)
# differences in relative abundances of phyla across fruits/veggies
taxa_summary_by_sample_type(
  ts, metadata_map = fruits_veggies$map_loaded,
  type_header = 'Sample_type', filter_level = 0.03,
  test_type = 'KW'
)
# differences in relative abundances of phyla between farm types
taxa_summary_by_sample_type(
  ts, metadata_map = fruits_veggies$map_loaded,
  type_header = 'Farm_type', filter_level = 0.03,
  test_type = '2WNP', grouping_factor = 'Sample_type'
)

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