| PTMN | R Documentation |
Constructs a phylogenetic trait multilayer network by calculating correlations between traits while accounting for phylogenetic relationships. The function creates a network where nodes represent traits organized into different layers, and edges represent significant correlations between traits.
PTMN(
traits_matrix,
layers_list,
rThres = 0.2,
pThres = 0.05,
method = "pearson",
phylo_correction = FALSE,
phylo_tree = NULL
)
traits_matrix |
A data frame or matrix containing trait values where rows represent species and columns represent traits. Row names should match the tip labels in the phylogenetic tree when phylogenetic correction is used. |
layers_list |
A named list where each element contains the names of traits belonging to that layer. Names of the list elements represent layer names. |
rThres |
Numeric. Correlation threshold for filtering weak correlations. Correlations with absolute values below this threshold are set to zero. Default is 0.2. |
pThres |
Numeric. P-value threshold for statistical significance after FDR correction. Correlations with p-values above this threshold are excluded. Default is 0.05. |
method |
Character. Correlation method to use. Either "pearson" or "spearman". Default is "pearson". |
phylo_correction |
Logical. Whether to apply phylogenetic correction using phylogenetic independent contrasts. Default is FALSE. |
phylo_tree |
A phylo object from the ape package. Required when phylo_correction = TRUE. Should contain all species present in traits_matrix. |
The function performs the following steps:
Validates input parameters and data consistency
Calculates correlation matrix using standard methods or phylogenetic independent contrasts
Filters correlations based on correlation and p-value thresholds
Applies FDR correction to p-values
Constructs an igraph network object
Maps traits to their respective layers
Returns edge list with layer information
When phylogenetic correction is enabled, the function uses phylogenetic independent contrasts to account for the non-independence of species data due to shared evolutionary history.
A data frame containing the network edges with the following columns:
node.from: Name of the source trait
layer.from: Layer name of the source trait
node.to: Name of the target trait
layer.to: Layer name of the target trait
correlation: Correlation coefficient between the traits
Returns an empty data frame with the same structure if no significant correlations are found.
## Not run:
# Load example data
data(forest_invader_tree)
data(forest_invader_traits)
traits <- forest_invader_traits[, 6:73]
# Define trait layers
layers <- list(
shoot_dynamics = c("LeafDuration", "LeafFall50", "LeafRate_max",
"Chl_shade50", "LAgain", "FallDuration",
"LeafOut", "Chl_sun50", "EmergeDuration",
"LeafTurnover"),
leaf_structure = c("PA_leaf", "Mass_leaf", "Lifespan_leaf",
"Thick_leaf", "SLA", "Lobe", "LDMC",
"Stomate_size", "Stomate_index"),
leaf_metabolism = c("J_max", "Vc_max", "Asat_area", "CC_mass",
"LSP", "AQY", "CC_area", "Rd_area",
"Asat_mass", "WUE", "Rd_mass", "PNUE"),
leaf_chemistry = c("N_area", "Chl_area", "DNA", "Phenolics",
"Cellulose", "N_mass", "N_litter", "Chl_ab",
"Chl_mass", "N_res", "C_litter", "C_area",
"C_mass", "Ash", "Lignin", "Solubles",
"Decomp_leaf", "Hemi"),
root = c("NPP_root", "SS_root", "SRL", "RTD", "RDMC",
"NSC_root", "Decomp_root", "Starch_root",
"C_root", "N_root", "Lignin_root"),
stem = c("Latewood_diam", "Metaxylem_diam", "Earlywood_diam",
"NSC_stem", "Vessel_freq", "SS_stem", "Cond_stem",
"Starch_stem")
)
# Run PTMN analysis without phylogenetic correction
PTMN(traits, layers_list = layers, method = "pearson")
# Run PTMN analysis with phylogenetic correction
PTMN(traits, layers_list = layers, method = "pearson",
phylo_correction = TRUE, phylo_tree = forest_invader_tree)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.