Contents

library(RedoxRRI)

1 Overview

RedoxRRI provides a transparent and extensible framework to quantify holobiont redox resilience by integrating three complementary domains: Plant physiology (oxidative / nitrosative buffering and stress traits) Soil redox stability (Eh and redox-coupled chemistry)

Microbial resilience, represented as a single blended domain that can incorporate: microbial abundance or functional composition (micro_data) microbial network organization (igraph network metrics) The primary output of the package is: a per-sample Redox Resilience Index (RRI) scaled to [0,1]) a ternary-ready compositional representation (Physio, Soil, Micro) with row sums equal to 1

an optional system-level index stored as attr(x, “RRI_index”)

2 Conceptual model

2.1 Domain-level aggregation implemented in rri_pipeline_st()

Each domain (Physiology, Soil, and Microbial) is first summarized into a one-dimensional latent score per sample using a user-selected method (e.g., PCA, FA, UMAP, or WGCNA). These latent scores are then scaled to the range [0, 1].

The Redox Resilience Index (RRI) is computed as a weighted linear combination of the scaled domain scores. The domain weights are user-defined and must sum to one. Higher RRI values indicate samples with stronger physiological buffering, greater soil redox stability, and higher microbial resilience relative to other samples in the same dataset.

Optional coupling terms can be included to capture coherence among domains, allowing the index to reflect not only domain magnitudes but also their agreement or joint stability.

3 Microbial domain as a blended score

To preserve a three-part (Physiology–Soil–Microbial) ternary representation, microbial resilience is modeled as a single blended domain score.

When both microbial abundance (or functional composition) data and microbial network data are available, the microbial domain score is computed as a weighted blend of the two components. The parameter alpha_micro controls their relative contribution:

This design allows flexible emphasis on microbial composition, microbial organization, or both, while maintaining a consistent three-domain representation suitable for compositional and ternary visualization.

4 Simulated example data

All data used in this vignette are fully simulated and are provided solely for demonstration and testing purposes.

generated using simulate_redox_holobiont() and mimics

qualitative properties of redox-ecological systems, including: correlated plant physiological traits soil redox gradients and stability microbial functional heterogeneity spatial grouping and temporal structure The simulation does not represent any real experiment, species, site, or ecosystem.

sim <- simulate_redox_holobiont()
# sim <- simulate_redox_holobiont(seed = 1)

str(sim, max.level = 1)
## List of 6
##  $ id          :'data.frame':    600 obs. of  4 variables:
##   ..- attr(*, "out.attrs")=List of 2
##  $ ROS_flux    :'data.frame':    600 obs. of  4 variables:
##  $ Eh_stability:'data.frame':    600 obs. of  4 variables:
##  $ micro_data  :'data.frame':    600 obs. of  60 variables:
##  $ latent_truth: num [1:600] 0.557 0.716 0.765 0.695 0.457 ...
##  $ graph       : NULL

The simulated object contains:

ROS_flux: plant physiological traits (samples × variables) Eh_stability: soil redox variables micro_data: microbial functional features id: sample metadata (spatial and temporal structure) graph (optional): an igraph network or list of networks

5 Computing the Redox Resilience Index

res <- rri_pipeline_st(
  ROS_flux = sim$ROS_flux,
  Eh_stability = sim$Eh_stability,
  micro_data = sim$micro_data,
  id = sim$id,
  direction_phys = "auto",
  direction_anchor_phys = "FvFm",
  direction_soil = "auto",
  direction_anchor_soil = "Eh"
)

6 Interpreting the compositional output

The compositional output is stored in res$row_scores_comp.

head(res$row_scores_comp)
##      Physio      Soil     Micro       RRI
## 1 0.2970730 0.3507027 0.3522243 0.6771311
## 2 0.3264677 0.3017265 0.3718058 0.8131403
## 3 0.3272112 0.3483252 0.3244635 0.8469042
## 4 0.2954390 0.3843173 0.3202437 0.7721450
## 5 0.2943085 0.3142173 0.3914743 0.5962782
## 6 0.3094179 0.3526520 0.3379301 0.7146770

The domain components satisfy:

rowSums(res$row_scores_comp[, c("Physio", "Soil", "Micro")])[1:6]
## [1] 1 1 1 1 1 1

7 Microbial subcomponents

When microbial abundance and/or network data are available, the output also includes the corresponding latent scores:

if ("Micro_abundance" %in% names(res$row_scores)) {
  summary(res$row_scores$Micro_abundance)
}
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.0000  0.6203  0.7355  0.7090  0.8163  1.0000

8 Ternary visualization

This plot requires suggested packages: ggtern, ggplot2, and viridis.

if (requireNamespace("ggtern", quietly = TRUE) &&
  requireNamespace("ggplot2", quietly = TRUE) &&
  requireNamespace("viridis", quietly = TRUE)) {
  
  plot_RRI_ternary(res$row_scores_comp)
  
} else {
  message("Install ggtern, ggplot2, and viridis to enable ternary plotting.")
}
## Warning in ggplot2::geom_point(data = centroid, ggplot2::aes(x = Physio, :
## Ignoring unknown aesthetics: z

Choosing latent-dimension methods

Different domains may justify different latent representations: physiology: pca, fa soil: pca, wgcna (when co-regulated redox syndromes are expected) microbial abundance: pca, nmf, wgcna nonlinear regimes: umap

Below we illustrate alternative specifications when suggested packages are available.

specA <- res

if (requireNamespace("WGCNA", quietly = TRUE)) {
  specA <- rri_pipeline_st(
    ROS_flux     = sim$ROS_flux,
    Eh_stability = sim$Eh_stability,
    micro_data   = sim$micro_data,
    graph        = sim$graph,
    alpha_micro  = 0.6,
    method_phys  = "pca",
    method_soil  = "wgcna",
    method_micro = "pca"
  )
  specA$meta$rri_index
} else {
  message("WGCNA not installed; skipping example.")
}
##    Power SFT.R.sq   slope truncated.R.sq  mean.k. median.k.   max.k.
## 1      1 0.120000 -33.000          0.282 1.30e+00  1.25e+00 1.58e+00
## 2      2 0.142000 -19.400          0.276 5.94e-01  5.50e-01 8.29e-01
## 3      3 0.158000 -14.800          0.265 2.82e-01  2.52e-01 4.38e-01
## 4      4 0.168000 -12.500          0.252 1.39e-01  1.21e-01 2.32e-01
## 5      5 0.174000 -11.000          0.237 6.98e-02  5.95e-02 1.23e-01
## 6      6 0.153000  -9.280          0.210 3.57e-02  3.02e-02 6.53e-02
## 7      7 0.153000  -8.540          0.199 1.86e-02  1.56e-02 3.48e-02
## 8      8 0.151000  -7.920          0.192 9.75e-03  8.19e-03 1.86e-02
## 9      9 0.148000  -7.390          0.189 5.16e-03  4.36e-03 9.99e-03
## 10    10 0.130000  -6.590          0.193 2.75e-03  2.34e-03 5.37e-03
## 11    12 0.125000  -5.840          0.212 7.91e-04  6.84e-04 1.56e-03
## 12    14 0.113000  -5.100          0.260 2.31e-04  2.04e-04 4.59e-04
## 13    16 0.112000  -4.650          0.300 6.82e-05  6.14e-05 1.36e-04
## 14    18 0.000974  -0.456          0.443 2.04e-05  1.87e-05 4.06e-05
## 15    20 0.001470  -0.524          0.514 6.12e-06  5.70e-06 1.22e-05
## [1] 0.6006695
specB <- res

if (requireNamespace("uwot", quietly = TRUE)) {
  specB <- rri_pipeline_st(
    ROS_flux     = sim$ROS_flux,
    Eh_stability = sim$Eh_stability,
    micro_data   = sim$micro_data,
    method_phys  = "umap",
    method_soil  = "umap",
    method_micro = "pca"
  )
  specB$meta$rri_index
} else {
  message("uwot not installed; skipping example.")
}
## [1] 0.5119079

9 Practical guidance

A recommended workflow is: Assemble domain matrices with samples in rows and consistent ordering. Choose latent methods appropriate to each domain. Decide microbial blending parameter alpha_micro. Sensitivity-test domain weights and methods. Validate RRI against independent outcomes (e.g. recovery, stress tolerance).

sessionInfo()
## R version 4.5.1 (2025-06-13)
## Platform: aarch64-apple-darwin20
## Running under: macOS Tahoe 26.1
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib 
## LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## time zone: Europe/Berlin
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] RedoxRRI_0.99.0  BiocStyle_2.38.0
## 
## loaded via a namespace (and not attached):
##  [1] tidyselect_1.2.1      WGCNA_1.74            viridisLite_0.4.2    
##  [4] dplyr_1.1.4           farver_2.1.2          viridis_0.6.5        
##  [7] S7_0.2.1              fastmap_1.2.0         latex2exp_0.9.8      
## [10] tensorA_0.36.2.1      digest_0.6.39         rpart_4.1.24         
## [13] lifecycle_1.0.5       cluster_2.1.8.1       survival_3.8-6       
## [16] magrittr_2.0.4        compiler_4.5.1        rlang_1.1.7          
## [19] Hmisc_5.2-5           sass_0.4.10           tools_4.5.1          
## [22] yaml_2.3.12           data.table_1.18.2.1   FNN_1.1.4.1          
## [25] knitr_1.51            labeling_0.4.3        htmlwidgets_1.6.4    
## [28] plyr_1.8.9            RColorBrewer_1.1-3    withr_3.0.2          
## [31] foreign_0.8-91        nnet_7.3-20           dynamicTreeCut_1.63-1
## [34] grid_4.5.1            preprocessCore_1.72.0 colorspace_2.1-2     
## [37] fastcluster_1.3.0     ggplot2_4.0.1         scales_1.4.0         
## [40] iterators_1.0.14      MASS_7.3-65           tinytex_0.58         
## [43] cli_3.6.5             rmarkdown_2.30        generics_0.1.4       
## [46] otel_0.2.0            RSpectra_0.16-2       rstudioapi_0.18.0    
## [49] robustbase_0.99-6     bayesm_3.1-7          cachem_1.1.0         
## [52] stringr_1.6.0         splines_4.5.1         parallel_4.5.1       
## [55] impute_1.84.0         BiocManager_1.30.27   matrixStats_1.5.0    
## [58] base64enc_0.1-6       vctrs_0.7.1           Matrix_1.7-4         
## [61] jsonlite_2.0.0        bookdown_0.46         Formula_1.2-5        
## [64] htmlTable_2.4.3       ggtern_4.0.0          magick_2.9.0         
## [67] foreach_1.5.2         jquerylib_0.1.4       hexbin_1.28.5        
## [70] proto_1.0.0           glue_1.8.0            DEoptimR_1.1-4       
## [73] codetools_0.2-20      uwot_0.2.4            stringi_1.8.7        
## [76] gtable_0.3.6          tibble_3.3.1          pillar_1.11.1        
## [79] compositions_2.0-9    htmltools_0.5.9       R6_2.6.1             
## [82] doParallel_1.0.17     evaluate_1.0.5        lattice_0.22-7       
## [85] backports_1.5.0       bslib_0.10.0          Rcpp_1.1.1           
## [88] gridExtra_2.3         checkmate_2.3.3       xfun_0.56            
## [91] pkgconfig_2.0.3