Demonstrates the complete workflow for computing the Holobiont Redox Resilience Index (RRI) using simulated plant, soil, and microbiome data.
Details
This example generates a fully synthetic dataset using
simulate_redox_holobiont and then computes the
Redox Resilience Index using rri_pipeline_st.
The simulation framework represents a simplified soil–plant–microbiome system and includes:
Disturbance forcing over time
Partial plant–soil–microbiome decoupling
pH–Eh interaction within the soil redox domain
Zero-inflated high-dimensional microbial abundance data
Optional stochastic microbial reassembly
A microbial association network generated using igraph
The simulated data do not represent any real biological system and are provided solely for demonstration purposes.
Examples
# Generate a synthetic dataset
sim <- simulate_redox_holobiont(seed = 1)
# Inspect structure
str(sim)
#> List of 6
#> $ id :'data.frame': 600 obs. of 4 variables:
#> ..$ plot : chr [1:600] "P1" "P2" "P3" "P4" ...
#> ..$ depth : chr [1:600] "D1" "D1" "D1" "D1" ...
#> ..$ plant_id: chr [1:600] "Plant1" "Plant1" "Plant1" "Plant1" ...
#> ..$ time : int [1:600] 1 1 1 1 1 1 1 1 1 1 ...
#> $ ROS_flux :'data.frame': 600 obs. of 4 variables:
#> ..$ SPAD : num [1:600] 39.5 40.8 39.7 38.6 38.8 ...
#> ..$ FvFm : num [1:600] 0.818 0.805 0.726 0.795 0.704 ...
#> ..$ PhiPSII: num [1:600] 0.469 0.424 0.385 0.49 0.356 ...
#> ..$ NPQ : num [1:600] 0.832 1.034 1.167 1.282 1.449 ...
#> $ Eh_stability:'data.frame': 600 obs. of 5 variables:
#> ..$ Eh : num [1:600] 458 417 407 555 397 ...
#> ..$ pH : num [1:600] 6.41 6.44 6.23 6.35 6.25 ...
#> ..$ Fe2.Fe3: num [1:600] 0.0468 0.1689 0.0281 0.0646 0.0887 ...
#> ..$ Mn2.Mn4: num [1:600] 0.1421 0.1169 0.2645 0.0924 0.2505 ...
#> ..$ NH4.NO3: num [1:600] 0.0704 0.2159 0.2965 0.1005 0.4216 ...
#> $ micro_data :'data.frame': 600 obs. of 60 variables:
#> ..$ ASV1 : int [1:600] 0 0 0 12 36 26 23 11 13 19 ...
#> ..$ ASV2 : int [1:600] 11 11 20 0 36 25 0 20 23 0 ...
#> ..$ ASV3 : int [1:600] 19 11 0 0 0 27 0 21 19 0 ...
#> ..$ ASV4 : int [1:600] 18 15 0 10 0 29 0 24 14 8 ...
#> ..$ ASV5 : int [1:600] 21 0 0 14 33 0 19 13 18 23 ...
#> ..$ ASV6 : int [1:600] 14 0 25 0 27 27 24 0 0 25 ...
#> ..$ ASV7 : int [1:600] 0 26 15 5 32 31 25 0 0 0 ...
#> ..$ ASV8 : int [1:600] 0 0 16 14 26 28 0 14 12 0 ...
#> ..$ ASV9 : int [1:600] 0 20 0 19 18 23 29 0 23 0 ...
#> ..$ ASV10: int [1:600] 7 0 18 0 17 0 17 22 15 20 ...
#> ..$ ASV11: int [1:600] 0 10 19 14 20 31 0 0 0 0 ...
#> ..$ ASV12: int [1:600] 6 15 18 0 15 27 25 26 0 19 ...
#> ..$ ASV13: int [1:600] 26 21 20 15 20 0 20 18 25 0 ...
#> ..$ ASV14: int [1:600] 17 0 14 13 0 0 24 14 0 15 ...
#> ..$ ASV15: int [1:600] 23 14 14 0 0 30 0 0 0 18 ...
#> ..$ ASV16: int [1:600] 0 17 16 0 35 24 26 0 20 26 ...
#> ..$ ASV17: int [1:600] 0 15 0 0 34 35 0 20 0 13 ...
#> ..$ ASV18: int [1:600] 21 0 14 0 0 27 30 13 17 18 ...
#> ..$ ASV19: int [1:600] 16 0 0 11 0 32 0 0 21 23 ...
#> ..$ ASV20: int [1:600] 0 0 0 0 0 0 32 19 16 19 ...
#> ..$ ASV21: int [1:600] 16 19 18 0 0 21 0 20 18 0 ...
#> ..$ ASV22: int [1:600] 8 0 14 9 28 26 0 0 0 20 ...
#> ..$ ASV23: int [1:600] 16 12 0 12 0 35 26 0 0 20 ...
#> ..$ ASV24: int [1:600] 10 0 0 10 0 0 26 12 29 15 ...
#> ..$ ASV25: int [1:600] 0 17 21 6 0 0 0 33 22 22 ...
#> ..$ ASV26: int [1:600] 0 17 14 11 23 23 20 27 0 0 ...
#> ..$ ASV27: int [1:600] 13 16 20 10 32 0 0 0 0 0 ...
#> ..$ ASV28: int [1:600] 17 15 19 0 0 20 0 20 17 0 ...
#> ..$ ASV29: int [1:600] 17 14 14 8 20 0 22 24 13 30 ...
#> ..$ ASV30: int [1:600] 0 18 11 0 34 18 21 14 0 0 ...
#> ..$ ASV31: int [1:600] 12 16 0 12 26 23 0 14 22 18 ...
#> ..$ ASV32: int [1:600] 0 0 0 8 23 32 14 0 21 0 ...
#> ..$ ASV33: int [1:600] 0 0 18 0 21 28 22 0 0 0 ...
#> ..$ ASV34: int [1:600] 16 0 15 11 0 0 0 0 0 16 ...
#> ..$ ASV35: int [1:600] 11 7 17 0 25 28 32 22 23 11 ...
#> ..$ ASV36: int [1:600] 0 0 14 0 0 20 31 0 16 21 ...
#> ..$ ASV37: int [1:600] 8 16 0 14 32 25 0 17 13 12 ...
#> ..$ ASV38: int [1:600] 19 20 0 13 0 0 0 15 16 13 ...
#> ..$ ASV39: int [1:600] 15 14 9 8 31 0 23 21 18 0 ...
#> ..$ ASV40: int [1:600] 12 15 0 11 0 26 0 18 19 17 ...
#> ..$ ASV41: int [1:600] 14 16 17 0 39 19 30 17 0 0 ...
#> ..$ ASV42: int [1:600] 14 19 13 0 29 0 26 27 23 20 ...
#> ..$ ASV43: int [1:600] 12 12 15 0 34 20 0 26 15 0 ...
#> ..$ ASV44: int [1:600] 13 0 15 0 20 0 18 0 16 25 ...
#> ..$ ASV45: int [1:600] 11 18 0 0 0 28 0 26 15 0 ...
#> ..$ ASV46: int [1:600] 0 13 0 8 32 0 37 16 21 0 ...
#> ..$ ASV47: int [1:600] 0 15 17 7 20 31 0 20 18 15 ...
#> ..$ ASV48: int [1:600] 15 18 0 7 0 24 25 0 0 13 ...
#> ..$ ASV49: int [1:600] 13 15 19 7 29 21 0 21 17 19 ...
#> ..$ ASV50: int [1:600] 0 11 19 0 17 20 26 0 19 29 ...
#> ..$ ASV51: int [1:600] 7 14 0 13 0 0 28 13 19 0 ...
#> ..$ ASV52: int [1:600] 0 18 18 14 24 0 0 0 0 29 ...
#> ..$ ASV53: int [1:600] 11 0 16 13 0 26 19 0 14 29 ...
#> ..$ ASV54: int [1:600] 0 0 0 0 0 27 26 24 0 0 ...
#> ..$ ASV55: int [1:600] 0 0 0 0 0 0 20 0 19 18 ...
#> ..$ ASV56: int [1:600] 22 19 0 0 27 28 0 18 10 0 ...
#> ..$ ASV57: int [1:600] 25 15 0 12 0 0 24 26 25 0 ...
#> ..$ ASV58: int [1:600] 10 0 22 11 37 23 18 25 0 0 ...
#> ..$ ASV59: int [1:600] 0 0 18 9 24 29 0 17 15 11 ...
#> ..$ ASV60: int [1:600] 0 0 19 0 20 24 34 17 0 24 ...
#> $ latent_truth: num [1:600] 0.711 0.703 0.707 0.865 0.504 ...
#> $ graph : NULL
# Compute the Redox Resilience Index
res <- rri_pipeline_st(
ROS_flux = sim$ROS_flux,
Eh_stability = sim$Eh_stability,
micro_data = sim$micro_data,
graph = sim$graph,
id = sim$id,
group_cols = c("plot", "depth"),
scale_by = c("plot", "depth"),
direction_phys = "auto",
direction_anchor_phys = "FvFm",
direction_soil = "auto",
direction_anchor_soil = "Eh"
)
head(res$row_scores)
#> Physio Soil Micro RRI Micro_abundance Micro_network
#> 1 0.9335789 0.8979846 0.07143388 0.8861928 0.07143388 NA
#> 2 0.8003815 0.6498172 0.16740520 0.6895149 0.16740520 NA
#> 3 0.6219623 0.6595208 0.10767690 0.5491272 0.10767690 NA
#> 4 0.6899985 0.8664856 0.02498001 0.6828674 0.02498001 NA
#> 5 0.8376724 0.8719060 0.13716092 0.8335991 0.13716092 NA
#> 6 0.7126422 0.7933967 0.16354334 0.7135469 0.16354334 NA
#> Micro_mfa
#> 1 NA
#> 2 NA
#> 3 NA
#> 4 NA
#> 5 NA
#> 6 NA
head(res$row_scores_comp)
#> Physio Soil Micro RRI
#> 1 0.4905834 0.4718791 0.03753756 0.8861928
#> 2 0.4947945 0.4017159 0.10348961 0.6895149
#> 3 0.4477255 0.4747623 0.07751224 0.5491272
#> 4 0.4363036 0.5479009 0.01579550 0.6828674
#> 5 0.4535954 0.4721327 0.07427194 0.8335991
#> 6 0.4268386 0.4752067 0.09795464 0.7135469