BioSANS2020.model.param_est.param_estimate
¶
This is the param_est module
The following are the functions inside this module
load_data
custom_likelihood
ave_abs_dev
label_param
param_estimate
Module Contents¶
Functions¶
|
This function reads the trajectory file containing the data which |
|
This function returns the negative of the sum of squared errors |
|
This function returns the mean of relative absolute deviation |
|
[summary] |
|
[summary] |
- BioSANS2020.model.param_est.param_estimate.load_data(file=None)¶
This function reads the trajectory file containing the data which should follow the following example format;
time A B 0.0 100.0 0.0 0.25 88.24969025197632 11.750309748023732 0.5 77.88007831231087 22.119921687689185 0.75 68.72892784164061 31.27107215835944 1.0 60.65306592491437 39.346934075085684 1.25 53.526142785532 46.473857214468055 1.5 47.236655135816875 52.76334486418318 1.75 41.68620193454698 58.31379806545308 2.0 36.78794415253036 63.21205584746969 2.25 32.46524678349081 67.53475321650924 …
The format above have a header where the first column is time and all other columns are species or components. The rows are the values of measurements corresponding to the header. Each row is delimited by tab character ” “. If the data file is in excel, just copy the data from excel to a text editor, save it with a filename and it will already be tab delimited. If there are several replicates of the data, just append them to the end without the header and this function can still handle all replicates.
time A B 0.0 100.0 0.0 # first replicate … # continuation 0.0 100.0 0.0 # second replicate … # continuation
- Args:
file (string, optional): trajectory file. Defaults to None.
- Returns:
- tuple: tuple of data and labels (data, labels). The data is a
list of all the trajectories in the file and the labels are the corresponding name of the columns in the trajectory
- BioSANS2020.model.param_est.param_estimate.custom_likelihood(ks_par, args=None)¶
This function returns the negative of the sum of squared errors between the true value of trajectory and estimated trajectory. This serves as the fitness/objective/cost function with a maximum value of zero.
- Args:
ks_par (list): list of parameters args (tuple): Tuple of (data, conc, tvar, sp_comp, ks_dict,
r_dict, p_dict, v_stoich, c_miss, k_miss, molar, rfile). Defaults to None. See param_estimate function for the pro- per definition of each variables.
- Returns:
float: negative of the sum of squared error
- BioSANS2020.model.param_est.param_estimate.ave_abs_dev(ks_par, args=None)¶
This function returns the mean of relative absolute deviation between the true value of trajectory and estimated trajectory. This serves as the fitness/objective/cost function with a maximum value of zero.
- Args:
ks_par (list): list of parameters args (tuple): Tuple of (data, conc, tvar, sp_comp, ks_dict,
r_dict, p_dict, v_stoich, c_miss, k_miss, molar, rfile). Defaults to None. See param_estimate function for the pro- per definition of each variables.
- Returns:
float: mean of relative absolute deviation
- BioSANS2020.model.param_est.param_estimate.label_param(k_miss, c_miss, ks_par)¶
[summary]
- Args:
- k_miss (list): list of position of unkwon parameters in the
reaction tag of BioSANS topology file. For example;
#REACTIONS A => B , -1 # forward rate constant is unknown B <=> C, -1, -1 # forward and backward is unknown
The negative values means rate constant is unknown for those reaction.
The value of k_miss will be;
k_miss = [(0,0), (1, 0), (1, 1)]
The format of the tuple is;
(reaction index, rate constant index) (0, 0) - first reaction, first rate constant (1, 0) - second reaction, first rate constant (1, 1) - second reaction, second rate constant
- c_miss (list): component/species without trajectory data. They
can be set in a topology file with negative values as well.
@CONCENTRATION A, Ao B, -1 C, Co
The value of c_miss will be;
c_miss = [‘B’]
- ks_par (list): list of estimated parameter values for k_miss as
it appears sequencially and list of initial value for c_miss as it appears sequencially.
Example;
- ks_par = [
k1f, # numeric value for position (0, 0) k2f, # numeric value for position (1, 0) k2b, # numeric value for position (1, 1) Bo # numeric initial value for B
]
- Returns:
dictionary: dictionary of estimated values with the following format {label : estimate,…}
- BioSANS2020.model.param_est.param_estimate.param_estimate(conc, tvar, sp_comp, ks_dict, r_dict, p_dict, v_stoich, items, molar=False, mode='MCEM', true_data_fil=None, rfile=None)¶
[summary]
- Args:
conc (dict): dictionary of initial concentration.
For example;
{‘A’: 100.0, ‘B’: -1.0, ‘C’: 0.0} negative means unknown or for estimation
tvar (list): time stamp of trajectories i.e. [0, 0.1, 0.2, …] sp_comp (dict): dictionary of appearance or position of species
or component in the reaction tag of BioSANS topology file.
For example;
#REACTIONS A => B, -kf1 # negative means to be estimated B => C, kf2
The value of sp_comp is
sp_comp = {‘A’: {0}, ‘B’: {0, 1}, ‘C’: {1}}
A appears in first reaction with index 0 B appears in first and second reaction with index 0, 1 C appears in second reaction with index 1
- ks_dict (dict): dictionary of rate constant that appears in each
reactions.
For example;
#REACTIONS A => B , 0.3 # first reaction B <=> C, 0.1, 0.2 # second reaction
The value of ks_dict is
- ks_dict = {
0 : [0.3], # first reaction 1 : [0.1, 0.2] # second reaction
}
r_dict (dict): dictionary of reactant stoichiometry. For example
- r_dict = {
0: {‘A’: 1}, # first reaction, coefficient of A is 1 1: {‘B’: 1} # second reaction, coefficient of B is 1
}
p_dict (dict): dictionary of product stoichiometry. For example
- p_dict = {
0: {‘B’: 1}, # first reaction, coefficient of B is 1 1: {‘C’: 1} # second reaction, coefficient of C is 1
}
v_stoich (numpy.ndarray): stoichiometric matrix. For example
- v_stoich = np.array([
[ -1, 0 ] # species A [ 1, -1 ] # species B [ 0, 1 ] # species C
#1st rxn 2nd rxn
])
items (list): list of [canvas, scroll_x, scroll_y] molar (bool, optional): If True, the units for any amount is in
molar. Propensity will be macroscopic. Defaults to False.
- mode (str, optional): parameter estimation method keyword which
is one of “MCEM”, “DEvol”, “NeldMead”, “Powell”, “L-BFGS-B”
- true_data_fil (string, optional): file name of the trajectory
file containing experimental or observed trajectory. Defaults to None.
- rfile (string, optional): name of topology file where some
parameters or components are negative indicating they have to be estimated. Defaults to None.
- Returns:
tuple: (0, param_res) where param_res is a dictionary of estima- ted values with the following format {label : estimate,…}