knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

library(ggplot2)
theme_set(theme_bw())

MEMC

R-CMD codecov Documentation

MEMC is a R package that allows users to explore various representation of soil organic matter (SOM) flux dynamics within a consistent SOM model structure. Popular microbial-explicit SOM models such as MEND^[Wang, Gangsheng, Sindhu Jagadamma, Melanie A. Mayes, Christopher W. Schadt, J. Megan Steinweg, Lianhong Gu, and Wilfred M. Post. 2015. “Microbial Dormancy Improves Development and Experimental Validation of Ecosystem Model.” The ISME Journal 9 (1): 226–37.], MIMICS^[.Wieder, William R., Steven D. Allison, Eric A. Davidson, Katerina Georgiou, Oleksandra Hararuk, Yujie He, Francesca Hopkins, et al. 2015. “Explicitly Representing Soil Microbial Processes in Earth System Models.” Global Biogeochemical Cycles 29 (10): 1782–1800.], and CORPSE^[Sulman, Benjamin N., Jessica A. M. Moore, Rose Abramoff, Colin Averill, Stephanie Kivlin, Katerina Georgiou, Bhavya Sridhar, et al. 2018. “Multiple Models and Experiments Underscore Large Uncertainty in Soil Carbon Dynamics.” Biogeochemistry 141 (2): 109–23.] vary significantly in their formulations of microbial mechanisms and underlying pool structure. MEMC provides a consistent pool structure with flexible flux dynamics: the conceptual and mathematical formulations of key SOC tranformations can be rapidly changed. This allows modelers to easily explore the effects of different conceptualizations of microbial mechanisms.

Installation

Follow the download and installation instructions for R and R studio.

Use remotes to install MEMC as a built R package directory from GitHub.

# use install.packages("remotes") to install this package the first time.
library(remotes)

# Now build and install the R package on your local machine.
install_github('Microbial-Explicit-Model/MEMC') 

Now load MEMC as you would any other package:

library(MEMC)

Getting Started

The MEMC package ships with several already defined model configuration (see help(configurations)). Here we demonstrate how to run a simulation using the "MEND_config" configuration. For more examples and package details, please check out our online documentation. Alternatively, users can look at the memc_all_configs table to see all model configurations included in the package and the microbial dynamics used in each configuration.

summary(memc_all_configs)

Look in detail at the pre-built MEND_config configuration (see help("MEND_config") for more details):

# Printing the summary table for a MEMC model configuration, this will indicate
# the dynamics that will be used in the model run. 
summary(MEND_config)

Parameter value

# The parameter values can be view using by indexing into the MEND_config object
print(MEND_config$params) 

Initial pool states for when simulation time is equal to 0.

# Similarly the initial pool values are accessed using 
print(MEND_config$state)

Perform a run using the MEND model:

time <- seq(0, 365, by = 25) 
mend_out <- memc_solve(mod = MEND_config, time = time)

memc_solve returns a long-format data frame with the state of the model pool at each time point. This makes it easy to plot the results:

ggplot(data = mend_out) + 
  geom_line(aes(time, value, color = name), linewidth = 0.75) + 
  facet_wrap("variable", scales = "free") + 
  labs(y = "mg C/g soil", 
       x = "time (days)",
       title = "MEND Run Results")

Building a Custom Model

MEMC allows users to easily run simulations with the provided model configurations and also build customized models of their own design by selecting any combination of the supported flux dynamics, and/or modifying the model parameters. For this example we will use the default parameter and initial pool values that are included as package data (see help("memc_params) and help("memc_initial_state) for more information).

# Use memc_configure to print a table describing the model configuration 
my_config <- memc_configure(params = memc_params, 
                           state = memc_initial_state, 
                           name = "my model", 
                           DOMuptake = "MM", 
                           POMdecomp = "LM", 
                           MBdecay = "LM")
summary(my_config)

Run our customized model...

time <- seq(0, 365, by = 25) 
my_out <- memc_solve(mod = my_config, time = time)

...and compare its output with the MEND model results from above:

ggplot(data = rbind(mend_out, my_out)) + 
  geom_line(aes(time, value, color = name), linewidth = 0.75) + 
  facet_wrap("variable", scales = "free") + 
  labs(y = "mg C/g soil", 
       title = "Comparing Model Results", 
       x = "time (days)") +
  theme(legend.title = element_blank())

Changing the POM and DOM decomposition flux dynamics affects model behavior! The flexibility of the flux dynamics makes MEMC a powerful tool for rapid SOM model exploration.

Additional features supported by MEMC include the ability to change model parameters, perform sensitivity analyses, and fit models with experimental/observational data (see online documentation for examples featuring capabilities).



Microbial-Explicit-Model/MEMC documentation built on April 12, 2025, 12:50 p.m.