Author: Yan He

# MultiTraits_tutorial

#### Yan He

#### 2026.3.22

## Introduction

MultiTraits is a comprehensive R package designed for advanced analysis and visualization of multidimensional plant traits. It provides a standardized workflow and intuitive visualization tools, streamlining the exploration of complex trait relationships for researchers, educators, and students. The package integrates four key analytical modules: Competitors–Stress Tolerators–Ruderals (CSR) strategy analysis, Leaf–Height–Seed (LHS) strategy analysis, Niche Periodic Table (NPT) analysis, and Plant Trait Network (PTN) analysis. These modules offer complementary perspectives, fostering a more comprehensive understanding of multidimensional trait variation patterns in plants. This tutorial aims to guide users through the core functionalities and practical applications of the MultiTraits package. Through hands-on demonstrations, we show how these analytical modules can be used to explore multidimensional relationships among plant traits, including essential steps in data preparation, analysis workflows, and results visualization.

## Installation

### From CRAN (recommended)

    # install.packages("MultiTraits")

### From GitHub (development version)

    # if (!requireNamespace("devtools", quietly = TRUE)) {install.packages("devtools")}
    # devtools::install_github("biodiversity-monitoring/MultiTraits")

## Main Functions

Module | Function | Description
--- | --- | ---
CSR Module | `CSR()` | Classifies plant species’ CSR ecological strategies based on leaf traits (LA, LDMC, and SLA) using the Pierce et al. (2017) method.
| `CSR_hodgson()` | Implements the Hodgson et al. (1999) method for CSR classification.
| `CSR_plot()` | Provides advanced ternary plot visualizations for CSR analysis to explore plant adaptation to different environments.
LHS Module | `LHS()` | Analyzes LHS strategies using SLA, plant height, and seed mass.
| `LHS_plot()` | Visualizes three-dimensional trait distributions in LHS space.
| `LHS_strategy_scheme()` | Classifies strategies based on the LHS scheme.
NPT Module | `NPT_discrete()` | Supports discrete niche classification schemes. Performs PCA and clustering (CART or K-means) to group species within each dimension.
| `NPT_discrete_plot()` | Visualizes the discrete niche classification scheme.
| `NPT_continuous()` | Supports continuous niche classification schemes. Performs a hierarchical PCA approach.
| `NPT_continuous_plot()` | Visualizes the results of the continuous niche classification.
PTN Module | `PTN_corr()` | Offers correlation computation and visualization for trait networks.
| `PTN()` | Generates trait correlation networks.
| `PTN_metrics()` | Quantifies network metrics for trait networks.
| `PTN_plot()` | Visualizes the trait network graph.
PTMN Module | `PTMN()` | Constructs trait multilayer networks.
| `PTMN_metrics()` | Calculates metrics for trait multilayer networks.
| `PTMN_plot()` | Visualizes trait multilayer networks.

### Example Datasets: PFF (Pine Forests Flora)

The package includes a built-in example dataset called PFF that can be loaded as follows:

    library(MultiTraits)
    data(PFF)
    # View the structure of the datasets
    head(PFF)

    ##                     species      genus      family Height Leaf_area LDMC SLA
    ## 1      Achillea millefolium   Achillea  Asteraceae     14       240   27   8
    ## 2           Agoseris glauca   Agoseris  Asteraceae     12       520   17  20
    ## 3      Agropyron desertorum  Agropyron     Poaceae     26       290   42   9
    ## 4     Ambrosia psilostachya   Ambrosia  Asteraceae     44       490   20  16
    ## 5 Androsace septentrionalis  Androsace Primulaceae      1        51   14  31
    ## 6     Antennaria parvifolia Antennaria  Asteraceae      2        66   27  13
    ##   SRL SeedMass FltDate FltDur k_value Leaf_Cmass Leaf_Nmass Leaf_CN Leaf_Pmass
    ## 1  35    0.140     197    152    1.70      41.16       1.92      22       0.36
    ## 2  56    2.530     213    183    1.10      42.62       1.72      25       0.39
    ## 3  99    0.388     198     91      NA      41.48       2.32      18       0.06
    ## 4  73    5.896     243    122    2.23      38.42       2.32      17       0.25
    ## 5  80    0.128     182    182      NA      40.83       1.95      22       0.29
    ## 6  27    0.061     182    122    0.54      44.07       1.53      30       0.18
    ##   Leaf_NP Leaf_CP Root_Cmass Root_Nmass Root_CN
    ## 1       6     114      40.96       0.48      85
    ## 2       4     109      45.86       0.89      52
    ## 3      52    1021      41.46       1.61      26
    ## 4      14     224      35.69       1.29      28
    ## 5       7     131      46.46       1.23      38
    ## 6       9     252      35.96       0.55      65

The PFF dataset contains trait measurements for plant species found in pine forests, with the following variables:

Height: Maximum plant height (cm)

Leaf_area: Leaf area (mm2)

LDMC: Leaf dry matter content (%)

SLA: Specific leaf area (mm2/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 (%)

Leaf_Nmass: Leaf nitrogen content (%)

Leaf_CN: Leaf carbon/nitrogen ratio

Leaf_Pmass: Leaf phosphorus content (%)

Leaf_NP: Leaf nitrogen/phosphorus ratio

Leaf_CP: Leaf carbon/phosphorus ratio

Root_Cmass: Root carbon content (%)

Root_Nmass: Root nitrogen content (%)

Root_CN: Root carbon/nitrogen ratio

### CSR Strategy

The CSR (Competitor–Stress-Tolerator–Ruderal) strategy, initially conceptualized by Grime (1974), classifies plants based on their ecological strategies, which are influenced by environmental factors such as competition, stress, and disturbance. The MultiTraits package offers two approaches for CSR analysis: the method proposed by Hodgson et al. (1999) and the method developed by Pierce et al. (2017). The Pierce method, used here, employs leaf area (LA), leaf dry matter content (LDMC), and specific leaf area (SLA) to classify species. The CSR_plot() function visualizes the results in a ternary plot, showing species’ positions based on their relative C, S, and R strategy proportions. This aids in understanding plant functional classification and predicting responses to environmental changes.

    # Load packages
    library(MultiTraits)
    # Load the PFF dataset
    data(PFF)
    head(PFF)

    ##                     species      genus      family Height Leaf_area LDMC SLA
    ## 1      Achillea millefolium   Achillea  Asteraceae     14       240   27   8
    ## 2           Agoseris glauca   Agoseris  Asteraceae     12       520   17  20
    ## 3      Agropyron desertorum  Agropyron     Poaceae     26       290   42   9
    ## 4     Ambrosia psilostachya   Ambrosia  Asteraceae     44       490   20  16
    ## 5 Androsace septentrionalis  Androsace Primulaceae      1        51   14  31
    ## 6     Antennaria parvifolia Antennaria  Asteraceae      2        66   27  13
    ##   SRL SeedMass FltDate FltDur k_value Leaf_Cmass Leaf_Nmass Leaf_CN Leaf_Pmass
    ## 1  35    0.140     197    152    1.70      41.16       1.92      22       0.36
    ## 2  56    2.530     213    183    1.10      42.62       1.72      25       0.39
    ## 3  99    0.388     198     91      NA      41.48       2.32      18       0.06
    ## 4  73    5.896     243    122    2.23      38.42       2.32      17       0.25
    ## 5  80    0.128     182    182      NA      40.83       1.95      22       0.29
    ## 6  27    0.061     182    122    0.54      44.07       1.53      30       0.18
    ##   Leaf_NP Leaf_CP Root_Cmass Root_Nmass Root_CN
    ## 1       6     114      40.96       0.48      85
    ## 2       4     109      45.86       0.89      52
    ## 3      52    1021      41.46       1.61      26
    ## 4      14     224      35.69       1.29      28
    ## 5       7     131      46.46       1.23      38
    ## 6       9     252      35.96       0.55      65

    # Create a data frame with the CSR traits
    csr_traits <- data.frame(LA=PFF$Leaf_area, LDMC=PFF$LDMC, SLA=PFF$SLA)
    rownames(csr_traits) <- PFF$species
    head(csr_traits)

    ##                            LA LDMC SLA
    ## Achillea millefolium      240   27   8
    ## Agoseris glauca           520   17  20
    ## Agropyron desertorum      290   42   9
    ## Ambrosia psilostachya     490   20  16
    ## Androsace septentrionalis  51   14  31
    ## Antennaria parvifolia      66   27  13

    # Perform CSR analysis
    csr_result <- CSR(csr_traits)
    head(csr_result)

    ##                            LA LDMC SLA         C         S        R type
    ## Achillea millefolium      240   27   8 18.845244 81.154756  0.00000 S/CS
    ## Agoseris glauca           520   17  20 34.290705  4.542473 61.16682 R/CR
    ## Agropyron desertorum      290   42   9 12.118306 87.881694  0.00000    S
    ## Ambrosia psilostachya     490   20  16 30.293240 30.891427 38.81533  CSR
    ## Androsace septentrionalis  51   14  31  4.068212  0.000000 95.93179    R
    ## Antennaria parvifolia      66   27  13  5.131786 73.958953 20.90926 S/SR

    # Create the CSR plot
    CSR_plot(csr_result)

### LHS Strategy

The Leaf–Height–Seed (LHS) scheme, proposed by Westoby (1998), classifies plant species based on specific leaf area (SLA), canopy height at maturity, and seed mass. These three traits reflect trade-offs in resource acquisition, spatial occupation, and reproductive investment. The MultiTraits package implements the LHS scheme by positioning species in a three-dimensional trait space using log-transformed trait values. This continuous space is then divided into eight discrete strategy types (e.g., S–S–S, L–L–L) based on median trait values, representing different trade-offs in growth, competition, and survival. The LHS_plot() function visualizes these strategies in 3D space, while LHS_strategy_scheme() provides a reference key for interpreting the strategy types.

    # Load packages
    library(MultiTraits)
    # Load the PFF dataset
    data(PFF)
    head(PFF)

    ##                     species      genus      family Height Leaf_area LDMC SLA
    ## 1      Achillea millefolium   Achillea  Asteraceae     14       240   27   8
    ## 2           Agoseris glauca   Agoseris  Asteraceae     12       520   17  20
    ## 3      Agropyron desertorum  Agropyron     Poaceae     26       290   42   9
    ## 4     Ambrosia psilostachya   Ambrosia  Asteraceae     44       490   20  16
    ## 5 Androsace septentrionalis  Androsace Primulaceae      1        51   14  31
    ## 6     Antennaria parvifolia Antennaria  Asteraceae      2        66   27  13
    ##   SRL SeedMass FltDate FltDur k_value Leaf_Cmass Leaf_Nmass Leaf_CN Leaf_Pmass
    ## 1  35    0.140     197    152    1.70      41.16       1.92      22       0.36
    ## 2  56    2.530     213    183    1.10      42.62       1.72      25       0.39
    ## 3  99    0.388     198     91      NA      41.48       2.32      18       0.06
    ## 4  73    5.896     243    122    2.23      38.42       2.32      17       0.25
    ## 5  80    0.128     182    182      NA      40.83       1.95      22       0.29
    ## 6  27    0.061     182    122    0.54      44.07       1.53      30       0.18
    ##   Leaf_NP Leaf_CP Root_Cmass Root_Nmass Root_CN
    ## 1       6     114      40.96       0.48      85
    ## 2       4     109      45.86       0.89      52
    ## 3      52    1021      41.46       1.61      26
    ## 4      14     224      35.69       1.29      28
    ## 5       7     131      46.46       1.23      38
    ## 6       9     252      35.96       0.55      65

    # Create a data frame with the LHS traits
    lhs_traits <- PFF[, c("SLA", "Height", "SeedMass")]
    rownames(lhs_traits) <- PFF$species
    head(lhs_traits)

    ##                           SLA Height SeedMass
    ## Achillea millefolium        8     14    0.140
    ## Agoseris glauca            20     12    2.530
    ## Agropyron desertorum        9     26    0.388
    ## Ambrosia psilostachya      16     44    5.896
    ## Androsace septentrionalis  31      1    0.128
    ## Antennaria parvifolia      13      2    0.061

    # Perform LHS analysis
    lhs_result <- LHS(lhs_traits)
    head(lhs_result)

    ##                           SLA Height SeedMass  log_SLA log_Height log_SeedMass
    ## Achillea millefolium        8     14    0.140 2.079442  2.6390573   -1.9661129
    ## Agoseris glauca            20     12    2.530 2.995732  2.4849066    0.9282193
    ## Agropyron desertorum        9     26    0.388 2.197225  3.2580965   -0.9467499
    ## Ambrosia psilostachya      16     44    5.896 2.772589  3.7841896    1.7742742
    ## Androsace septentrionalis  31      1    0.128 3.433987  0.0000000   -2.0557250
    ## Antennaria parvifolia      13      2    0.061 2.564949  0.6931472   -2.7968814
    ##                           LHS_strategy
    ## Achillea millefolium             S-S-S
    ## Agoseris glauca                  L-S-L
    ## Agropyron desertorum             S-L-S
    ## Ambrosia psilostachya            L-L-L
    ## Androsace septentrionalis        L-S-S
    ## Antennaria parvifolia            S-S-S

    table(lhs_result$LHS_strategy)

    ##
    ## L-L-L L-L-S L-S-L L-S-S S-L-L S-L-S S-S-L S-S-S
    ##    16    18    11    21    20     9    19    19

    # Create a visualization plot of the LHS analysis results
    LHS_plot(lhs_result, group = "LHS_strategy", show_cube = TRUE)

    # Display the LHS strategy scheme diagram
    LHS_strategy_scheme()

    ##    type                                                         strategy
    ## 1 L-L-L    Rapid growth, strong competitiveness and strong survivability
    ## 2 L-L-S Rapid growth, strong competitiveness and long-distance dispersal
    ## 3 L-S-L      Rapid growth, weak competitiveness and strong survivability
    ## 4 L-S-S   Rapid growth, weak competitiveness and long-distance dispersal
    ## 5 S-L-L     Slow growth, strong competitiveness and strong survivability
    ## 6 S-L-S  Slow growth, strong competitiveness and long-distance dispersal
    ## 7 S-S-L       Slow growth, weak competitiveness and strong survivability
    ## 8 S-S-S    Slow growth, weak competitiveness and long-distance dispersal

### Niche Periodicity Table

The Niche Periodic Table (NPT) framework systematically describes and predicts species functions by identifying recurring trait combinations driven by convergent evolution. Within the MultiTraits R package, the NPT module offers both discrete and continuous classification schemes. The NPT_discrete() function categorizes species into distinct niche groups using PCA and clustering, with NPT_discrete_plot() visualizing the results. For continuous classification, NPT_continuous() performs hierarchical PCA to create a two-dimensional ordination space, while NPT_continuous_plot() visualizes these integrated niche patterns.

    # Load packages
    library(MultiTraits)
    # Load and prepare data
    data(PFF)
    rownames(PFF) <- PFF$species
    PFF_traits <- PFF[, c("SLA", "SRL", "Leaf_Nmass", "Root_Nmass","Height",
                          "Leaf_CN", "Root_CN","SeedMass", "FltDate", "FltDur")]
    # Perform log transformation of data and remove missing values
    PFF_traits <- log(na.omit(PFF_traits))
    head(PFF_traits)

    ##                                SLA      SRL Leaf_Nmass Root_Nmass    Height
    ## Achillea millefolium      2.079442 3.555348  0.6523252 -0.7339692 2.6390573
    ## Agoseris glauca           2.995732 4.025352  0.5423243 -0.1165338 2.4849066
    ## Agropyron desertorum      2.197225 4.595120  0.8415672  0.4762342 3.2580965
    ## Ambrosia psilostachya     2.772589 4.290459  0.8415672  0.2546422 3.7841896
    ## Androsace septentrionalis 3.433987 4.382027  0.6678294  0.2070142 0.0000000
    ## Antennaria parvifolia     2.564949 3.295837  0.4252677 -0.5978370 0.6931472
    ##                            Leaf_CN  Root_CN   SeedMass  FltDate   FltDur
    ## Achillea millefolium      3.091042 4.442651 -1.9661129 5.283204 5.023881
    ## Agoseris glauca           3.218876 3.951244  0.9282193 5.361292 5.209486
    ## Agropyron desertorum      2.890372 3.258097 -0.9467499 5.288267 4.510860
    ## Ambrosia psilostachya     2.833213 3.332205  1.7742742 5.493061 4.804021
    ## Androsace septentrionalis 3.091042 3.637586 -2.0557250 5.204007 5.204007
    ## Antennaria parvifolia     3.401197 4.174387 -2.7968814 5.204007 4.804021

    # Define trait dimensions
    dimension <- list(
      Grow = c("SLA", "SRL", "Leaf_Nmass", "Root_Nmass"),
      Survive = c("Height", "Leaf_CN", "Root_CN"),
      Reproductive = c("SeedMass", "FltDate", "FltDur")
    )

    # Perform discrete niche scheme
    set.seed(123)
    discrete_result <- NPT_discrete(data = PFF_traits, dimension = dimension)

    ## === PCA Analysis Results ===
    ## Dimension: Grow
    ## PC1 variance explained: 51.38 %
    ## PC2 variance explained: 31.01 %
    ##
    ## Dimension: Survive
    ## PC1 variance explained: 80.24 %
    ## PC2 variance explained: 15.45 %
    ##
    ## Dimension: Reproductive
    ## PC1 variance explained: 94.75 %
    ## PC2 variance explained: 4.5 %
    ##
    ## ===  CART  Clustering Results ===
    ## Dimension Grow cluster count: 8
    ## Dimension Survive cluster count: 8
    ## Dimension Reproductive cluster count: 8
    ##
    ## === Niche Classification Results ===
    ## Total potential niches: 512
    ## Actual occupied niches: 99
    ## Niche occupancy rate: 19.34 %

    discrete_result

    ## $niche_classification
    ##                        species Grow Survive Reproductive niche_code
    ## 1         Achillea millefolium    7       1            2      7,1,2
    ## 2              Agoseris glauca    1       1            5      1,1,5
    ## 3         Agropyron desertorum    4       2            3      4,2,3
    ## 4        Ambrosia psilostachya    1       2            4      1,2,4
    ## 5    Androsace septentrionalis    4       8            6      4,8,6
    ## 6        Antennaria parvifolia    3       8            6      3,8,6
    ## 7          Antennaria rosulata    3       8            6      3,8,6
    ## 8            Arenaria fendleri    1       1            5      1,1,5
    ## 9          Arenaria lanuginosa    3       1            2      3,1,2
    ## 10           Aristida purpurea    7       5            5      7,5,5
    ## 11        Artemisia campestris    1       2            6      1,2,6
    ## 12         Artemisia carruthii    1       2            6      1,2,6
    ## 13       Artemisia dracunculus    4       6            6      4,6,6
    ## 14      Astragalus humistratus    3       7            2      3,7,2
    ## 15           Astragalus rusbyi    8       7            1      8,7,1
    ## 16              Bahia dissecta    4       6            3      4,6,3
    ## 17  Blepharoneuron tricholepis    7       5            1      7,5,1
    ## 18      Bouteloua curtipendula    4       5            5      4,5,5
    ## 19          Bouteloua gracilis    4       2            1      4,2,1
    ## 20           Bouteloua simplex    6       1            8      6,1,8
    ## 21             Bromus ciliatus    1       2            4      1,2,4
    ## 22             Bromus tectorum    3       1            8      3,1,8
    ## 23              Carex geophila    3       5            3      3,5,3
    ## 24    Castilleja austromontana    5       2            2      5,2,2
    ## 25          Castilleja integra    5       1            6      5,1,6
    ## 26          Ceanothus fendleri    1       1            4      1,1,4
    ## 27           Centaurea diffusa    1       2            3      1,2,3
    ## 28       Chaetopappa ericoides    1       1            5      1,1,5
    ## 29         Chamaesyce fendleri    4       5            6      4,5,6
    ## 30    Chamaesyce serpyllifolia    6       8            5      6,8,5
    ## 31       Chenopodium fremontii    8       6            1      8,6,1
    ## 32      Chenopodium graveolens    8       7            8      8,7,8
    ## 33            Cirsium wheeleri    5       6            7      5,6,7
    ## 34        Convolvulus arvensis    3       4            7      3,4,7
    ## 35         Coreopsis tinctoria    3       1            1      3,1,1
    ## 36          Cosmos parviflorus    8       3            4      8,3,4
    ## 37             Draba asperella    1       8            6      1,8,6
    ## 38        Drymaria leptophylla    6       8            8      6,8,8
    ## 39         Drymaria molluginea    7       8            8      7,8,8
    ## 40        Echeandia flavescens    4       1            8      4,1,8
    ## 41            Elymus elymoides    1       2            4      1,2,4
    ## 42         Elymus trachycaulus    2       5            4      2,5,4
    ## 43      Epilobium brachycarpum    4       3            8      4,3,8
    ## 44         Eragrostis mexicana    6       1            3      6,1,3
    ## 45          Erigeron divergens    3       1            6      3,1,6
    ## 46         Erigeron flavescens    1       8            6      1,8,6
    ## 47      Erigeron formosissimus    1       1            3      1,1,3
    ## 48           Erigeron speciosa    3       2            3      3,2,3
    ## 49            Eriogonum alatum    7       1            4      7,1,4
    ## 50     Eriogonum pharnaceoides    1       1            1      1,1,1
    ## 51         Eriogonum racemosum    2       4            2      2,4,2
    ## 52          Erodium cicutarium    8       8            2      8,8,2
    ## 53               Euphorbia sp.    5       1            4      5,1,4
    ## 54           Festuca arizonica    2       5            3      2,5,3
    ## 55      Gaillardia pinnatifida    1       4            2      1,4,2
    ## 56        Geranium caespitosum    5       1            5      5,1,5
    ## 57       Geranium richardsonii    1       1            5      1,1,5
    ## 58       Gutierrezia sarothrae    4       1            2      4,1,2
    ## 59       Heliomeris multiflora    4       3            5      4,3,5
    ## 60  Helianthella quinquinervis    5       2            7      5,2,7
    ## 61         Hesperostipa comata    7       5            7      7,5,7
    ## 62         Heterotheca villosa    1       1            5      1,1,5
    ## 63          Hieracium fendleri    2       4            1      2,4,1
    ## 64          Houstonia wrightii    3       8            8      3,8,8
    ## 65           Hymenoxys hoopsii    1       6            1      1,6,1
    ## 66      Hymenoxys richardsonii    1       1            2      1,1,2
    ## 67      Hymenopappus mexicanus    3       1            1      3,1,1
    ## 68         Ipomopsis aggregata    2       2            2      2,2,2
    ## 69        Ipomopsis multiflora    1       1            1      1,1,1
    ## 70          Iris missouriensis    5       2            7      5,2,7
    ## 71          Koeleria macrantha    2       1            6      2,1,6
    ## 72        Laennecia schiedeana    1       2            6      1,2,6
    ## 73        Lepidium densiflorum    8       3            2      8,3,2
    ## 74              Linum australe    1       1            3      1,1,3
    ## 75               Linum lewisii    3       2            5      3,2,5
    ## 76           Linaria dalmatica    3       6            8      3,6,8
    ## 77    Lithospermum multiflorum    5       2            4      5,2,4
    ## 78              Lotus wrightii    8       7            4      8,7,4
    ## 79           Lupinus argenteus    8       7            7      8,7,7
    ## 80              Lupinus kingii    8       7            7      8,7,7
    ## 81    Machaeranthera canescens    1       2            5      1,2,5
    ## 82     Machaeranthera gracilis    4       1            5      4,1,5
    ## 83         Mirabilis decipiens    8       3            4      8,3,4
    ## 84            Monroa squarrosa    4       4            2      4,4,2
    ## 85    Muhlenbergia minutissima    6       1            6      6,1,6
    ## 86        Muhlenbergia montana    7       5            3      7,5,3
    ## 87       Muhlenbergia ramulosa    7       1            8      7,1,8
    ## 88         Muhlenbergia rigens    7       5            6      7,5,6
    ## 89       Muhlenbergia wrightii    4       2            1      4,2,1
    ## 90             Nama dichotomum    8       3            8      8,3,8
    ## 91             Noccaea montana    1       8            5      1,8,5
    ## 92         Oenothera pubescens    4       1            1      4,1,1
    ## 93                  Oxalis sp.    8       8            3      8,8,3
    ## 94         Oxytropis lambertii    8       7            5      8,7,5
    ## 95         Packera multilobata    3       1            5      3,1,5
    ## 96          Pascopyrum smithii    3       6            4      3,6,4
    ## 97          Penstemon barbatus    3       2            8      3,2,8
    ## 98          Penstemon linearis    7       5            1      7,5,1
    ## 99          Penstemon virgatus    3       2            1      3,2,1
    ## 100             Phlox speciosa    3       4            3      3,4,3
    ## 101            Pinus ponderosa    7       6            8      7,6,8
    ## 102          Plantago argyraea    4       1            1      4,1,1
    ## 103              Poa compressa    2       5            5      2,5,5
    ## 104            Poa fendleriana    7       5            2      7,5,2
    ## 105              Poa pratensis    1       2            6      1,2,6
    ## 106        Polygonum aviculare    4       7            5      4,7,5
    ## 107        Polygonum douglasii    4       1            1      4,1,1
    ## 108         Portulaca oleracea    6       8            6      6,8,6
    ## 109         Potentilla crinita    2       4            5      2,4,5
    ## 110        Potentilla hippiana    5       1            1      5,1,1
    ## 111      Potentilla subviscosa    2       8            1      2,8,1
    ## 112  Pseudognaphalium macounii    6       1            6      6,1,6
    ## 113        Cymopterus lemmonii    5       1            5      5,1,5
    ## 114           Quercus gambelii    5       6            8      5,6,8
    ## 115               Rosa woodsii    3       5            4      3,5,4
    ## 116             Salsola tragus    8       7            1      8,7,1
    ## 117    Schizachyrium scoparium    4       6            3      4,6,3
    ## 118          Senecio actinella    2       4            1      2,4,1
    ## 119        Senecio eremophilis    8       6            1      8,6,1
    ## 120              Solidago nana    4       5            3      4,5,3
    ## 121          Solidago velutina    3       2            2      3,2,2
    ## 122     Sporobolus interruptus    4       5            3      4,5,3
    ## 123   Symphyotrichum ascendens    1       1            1      1,1,1
    ## 124       Taraxacum officinale    8       3            5      8,3,5
    ## 125        Thalictrum fendleri    3       6            4      3,6,4
    ## 126         Townsendia exscapa    1       8            3      1,8,3
    ## 127          Tragopogon dubius    1       2            4      1,2,4
    ## 128         Trifolium longipes    8       4            2      8,4,2
    ## 129          Verbena bracteata    1       1            2      1,1,2
    ## 130          Verbascum thapsus    1       6            6      1,6,6
    ## 131            Vicia americana    8       7            7      8,7,7
    ## 132            Vicia pulchella    8       7            7      8,7,7
    ## 133           Viola canadensis    2       1            5      2,1,5
    ##
    ## $summary
    ## # A tibble: 99 × 3
    ##    niche_code species_count species_list
    ##    <chr>              <int> <chr>
    ##  1 1,1,1                  3 Eriogonum pharnaceoides, Ipomopsis multiflora, Symp…
    ##  2 1,1,2                  2 Hymenoxys richardsonii, Verbena bracteata
    ##  3 1,1,3                  2 Erigeron formosissimus, Linum australe
    ##  4 1,1,4                  1 Ceanothus fendleri
    ##  5 1,1,5                  5 Agoseris glauca, Arenaria fendleri, Chaetopappa eri…
    ##  6 1,2,3                  1 Centaurea diffusa
    ##  7 1,2,4                  4 Ambrosia psilostachya, Bromus ciliatus, Elymus elym…
    ##  8 1,2,5                  1 Machaeranthera canescens
    ##  9 1,2,6                  4 Artemisia campestris, Artemisia carruthii, Laenneci…
    ## 10 1,4,2                  1 Gaillardia pinnatifida
    ## # ℹ 89 more rows

    NPT_discrete_plot(discrete_result$niche_classification)

    # Perform continuous niche scheme
    continuous_result <- NPT_continuous(data = PFF_traits, dimension = dimension)
    continuous_result

    ## $PCA_first
    ##              pc1_percent pc1_major_eigenvector pc2_percent
    ## Grow            51.37787                   SRL    31.00776
    ## Survive         80.23625                Height    15.44795
    ## Reproductive    94.74834              SeedMass     4.49701
    ##              pc2_major_eigenvector
    ## Grow                    Leaf_Nmass
    ## Survive                    Root_CN
    ## Reproductive                FltDur
    ##
    ## $PCA_second
    ##                         PC1        PC2
    ## pc1.Grow          0.1089647 -0.5590265
    ## pc2.Grow          0.6488371  0.1751767
    ## pc1.Survive      -0.1162702  0.5380610
    ## pc2.Survive      -0.6329334 -0.2313366
    ## pc1.Reproductive -0.3185430  0.5385830
    ## pc2.Reproductive  0.2270331  0.1539628
    ##
    ## $result
    ## Call: rda(X = P)
    ##
    ## -- Model Summary --
    ##
    ##               Inertia Rank
    ## Total         0.04545
    ## Unconstrained 0.04545    6
    ##
    ## Inertia is variance
    ##
    ## -- Eigenvalues --
    ##
    ## Eigenvalues for unconstrained axes:
    ##      PC1      PC2      PC3      PC4      PC5      PC6
    ## 0.015689 0.012709 0.008295 0.004579 0.003609 0.000573

    NPT_continuous_plot(continuous_result$result)

### Plant Trait Network

Plant Trait Networks (PTNs) provide a framework for understanding complex interdependencies among plant traits by treating traits as nodes and their associations as edges within a network. The PTN module, implemented as described by He et al. (2020), offers functions to calculate correlations (PTN_corr()), generate networks (PTN()), quantify network metrics (PTN_metrics()), and visualize networks (PTN_plot()). The package supports phylogenetic correction to account for species’ shared evolutionary history. Significant correlations are selected based on defined thresholds, and network metrics, including both node-level and network-level parameters, are used to analyze trait interdependence.

    # Load packages
    library(MultiTraits)
    # Load and prepare data
    data(PFF)
    rownames(PFF) <- PFF$species
    PFF_traits <- PFF[, c("Leaf_area","LDMC","SLA", "Leaf_Cmass","Leaf_Nmass",
                          "Leaf_CN","Leaf_Pmass", "Leaf_NP","Leaf_CP")]
    # Perform log transformation of data and remove missing values
    PFF_traits <- log(na.omit(PFF_traits))
    head(PFF_traits)

    ##                           Leaf_area     LDMC      SLA Leaf_Cmass Leaf_Nmass
    ## Achillea millefolium       5.480639 3.295837 2.079442   3.717467  0.6523252
    ## Agoseris glauca            6.253829 2.833213 2.995732   3.752324  0.5423243
    ## Agropyron desertorum       5.669881 3.737670 2.197225   3.725211  0.8415672
    ## Ambrosia psilostachya      6.194405 2.995732 2.772589   3.648578  0.8415672
    ## Androsace septentrionalis  3.931826 2.639057 3.433987   3.709417  0.6678294
    ## Antennaria parvifolia      4.189655 3.295837 2.564949   3.785779  0.4252677
    ##                            Leaf_CN Leaf_Pmass  Leaf_NP  Leaf_CP
    ## Achillea millefolium      3.091042 -1.0216512 1.791759 4.736198
    ## Agoseris glauca           3.218876 -0.9416085 1.386294 4.691348
    ## Agropyron desertorum      2.890372 -2.8134107 3.951244 6.928538
    ## Ambrosia psilostachya     2.833213 -1.3862944 2.639057 5.411646
    ## Androsace septentrionalis 3.091042 -1.2378744 1.945910 4.875197
    ## Antennaria parvifolia     3.401197 -1.7147984 2.197225 5.529429

    data(PFF_tree)
    PFF_tree

    ##
    ## Phylogenetic tree with 133 tips and 121 internal nodes.
    ##
    ## Tip labels:
    ##   Hymenopappus mexicanus, Heliomeris multiflora, Bahia dissecta, Gaillardia pinnatifida, Hymenoxys richardsonii, Hymenoxys hoopsii, ...
    ## Node labels:
    ##   Spermatophyta, mrcaott2ott121, eudicotyledons, Pentapetalae, mrcaott248ott557, mrcaott248ott650, ...
    ##
    ## Rooted; includes branch length(s).

    # Calculate trait correlations using specified thresholds
    PTN_corr(traits_matrix=PFF_traits, rThres = 0.2, pThres = 0.05,method = "pearson",
             phylo_correction = TRUE,phylo_tree = PFF_tree)

    ## Warning: Phylogenetic tree is not binary. Converting to binary tree using multi2di()...
    ## Tree converted to binary successfully.

    ## $corr
    ##             Leaf_area  Leaf_Pmass         SLA  Leaf_Nmass    Leaf_CN
    ## Leaf_area   1.0000000  0.43912732  0.07106310  0.29303640 -0.2770506
    ## Leaf_Pmass  0.4391273  1.00000000  0.12060634  0.18114586 -0.1622283
    ## SLA         0.0710631  0.12060634  1.00000000  0.26196776 -0.3165084
    ## Leaf_Nmass  0.2930364  0.18114586  0.26196776  1.00000000 -0.9761786
    ## Leaf_CN    -0.2770506 -0.16222829 -0.31650840 -0.97617860  1.0000000
    ## Leaf_NP    -0.1850404 -0.81553086 -0.02961639  0.26587312 -0.2712585
    ## Leaf_CP    -0.3384473 -0.90624588 -0.17882705 -0.18159881  0.1847273
    ## LDMC       -0.0586106 -0.21033983 -0.53223724 -0.06763656  0.1264002
    ## Leaf_Cmass  0.1708826 -0.05369696 -0.26471993  0.32997265 -0.1559343
    ##                Leaf_NP    Leaf_CP        LDMC  Leaf_Cmass
    ## Leaf_area  -0.18504037 -0.3384473 -0.05861060  0.17088257
    ## Leaf_Pmass -0.81553086 -0.9062459 -0.21033983 -0.05369696
    ## SLA        -0.02961639 -0.1788270 -0.53223724 -0.26471993
    ## Leaf_Nmass  0.26587312 -0.1815988 -0.06763656  0.32997265
    ## Leaf_CN    -0.27125855  0.1847273  0.12640024 -0.15593428
    ## Leaf_NP     1.00000000  0.8903621  0.19732960  0.24660715
    ## Leaf_CP     0.89036211  1.0000000  0.28270267  0.17686543
    ## LDMC        0.19732960  0.2827027  1.00000000  0.37675591
    ## Leaf_Cmass  0.24660715  0.1768654  0.37675591  1.00000000
    ##
    ## $corrPos
    ##         xName      yName x y        corr p.value
    ## 1   Leaf_area Leaf_Pmass 1 8  0.43912732       0
    ## 2   Leaf_area        SLA 1 7  0.07106310       1
    ## 3   Leaf_area Leaf_Nmass 1 6  0.29303640       0
    ## 4   Leaf_area    Leaf_CN 1 5 -0.27705059       0
    ## 5   Leaf_area    Leaf_NP 1 4 -0.18504037       1
    ## 6   Leaf_area    Leaf_CP 1 3 -0.33844728       0
    ## 7   Leaf_area       LDMC 1 2 -0.05861060       1
    ## 8   Leaf_area Leaf_Cmass 1 1  0.17088257       1
    ## 9  Leaf_Pmass        SLA 2 7  0.12060634       1
    ## 10 Leaf_Pmass Leaf_Nmass 2 6  0.18114586       1
    ## 11 Leaf_Pmass    Leaf_CN 2 5 -0.16222829       1
    ## 12 Leaf_Pmass    Leaf_NP 2 4 -0.81553086       0
    ## 13 Leaf_Pmass    Leaf_CP 2 3 -0.90624588       0
    ## 14 Leaf_Pmass       LDMC 2 2 -0.21033983       0
    ## 15 Leaf_Pmass Leaf_Cmass 2 1 -0.05369696       1
    ## 16        SLA Leaf_Nmass 3 6  0.26196776       0
    ## 17        SLA    Leaf_CN 3 5 -0.31650840       0
    ## 18        SLA    Leaf_NP 3 4 -0.02961639       1
    ## 19        SLA    Leaf_CP 3 3 -0.17882705       1
    ## 20        SLA       LDMC 3 2 -0.53223724       0
    ## 21        SLA Leaf_Cmass 3 1 -0.26471993       0
    ## 22 Leaf_Nmass    Leaf_CN 4 5 -0.97617860       0
    ## 23 Leaf_Nmass    Leaf_NP 4 4  0.26587312       0
    ## 24 Leaf_Nmass    Leaf_CP 4 3 -0.18159881       1
    ## 25 Leaf_Nmass       LDMC 4 2 -0.06763656       1
    ## 26 Leaf_Nmass Leaf_Cmass 4 1  0.32997265       0
    ## 27    Leaf_CN    Leaf_NP 5 4 -0.27125855       0
    ## 28    Leaf_CN    Leaf_CP 5 3  0.18472730       1
    ## 29    Leaf_CN       LDMC 5 2  0.12640024       1
    ## 30    Leaf_CN Leaf_Cmass 5 1 -0.15593428       1
    ## 31    Leaf_NP    Leaf_CP 6 3  0.89036211       0
    ## 32    Leaf_NP       LDMC 6 2  0.19732960       1
    ## 33    Leaf_NP Leaf_Cmass 6 1  0.24660715       0
    ## 34    Leaf_CP       LDMC 7 2  0.28270267       0
    ## 35    Leaf_CP Leaf_Cmass 7 1  0.17686543       1
    ## 36       LDMC Leaf_Cmass 8 1  0.37675591       0
    ##
    ## $arg
    ## $arg$type
    ## [1] "lower"

    # Perform Trait Network (TN) analysis
    PTN_phylo_result <- PTN(traits_matrix = PFF_traits,
                          rThres = 0.2,
                          pThres = 0.05,
                          method = "pearson",
                          phylo_correction = TRUE,
                          phylo_tree = PFF_tree)

    ## Warning: Phylogenetic tree is not binary. Converting to binary tree using multi2di()...
    ## Tree converted to binary successfully.

    # Calculate network metrics for the trait network
    PTN_metrics(PTN_phylo_result)

    ## $node
    ##            degree  closeness betweenness clustering_coefficient
    ## Leaf_area       4 0.08333333    2.000000              0.3333333
    ## LDMC            4 0.08333333    3.000000              0.3333333
    ## SLA             4 0.08333333    1.833333              0.5000000
    ## Leaf_Cmass      4 0.08333333    1.166667              0.5000000
    ## Leaf_Nmass      5 0.09090909    2.416667              0.5000000
    ## Leaf_CN         4 0.08333333    1.083333              0.5000000
    ## Leaf_Pmass      4 0.08333333    1.083333              0.5000000
    ## Leaf_NP         5 0.09090909    3.333333              0.3000000
    ## Leaf_CP         4 0.08333333    1.083333              0.5000000
    ##
    ## $global
    ##   edge_density diameter avg_path_length avg_clustering_coefficient modularity
    ## 1    0.5277778        2        1.472222                  0.4354839  0.1717452

    set.seed(22)
    # Create visualization plots of the trait network
    PTN_plot(PTN_phylo_result, style = 1, vertex.size = 20, vertex.label.cex = 0.6)

### Plant Trait Multilayer Network

Plant Trait Multilayer Networks (PTMNs) provide an innovative framework for understanding multidimensional plant trait coordination, addressing the limitations of traditional, single-layer plant trait networks (PTNs). As outlined by He et al. (2026), this approach systematically organizes traits into distinct layers based on organs or functional systems (e.g., leaves, stems, roots). A key strength of PTMNs is the ability to differentiate between intralayer edges, which represent relationships within a single system, and interlayer edges, which capture the crucial coordination between different systems. The MultiTraits PTMN module implements this framework with functions to construct networks (PTMN()), calculate specialized multilayer metrics such as interlayer degree and module association (PTMN_metrics()), and create visualizations that clearly distinguish layer structure (PTMN_plot()). This methodology is powerful for identifying key traits that integrate whole-plant functioning and for revealing complex strategies of plant adaptation.

    # Load packages
    library(MultiTraits)

    # Load and prepare data
    data(forest_invader_traits)
    traits <- forest_invader_traits[, 6:73]

    # Define the layers, grouping traits by organ or functional system
    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")
    )

    # Construct the Plant Trait Multilayer Network (PTMN)
    ptmn_edges <- PTMN(traits, layers_list = layers, method = "pearson")

    # Calculate network metrics for the PTMN
    PTMN_metrics(ptmn_edges)

    ## $node
    ##              node           layer interlayer_degree interlayer_closeness
    ## 5         CC_area leaf_metabolism                23            0.5957447
    ## 14       Chl_mass  leaf_chemistry                23            0.6410256
    ## 26         LAgain  shoot_dynamics                23            0.5979381
    ## 27           LDMC  leaf_structure                22            0.5959596
    ## 40 Metaxylem_diam            stem                22            0.6000000
    ## 46         N_mass  leaf_chemistry                22            0.6329114
    ## 25          J_max leaf_metabolism                21            0.6021505
    ## 44         N_area  leaf_chemistry                21            0.6097561
    ## 65     Thick_leaf  leaf_structure                21            0.5959596
    ## 3       Asat_mass leaf_metabolism                20            0.6021505
    ## 6         CC_mass leaf_metabolism                20            0.6021505
    ## 66         Vc_max leaf_metabolism                20            0.6021505
    ## 2       Asat_area leaf_metabolism                19            0.5957447
    ## 7          C_area  leaf_chemistry                19            0.5952381
    ## 33   LeafRate_max  shoot_dynamics                19            0.5858586
    ## 55        Rd_mass leaf_metabolism                19            0.5773196
    ## 13       Chl_area  leaf_chemistry                17            0.5813953
    ## 21 Earlywood_diam            stem                17            0.5555556
    ## 22 EmergeDuration  shoot_dynamics                17            0.5576923
    ## 30   LeafDuration  shoot_dynamics                17            0.5686275
    ## 48         N_root            root                17            0.5588235
    ## 43       NSC_stem            stem                16            0.5607477
    ## 56            SLA  leaf_structure                16            0.5514019
    ## 58        SS_root            root                16            0.5533981
    ## 23   FallDuration  shoot_dynamics                15            0.5686275
    ## 31     LeafFall50  shoot_dynamics                15            0.5471698
    ## 59        SS_stem            stem                15            0.5454545
    ## 35  Lifespan_leaf  leaf_structure                14            0.5221239
    ## 57            SRL            root                14            0.5327103
    ## 67    Vessel_freq            stem                14            0.5263158
    ## 1             AQY leaf_metabolism                13            0.5233645
    ## 50           PNUE leaf_metabolism                13            0.5185185
    ## 24           Hemi  leaf_chemistry                12            0.5376344
    ## 15    Chl_shade50  shoot_dynamics                11            0.5087719
    ## 49        PA_leaf  leaf_structure                11            0.5086207
    ## 51      Phenolics  leaf_chemistry                11            0.5319149
    ## 53            RTD            root                11            0.5229358
    ## 32        LeafOut  shoot_dynamics                10            0.5043478
    ## 38           Lobe  leaf_structure                 9            0.5086207
    ## 45       N_litter  leaf_chemistry                 9            0.5319149
    ## 29  Latewood_diam            stem                 8            0.4838710
    ## 34   LeafTurnover  shoot_dynamics                 8            0.4957265
    ## 12         Chl_ab  leaf_chemistry                 7            0.5050505
    ## 47          N_res  leaf_chemistry                 7            0.4854369
    ## 4             Ash  leaf_chemistry                 6            0.4629630
    ## 10         C_root            root                 6            0.4596774
    ## 61    Starch_root            root                 6            0.4789916
    ## 68            WUE leaf_metabolism                 6            0.4869565
    ## 8        C_litter  leaf_chemistry                 5            0.4807692
    ## 16      Chl_sun50  shoot_dynamics                 5            0.4566929
    ## 19    Decomp_leaf  leaf_chemistry                 5            0.4716981
    ## 39      Mass_leaf  leaf_structure                 5            0.4796748
    ## 42       NSC_root            root                 5            0.4789916
    ## 62    Starch_stem            stem                 5            0.4615385
    ## 17      Cond_stem            stem                 4            0.4255319
    ## 36         Lignin  leaf_chemistry                 4            0.4347826
    ## 9          C_mass  leaf_chemistry                 3            0.4716981
    ## 18            DNA  leaf_chemistry                 3            0.4065041
    ## 52           RDMC            root                 3            0.4384615
    ## 60       Solubles  leaf_chemistry                 3            0.4273504
    ## 63  Stomate_index  leaf_structure                 3            0.4041096
    ## 64   Stomate_size  leaf_structure                 3            0.4125874
    ## 54        Rd_area leaf_metabolism                 2            0.4409449
    ## 11      Cellulose  leaf_chemistry                 1            0.3875969
    ## 28            LSP leaf_metabolism                 1            0.3612903
    ## 37    Lignin_root            root                 1            0.4014085
    ## 41       NPP_root            root                 1            0.3800000
    ## 20    Decomp_root            root                 0            0.3630573
    ##    interlayer_clustering_coefficient
    ## 5                          0.3794466
    ## 14                         0.5256917
    ## 26                         0.4071146
    ## 27                         0.4242424
    ## 40                         0.5194805
    ## 46                         0.4848485
    ## 25                         0.4714286
    ## 44                         0.3619048
    ## 65                         0.3761905
    ## 3                          0.4736842
    ## 6                          0.3473684
    ## 66                         0.4473684
    ## 2                          0.4795322
    ## 7                          0.5146199
    ## 33                         0.4619883
    ## 55                         0.4619883
    ## 13                         0.5147059
    ## 21                         0.4411765
    ## 22                         0.4411765
    ## 30                         0.5441176
    ## 48                         0.4558824
    ## 43                         0.5083333
    ## 56                         0.5500000
    ## 58                         0.6083333
    ## 23                         0.5904762
    ## 31                         0.6000000
    ## 59                         0.5238095
    ## 35                         0.5054945
    ## 57                         0.4065934
    ## 67                         0.6263736
    ## 1                          0.6153846
    ## 50                         0.4615385
    ## 24                         0.6818182
    ## 15                         0.5454545
    ## 49                         0.4363636
    ## 51                         0.5818182
    ## 53                         0.6545455
    ## 32                         0.3333333
    ## 38                         0.8333333
    ## 45                         0.7777778
    ## 29                         0.3571429
    ## 34                         0.6785714
    ## 12                         0.1904762
    ## 47                         0.6666667
    ## 4                          0.4000000
    ## 10                         0.4000000
    ## 61                         0.3333333
    ## 68                         0.6000000
    ## 8                          0.3000000
    ## 16                         0.9000000
    ## 19                         0.6000000
    ## 39                         0.2000000
    ## 42                         0.5000000
    ## 62                         0.5000000
    ## 17                         1.0000000
    ## 36                         0.5000000
    ## 9                          0.3333333
    ## 18                         0.3333333
    ## 52                         0.3333333
    ## 60                         0.3333333
    ## 63                         1.0000000
    ## 64                         0.3333333
    ## 54                         1.0000000
    ## 11                         0.0000000
    ## 28                         0.0000000
    ## 37                         0.0000000
    ## 41                         0.0000000
    ## 20                         0.0000000
    ##
    ## $global
    ##   Interlayer_edge_density Average_interlayer_path_length
    ## 1               0.2058047                        1.98153
    ##   Average_interlayer_clustering_coefficient Module_interlayer_association
    ## 1                                 0.4730529                     0.8167989

    set.seed(42)
    # Create a visualization of the PTMN
    PTMN_plot(ptmn_edges, style = 1, vertex.size = 8,
              vertex.label.cex = 0.5, edge.width = 2,
              show.legend = FALSE)