TN: Generate Plant Trait Network

View source: R/TN.R

TNR Documentation

Generate Plant Trait Network

Description

This function creates a network graph from a plant trait correlation matrix, applying thresholds for correlation strength and significance.

Usage

TN(traits_matrix, rThres = 0.2, pThres = 0.05, method = "pearson")

Arguments

traits_matrix

A numeric matrix where each column represents a plant trait and each row represents a sample.

rThres

Numeric, threshold for correlation coefficient, default is 0.2. Correlations with absolute values below this threshold are set to zero.

pThres

Numeric, threshold for p-value, default is 0.05. Only correlations with p-values below this threshold are included in the network.

method

Character, specifies the correlation method to use: "pearson" (default) or "spearman".

Details

The function performs the following steps:

  1. Calculates Pearson correlation coefficients and p-values for the trait matrix.

  2. Applies correlation coefficient and p-value thresholds to filter relationships.

  3. Constructs a weighted undirected graph from the filtered correlation matrix.

  4. Removes self-loops and isolated nodes from the graph.

  5. Adds correlation coefficients as edge attributes.

Value

Returns an igraph object representing the trait network.

References

  1. He, N., Li, Y., Liu, C., et al. (2020). Plant trait networks: improved resolution of the dimensionality of adaptation. Trends in Ecology & Evolution, 35(10), 908-918. https://doi.org/10.1016/j.tree.2020.06.003

  2. Li, Y., Liu, C., Sack, L., Xu, L., Li, M., Zhang, J., & He, N. (2022). Leaf trait network architecture shifts with species‐richness and climate across forests at continental scale. Ecology Letters, 25(6), 1442-1457. https://doi.org/10.1111/ele.14009

Examples

data(PFF)
PFF_traits <- PFF[, c("Height", "Leaf_area","LDMC","SLA","SRL","SeedMass","FltDate",
                      "FltDur","Leaf_Cmass","Leaf_Nmass","Leaf_CN","Leaf_Pmass",
                      "Leaf_NP","Leaf_CP","Root_Cmass","Root_Nmass","Root_CN")]
PFF_traits <- na.omit(PFF_traits)
head(PFF_traits)
Tn_result <- TN(traits_matrix = PFF_traits, rThres = 0.2, pThres = 0.05, method = "pearson")
Tn_result


MultiTraits documentation built on April 16, 2025, 9:07 a.m.