Package SloppyCell :: Package ReactionNetworks :: Module OptDesign
[hide private]

Module OptDesign

source code

Functions [hide private]
 
load(filename)
Load an object from a file
source code
 
save(obj, filename)
Save an object to a file
source code
 
setup(paramfile, calcobject, senstrajfile, jtjfile)
Set up the quantities necessary to run the optimal design algorithms.
source code
 
make_sens_traj(calcobject, params, times, senstrajfilename)
Make the sensitivity trajectory for the calculation calcoject (same as in setup(...) above).
source code
 
design_over_chems(chemnames, designchemnames, logprior=1.0e20)
chemnames = list of unmeasurable chemicals designchemnames = list of measurable chemicals logprior = prior on params, e.g.
source code
 
design_over_single_variance(sensvect, designchemnames, logprior=1.0e20)
sensvect : a sensitivity vector (length = # of params) of unmeasurable quantity of interest designchemnames : list of measurable chemicals
source code
 
variances(chemnames, logprior=1.0e20)
chemnames : list of chemical names for which the variance at all timepoints will be computed logprior : prior on parameters.
source code
 
variances_log_chems(chemnames, logprior=1.0e20)
Same as above except the variances are now on the logs of the chemicals trajectories.
source code
 
single_variance(sensvect, logprior=1.0e20)
Get the variance for a single function of parameters that has a sensitivity vector sensvect.
source code
 
variance_change(chemnames, sensvect_design, logprior=1.0e20)
chemnames : list of chemical names at which we will look at variance sensvect_design : the sensitivity vector (one by no.
source code
 
single_variance_change(sensvect, sensvect_design, logprior=1.0e20)
sensvect : given a single function f(p) of parameters, this is the derivative w.r.t.
source code
 
get_sens_vect(chemname, time)
get a sensitivity vector for a chemical "chemname" at a...
source code
 
get_sens_array(chemname)
get an array of sens_vects for all the times the chemical is defined...
source code
 
integrated_var_change(chemnames, sensvect_design, logprior=1.0e20) source code
 
var_change_weighted(weights, chemnames, sensarray_design, logprior=1.0e20)
This is similar to var_change except now we pass in a sensarray instead of sensvect --- this is a matrix of sensvects aligned rowwise.
source code
 
integrated_var_change_weighted(weights, chemnames, sensarray_design, logprior=1.0e20) source code
 
weight_cost(weights, chemnames, sensarray_design, logprior=1.0e20)
For this cost function we're going to assume unconstrained variables are being passed in, so we need to convert them to a range between 0 and 1.
source code
 
weights_trans(weights) source code
 
weights_inv_trans(transweights) source code
 
minimize_weight_cost(weights, chemnames, sensarray_design, logprior=1.0e20)
weights : a vector of positive numbers with length the same as the number of rows of sensarray_design.
source code
 
plot_variances(chemnames, logprior, scale=1.0, return_var=False)
chemnames: list of chemical names logprior: prior on params.
source code
 
plot_variances_log_chems(chemnames, logprior)
chemnames: list of chemical names logprior: prior on params Plots the standard deviation of the chemicals when the variance is computed using logs of the chemical trajectories.
source code
 
plot_variance_newpoint(chemnames, sensvect_design, logprior=1.0e20, return_data=True)
chemnames: list of chemical names...
source code
 
plot_variance_newweights(weights, chemnames, sensarray_design, logprior=1.0e20, scale=1.0, return_data=True)
weights : a proposed set of weights for each of the row vectors in sensarray_design chemnames : a list of chemicals for which we will plot the variance logprior : as before This will plot the old and new variances on chemnames, similar to above.
source code
 
plot_variances_subplot(chemnames, logprior) source code
 
reduce_size(array, skipsize)
reduce_size takes an array of dimension m,n and returns an array with every skipsize row sampled.
source code

Imports: scipy, copy, SloppyCell, Dynamics, Plotting


Function Details [hide private]

setup(paramfile, calcobject, senstrajfile, jtjfile)

source code 
Set up the quantities necessary to run the optimal design
algorithms. NOTE: This function needs to be called first 
before any of the optimal design functions can be called.

paramfile: the name of a pickled file containing the 
best fit parameters in KeyedList format
calcobject: the calculation object for which we are doing the 
optimal design. (Note that in general, may be searching a 
design over many different calculations, but here we only 
consider one. Thus, we set design_sentraj equal to senstraj)
senstrajfile: the name of the file containing the pickled 
sensitivity trajectory for the calculation, calcobject, 
for the set of parameters in paramfile.
jtjfile: the name of the file containing the pickled Fisher
Information Matrix (J^t J) for the current set of data and
for the parameters in paramfile. 
NOTE: The derivatives computed for J^tJ need to be with respect
to the *log* of the parameters

make_sens_traj(calcobject, params, times, senstrajfilename)

source code 
Make the sensitivity trajectory for the calculation
calcoject (same as in setup(...) above). 
params: parameters as a KeyedList, sensitivity traj is 
calculated at these parameters (should be same as in paramfile 
in setup(...) above)
times: the timepoints in the sensitivity trajectory (1-d array)
senstrajfilename: the file to save the sensitivity trajectory to

Note that if times is very finely spaced, the 
sensitivity trajectory will need a lot of storage space 

design_over_chems(chemnames, designchemnames, logprior=1.0e20)

source code 

chemnames = list of unmeasurable chemicals
designchemnames = list of measurable chemicals
logprior = prior on params, e.g. logprior = log(1000.0) means
parameter standard deviation will be less than a factor of 1000.0

Out of the list chemnames, find the best chemical and 
best time point, that most reduces the integrated variance
over designchemnames 

design_over_single_variance(sensvect, designchemnames, logprior=1.0e20)

source code 

sensvect : a sensitivity vector (length = # of params) of 
unmeasurable quantity of interest
designchemnames : list of measurable chemicals

sensvect could be the sensitivity of a single chemical at a
single timepoint; then can use method get_sens_vect (see elsewhere
in this file) to compute this sensitivity vector. In that
case we are designing over the species variance at that single point

variances(chemnames, logprior=1.0e20)

source code 
chemnames : list of chemical names for which the 
variance at all timepoints will be computed
logprior : prior on parameters. logprior = log(1000.0)
means params allowed to vary by about a factor of 1000.0
return values : 
times: times of the trajectory
bestfit: a dictionary of best fit trajectories (keys are entries in chemnames)
var: a dictionary of variances (keys are entries in chemnames)

single_variance(sensvect, logprior=1.0e20)

source code 
Get the variance for a single function of parameters 
that has a sensitivity vector sensvect. Useful for looking at
variances in parameter combinations, or simple functions of
parameters. Note that if we are concerned with ratios and 
products of parameters, it's often best to consider sensvect
as a sensitivity w.r.t. log parameters 

variance_change(chemnames, sensvect_design, logprior=1.0e20)

source code 

chemnames : list of chemical names at which we will look 
at variance
sensvect_design : the sensitivity vector (one by no. params array) at
the new design point.
returns : (times, varchange) 
the times and the change in variances at those times (should
be negative) for each of the chemicals in chemnames, after the 
addition of the new timepoint. varchange is a dictionary 
indexed by entries in chemnames.

single_variance_change(sensvect, sensvect_design, logprior=1.0e20)

source code 

sensvect : given a single function f(p) of parameters, this is the
derivative w.r.t. each of the parameters (in log parameters). For
ratios or products of rate constants, f(p) is a linear function
sensvect_design : the sensitivity vector of the new point in the 
design you wish to add
returns: the variance change of the quantity f(p), given the 
addition of the new data point, with sensitivity vector sensvect_design.

get_sens_vect(chemname, time)

source code 
get a sensitivity vector for a chemical "chemname" at a
time, time 

get_sens_array(chemname)

source code 
get an array of sens_vects for all the times the chemical is defined
and convert to log sensitivities 

var_change_weighted(weights, chemnames, sensarray_design, logprior=1.0e20)

source code 
This is similar to var_change except now we pass in a sensarray
instead of sensvect --- this is a matrix of sensvects aligned rowwise.
Row i will be multiplied by sqrt(weights[i]) where sum(weights)=1 and 
each weight is a number between zero and one. We will return the 
change in variance for all the chemicals in chemnames 

weight_cost(weights, chemnames, sensarray_design, logprior=1.0e20)

source code 
For this cost function we're going to assume unconstrained 
variables are being passed in, so we need to convert them to 
a range between 0 and 1. The sum of the weights should also = 1 

minimize_weight_cost(weights, chemnames, sensarray_design, logprior=1.0e20)

source code 

weights : a vector of positive numbers with length the same as the number of 
rows of sensarray_design. The weights should sum to 1 
chemnames: a list of unmeasurable chemical names over which we wish
to design experiments 
sensarray_design: an array of sensitivities of measurable chemicals
or just an array of sensitivity vectors, each row a different 
sensitivity vector 
logprior : prior on parameters. logprior = log(1000.0) allows parameters
to fluctuate by a factor of 1000 

plot_variances(chemnames, logprior, scale=1.0, return_var=False)

source code 

chemnames: list of chemical names 
logprior: prior on params. logprior = log(1000.0) means parameters
allowed to fluctuate by a factor of 1000 

plot_variances_log_chems(chemnames, logprior)

source code 

chemnames: list of chemical names
logprior: prior on params
Plots the standard deviation of the chemicals when the variance
is computed using logs of the chemical trajectories. This 
makes sure the final plots do not have best_fit+-stddev that
do not become negative 

plot_variance_newpoint(chemnames, sensvect_design, logprior=1.0e20, return_data=True)

source code 

chemnames: list of chemical names
sensvect_design: a sensivity vector of a quantity that is 
measurable
This will plot the old and new variances of the chemicals in 
chemnames, given a new measurement that has sensitivity vector
sensvect_design

plot_variance_newweights(weights, chemnames, sensarray_design, logprior=1.0e20, scale=1.0, return_data=True)

source code 

weights : a proposed set of weights for each of the row vectors in 
sensarray_design
chemnames : a list of chemicals for which we will plot the variance
logprior : as before 
This will plot the old and new variances on chemnames, similar to
above.
NOTE: the weights that are passed in do not necessarily have to sum to
one. e.g. if the weights are normalized such that max(weights) = 1, then
by scaling all the weights by 1/sigma, you are then assuming that
the most accurate measurement has an error of size sigma. sigma for 
example could be 20% of the maximum value of a trajectory.