aggregate_specs_list: aggregate_specs_list

View source: R/aggregate_specs_list.r

aggregate_specs_listR Documentation

aggregate_specs_list

Description

Aggregates a list of outputs from phy_or_env_spec() into a single data.frame object. Can also include feature data (e.g. species taxonomy) into that output. Output can also be byFeature, with one row per feature, and multiple columns for different variables.

Usage

aggregate_specs_list(sl, byFeature = FALSE, fd = NULL, fd_id = 1)

Arguments

sl

specs_list. A named list of outputs from phy_or_env_spec. See examples.

byFeature

bool. If true, each feature will occupy only one row, with multiple columns to represent the different variables in specs_list (default: FALSE)

fd

data.frame. Optional feature data - a data.frame object with one row per feature, including some column with feature IDs that includes feature IDs in sl as rownames (default:NULL)

fd_id

integer or string. If integer, specifies the column index of fd that contains feature ids. If character, specifies the column name (default: 1).

Value

a data.frame object.

Author(s)

John L. Darcy

Examples

# attach(endophyte)
# otutable <- occ_threshold(prop_abund(otutable), 20)
# specs_list <- list()
# # note: "index_rough" is only being used here to save time for demonstration purposes.
# specs_list$elevation <- phy_or_env_spec(otutable, env=metadata$Elevation, 
#   n_cores=20, n_sim=100, denom_type="sim_center")
# specs_list$rainfall <- phy_or_env_spec(otutable, env=metadata$Rainfall, 
#   n_cores=20, n_sim=100, denom_type="sim_center")
# # aggregate, long mode, like for ggplot:
# specs_df_long <- aggregate_specs_list(specs_list, byFeature=FALSE, fd=taxonomy, fd_id=1)
# # aggregate, wide mode:
# specs_df_wide <- aggregate_specs_list(specs_list, byFeature=TRUE, fd=taxonomy, fd_id=1)
# # example plot with ggplot:
# library(ggplot2)
# ggplot(specs_df_long, aes(x=Variable, y=Spec)) + geom_violin() + geom_jitter(width=0.3)


darcyj/specificity documentation built on Aug. 1, 2023, 8 a.m.