knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 8, fig.height = 5 ) library(ggplot2) theme_set(theme_bw(base_size = 14))
MEMC
is a R package that allows users to explore various
representation of soil organic matter (SOM) flux dynamics within a
consistent SOM pool model structure.
MEMC
may be installed using the install_github
function from
the remotes
package.
# Install the remotes package if needed, and then # remotes::install_github("Microbial-Explicit-Model/MEMC") # Load the installed MEMC package library(MEMC)
MEMC
MENDThe package ships with several already defined model configurations; use help(configurations)
to see a list. Currently there are six configurations
included as internal MEMC package data, with each using different
representations for DOM uptake, POM decomposition, and MB decay.
All MEMC model configurations are listed in the memc_all_configs
and are listed in the summary table.
summary(memc_all_configs)
Let's try using MEND, the microbial enzyme-mediated decomposition model originally developed by Wang et al. 2014.
You can type help("MEND_config")
for more details about the pre-built configuration.
# Printing this MEMC model configuration will return a list giving the # run name, a table of the flux dynamics, parameter values, and initial # SOM pool sizes. print(MEND_config)
Perform a model run using the memc_solve
function, whose inputs are:
mod
. A MEMC
model object, either one of the model configurations
included with the package or created using the memc_configure()
; and times
. A numeric vector of the time sequence for which the model will be
solved; the first value of times is the initial time. mend_out <- memc_solve(mod = MEND_config, time = 0:600)
The model run results are saved in the mend_out
data frame.
# Preview the run results head(mend_out)
Visualize the run results:
library(ggplot2) 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")
With MEMC
, users are able not only to easily run simulations with the
provided model configurations, but also build toy model of their own
design by selecting any combination of the supported flux dynamics. See
here for an example for how to use memc_configure
to build your own
SOM model.
The MEMC
package includes default parameter and initial pool values
that are included as package data that are based on Wang et al.
2015^[Wang, G., Jagadamma, S., Mayes, M. et al. Microbial dormancy
improves development and experimental validation of ecosystem model.
ISME J 9, 226–237 (2015). https://doi.org/10.1038/ismej.2014.120]. This
example will use these values.
Before setting up the model configuration, take a look at these defaults:
print(memc_initial_state) # this is MEMC::memc_initial_state
print(memc_params) # data(memc_params) or MEMC::memc_params
Set up the model configuration:
# Running memc_configure will 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")
Use memc_solve
to run our model...
my_out <- memc_solve(mod = my_config, time = 0:500) head(my_out)
...and compare our toy model results with the MEND results:
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())
For more examples and tutorials please see our online documentation.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.