BGF: Helper to set up a 'BGF' object

View source: R/helper.R

BGFR Documentation

Helper to set up a BGF object

Description

Three helper functions exist that allows users to set up BGF objects either from scratch or from external data files.

Usage

BGF(
  ReactorLayout,
  BlankLabel = "Blank",
  name = "new_BGF",
  ProcessTemp = NA,
  InocToSubRatio = 2,
  MeasurementType = NA
)

from_AMPTSV2_report(
  ReactorLayout,
  BlankLabel = "Blank",
  name = "new_BGF",
  ProcessTemp,
  InocToSubRatio,
  path,
  feedback = FALSE
)

from_standard_record(
  ReactorLayout,
  ProcessTemp,
  InocToSubRatio,
  path,
  time_col,
  product_col,
  BlankLabel = "Blank",
  name = "new_BGF",
  units = "hours",
  RName = "R1",
  feedback = FALSE,
  ...
)

Arguments

ReactorLayout

A character vector providing the reactor layout, e.g. the grouping factor used for plotting and yield calculation of fermentation(s) in a BGF object

BlankLabel

A character string indicating which group in ReactorLayout is the inoculum used for net gas/ yield calculation

name

A character vector specifying the name of the new BGF object

ProcessTemp

The process temperature of the fermentation(s) to be stored in the BGF object

InocToSubRatio

The inoculum to substrate ratio (= inoculation strength) of the fermentation(s) to be stored in the BGF object

MeasurementType

An optional character string indicating the measurement type of the BGF object to be created

path

A path pointing an external data input file must be. Must be in a tidy format for from_standard_record or a report generated by an AMPTS II (see Details)

feedback

Logical if TRUE the function prints a summary to the R console

time_col

numeric. Indicates the position of the time stamp column in the imported report

product_col

numeric. Indicates the position of the product column (e.g. cumulative biogas volume) in the imported report

units

character string. Units in which the results are desired. Can be abbreviated.

RName

character. Label to be added to the data of the imported report. Should match a value of ReactorLayout

...

further arguments passed to read.table

Details

All three helper functions internally call new_BGF() with distinct parameters arguments pre-set. The easiest way to generate a BGF object is the BGF() function. It only needs the ReaktorLayout argument to be specified by the user and will subsequently create a object of class BGF.

If from_AMPTSV2_report is used, path must point to the report_yyyy-mm-dd_HHMM.csv-file created by an AMPTS II (BioProcess Control; Lund; Sweden). This special feature was included as the AMPTS II is widely distributed among biogas labs and several R tutorials exist online, that also refer on this system.

When from_standard_record is used to create the BGF object any text file storing biogas fermentation data could serve as a template. It is a wrapper to call read.table with certain arguments pre-set. These are: dec=".", sep="\t" and header=TRUE.

Such a text file must have a matrix like structure in which each row represents a unique observation. It must have at least two columns. One with the time stamp of the observation (format: ⁠%y-%m-%d %H:%M:%S⁠). The other one must be an accumulating volume measurement of exhaust gas (biogas) at this moment. Further columns providing additional information (such as pH, temperature or RedOx potential) can be present and will be imported as well.

Value

A BGF object

Examples

# create a simple BGF without data
BGF(LETTERS[c(1:5)])

# create a BGF based on the report of an AMPTS II
from_AMPTSV2_report(
        ReactorLayout = c("2*Blank","Cellulose","3*neg ctrl","3*FR1","3*FR2","3*FR3"),
        BlankLabel = "Blank",
        name = "Test",
        InocToSubRatio=2,
        ProcessTemp = 52,
        path = base::system.file("extdata","AMPTSV2.csv",package = "bgfanalyzer"))

# create a BGF from a minimal external data file
from_standard_record(ReactorLayout = "A",
        ProcessTemp = 80,
        InocToSubRatio = .1,
        path = base::system.file("extdata","Fermentation_A.tsv",package = "bgfanalyzer"),
        time_col = 1,
        product_col = 3)


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