Type: | Package |
Title: | Analyzing and Visualizing Multidimensional Plant Traits |
Version: | 0.5.0 |
Date: | 2025-4-20 |
Maintainer: | Yan He <heyan@njfu.edu.cn> |
Description: | Implements analytical methods for multidimensional plant traits, including Competitors-Stress tolerators-Ruderals strategy analysis using leaf traits, Leaf-Height-Seed strategy analysis, Niche Periodicity Table analysis, and Trait Network analysis. Provides functions for data analysis, visualization, and network metrics calculation. Methods are based on Grime (1974) <doi:10.1038/250026a0>, Pierce et al. (2017) <doi:10.1111/1365-2435.12882>, Westoby (1998) <doi:10.1023/A:1004327224729>, Yang et al. (2022) <doi:10.1016/j.foreco.2022.120540>, Winemiller et al. (2015) <doi:10.1111/ele.12462>, He et al. (2020) <doi:10.1016/j.tree.2020.06.003>. |
Imports: | ggtern,igraph,Hmisc,corrplot,scatterplot3d,vegan,ggrepel |
Depends: | R (≥ 4.0.0), ggplot2 |
Suggests: | knitr,rmarkdown,testthat (≥ 3.0.0),devtools |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.3.2 |
Config/testthat/edition: | 3 |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2025-04-20 06:41:52 UTC; Administrator |
Author: | Yan He [aut, cre], Zhaogang Liu [aut], Jiangshan Lai [aut], Lingfeng Mao [aut] |
Repository: | CRAN |
Date/Publication: | 2025-04-20 18:40:02 UTC |
Calculate CSR strategy for multiple plant species
Description
This function processes a dataframe containing leaf traits (LA, LDMC, SLA) and applies the Strate_CSR function to each row.
Usage
CSR(data)
Arguments
data |
A dataframe containing columns for LA (Leaf Area), LDMC (Leaf Dry Matter Content), and SLA (Specific Leaf Area). |
Value
A dataframe with the original input data and additional columns:
C: Competitive strategy score
S: Stress-tolerant strategy score
R: Ruderal strategy score
type: The dominant CSR strategy type
References
Grime, J.P. (1974). Vegetation classification by reference to strategies. Nature, 250, 26–31.
Pierce, S., Negreiros, D., Cerabolini, B.E.L., Kattge, J., Díaz, S., et al. (2017). A global method for calculating plant CSR ecological strategies applied across biomes world-wide. Funct Ecol, 31: 444-457.
Examples
LA <- c(369615.7, 11.8, 55.7, 36061.2, 22391.8, 30068.1, 31059.5, 29895.1)
LDMC <- c(25.2, 39.7, 13.3, 35.5, 33.2, 36.1, 35.2, 34.9)
SLA <- c(17.4, 6.6, 34.1, 14.5, 8.1, 12.1, 9.4, 10.9)
traits <- data.frame(LA, LDMC, SLA)
CSR(data = traits)
Create a ternary plot of CSR strategies
Description
This function creates a ternary plot of Competition-Stress-Ruderal (CSR) strategies using the ggtern package.
Usage
CSR_plot(
data,
point_size = 3,
point_shape = 21,
expand_margin = 1,
custom_colors = c("#57C4AD", "#E6E1BC", "#EDA348", "#006165", "#F8E3EF", "#FFFF99",
"#376CB1", "#B2589B", "#DC4325", "#F16C4E", "#85B97B", "#FCEB2D", "#04A89E",
"#F49320", "#8F88C1", "#33B5D9", "#440153", "#B29BBD", "#28C865")
)
Arguments
data |
A dataframe containing required columns: C, S, R (numeric values between 0-1) and type (categorical classification) |
point_size |
Numeric, diameter of plot points (default = 3) |
point_shape |
Numeric, symbol code for data points (default = 21, circle with border) |
expand_margin |
Numeric, coefficient for plot margin expansion (default = 1) |
custom_colors |
Character vector specifying hex color codes for categorical types |
Details
This function implements:
Configurable point attributes (size, shape)
Adjustable plot boundaries
User-defined color schemes for categories
Automated legend column optimization
Standardized legend positioning
Reference grid and directional indicators
Value
A ggplot object representing the ternary plot of CSR strategies.
References
Grime, J.P. (1974). Vegetation classification by reference to strategies. Nature, 250, 26–31.
Pierce, S., Negreiros, D., Cerabolini, B.E.L., Kattge, J., Díaz, S., et al. (2017). A global method for calculating plant CSR ecological strategies applied across biomes world-wide. Funct Ecol, 31: 444-457.
Examples
data(PFF)
head(PFF)
traits <- data.frame(LA=PFF$Leaf_area, LDMC=PFF$LDMC, SLA=PFF$SLA)
head(traits)
result <- CSR(data = traits)
head(result)
CSR_plot(data=result)
Calculate LHS (Leaf-Height-Seed) Strategy
Description
This function calculates the LHS strategy for plant species based on their SLA (Specific Leaf Area), Height, and Seed Mass values.
Usage
LHS(data)
Arguments
data |
A data frame containing columns for SLA, Height, and SeedMass. |
Details
The function calculates median values for SLA, Height, and SeedMass from the input data. It then determines the LHS strategy for each species based on whether its trait values are less than or equal to (S) or greater than (L) the median values.
The resulting strategy is a combination of three letters (S or L) representing Leaf (SLA), Height, and Seed (SeedMass) respectively, separated by hyphens.
Value
A data frame with an additional column 'LHS_strategy' containing the calculated LHS strategy.
References
Westoby, M. (1998). A leaf-height-seed (LHS) plant ecology strategy scheme. Plant and Soil, 199, 213–227. https://doi.org/10.1023/A:1004327224729
Yang, J., Wang, Z., Zheng, Y., & Pan, Y. (2022). Shifts in plant ecological strategies in remnant forest patches along urbanization gradients. Forest Ecology and Management, 524, 120540. https://doi.org/10.1016/j.foreco.2022.120540
Examples
data(PFF)
pff <- PFF[, c("SLA", "Height", "SeedMass")]
result <- LHS(pff)
head(result)
Generate a 3D scatterplot of plant traits
Description
This function creates a three-dimensional scatterplot of plant traits (Specific Leaf Area, Height, and Seed Mass) based on the Leaf-Height-Seed (LHS) plant ecology strategy scheme.
Usage
LHS_plot(
data,
colors = c("#30123BFF", "#4777EFFF", "#1BD0D5FF", "#62FC6BFF", "#D2E935FF",
"#FE9B2DFF", "#DB3A07FF", "#7A0403FF"),
log_transform = TRUE
)
Arguments
data |
A data frame containing columns: SLA, Height, SeedMass, and LHS_strategy. |
colors |
A vector of colors for different LHS strategies. Default is a predefined color palette. |
log_transform |
Logical, indicating whether to log-transform the data. Default is TRUE. |
Details
The function performs the following steps: Checks if the input data contains the required columns. Converts LHS_strategy to a factor. Optionally log-transforms the data based on the log_transform parameter. Creates a 3D scatterplot using (potentially log-transformed) values of SLA, Height, and Seed Mass. Colors points based on LHS strategy. Adds a legend to identify different LHS strategies.
Value
A 3D scatterplot of SLA, Height, and Seed Mass (optionally log-transformed), with points colored by LHS strategy.
References
Westoby, M. (1998). A leaf-height-seed (LHS) plant ecology strategy scheme. Plant and Soil, 199, 213–227. https://doi.org/10.1023/A:1004327224729
Yang, J., Wang, Z., Zheng, Y., & Pan, Y. (2022). Shifts in plant ecological strategies in remnant forest patches along urbanization gradients. Forest Ecology and Management, 524, 120540. https://doi.org/10.1016/j.foreco.2022.120540
Examples
data(PFF)
pff <- PFF[, c("SLA", "Height", "SeedMass")]
result <- LHS(pff)
LHS_plot(result)
LHS_plot(result, log_transform = FALSE)
Create a table of Leaf-Height-Seed (LHS) strategy types
Description
This function generates a data frame containing different plant growth strategies based on the Leaf-Height-Seed (LHS) scheme. Each strategy is described by a combination of traits and their corresponding ecological interpretation.
Usage
LHS_strategy_scheme()
Value
A data frame with two columns:
- type
Character vector of LHS strategy combinations (e.g., "L-L-L", "L-L-S", etc.)
- strategy
Character vector describing the ecological strategy for each type
References
Westoby, M. (1998). A leaf-height-seed (LHS) plant ecology strategy scheme. Plant and Soil, 199, 213–227. https://doi.org/10.1023/A:1004327224729
Yang, J., Wang, Z., Zheng, Y., & Pan, Y. (2022). Shifts in plant ecological strategies in remnant forest patches along urbanization gradients. Forest Ecology and Management, 524, 120540. https://doi.org/10.1016/j.foreco.2022.120540
Examples
LHS_strategy_scheme()
Perform nested principal component analysis (PCA of PCAs) for ecological niche periodicity
Description
This function conducts a ‘PCA of PCAs’ to analyze ecological niche periodicity based on multiple trait dimensions.
Usage
NPT(data, dimension)
Arguments
data |
A data frame containing species trait data. |
dimension |
A list of character vectors, each representing a trait dimension with corresponding column names from the data. |
Details
The function performs the following steps:
Checks and cleans input data, removing rows with NA values
Conducts first-level PCA for each trait dimension
Extracts PC1 and PC2 scores from each first-level PCA
Combines all PC scores and performs a second-level PCA
Returns summary statistics and results from both levels of analysis
Value
A list containing three elements:
PCA_first |
A data frame summarizing the first-level PCA results for each dimension |
PCA_second |
A matrix of species scores from the second-level PCA |
result |
The complete rda object from the second-level PCA |
References
Winemiller, K. O., Fitzgerald, D. B., Bower, L. M., & Pianka, E. R. (2015). Functional traits, convergent evolution, and periodic tables of niches. Ecology letters, 18(8), 737-751. https://doi.org/10.1111/ele.12462
Yu, R., Huang, J., Xu, Y., Ding, Y., & Zang, R. (2020). Plant functional niches in forests across four climatic zones: Exploring the periodic table of niches based on plant functional traits. Frontiers in Plant Science, 11, 841. https://doi.org/10.3389/fpls.2020.00841
Examples
data(PFF)
PFF[,3:20] <- log(PFF[,3:20])
traits_dimension <- list(
grow = c("SLA","Leaf_area","LDMC","SRL","Leaf_Nmass","Leaf_Pmass","Root_Nmass"),
survive = c("Height","Leaf_Cmass","Root_Cmass","Leaf_CN","Leaf_NP","Leaf_CP","Root_CN"),
reproductive = c("SeedMass","FltDate","FltDur")
)
result <- NPT(data = PFF, dimension = traits_dimension)
result
Plot results from nested principal component analysis
Description
This function creates a visualization of the results from the nested principal component analysis (NPT function) for ecological niche periodicity.
Usage
NPT_plot(pca_obj, group = NULL)
Arguments
pca_obj |
An rda object returned by the second-level PCA in the NPT function. |
group |
A vector or factor specifying the grouping of samples. |
Details
The function creates a biplot that includes:
Sample points colored by group
Species scores represented as arrows
Species labels positioned using ggrepel to avoid overlapping
The plot also includes dashed lines at x=0 and y=0, and displays the percentage of variance explained by each principal component on the axes.
Value
A ggplot object representing a biplot of species scores and sample points.
References
Winemiller, K. O., Fitzgerald, D. B., Bower, L. M., & Pianka, E. R. (2015). Functional traits, convergent evolution, and periodic tables of niches. Ecology letters, 18(8), 737-751. https://doi.org/10.1111/ele.12462
Yu, R., Huang, J., Xu, Y., Ding, Y., & Zang, R. (2020). Plant functional niches in forests across four climatic zones: Exploring the periodic table of niches based on plant functional traits. Frontiers in Plant Science, 11, 841. https://doi.org/10.3389/fpls.2020.00841
Examples
data(PFF)
PFF[,3:20] <- log(PFF[,3:20])
PFF <- na.omit(PFF)
traits_dimension <- list(
grow = c("SLA","Leaf_area","LDMC","SRL","Leaf_Nmass","Leaf_Pmass","Root_Nmass"),
survive = c("Height","Leaf_Cmass","Root_Cmass","Leaf_CN","Leaf_NP","Leaf_CP","Root_CN"),
reproductive = c("SeedMass","FltDate","FltDur")
)
npt_result <- NPT(data = PFF, dimension = traits_dimension)
dev.new() # A window that is too small will interfere with the drawing.
# Optionally, you can set the drawing window to pop up automatically.
NPT_plot(npt_result$result)
NPT_plot(npt_result$result, PFF$family)
Plant Functional Traits Dataset from Ponderosa Pine Forests Flora (PFF)
Description
A dataset containing functional traits for 133 plant species commonly found in southwestern USA Pinus ponderosa var. scopulorum P. & C. Lawson (ponderosa pine) forests.
Usage
PFF
Format
A data frame with 137 rows and 20 variables:
- family
Plant family
- species
Plant species
- Height
Canopy height (cm)
- Leaf_area
Leaf area (mm^2)
- LDMC
Leaf dry matter content (%)
- SLA
Specific leaf area (mm^2/mg)
- SRL
Specific root length (m/g)
- SeedMass
Seed mass (mg)
- FltDate
mean Flowering date (Julian day)
- FltDur
mean Flowering duration (days)
- k_value
decomposition decay constant, where proportion of original mass remaining = exp(- k-value*0.926)
- Leaf_Cmass
Leaf carbon content (% dry mass)
- Leaf_Nmass
Leaf nitrogen content (% dry mass)
- Leaf_CN
Leaf carbon to nitrogen ratio
- Leaf_Pmass
Leaf phosphorus content (% dry mass)
- Leaf_NP
Leaf nitrogen to phosphorus ratio
- Leaf_CP
Leaf carbon to phosphorus ratio
- Root_Cmass
Root carbon content (% dry mass)
- Root_Nmass
Root nitrogen content (% dry mass)
- Root_CN
Root carbon to nitrogen ratio
Details
This dataset contains measurements of a core set of functional traits that reflect aspects of each species' ability to disperse, establish, acquire water and nutrients, and photosynthesize. Traits include specific leaf area (SLA), height, seed mass, specific root length (SRL), leaf and fine root nitrogen concentration, leaf phosphorus concentration, and leaf dry matter content (LDMC). Julian flowering date and flowering duration were also obtained for each species. Leaf litter decomposition rates were measured on 103 species.
Source
Laughlin, D. C., Leppert, J. J., Moore, M. M., & Sieg, C. H. (2010). A multi-trait test of the leaf-height-seed plant strategy scheme with 133 species from a pine forest flora. Functional Ecology, 24(3), 485-700.
Examples
data(PFF)
head(PFF)
Calculate CSR (Competition-Stress-Ruderal) Strategy
Description
This function calculates the CSR strategy based on leaf traits.
Usage
Strate_CSR(LA, LDMC, SLA)
Arguments
LA |
Leaf area in mm^2 |
LDMC |
Leaf dry matter content in % |
SLA |
Specific leaf area in mm^2/mg |
Value
A list containing:
-
C
: Proportion of competition strategy -
S
: Proportion of stress-tolerance strategy -
R
: Proportion of ruderal strategy -
type
: Type of CSR strategy
References
Grime, J.P. (1974). Vegetation classification by reference to strategies. Nature, 250, 26–31.
Pierce, S., Negreiros, D., Cerabolini, B.E.L., Kattge, J., Díaz, S., et al. (2017). A global method for calculating plant CSR ecological strategies applied across biomes world-wide. Funct Ecol, 31: 444-457.
Examples
Strate_CSR(LA = 369615.7, LDMC = 25.2, SLA = 17.4)
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:
Calculates Pearson correlation coefficients and p-values for the trait matrix.
Applies correlation coefficient and p-value thresholds to filter relationships.
Constructs an unweighted undirected graph from the filtered correlation matrix.
Removes self-loops and isolated nodes from the graph.
Adds correlation coefficients as edge attributes.
Value
Returns an igraph object representing the trait network.
References
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
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
Calculate and Visualize Plant Trait Correlation Network
Description
This function calculates correlation coefficients for given plant traits and generates a correlation network plot.
Usage
TN_corr(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. Only correlations with absolute values above this threshold will be displayed in the plot. |
pThres |
Numeric, threshold for p-value, default is 0.05. Only correlations with p-values below this threshold will be displayed in the plot. |
method |
Character, specifies the correlation method to use: "pearson" (default) or "spearman". |
Details
The function first calculates Pearson correlation coefficients between traits, then adjusts p-values using the FDR method. Finally, it plots the correlation network using the corrplot package. The plot displays only correlations that meet both the correlation coefficient and p-value thresholds.
Value
Returns a correlation network plot object.
References
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
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_corr(traits_matrix = PFF_traits, rThres = 0.3, pThres = 0.01,method = "pearson")
Calculate Node and Global Metrics for Trait Networks
Description
This function computes various node and global metrics for a trait network graph.
Usage
TN_metrics(graph)
Arguments
graph |
An igraph object representing the trait network, typically generated by the |
Value
A list containing two data frames:
node |
A data frame with node-level metrics including degree, closeness, betweenness, and local clustering coefficient. |
global |
A data frame with global metrics including edge density, diameter, average path length, average clustering coefficient, and modularity. |
References
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
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)
TN_metrics(Tn_result)
Plot Trait Network Graph
Description
This function visualizes the trait network graph generated by the TN
function.
Usage
TN_plot(graph, style = 1, vertex.size = 20, vertex.label.cex = 0.6)
Arguments
graph |
An igraph object representing the trait network. |
style |
A numeric value that determines the plotting style (default is 1). |
vertex.size |
Numeric value for the size of vertices in the plot (default is 20). |
vertex.label.cex |
Numeric value for the scaling factor of vertex labels (default is 0.6). |
Details
The function uses the cluster_edge_betweenness
algorithm to identify communities
in the graph and assigns community membership to vertices. It offers two
plotting styles:
Style 1: Plots the community structure.
Style 2: Plots the graph in a circular layout with vertex colors representing communities. The vertex size and label size can be customized using vertex.size and vertex.label.cex parameters respectively.
Value
An object of class igraph
. This function generates a visualization of the trait network graph.
When style = 1, it displays a community structure plot.
When style = 2, it displays a circular layout plot where vertex colors represent community membership,
edge thickness represents correlation strength, and edge color represents the sign of the correlation (black for positive, red for negative).
References
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
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)
TN_plot(Tn_result, style = 1, vertex.size = 20, vertex.label.cex = 0.6)
TN_plot(Tn_result, style = 2, vertex.size = 20, vertex.label.cex = 0.6)