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 numeric, or POSIX); and the response variable biogas volume or cumulative volume. The names of these columns can be specified with id.name, time.name, and vol.name. Or, the default names can be used. Additional columns can be present– these will be returned in the output data frame. Optional: as of version 1.11.5, vol can be a list of suitable data frames. This is convenient for comparing different approaches for calculating methane production, for example.

setup

a data frame containing information to summarise, substract inoculum effect or normalise the data. Should contain at least the column id.name (bottle identification code), and the additional columns depending on the operations desired. See ‘Details’ for more information.

id.name

name of the bottle identification code column in vol and setup. Should be the same in all data frames used in the function. Default is "id".

time.name

name of column containing time data in vol. Default is "time".

descrip.name

(optional) name of column containing a description of bottle substrate (or a code for this) in setup data frame. The summary of the data will be made following this column. Default is "descrip".

inoc.name

(optional) the value in the descrip.name (setup data frame) column that is used to describe the inoculum-only bottles. Length one character vector. Argument not used by default.

norm.name

(optional) the name of the column in setup that has the mass to perform the normalisation (typically substrate VS mass). Length one character vector. Argument not used by default.

norm.se.name

(optional) the name of the column in setup that has the standard error of the data in the column norm.name. Length one character vector. If provided, this error in substrate mass will be included in the standard error and standard deviation given in the output. Argument not used by default.

inoc.m.name

(optional) the name of the column in setup that has inoculum mass. If specified, these data are used to subtract the inoculum contribution to methane production. Length one character vector. Default is "minoc".

vol.name

the name of the column(s) in vol that contains the response variable used for the summary–typically cumulative methane volume. The default is "cvCH4" for cumulative volume of methane (CH4). Optional: as of version 1.12.0, vol.name may be a vector with length > 1. In this case each response variable will be used and results will be returned for all, together in a single data frame. Character vector.

imethod

the interpolation method to be used. This is passed as the method argument to interp. Length one character vector. Default is "linear" for linear interpolation.

extrap

should extrapolation be carried out? Set to TRUE if extrapolation wanted. Length one logical vector. This is passed as the extrap argument to interp. Default is FALSE

when

value(s) of time.name in vol data frame at which the results should be evaluated. Alternatively, set to "end" (to return the latest values for each bottle) or "meas" (to return a value for each measured time for each bottle). To select a time for each bottle based on the methane production rate, use, e.g., "1p3d" for 1% per day for at least 3 d (any values can be used, even something impractical like "0.1p10d"). In this case, the earliest time where production rate drops below 1% of cumulative production per day for at least 3 days will be used. Where this time differs for multiple bottles with the same descrip.name, the latest one will be used. Numeric or character vector or list (use a list for, e.g., list("1p3d", "end", 30)).

when.min

minimum duration (value of when) to be used with a relative duration criterion, e.g., if you want "1p3d" but no less than 15 days set when.min = 15. Ignored if when is numeric. Default is Inf (no limit).

rate.crit

type of rate criterion to be applied for relative when, e.g., when = "1p3d" and rate.crit = "net" is based on net gas production (after subtracting incoulum contribution). Options are "net" or "gross".

show.obs

set to TRUE to return all observations, otherwise means and standard deviations are returned. Default is FALSE.

show.rates

set to TRUE to return all observations with relative rates. Used to check rates for evaluation time. The when argument will be ignored if show.rates = TRUE. Default is FALSE.

show.more

set to TRUE to return additional details, including fraction of total methane produced by inoculum. Default is FALSE.

sort

controls sorting of results, which is by descrip.name and then time.name by default. Set to FALSE to use order of descrip.name from the setup data frame. Default is TRUE.

set.name

column name in result for set of observations, corresponding to elements in vol when it is a list.

quiet

use to suppress messages. Default is FALSE.

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 vol.name, typically after subtraction of inoculum contribution and normalization by substrate mass

sd

standard deviation of the response variable vol.name

se

standard error of the response variable vol.name

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 vol.name (methane) production by inouclum among replicates

fv.inoc

(mean) fraction of bottle vol.name (methane) estimated to have come from inoculum

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 vol.name, total vol.name produced by bottle, normalization applied as for vol.name (and may be nonsensical)

cvCH4.inoc

name based on vol.name, vol.name produced by bottle estimated as coming from inoculum, normalization applied as for vol.name (and may be nonsensical)

se.inoc

standard error from inoculum used to calculate se2

cvCH4.se

name based on vol.name, standard error from substrate mass used to calculate se3

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

cumBg

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)


[Package biogas version 1.23.2 Index]