subset_BGF: Split or merge 'BGF"s

View source: R/subsetting_BGF.R

subset_BGFR Documentation

Split or merge BGF's

Description

Functions that allow sub-setting and merging of ‘BGF“’s.

Usage

subset_BGF(x, reactor = NULL, layout = NULL, name = NULL)

merge_BGF(x, y, mergeParam = FALSE, x_tag = NULL, y_tag = NULL, name = NULL)

Arguments

x, y

a BGF

reactor

defaults to NULL. Can be an integer or character specifying the reactors/ fermentations to keep based on the reactor name (= row name of the fermentation in metaData-layer)

layout

defaults to NULL.Can be an integer or character specifying the reactors/ fermentations to keep based on the reactor layout (= respective value in the 'Layout' column of the metaData-layer)

name

defaults to NULL. Can be a character providing a new name for the BGF

mergeParam

logic; defaults to FALSE. Should the ExpParam-layer of the BGF's be also merged?

x_tag, y_tag

defaults to NULL. Can be a character which is used as a tag when merging ExpParam-layers

Details

The function subset_BGF can be used to subset a BGF. The user can either use reactor/ fermentation names (= row names of metaData-layer, values in column 'reactor' of BioGasData-layer), or reactor layouts (= values in 'Layout' column of metaData-layer) as a basis for subsetting. Furthermore, it is possible to give a new name to the resulting subset.

The function merge_BGF can be used to merge two BGF's. On the way, it will generate new row names for the metaData-layer and adjust the values in the 'reactor' column of the BioGasData-layer appropriately.

In general, it is advised to only merge BGF's that have the same values in their ExpParam-layer, as with the default setting only the ExpParam-layer of the first BGF passed to merge_BGF is preserved. It is possible to change the default behavior with the 'mergeParam' argument. In that case, new names for entries in the merged ExpParam-layer will be generated if a entry is either present in only one ÈxpPram-layer of the BGF's or if the values for the same entry in both BGF's differs. The new names are prolonged by a specific tag (controlled via arguments 'x_tag' and 'y_tag'), so that it is clear where that entry originates from.

Furthermore, these tags will be added to the metaData- and BioGasData-layer.

Value

a BGF

Examples

# create an example BGF
myBGF <- from_AMPTSV2_report(
        ReactorLayout = c("2*Blank","Cellulose","2*S1 ctrl","2*S1 7d","2*S1 4d",
                          "2*S2 ctrl","2*S2 4d","2*S2 6d"),
        BlankLabel = "Blank",
        name = "myBGF",
        InocToSubRatio=2,
        ProcessTemp = 52,
        path = base::system.file("extdata","AMPTSV2.csv",package = "bgfanalyzer"))
myBGF

# subset using 'reactor' argument
myBGF_subset1 <- subset_BGF(myBGF,reactor=c(4:9),name="subset 1")
myBGF_subset1

# subset using 'layout' argument
myBGF_subset2 <- subset_BGF(myBGF,layout=c("S2 ctrl","S2 4d","S2 6d"),name="subset 2")
myBGF_subset2

# merge the BGF's
mergedBGF <- merge_BGF(myBGF_subset1,myBGF_subset2,TRUE)
mergedBGF


bgfanalyzer documentation built on Sept. 26, 2026, 5:07 p.m.