Package: fermy
Fermy is a toolkit to empower fermentation data analysis independent of any SCADA.
Input data have to be converted in Python Pandas DataFrame with datetime or deltatime converted into float as index.
Fermy is composed of two sub-modules:pandasfermy add to Pandas methods to compute specific analysis on fermentation data e.g. with growth rate and lagtime calculation with DataFrame.fermgrowth()plotlyfermy add to Pandas methods to plot fermentation data with dedicated kinds of charts like Control Chart or Multi-Yaxis Chart e.g. DataFrame.fccplot().Fermy also includes drivers for laboratory devices like scales (Sartorius Entris or Entris II), peristaltic pumps (Watson Marlow pump 120U connect to a computer through a Labjack T7) & Mettler Toledo sensor mount transmitter as new classes:PompWatMarlo,BalanceEntris,MTPReader&M80.
To access to those drivers just make“import fermy.driverslabtool”and then“fermy.driverslabtool.pumps.<ClassName>”or“fermy.driverslabtool.scales.<ClassName>”or“fermy.driverslabtool.probes.<ClassName>”.Fermy also includes “CINAC” like calculations from DataFrame with pH values in columns and time in minutes as float as index.
To access to those tool just make“import fermy.CINAC”and then new methods are availableDataFrame.cinac() & DataFrame.inter().Fermy also includes support for Micro Titer Plate (MTP) like 96-well readers from many brands.
To access to those function just make“import fermy.MTP”.The project is hosted onhttps://gitlab.com/To install it, please simply used“pip install fermy”or to install it, and use laboratory hardware drivers used“pip install fermy[device]”To use it, please simply make:import fermyand then use them as any other methods of Pandas:DataFrame.<methodname>()Methods from pandasfermyfermgrowth:Function to compute maximal growth rate and lagtime. It is based on a mix of two algorithms describes in Toussaint et al. 2006 and Hall et al. 2014.Input: A DataFrame with only data considered as proxy of biomass can be used. DataFrame index has to be a float corresponding to a delta time (in hours) or pandas.DatetimeIndexParameters:usemax: allow users by use chose between normalization methods: average of the first five points (by default) or percentage of the maximal value of datasetpercentofmax: allow users to change the percentage of maximal value usedtimethreshold: allow users to compute growth rate without considering data from time before the provided number of hoursdeltathreshold: allow users to exclude data without a minimal Biomass proxy delta between min and max of the columnpercentegra: allow users to change the % used to select the relevent slope area (EGRA) variation of max slope by default 95% (0.95) of max slope.Output: return a DataFrame with lagtime and maximal growth ratefermmultiaux:Function to compute growths rates and lagtimes for multiauxies It is based on a mix of two algorithms describes in the following: Toussaint et al. 2006 and Hall et al. 2014. Whereas growth rates are found with local max computation.Input: A DataFrame with only data considered as proxy of biomass can be used. DataFrame index has to be a float corresponding to a delta time (in hours) or pandas.DatetimeIndexParameters:usemax: allow users by use chose between normalization methods: average of the first five points or  percentage of the maximal value of datasetpercentofmax: allow users to change the percentage of maximal value usedOutput: return a DataFrame with lagtimes and growth ratesmultirename:Function to rename from a dictionary in forme {"newname" : (possibleoldname1, possibleoldname2)} and rename columns in a DataFrame like possiblename1 ==> new name.Input: DataFrame, Dictionary with key as new column name and values list of values possibly used in the Dataframe as columnsOutput: return a DataFrame with new columns namesreplicates(“SeparationCharacter”):Function to average data from a pandas DataFrame grouping by left part of column name after splitting it by a defined separated character (sepchar).Input: DataFrame with columns name with pattern “commonpartSEPCHARuniqueid”, The character that separate base name to sample identificationOutput: return a DataFrame with averaged data per base nameMethods from plotlyfermyfccplot:Function to compute and plot a simple (and pretty) Control Chart with Plotly express.Input: Data will be values of the column named variableofinterest and index of the DataFrame as plot indexParameters:path: is provided the graph will be saved in this location.dicorename: allow users to custom names of axis with {“old name” : “desired name”}.forcepower: allow users to force scientific notation 10^n for the y-axis and control limits.addccviol: allow users to add a new column to original data with CC rules check-in.colorby: allow users to color data help to one column valuesoutref: allow users to compute ULC, LCL and mean from given data (pd.Series)hql: allow to plot high quality limitlql: allow to plot low quality limitoverinfo: allow to request additional information on ccplotOutput: return a DataFrame like data with only Control Chart violations datafplotsimple:Plot all columns of a Dataframe as Y and index for x with Plotly expressfplotmultiy:Plot all columns of a Dataframe with autogenerated multi-y-axis and index for x.Input: DataFrameParameters:path: is provided the graph will be saved in this locationyspace: allows users to custom space between yaxissizep: allows users to custom font sizegroupby: used character to build group for plotting e.g. groupby=”-” for pH-Biroeactor1 => group pH and subdataset bioreactor1xtitle: allows to custom x title (string is exptected)Output: No output only graphUsage and code demonstrationFirst we create fake datasets: fakedfcc for control chart and fakedfferm for fermentationimportnumpyasnpimportpandasaspdimportmath# fake process follow-up datanp.random.seed(2)datanorm=np.random.normal(size=100,loc=50)datanormpower=datanorm*10**5datanorm[51]=56# add uggly datafakedfcc=pd.DataFrame(data={"num":datanorm,"numpower":datanormpower},columns=["num","numpower"])# fake fermentation datatime=[time/60fortimeinrange(0,60*6,5)]# time 5 minutes steps in hours for 6 hourspH1=np.random.normal(size=len(time),loc=6.5,scale=0.005)pH2=np.random.normal(size=len(time),loc=7.2,scale=0.005)lagtime=time[20]# 1.66 hbiomass1=[0.5]*20+[0.5*math.exp(0.5*(time-lagtime))fortimeintime[20:]]biomass2=[0.5*math.exp(0.5*(time))fortimeintime]biomass3=[0.5*math.exp(0.25*(time))fortimeintime]temp1=np.random.normal(size=len(time),loc=37,scale=0.5)temp2=np.random.normal(size=len(time),loc=37,scale=0.2)fakedfferm=pd.DataFrame(data={"pH-1":pH1,"pH-2":pH2,"biomass-1":biomass1,"biomass-2":biomass2,"biomass-3":biomass3,"temperature-1":temp1,"temperature-2":temp2},columns=["pH-1","pH-2","biomass-1","biomass-2","biomass-3","temperature-1","temperature-2"],index=time)What our fake data looks like?fakedfccnumnumpower049.58324.95832e+06149.94374.99437e+06247.86384.78638e+06351.64035.16403e+06448.20664.82066e+06………fakedffermpH-1pH-2biomass-1biomass-2biomass-3temperature-1temperature-206.505817.201830.50.50.536.920136.94730.08333336.501937.203870.50.5212730.51052637.274536.86450.1666676.494337.198180.50.5434520.52127336.690837.06540.256.502177.195620.50.5665740.53224737.189436.70890.3333336.498487.201980.50.590680.54345237.256636.9257……………………Demo of fermyimportfermy# Control Chart Demofakedfcc.fccplot("num")fakedfcc.fccplot("numpower",forcepower=True)# Fermentation plot Demofakedfferm.fplotmultiy(groupby="-")# Calculation on fermentation databiomassproxy=fakedfferm.iloc[:,2:5]# selection of biomass related columnsbiomassproxy.fermgrowth()Examples of Fermy outputsmaximal_growth_rate_per_hlagtime_hmaximal_growth_rate_time_hbiomass-10.51.672.58biomass-20.50.173.83biomass-30.250.175.25Examples of CINAC like calculationsimportpandasaspdimportfermy.CINACdfcinac=pd.read_csv("https://gitlab.com/Shinuginn/data-sample/-/raw/main/pHkinetic.csv",sep=";",index_col=0)desc=dfcinac.cinac()print(dfcinac)# print dataframe with pH kineticsprint(desc)# print dataframe with cinac descriptors# Way to add a new descriptor named newdescrdefnewdescr(seriepH:pd.Series):returnseriepH.max()fermy.CINAC.mycinactable.append(newdescr)desc=dfcinac.cinac()print(desc)# print dataframe with cinac descriptors plus a new one# New descriptors can be built bases one of the four mother functions:# TimetopH(pHtarget) or pHatTime(Time) or TimeDeltapH (pHini, pHfin, taux:bool) or Ta(timepHini, deltapH)# Exemple: slope between pH 5.9 and 5defslopebetweenpH5dot9and5(seriepH:pd.Series):returnfermy.CINAC.TimeDeltapH(seriepH,5.9,5,True)fermy.CINAC.mycinactable.append(slopebetweenpH5dot9and5)Examples of MTP optionimportfermy.MTPreads=fermy.MTP.MTPReader("fakepathasstring","fakeMTP")print(reads)# The MTP reader is set as fakeMTP# The path of data file is fakepathasstring# Other avaible readers ['Epoch2', 'fakeMTP', 'Tecan96', 'Tecan384', 'Logphase' ,'Fluostar']dfMTP=reads.readMTP()print(dfMTP)# Dataframe with well coordinates as columns and Time of run float of hours as indexGrowth Rate Algorithm DescriptionNormalization of data with two user-defined ways. First by divided all data points by a percentage (5 % percent by default) of the maximum value of the distribution. This option may be used if initial data are very noisy (e.g. Biomass proxy coming from a lab scale). Second method divide all data points by the average of the first five points (like in Toussaint et al. 2006). To be more robust regarding next steps each values under 1 is replaced by 1.Then natural logarithm is applied to the normalized data like in Toussaint et al. 2006A smoothing procedure is applied to the corrected biomass proxy by averaging each point with its eight closest neighbors like in Toussaint et al. 2006.The slope of each point was obtained by calculating the slope between the two fourth neighboring points on each side like in Toussaint et al. 2006.The exponential growth rate area (EGRA) is defined where slopes are equal to or greater than 95% of the maximum slope value like in Hall et al 2014.Finally, linear regression is calculated in the EGRA and the slope of the regression gives the maximum (specific) growth rate and the intercept gives Lag time.Biological significationThe maximum (specific) growth rate (commonly express in per hours) is the growth rate during logarithmic growth phase (in batch culture) corresponding to the maximum value for the specific condition.Lag time (commonly express in hours) is the duration of the phase where growth is absent at the beginning of the culture.BibliographyHall B.G., Acar H., Nandipati A. and Barlow M. Growth rates made easy. Molecular Biology and Evolution, 31 (1):232-238, 2014.Toussaint H., Levasseur G., Gervais-Bird J.,Wellinger R. J., Elela S. A., and Conconi A. A high-throughput method to measure the sensitivity of yeast cells to genotoxic agents in liquid cultures. Mutation Research/Genetic Toxicology and Environmental Mutagenesis, 606 (1-2):92-105, jul 2006.