summBg {biogas} | R Documentation |
Summarise and Normalise Cumulative Methane Production
Description
From cumulative gas production, use summBg
to standardise, interpolate, subtract innoculum contribution, normalise by substrate mass, and summarise the output calculating mean and standard devations for each type of sample (groups of replicates).
The function is flexible: some, all, or none of these operations can be carried out in a call.
Typically summBg
is used to calculate biochemical methane potential (BMP) from cumulative methane production.
Usage
summBg(vol, setup, id.name = "id", time.name = "time",
descrip.name = "descrip", inoc.name = NULL, inoc.m.name = NULL,
norm.name = NULL, norm.se.name = NULL, vol.name = "cvCH4",
imethod = "linear", extrap = FALSE, when = 30,
when.min = 0, rate.crit = 'net',
show.obs = FALSE, show.rates = FALSE, show.more = FALSE,
sort = TRUE, set.name = 'set', quiet = FALSE)
Arguments
vol |
a data frame with the columns bottle identification code; time of measurement (as |
setup |
a data frame containing information to summarise, substract inoculum effect or normalise the data. Should contain at least the column |
id.name |
name of the bottle identification code column in |
time.name |
name of column containing time data in |
descrip.name |
(optional) name of column containing a description of bottle substrate (or a code for this) in |
inoc.name |
(optional) the value in the |
norm.name |
(optional) the name of the column in |
norm.se.name |
(optional) the name of the column in |
inoc.m.name |
(optional) the name of the column in |
vol.name |
the name of the column(s) in |
imethod |
the interpolation method to be used.
This is passed as the |
extrap |
should extrapolation be carried out? Set to |
when |
value(s) of |
when.min |
minimum duration (value of |
rate.crit |
type of rate criterion to be applied for relative |
show.obs |
set to |
show.rates |
set to |
show.more |
set to |
sort |
controls sorting of results, which is by |
set.name |
column name in result for set of observations, corresponding to elements in |
quiet |
use to suppress messages. Default is |
Details
summBg
was primarily designed to calculate the biochemical methane potential (BMP) from cumulative methane production of a set of batch bottles through these steps: interpolation of cumulative production to a specified time (if needed), subtratction of apparent innoculum contribution, normalisation of the results by substrate mass (typically volatile solids (VS) mass, but could be the mass of anything within the bottle) and calculation of mean and standard deviation for each sample type (set of replicates, identified by descrip.name
).
If needed summBg
can return values for all observations and be used for simpler operations e.g., determining cumulative biogas production at some specified time or normalising gas volume by different substrate characteristics.
To summarise data, the setup
data frame should have a column with a description of bottle substrate (or a code for this).
The name of the column is set by the descrip.name
argument.
If the inoculum effect is to be subtracted out, a column named descrip.name
(for identifying replicates) and a column with the mass of inoculum present (any units), with a name set by inoc.m.name
are both required in setup
.
To normalise by substrate mass (or any mass to be used for normalisation), an additional column with the mass of substrate is needed in setup
–its name is set by norm.name
.
This function is probably easier to understand by example. See ‘Examples’.
Value
a data frame, with the colums:
descrip |
from the input data frame setup |
mean |
mean of the response variable |
sd |
standard deviation of the response variable |
se |
standard error of the response variable |
n |
number of bottles |
If show.more = TRUE
additional columns are returned:
summ2 <- summ2[ , c(descrip.name, time.name, 'mean', 'se', 'sd', 'n', 'rsd.inoc', 'fv.inoc', 'se1', 'se2', 'se3')]
rsd.inoc |
relative standard deviation in specific |
fv.inoc |
(mean) fraction of bottle |
se1 |
standard error contribution from variation among replicate substrate bottles |
se2 |
standard error contribution from variation among inoculum-only bottles |
se2 |
standard error contribution from uncertainty in substrate mass addition |
If show.obs = TRUE
even more columns are returned:
cvCH4.tot |
name based on |
cvCH4.inoc |
name based on |
se.inoc |
standard error from inoculum used to calculate |
cvCH4.se |
name based on |
Note
Reported standard deviation and standard error includes an estimate of variability from subtracting the inoculum contribution when this is done.
Author(s)
Sasha D. Hafner and Charlotte Rennuit
See Also
Examples
data("vol")
data("comp")
data("setup")
# First need to calculate cumulative methane production data
cum.prod <- cumBg(vol, comp = comp, temp = 20, pres = 1,
time.name = "days", extrap = TRUE)
head(cum.prod)
# Cumulative methane production (default) at 30 d
# Uses default names for some columns
summBg(vol = cum.prod, setup = setup, time.name = "days", when = 30)
# Or total cumulative biogas
summBg(vol = cum.prod, setup = setup, time.name = "days",
vol.name = "cvBg", when = 30)
# Cumulative CH4 only, subtract inoculum contribution
summBg(vol = cum.prod, setup = setup, time.name = "days",
inoc.name = "inoc", inoc.m.name = "minoc", when = 30)
# And normalise by mvs.sub column (mass of substrate VS here) (so the result is BMP)
summBg(vol = cum.prod, setup = setup, time.name = "days",
inoc.name = "inoc", inoc.m.name = "minoc", when = 30,
norm.name = "mvs.sub")
# Same example, but return results for three times
summBg(vol = cum.prod, setup = setup, time.name = "days",
inoc.name = "inoc", inoc.m.name = "minoc", when = c(10, 30, 60),
norm.name = "mvs.sub")
# Back to earlier example, but return all individual observations
# (and total production and individual contributions of substrate
# and inoculum)
summBg(vol = cum.prod, setup = setup, time.name = "days",
inoc.name = "inoc", inoc.m.name = "minoc", when = 30,
norm.name = "mvs.sub", show.obs = TRUE)
# Something different: interpolated biogas production rates
summBg(vol = cum.prod, setup = setup, time.name = "days",
vol.name = "rvBg", when = 30, show.obs = TRUE)
# The when argument could also be 'meas', 'end', or '1p3d' (or related) for any of these examples
summBg(vol = cum.prod, setup = setup, time.name = "days",
inoc.name = "inoc", inoc.m.name = "minoc", when = "end",
norm.name = "mvs.sub")
summBg(vol = cum.prod, setup = setup, time.name = "days",
inoc.name = "inoc", inoc.m.name = "minoc", when = "meas",
norm.name = "mvs.sub")
summBg(vol = cum.prod, setup = setup, time.name = "days",
inoc.name = "inoc", inoc.m.name = "minoc", when = "1p3d",
norm.name = "mvs.sub")
# Or combine multiple values of when in a list
summBg(vol = cum.prod, setup = setup, time.name = "days",
inoc.name = "inoc", inoc.m.name = "minoc",
when = list(30, "1p3d", "end"),
norm.name = "mvs.sub")
# If you want to apply the 1% criterion but also want a single fixed time for all bottles,
# you have to use two calls
summBg(vol = cum.prod, setup = setup, time.name = "days",
inoc.name = "inoc", inoc.m.name = "minoc", when = "1p3d",
norm.name = "mvs.sub")
# From the first call, the longest time is 42 days, so use when = 42
summBg(vol = cum.prod, setup = setup, time.name = "days",
inoc.name = "inoc", inoc.m.name = "minoc", when = 42,
norm.name = "mvs.sub")
# If an error is thrown because a bottle doesn't meet the 1% criterion, use
# show.rates = TRUE to see rates
## Not run:
# Will return error
cpshort <- cum.prod[cum.prod$days < 10, ]
summBg(vol = cpshort, setup = setup, time.name = "days",
inoc.name = "inoc", inoc.m.name = "minoc", when = "1p",
norm.name = "mvs.sub")
## End(Not run)
# So then use this to see which bottles are causing problems
cpshort <- cum.prod[cum.prod$days < 10, ]
summBg(vol = cpshort, setup = setup, time.name = "days",
inoc.name = "inoc", inoc.m.name = "minoc", when = "1p",
norm.name = "mvs.sub", show.rates = TRUE)
# Example with dataset with different column names
data("vol2")
data("comp2")
data("setup2")
# First need to calculate cumulative methane production data
cum.prod <- cumBg(vol2, comp = comp2, temp = 20, pres = 1,
id.name = "bottle", time.name = "days",
dat.name = "meas.vol", comp.name = "CH4.conc",
extrap = TRUE)
head(cum.prod)
# Cumulative CH4 production at 30 d, subtract inoculum contribution
# and normalise by sub.vs column (mass of substrate VS here) (look at setup2).
summBg(vol = cum.prod, setup = setup2, id.name = "bottle",
time.name = "days", descrip.name = "description",
inoc.name = "Inoculum", inoc.m.name = "inoc.mass",
norm.name = "sub.vs", when = 30)