src package

Submodules

src.BoolODE module

src.BoolODE.Experiment(Model, ModelSpec, tspan, num_cells, sampleCells, varmapper, parmapper, genelist, proteinlist, outPrefix, icsDF, nClusters, x_max, doParallel, burnin=False, writeProtein=False, normalizeTrajectory=False)[source]

Carry out an in-silico experiment. This function takes as input an ODE model defined as a python function and carries out stochastic simulations. BoolODE defines a _cell_ as a single time point from a simulated time course. Thus, in order to obtain 50 single cells, BoolODE carries out 50 simulations, which are stored in ./simulations/. Further, if it is known that the resulting single cell dataset will exhibit multiple trajectories, the user can specify the number of clusters in nClusters; BoolODE will then cluster the entire simulation, such that each simulated trajectory possesess a cluster ID.

Parameters:
  • Model (function) – Function defining ODE model
  • ModelSpec (dict) – Dictionary defining ODE model. See readBooleanRules()
  • tspan (ndarray) – Array of time points
  • num_cells (int) – Number of simulations to perform
  • sampleCells (bool) – Bool that specifies if a random sample of size num_cells should be generated from the simulated output, where one cell is picked per simulation without replacement
  • varmapper (dict) –
  • parmapper (dict) –
  • genelist (list) – List of all gene names
  • proteinlist (list) – List of all protein names
  • outPrefix (str) – Name of output folder.
  • icsDF (pandas DataFrame) – Dataframe specifying initial condition for simulation
  • nClusters (int) – Number of expected trajectories. Used to perform k-means clustering
  • x_max (float) – max value of gene. By default 2.0, will vary if parameters are sampled
  • doParallel (bool) – Bool specifying starting simulations in parallel
  • burnin (bool) – Bool specifying that initial fraction of simulation should be discarded. Obsolete
  • writeProtein (bool) – Bool specifying if the protein values should be written to file. Default = False
  • normalizeTrajectory (bool) – Bool specifying if the gene expression values should be scaled between 0 and 1.
src.BoolODE.generateModelDict(DF, identicalPars, samplePars, sampleStd, withoutRules, speciesTypeDF, parameterInputsDF, parameterSetDF, interactionStrengthDF)[source]

Take a DataFrame object with Boolean rules, construct ODE equations for each variable. Takes optional parameter inputs and interaction strengths

Parameters:
  • DF (pandas DataFrame) – Table of values with two columns, ‘Gene’ specifies target, ‘Rule’ specifies Boolean function
  • identicalPars (bool) – Passed to utils.getSaneNval to set identical parameters
  • samplePars (bool) – Sample kinetic parameters using a Gaussian distribution centered around the default parameters
  • sampleStd (float) – Sample from a distribution of mean=par, sigma=sampleStd*par
  • speciesTypeDF (pandas DataFrame) – Table defining type of each species. Takes values ‘gene’ or ‘protein’
  • parameterInputsDF (pandas DataFrame) – Optional table that specifies parameter input values. Useful to specify experimental conditions.
  • parameterSetDF (pandas DataFrame) – Optional table that specifies a predefined parameter set.
  • interactionStrengthDF (pandas DataFrame) – Optional table that specifies interaction strengths. When not specified, default strength is set to 1.
Returns:

ModelSpec : dict

Dictionary of dictionaries. ‘varspecs’ {variable:ODE equation} ‘ics’ {variable:initial condition} ‘pars’ {parameter:parameter value}

src.BoolODE.getInitialCondition(ss, ModelSpec, rnaIndex, proteinIndex, genelist, proteinlist, varmapper, revvarmapper)[source]

Calculate the initial values of all state variables. Takes into consideration user defined initial conditions, and computes the steady states of the protein variables based on the estimated values of their corresponding genes.

Parameters:
  • ss (ndarray) – Steady state array
  • ModelSpec (dict) – Dictionary of dictionary specifying the ODE model, containing parameters, initial conditions and equations.
  • rnaIndex (list) – list of indices of genes
  • proteinIndex (list) – List of indices of proteins
  • genelist (list) – List of names of all genes in the model
  • proteinlist (list) – List of names of all proteins in the model
  • varmapper (dict) – Mapper: {variable name : index}
  • revvarmapper (dict) – Mapper: {index : variable name}
Returns:

  • newics: List containing new initial conditions

src.BoolODE.getParameters(DF, identicalPars, samplePars, sampleStd, genelist, proteinlist, withoutRules, parameterInputsDF, parameterSetDF, interactionStrengthDF)[source]

Create dictionary of parameters and values. Assigns parameter values by evaluating the Boolean expression for each variable.

Parameters:
  • DF (pandas DataFrame) – Table of values with two columns, ‘Gene’ specifies target, ‘Rule’ specifies Boolean function
  • identicalPars (bool) – Passed to utils.getSaneNval to set identical parameters
  • samplePars (bool) – Sample kinetic parameters using a Gaussian distribution centered around the default parameters
  • parameterInputsDF (pandas DataFrame) – Optional table that specifies input parameter values. Useful to specify experimental conditions.
  • parameterSetDF (pandas DataFrame) – Optional table that specifies predefined parameter set.
  • interactionStrengthDF (pandas DataFrame) – Optional table that specifies interaction strengths. When not specified, default strength is set to 1.
Returns:

pars : dict

Dictionary of parameters

src.BoolODE.main(args)[source]
src.BoolODE.parseArgs(args)[source]
src.BoolODE.readBooleanRules(path, parameterInputsPath, outPrefix='', add_dummy=False, max_parents=1)[source]

Reads a rule file from path and stores the rules in a dictionary

Parameters:
  • path (str) – Path to Boolean Rule file
  • parameterInputsPath (str) – Path to file containing input parameters to the model
  • add_dummy (bool) – Experimental feature, adds dummy targets to each gene in the model. Useful to change the density of the network
  • max_parents (int) – Experimental feature, specifies number of parent genes per dummy gene added
Returns:

  • DF: Dataframe containing rules
  • withoutrules: list of nodes in input file without rules

src.BoolODE.simulateAndSample(argdict)[source]
src.BoolODE.simulateModel(Model, y0, parameters, isStochastic, tspan, seed)[source]

Call numerical integration functions, either odeint() from Scipy, or simulator.eulersde() defined in simulator.py. By default, stochastic simulations are carried out using simulator.eulersde.

Parameters:
  • Model (function) – Function defining ODE model
  • y0 (array) – array of initial values for each state variable
  • parameters (list) – list of parameter values to be used in simulations
  • isStochastic (bool) – User defined parameter. Default = True, can be turned off to perform ODE simulations.
  • tspan (ndarray) – Time points to simulate
  • seed (float) – Seed to initialize random number generator
Returns:

  • P: Time course from numerical integration

Return type:

ndarray

src.simulator module

src.simulator.deltaW(N, m, h, seed=0)[source]

Generate sequence of Wiener increments for m independent Wiener processes W_j(t) j=0..m-1 for each of N time intervals of length h. From the sdeint implementation

Returns:
  • dW : The [n, j] element has the value W_j((n+1)*h) - W_j(n*h) ( has shape (N, m) )
src.simulator.eulersde(f, G, y0, tspan, pars, seed=0.0, dW=None)[source]

Adapted from sdeint implementation https://github.com/mattja/sdeint/

Parameters:
  • f (function) – function defining ODE model. Should take vector of current state, current time, and list of parameter values as arguments.
  • pars (list) – List of parameter values
  • y0 (list) – list of initial values
  • tspan (ndarray) – Array of timepoints to simulate
  • seed (float) – Seed to initialize random number generator
Returns:

  • y: Array containing the time course of state variables

src.simulator.noise(x, t)[source]

src.utils module

src.utils.generateInputFiles(resultDF, outputfilenames, BoolDF, withoutRules, parameterInputsPath, outPrefix='')[source]

Generates input files required from the Beeline pipeline

Parameters:
  • resultDF (pandas DataFrame) – The simulation output, rows are genes, columns are “cells” or timepoints
  • outputfilenames (list) – List of filenames generated containing individual time courses
  • BoolDF (pandas DataFrame) – Dataframe containing rules
  • withoutrules (list) – List of nodes in input file without rules
  • parameterInputsPath (str) – Specifies if there are any inputs to the model
  • outPrefix (str (Optional)) – Prefix specifying target directory
src.utils.getSaneNval(size, lo=1.0, hi=10.0, mu=2.0, sig=2.0, identicalPars=False)[source]

Generates a gaussian random number which is bounded by lo and hi

Parameters:
  • size (int) – number of random numbers to generate
  • lo (float) – lower bound of sample range
  • hi (float) – upper bound of sample range
  • mu (float) – Mean of Gaussian distribution to be sampled from
  • sigma (float) – Standard deviation of Gausssian distribution to be sampled from
  • identicalPars (bool) – Flag to sample single value and return a list of identical values
Returns:

  • K: list of sampled values

src.utils.get_ss(P)[source]

Return the final time point of the simulated time course

Parameters:P (np.array) – 2-D array containing time course of the model
Returns:
  • ss : np.array containing the last entry in each time series list
src.utils.minmaxnorm(X)[source]

Scales the values in X

Parameters:X (list) – Input list of values to be scaled
Returns:
  • N : list of values scaled between min and max values in input list
src.utils.normalizeData(P)[source]

Calls minmaxnorm() for each time series

Returns:Pnorm : list of scaled values
src.utils.normalizeExp(DF)[source]

Calls minmaxnorm() for each gene across all experiments

Parameters:DF (pd.DataFrame) – Dataframe containing gene expression values as rows, time points as columns
Returns:newDF : DataFrame with values of DF scaled between min and max of DF
src.utils.sampleCellFromTraj(cellid, tspan, P, varmapper, sampleAt, genelist, proteinlist, header, writeProtein=False)[source]

Returns pandas DataFrame with columns corresponding to time points and rows corresponding to genes

src.utils.sampleTimeSeries(num_timepoints, expnum, tspan, P, varmapper, timeIndex, genelist, proteinlist, header, writeProtein=False)[source]

Returns pandas DataFrame with columns corresponding to time points and rows corresponding to genes

src.utils.writeModelToFile(ModelSpec, prefix='')[source]

Writes model to file as a python function, which is then imported.

Parameters:
  • ModelSpec (dict) – ODE equations stored in a dictionary
  • prefix (str) – Optional argument that specifies prefix to model filename
Returns:

  • dir_path : path to output directory

Return type:

str

src.utils.writeParametersToFile(ModelSpec, outPrefix, outname='parameters.txt')[source]

Writes dictionary of parameters to file

Parameters:
  • ModelSpec (dict) – Model definition dictionary containing the keys ‘ics’, ‘pars’, and ‘varspec’
  • outPrefix (str) – Prefix to output folder name
  • outname (str (Optional)) – User defined name for parameters file. Default is parameters.txt