The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
BGF from a Custom
Fermentation SystemThis vignette is the second of three, that focus the topic of how to
get data into a BGF. Assuming the reader has read
vignette("Introducing-BGF",package="bgfanalyzer") and
vignette("BGF-commercial",package="bgfanalyzer") and is
familiar with the general concepts of BGF’s and how to
build a BGF from a report generated by a distinct
commercial fermentation system (see
vignette("BGF-commercial",package="bgfanalyzer") for
details).
In this vignette, we will discuss how to build a BGF
from one or more external files, that are in a standardized text format.
Such files are expected to contain at least cumulative exhaust gas
volume measurements and a time log of a single fermentation, but can
include additional sensor readings such as pH or gas quality
measurements.
In the following sections we will see how to build a BGF
from multiple such standardized files, which store the data of several
fermentations.
The data used during this vignette was acquired from a custom fermentation system. It consisted of a 2l stirred and heated batch reactor. This reactor was equipped with several sensors, such as a pH-, temperature- and RedOx-electrodes, allowing continuously monitoring of essential fermentation parameters. In addition, the cumulative exhaust gas volume was recorded and the exhaust gas composition (= gas quality) was sequentially analyzed.
The data files used in the following, can be grouped in two groups:
The Fermentation_*-files store cumulative exhaust gas volumes measurements together with other sensor readings of each one fermentation. The gasq_*-files store gas quality measurements of the respective fermentations.
The fermentations were carried out in individually heated batch reactors and sensor readings within Fermentation_*-files were recorded by third party software. The data in gasq_*-files originates from a gas chromatograph sequentially analyzing the gas composition within the exhaust gas of the same fermentations.
Sensor readings in Fermentation_*-files were manually converted into the standard format using an R script specifically developed to convert text reports generated by the third party software. Gas quality measurements were collected using instrument specific software and uploaded into a database afterwards. The gasq_*-files were extracted from that database and were already in the standardized format upon database extraction.
Now, let’s start building a simple BGF form an external
file in standard format. This BGF will not contain any
‘Blank’ fermentations.
We will use the function from_standard_record() to
create a new BGF.
# load library
library(bgfanalyzer)
# We build a BGF from
myBGF<-from_standard_record(ReactorLayout = "Substrat A",
ProcessTemp = 80,
InocToSubRatio = 0.1,
path = system.file("extdata","Fermentation_A.tsv",package = "bgfanalyzer"),
time_col = 1,
product_col = 3,
BlankLabel = "Blank",
name = "myBGF",
units = "days")
# inspect object
myBGF
#> 'myBGF' - a BGF with 1 fermentation(s)
#>
#>
#> $ExpParam: 4 experimental paramerters
#> $metaData: 3 meta variables
#> $BioGasData: 995 observations of 15 fermentation variables
#>
#>
#> A '$yield' is not calculated yet
# have a closer look at its 'metaData'-layer
myBGF$metaData
#> Layout Blank Excluded
#> R1 Substrat A FALSE FALSEA new BGF was created with only one row in the
metaData-layer!
How about the BioGasData-layer? Let’s take a look at its
head() and tail() output:
# look at the first six rows of the 'BioGasData'-layer
head(myBGF$BioGasData)
#> reactor time product production net_product yield rel_production
#> 1 R1 0.000000000 2865.463 NA NA NA NA
#> 2 R1 0.006944444 2907.658 NA NA NA NA
#> 3 R1 0.013888889 2990.367 NA NA NA NA
#> 4 R1 0.020833333 3157.891 NA NA NA NA
#> 5 R1 0.027777778 3368.889 NA NA NA NA
#> 6 R1 0.034722222 3577.206 NA NA NA NA
#> UTC LocalTime GCounter..bar. GCounter...C. pH..pH.
#> 1 2025-05-11 09:40:00 2025-05-11 13:40:00 1.056473 21.90701 5.069743
#> 2 2025-05-11 09:50:00 2025-05-11 13:50:00 1.056430 21.84665 7.216237
#> 3 2025-05-11 10:00:00 2025-05-11 14:00:00 1.056284 21.81089 7.275986
#> 4 2025-05-11 10:10:00 2025-05-11 14:10:00 1.056257 21.81312 7.231942
#> 5 2025-05-11 10:20:00 2025-05-11 14:20:00 1.056395 21.78528 7.202862
#> 6 2025-05-11 10:30:00 2025-05-11 14:30:00 1.056511 21.73041 7.181225
#> pH...C. RedOx..mV. RedOx...C.
#> 1 83.89395 51.21505 67.22814
#> 2 90.56280 -362.65171 79.53166
#> 3 97.62533 -342.68693 85.79633
#> 4 102.19466 -322.54121 89.84846
#> 5 105.24368 -326.00050 92.60292
#> 6 107.40473 -349.45627 94.43379
# look at a snippet of the last six rows of the 'BioGasData'-layer
tail(myBGF$BioGasData[c(1,2,3,(length(myBGF$BioGasData)-c(2,1,0)))])
#> reactor time product pH...C. RedOx..mV. RedOx...C.
#> 990 R1 NA 1128.143 111.7845 -834.4330 98.04702
#> 991 R1 NA 4050.876 110.9282 -784.4165 97.31104
#> 992 R1 NA 4368.393 110.8813 -718.3926 97.27507
#> 993 R1 NA 4520.125 110.8102 -723.8605 97.27507
#> 994 R1 NA 4545.449 110.8135 -738.0396 97.27514
#> 995 R1 NA 4545.449 110.8834 -732.7213 97.27511As we can see, reactor, time and
product columns were already filled with data from the
external file and in addition eight new columns with data were added to
the BioGasData-layer of ‘myBGF’ through the call to
from_standard_record()
BioGasData-layerNow we will add the gas composition measurements stored in
gasq_A.tsv. First, we import the file, next we add it to the
BGF.
# import the gas quality measurements stored in a separate file
gasq_A <- import_standard_record(ipath = system.file("extdata","gasq_A.tsv",package = "bgfanalyzer"),
dec = ".",
sep = "\t",
header = TRUE,
mkFRTime = "2025-05-11 14:08:35",
FRTime_col = 1,
units = "days")
# add gas quality measurements to BGF
myBGF <- add_BG_parameter(myBGF,
parameter = gasq_A,
reactor = "R1",
time = 3,
value = 2,
name = "H2",
cut_zero = TRUE,
interpolate_missing = FALSE)
# look at a snippet of the first six rows of the 'BioGsaData'-layer to see the results
head(myBGF$BioGasData[c(1,2,3,(length(myBGF$BioGasData)-c(3,2,1,0)))])
#> reactor time product pH...C. RedOx..mV. RedOx...C. H2
#> 1 R1 0.000000000 2865.463 83.89395 51.21505 67.22814 0
#> 2 R1 0.006944444 2907.658 90.56280 -362.65171 79.53166 NA
#> 3 R1 0.013888889 2990.367 97.62533 -342.68693 85.79633 NA
#> 4 R1 0.020833333 3157.891 102.19466 -322.54121 89.84846 NA
#> 5 R1 0.027777778 3368.889 105.24368 -326.00050 92.60292 NA
#> 6 R1 0.034722222 3577.206 107.40473 -349.45627 94.43379 NAA new column, H2, storing the amount of the target gas
in the exhaust gas (in this example the target gas is Hydrogen,
H2) was added to the
BioGasData-layer.
However, most of the entries in this new column are NA
and insertion of data into the existing BioGasData-layer
created additional NA’s whenever a value was inserted:
# data insertion created gaps
myBGF$BioGasData[c(97:99),c(1,2,3,(length(myBGF$BioGasData)-c(3,2,1,0)))]
#> reactor time product pH...C. RedOx..mV. RedOx...C. H2
#> 97 R1 0.6299421 NA NA NA NA 7.415011
#> 98 R1 0.6319444 12.95256 111.2624 -585.4235 98.04046 NA
#> 99 R1 0.6388889 12.95256 111.2922 -582.1135 98.04129 NANA removal through data inter- and extrapolationSuch ‘gaps’ in the data can be closed using the function
na_correction(). By default, this function will close the
gaps in all numeric columns of the BioGasData-layer, as
long as there is a value before and a value after the gap.
# close the gaps
myBGF <- na_correction(myBGF)
# look at a snippet of the first six rows
head(myBGF$BioGasData[c(1,2,3,(length(myBGF$BioGasData)-c(3,2,1,0)))])
#> reactor time product pH...C. RedOx..mV. RedOx...C. H2
#> 1 R1 0.000000000 2865.463 83.89395 51.21505 67.22814 0.0000000
#> 2 R1 0.006944444 2907.658 90.56280 -362.65171 79.53166 0.1198007
#> 3 R1 0.013888889 2990.367 97.62533 -342.68693 85.79633 0.2396015
#> 4 R1 0.020833333 3157.891 102.19466 -322.54121 89.84846 0.3594022
#> 5 R1 0.027777778 3368.889 105.24368 -326.00050 92.60292 0.4792029
#> 6 R1 0.034722222 3577.206 107.40473 -349.45627 94.43379 0.5990036
# look at the gap that arrose from data insertion
myBGF$BioGasData[c(97:99),c(1,2,3,(length(myBGF$BioGasData)-c(3,2,1,0)))]
#> reactor time product pH...C. RedOx..mV. RedOx...C. H2
#> 97 R1 0.6299421 12.95256 111.2690 -585.2305 98.04065 7.415011
#> 98 R1 0.6319444 12.95256 111.2624 -585.4235 98.04046 7.502900
#> 99 R1 0.6388889 12.95256 111.2922 -582.1135 98.04129 7.807715
# look at a snippet of the last six rows
tail(myBGF$BioGasData[c(1,2,3,(length(myBGF$BioGasData)-c(3,2,1,0)))])
#> reactor time product pH...C. RedOx..mV. RedOx...C. H2
#> 1058 R1 6.854167 4545.449 110.8785 -727.9693 97.27511 NA
#> 1059 R1 6.861111 4545.449 110.8831 -713.6151 97.27511 NA
#> 1060 R1 6.868056 4545.449 110.8850 -733.5847 97.27515 NA
#> 1061 R1 6.875000 4545.449 110.8880 -740.5657 97.27524 NA
#> 1062 R1 6.881944 4545.449 110.8863 -730.1653 97.27516 NA
#> 1063 R1 6.888889 4545.449 110.8859 -723.5141 97.27507 NAThe data is almost free of NA’s now. Only in the end of
the BioGasData-layer, NA’s in H2
still exist. We can handle this by a second call to
na_correction() with some adjustments.
We will specifically correct column H2 and will not end
correction if no value after the gap exist. To avoid that this
NA-correction yields in negative concentrations, we add
argument sub_zero = 0 to the function call:
# correct remaining NA's in H2
myBGF <- na_correction(myBGF,
which = "H2",
end=F,
sub_zero=0)
# insepct results
tail(myBGF$BioGasData[c(1,2,3,(length(myBGF$BioGasData)-c(3,2,1,0)))])
#> reactor time product pH...C. RedOx..mV. RedOx...C. H2
#> 1058 R1 6.854167 4545.449 110.8785 -727.9693 97.27511 57.66652
#> 1059 R1 6.861111 4545.449 110.8831 -713.6151 97.27511 57.65030
#> 1060 R1 6.868056 4545.449 110.8850 -733.5847 97.27515 57.63407
#> 1061 R1 6.875000 4545.449 110.8880 -740.5657 97.27524 57.61785
#> 1062 R1 6.881944 4545.449 110.8863 -730.1653 97.27516 57.60163
#> 1063 R1 6.888889 4545.449 110.8859 -723.5141 97.27507 57.58541As we can see, the terminal NA’s in H2 have
been replaced by interpolated values.
Now, we have build a BGF from data stored within two
external files in a standardized data format. This BGF
still has missing values in production,
rel_production, net_product and
yield of its BioGasData-layer, which we need
to take care of.
First, we calculate the values for production using
calculate_flow_from_volume():
# cumulative exhaust gas volume mesurements in 'product' can be used to calculate
# the 'production', a.k.a the biogas flow
myBGF <- calculate_flow_from_volume(myBGF)
# inspect standard columns of 'BioGasData'-layer
head(myBGF$BioGasData[c(1:7)])
#> reactor time product production net_product yield rel_production
#> 1 R1 0.000000000 2865.463 0.00000 NA NA NA
#> 2 R1 0.006944444 2907.658 42.19506 NA NA NA
#> 3 R1 0.013888889 2990.367 82.70831 NA NA NA
#> 4 R1 0.020833333 3157.891 167.52464 NA NA NA
#> 5 R1 0.027777778 3368.889 210.99756 NA NA NA
#> 6 R1 0.034722222 3577.206 208.31685 NA NA NASimilarly, we can calculate values for rel_production
using relative_production():
# calculate relative production
myBGF <- relative_production(myBGF)
# inspect standard columns of 'BioGasData'-layer
head(myBGF$BioGasData[c(1:7)])
#> reactor time product production net_product yield rel_production
#> 1 R1 0.000000000 2865.463 0.00000 NA NA 63.04
#> 2 R1 0.006944444 2907.658 42.19506 NA NA 63.97
#> 3 R1 0.013888889 2990.367 82.70831 NA NA 65.79
#> 4 R1 0.020833333 3157.891 167.52464 NA NA 69.47
#> 5 R1 0.027777778 3368.889 210.99756 NA NA 74.12
#> 6 R1 0.034722222 3577.206 208.31685 NA NA 78.70Let’s proceed with the calculation of net_product.
Therefore, we use the function netGasGC(), which takes the
values of production and multiplies it with the target gas
concentration stored in H2, to calculate the net amount of
target gas produced in between observations. Next, this function will
cumulate these ‘net production’ values which yields in the final
net_product values.
# calculate net_product
myBGF <- netGasGC(myBGF,
purity = "H2",
substract_blank = FALSE)
# inspect standard columns of 'BioGasData'-layer
tail(myBGF$BioGasData[c(1:7)])
#> reactor time product production net_product yield rel_production
#> 1058 R1 6.854167 4545.449 0 3162.314 NA 100
#> 1059 R1 6.861111 4545.449 0 3162.314 NA 100
#> 1060 R1 6.868056 4545.449 0 3162.314 NA 100
#> 1061 R1 6.875000 4545.449 0 3162.314 NA 100
#> 1062 R1 6.881944 4545.449 0 3162.314 NA 100
#> 1063 R1 6.888889 4545.449 0 3162.314 NA 100We successfully calculated net_product. Before we
continue calculating the yield, we must first add some
information to the metaData-layer. The yield
reflects the amount of net_product produced per ‘input
organics’. This example fermentation was conducted in a 3L reactor with
3.23 wt.% organic total solutes (oTS), which makes 96.89 g oTS in the
fermentation. We add this value like this:
# add the oTS to 'metaData'-layer
myBGF <- add_metaData(myBGF,98.89,lab = "oTS")
# inspect change in 'metaData'-layer
myBGF$metaData
#> Layout Blank Excluded oTS
#> R1 Substrat A FALSE FALSE 98.89Now, we can calculate the yield like this:
# calculate 'yield'
myBGF <- calc_yield(myBGF,pos = 4)
# inspect standard columns of 'BioGasData'-layer
tail(myBGF$BioGasData[c(1:7)])
#> reactor time product production net_product yield rel_production
#> 1058 R1 6.854167 4545.449 0 3162.314 31.9781 100
#> 1059 R1 6.861111 4545.449 0 3162.314 31.9781 100
#> 1060 R1 6.868056 4545.449 0 3162.314 31.9781 100
#> 1061 R1 6.875000 4545.449 0 3162.314 31.9781 100
#> 1062 R1 6.881944 4545.449 0 3162.314 31.9781 100
#> 1063 R1 6.888889 4545.449 0 3162.314 31.9781 100
# get the yield summary
myBGF <- summarize_yield(myBGF)
# inspect change in 'metaData'-layer
myBGF$metaData
#> Layout Blank Excluded oTS yield sd_yield production
#> R1 Substrat A FALSE FALSE 98.89 31.9780978206744 <NA> 235.58735599788
#> sd_production time_production sd_time_production
#> R1 <NA> 0.0694444444444444 <NA>Afterwards, all standard columns of the BGF were
calculated and we can use bgf_plot() to visualize the
data:
#>
#> $net_product_curve
#>
#> $production_curve
#>
#> $rel_production_curve
#>
#> $yield_col
#>
#> $yield_box
In the line plots, we can see some disturbance in the beginning of the fermentation. We can ‘correct’ this by moving the ‘0’ value in the observation time to the right, and afterwards delete all data with a ‘negative’ observation time. A suitable new ‘0’ value can be found interactively:
Now we can hover with the courser over the line and identify
‘time=0.104’ as the first value after the disturbance. Alternatively, we
could have use `View(myBGF\$BioGasData)` (or
`print(myBGF\$BioGasData)`) and search for a suitable time
there.
So, data clean up is possible by deleting the first 0.11 days of this 6 days fermentation. By doing this, 98 % of the data will be kept.
# trim the fermentation
myBGF<-trim_FR_time(myBGF,0.11)
# inspect results by ploting
bgf_plot(myBGF,type = "product")When shifting the ‘0’ value to the right, it is advised to run
update_BGF() to ensure the internal logic of the
BGF and to rerun data processing functions
(calculate_flow_from_volume(),
relative_production(), netGasGC(),
calc_yield() and summarize_yield()).
So:
# ensure internal logic of the 'BGF'
myBGF<-update_BGF(myBGF)
# re-calculate 'production'
myBGF <- calculate_flow_from_volume(myBGF)
# re-calculate 'rel_production'
myBGF <- relative_production(myBGF)
# re-calculate 'net_product'
myBGF <- netGasGC(myBGF,"H2",substract_blank = FALSE)
# re-calculate 'yield'
myBGF <- calc_yield(myBGF,pos = 4)
# plot 'BGF' again
bgf_plot(myBGF)
#> $product_curve#>
#> $net_product_curve
#>
#> $production_curve
#>
#> $rel_production_curve
#>
#> $yield_col
#>
#> $yield_box
Let’s try printing the BGF:
# print the BGF
myBGF
#> 'myBGF' - a BGF with 1 fermentation(s)
#>
#>
#> $ExpParam: 4 experimental paramerters
#> $metaData: 10 meta variables
#> $BioGasData: 1047 observations of 16 fermentation variables
#>
#>
#> yield sd_yield production sd_production time_production
#> Substrat A 31.9781 NA 235.5874 NA 0.06944444
#> sd_time_production
#> Substrat A NAFinally, we have a complete BGF with data of a single
fermentation. The input data of that BGF was split over two
external data files. In the following, we will see, how to add further
fermentations with the same, or a different reactor layout to that
BGF.
Now, that a final BGF is build let’s see how to add
another fermentation with the same reactor layout.
Like the first fermentation, also the input data of the second is
split in two external files. The first step is importing these files and
adding the new data to the existing BGF:
# Import the new data directly from the input file with cumulative exhaust gas volume measurements
myBGF <- add_standard_record(myBGF,
path = system.file("extdata","Fermentation_B.tsv",package = "bgfanalyzer"),
RName = "R2",
time_col = "UTC",
units = "days",
product_col = "GCounter..ml.")
#> Standard record imported from '/tmp/Rtmpe1TQeS/Rinst270867ca294a/bgfanalyzer/extdata/Fermentation_B.tsv'...
# updating internal logic is highly recommended
myBGF <- update_BGF(myBGF)
# correct 'metaData$Layout' for new fermentation
myBGF <- alter_whatever(myBGF,layer = "metaData",what = "Layout",value = "Substrate A")
# already add 'metaData$oTS' at this point
myBGF <- alter_whatever(myBGF,layer = "metaData",what = "oTS",value = 98.89,ID = "R2")
# import respective gas quality measurements
gasq_B <- import_standard_record(ipath = system.file("extdata","gasq_B.tsv",package = "bgfanalyzer"),
dec = ".",
sep = "\t",
header = TRUE,
mkFRTime = "2025-05-19 22:00:00",
FRTime_col = 1,
units = "days")
# add gas quality measurements to BGF
myBGF <- add_BG_parameter(myBGF,
parameter = gasq_B,
reactor = "R2",
time = 3,
value = 2,
name = "H2",
makeCol = FALSE,
cut_zero = TRUE,
interpolate_missing = TRUE)
# look at a snippet of the first six rows of the 'BioGsaData'-layer to see the results
tail(myBGF$BioGasData[c(1,2,3,(length(myBGF$BioGasData)-c(3,2,1,0)))])
#> reactor time product pH...C. RedOx..mV. RedOx...C. H2
#> 1427 R2 2.569444 2215.463 34.70880 -405.5080 104.30013 33.53799
#> 1428 R2 2.576389 2729.556 34.97007 -411.2913 105.01960 33.53799
#> 1429 R2 2.583333 3268.039 35.14481 -418.7118 105.71285 33.53799
#> 1430 R2 2.590278 3833.446 35.25318 -426.7012 105.98763 33.53799
#> 1431 R2 2.597222 4434.281 35.31363 -434.5725 106.55078 33.53799
#> 1432 R2 2.604167 2879.980 21.84904 -287.6903 65.96045 33.53799Now that we have added the raw data of a second fermentation we can interactively plot the product curve to see if (and how) we need to trim the added data:
The data of ‘R2’ look strange from 0 to 0.61 d and after 2.49 d. We can adjust this like before using
# remove data later than 2.49d
myBGF <- trim_FR_time(myBGF,
value = 2.49,
mode = "R2",
left_end = FALSE)
# remove data before 0.61d
myBGF <- trim_FR_time(myBGF,
value = 0.61,
mode = "R2")
# plot product curve again to inspect results
plot_product_curve(myBGF)The data looks much better now! Let’s continue with calculating
production, rel_production,
netGas and yield for the newly added
fermentation.
We can use the same functions as before:
# ensure internal logic of the 'BGF'
myBGF<-update_BGF(myBGF)
# close gaps
myBGF <- na_correction(myBGF)
# re-calculate 'production'
myBGF <- calculate_flow_from_volume(myBGF)
# re-calculate 'rel_production'
myBGF <- relative_production(myBGF)
# re-calculate 'net_product'
myBGF <- netGasGC(myBGF,"H2",substract_blank = FALSE)
# re-calculate 'yield'
myBGF <- calc_yield(myBGF,pos = 4)
# summarize yield
myBGF <- summarize_yield(myBGF)
# print the new BGF
myBGF
#> 'myBGF' - a BGF with 2 fermentation(s)
#>
#>
#> $ExpParam: 4 experimental paramerters
#> $metaData: 10 meta variables
#> $BioGasData: 1337 observations of 16 fermentation variables
#>
#>
#> yield sd_yield production sd_production time_production
#> Substrate A 38.91872 8.816806 213.272 15.18758 1.199028
#> sd_time_production
#> Substrate A 0.1718662In the print() we see, the BGF now has 2
fermentations. In the ‘yield summary’ standard deviations for ‘yield’,
‘production’ and ‘time_production’ are calculated as the fermentations
both have ‘Layout’ ‘Substrate A’.
Interestingly, although the observation times of these example fermentations differ, the ‘yield’ at the final observation time is quite similar as seen in the low ‘sd_yield’ value.
Now that we have build a BGF with two fermentations of
the same reactor layout from several external files, it is time to add
further fermentations, that have a different reactor layout.
At first we create a second BGF with two fermentations
of reactor layout ‘Substrate B’, and next we merge the two
BGF’s into a single object.
Let’s start with creating the new BGF. It will have 2
fermentations in the metaData-layer, and the raw data of
the first fermentation will be directly imported to the
BioGasLayer-layer.
# create a new BGF directly from the record of a third fermentation
myBGF2<-from_standard_record(ReactorLayout = c("2*Substrate B"),
ProcessTemp = 80,
InocToSubRatio = 0.1,
path = system.file("extdata","Fermentation_C.tsv",package = "bgfanalyzer"),
time_col = 1,
product_col = 3,
BlankLabel = "Blank",
name = "myBGF2",
units = "days")
# import respective gas quality data
gasq_C <- import_standard_record(ipath = system.file("extdata","gasq_C.tsv",package = "bgfanalyzer"),
dec = ".",
sep = "\t",
header = TRUE,
mkFRTime = "2024-10-27 05:30:00",
FRTime_col = 1,
units = "days")
# add gas quality measurements to BGF
myBGF2 <- add_BG_parameter(myBGF2,
parameter = gasq_C,
reactor = "R1",
time = 3,
value = 2,
name = "H2",
cut_zero = TRUE,
interpolate_missing = TRUE)
# print the new BGF
myBGF2
#> 'myBGF2' - a BGF with 2 fermentation(s)
#>
#>
#> $ExpParam: 4 experimental paramerters
#> $metaData: 3 meta variables
#> $BioGasData: 624 observations of 16 fermentation variables
#>
#>
#> A '$yield' is not calculated yetBefore, further processing the data, let’s add the raw data from the last fermentation:
myBGF2 <- add_standard_record(myBGF2,
path = system.file("extdata","Fermentation_D.tsv",package = "bgfanalyzer"),
RName = "R2",
time_col = "UTC",
units = "days",
product_col = "GCounter..ml.")
#> Standard record imported from '/tmp/Rtmpe1TQeS/Rinst270867ca294a/bgfanalyzer/extdata/Fermentation_D.tsv'...
# updating internal logic is highly recommended
myBGF2 <- update_BGF(myBGF2)
# import respective gas quality data
gasq_D <- import_standard_record(ipath = system.file("extdata","gasq_D.tsv",package = "bgfanalyzer"),
dec = ".",
sep = "\t",
header = TRUE,
mkFRTime = "2024-10-30 23:00:00",
FRTime_col = 1,
units = "days")
# add gas quality measurements to BGF
myBGF2 <- add_BG_parameter(myBGF2,
parameter = gasq_D,
reactor = "R2",
time = 3,
value = 2,
name = "H2",
makeCol = FALSE,
cut_zero = TRUE,
interpolate_missing = TRUE)
# print the BGF
myBGF2
#> 'myBGF2' - a BGF with 2 fermentation(s)
#>
#>
#> $ExpParam: 4 experimental paramerters
#> $metaData: 3 meta variables
#> $BioGasData: 1144 observations of 16 fermentation variables
#>
#>
#> A '$yield' is not calculated yetAs we can see, the number of observations in the
BioGasData-layer has increased indicating a successful data
addition.
We continue with processing the data. First, we check if the data
needs trimming and afterwards we can head towards yield
calculation!
We see that both fermentations need adjustments in the beginning. ‘R1’ will be trimmed by 0.42d and ‘R2’ will be trimmed by 0.56d counting from observation start. Furthermore, ‘R1’ needs to be cut after 4.08d, which will be our first step:
# trim 'R1' fermentation
myBGF2 <- trim_FR_time(myBGF2,4.08,"R1",left_end = FALSE)
# updating internal logic is highly recommended
myBGF2 <- update_BGF(myBGF2)
# trim 'R1' fermentation
myBGF2 <- trim_FR_time(myBGF2,0.42,"R1")
# updating internal logic is highly recommended
myBGF2 <- update_BGF(myBGF2)
# trim 'R2' fermentation
myBGF2 <- trim_FR_time(myBGF2,0.56,"R2")
# updating internal logic is highly recommended
myBGF2 <- update_BGF(myBGF2)
# plot the product curve again to see results
plot_product_curve(myBGF2)Now we can start the data processing loop:
# updating internal logic is highly recommended
myBGF2 <- update_BGF(myBGF2)
# close gaps in data
myBGF2 <- na_correction(myBGF2,end=F)
# calculate production
myBGF2 <- calculate_flow_from_volume(myBGF2)
# calculate relative production
myBGF2 <- relative_production(myBGF2)
# calculate net gas
myBGF2 <- netGasGC(myBGF2,"H2",substract_blank = FALSE)
# add a oTS column at the metaData-layer
myBGF2<-add_metaData(myBGF2,c(85.5,85.5),lab="oTS")
# calculate yield
myBGF2<-calc_yield(myBGF2,4)
# summarize yield
myBGF2<-summarize_yield(myBGF2)
# print BGF
myBGF2
#> 'myBGF2' - a BGF with 2 fermentation(s)
#>
#>
#> $ExpParam: 4 experimental paramerters
#> $metaData: 10 meta variables
#> $BioGasData: 1008 observations of 16 fermentation variables
#>
#>
#> yield sd_yield production sd_production time_production
#> Substrate B 0.09416218 0.1244923 67.50064 90.82305 0.4613889
#> sd_time_production
#> Substrate B 0.639146Finally, we can merge the two BGF’s into a new
BGF containing all 4 fermentations using
merge_BGF() :
# merge the two BGFs
mergedBGF<-merge_BGF(myBGF,myBGF2,name = "merged BGF")
# print the merged BGF
mergedBGF
#> 'myBGF' - a BGF with 4 fermentation(s)
#>
#>
#> $ExpParam: 4 experimental paramerters
#> $metaData: 10 meta variables
#> $BioGasData: 2345 observations of 16 fermentation variables
#>
#>
#> yield sd_yield production sd_production time_production
#> Substrate A 38.91871534 8.8168064 213.27202 15.18758 1.1990278
#> Substrate B 0.09416218 0.1244923 67.50064 90.82305 0.4613889
#> sd_time_production
#> Substrate A 0.1718662
#> Substrate B 0.6391460Now we have successfully created a single BGF with 4
fermentations of two reactor layouts! The raw data for this
BGF was extracted from 8 external files.
Note that it would have been possible to create the same object
without merging two BGF‘s. To do this one could set
e.g. ’ReactorLayout = c("2*Substrate A","2*Substrate B")’
in the initial call to from_standard_record() to set up a
BGF for 4 fermentations and than successively add further
data from external files like described e. g. for myBGF2 in
the section above.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.