robustnet.sensitivity ===================== .. py:module:: robustnet.sensitivity .. autoapi-nested-parse:: Define class for robusness analysis. Attributes ---------- .. autoapisummary:: robustnet.sensitivity.DEFAULT_FOLD_CHANGE Classes ------- .. autoapisummary:: robustnet.sensitivity.EnsembleSimulator Module Contents --------------- .. py:data:: DEFAULT_FOLD_CHANGE :value: (0.2, 5) .. py:class:: EnsembleSimulator(model, exclude_metabs=None) Bases: :py:obj:`robustnet.kinetics.Simulator` Implement the continuation method to evaluate the effects of parameter perturbations on a metabolic system. Enzyme concentrations are treated as perturbation parameters in the robustness analysis. .. py:method:: _get_plural(test_list) .. py:method:: _select_parameter_sets(n_models, rng_seed=None) Check whether sufficient parameter sets are available for ``n_models``. If enough parameter sets are available, randomly select ``n_models`` sets. Otherwise, use all available parameter sets. .. py:method:: _check_metabolite_set_inclusion(ini_x_set) Check whether sampled initial concentrations are available for all metabolites included in the analysis, and reorder them according to ``self.stoy_mat.index``. .. py:method:: _check_enzyme_set_inclusion(e_conc_set) Check whether sampled concentrations are available for all enzymes included in the analysis, and reorder them according to ``self.enz_vars``. .. py:method:: _check_kinetic_parameter_set_inclusion(kparam_set) Check whether sampled values are available for all kinetic parameters required in the analysis, and reorder them according to ``self.kparams``. .. py:method:: _check_influx_set_inclusion(vin_set) Check whether sampled influxes are available for all initial substrates, and reorder them according to ``self.ini_subs``. .. py:method:: _check_efflux_set_inclusion(vout_set) Check whether sampled effluxes are available for all final products, and reorder them according to ``self.fin_pros``. .. py:method:: _check_fold_change(bounds) .. py:method:: _get_perturbation_bounds(perturb_enzymes, fold_change) Get relative enzyme concentration levels corresponding to the left and right perturbation bounds. .. py:method:: _get_split_chunks(*all_sets, n_chunks) .. py:method:: _compute_v(ss_x, e, kparams, vins, vouts, v_fun) Compute the fluxes (including influxes and effluxes). :param ss_x: Steady-state metabolite concentrations ordered according to ``self.stoy_mat.index``. If two-dimensional, columns correspond to metabolites also in order of ``self.stoy_mat.index``. :type ss_x: numpy.array :param e: Enzyme concentrations ordered according to ``self.enz_vars``. If two-dimensional, columns correspond to enzymes also in order of ``self.enz_vars``. :type e: numpy.array :param kparams: Kinetic parameters ordered according to ``self.kparams``. :type kparams: numpy.array :param vins: Influx rates for initial substrates ordered according to ``self.ini_subs``. :type vins: numpy.array :param vouts: Efflux rates for final products ordered according to ``self.fin_pros``. :type vouts: numpy.array :param v_fun: Callable function that computes the fluxes. :type v_fun: callable .. py:method:: _compute_dvdx(ss_x, e, kparams, vins, vouts, dvdx_fun) Compute the derivative of fluxes (including influxes and effluxes) with respect to metabolite concentrations. :param ss_x: Steady-state metabolite concentrations ordered according to ``self.stoy_mat.index``. :type ss_x: numpy.array :param e: Enzyme concentrations ordered according to ``self.enz_vars``. :type e: numpy.array :param kparams: Kinetic parameters ordered according to ``self.kparams``. :type kparams: numpy.array :param vins: Influx rates for initial substrates ordered according to ``self.ini_subs``. :type vins: numpy.array :param vouts: Efflux rates for final products ordered according to ``self.fin_pros``. :type vouts: numpy.array :param dvdx_fun: Callable function that computes derivatives of fluxes with respect to metabolite concentrations. :type dvdx_fun: callable .. py:method:: _compute_dvde(ss_x, e, kparams, vins, vouts, dvde_fun) Compute the derivative of fluxes (including influxes and effluxes) with respect to enzyme concentrations. :param ss_x: Steady-state metabolite concentrations ordered according to ``self.stoy_mat.index``. :type ss_x: numpy.array :param e: Enzyme concentrations ordered according to ``self.enz_vars``. :type e: numpy.array :param kparams: Kinetic parameters ordered according to ``self.kparams``. :type kparams: numpy.array :param vins: Influx rates for initial substrates ordered according to ``self.ini_subs``. :type vins: numpy.array :param vouts: Efflux rates for final products ordered according to ``self.fin_pros``. :type vouts: numpy.array :param dvde_fun: Callable function that computes derivatives of fluxes with respect to enzyme concentrations. :type dvde_fun: callable .. py:method:: _euler(x_ini, v_ini, e_ini, steps, Sr, L, compute_dvdx, compute_dvde, compute_v, flux_sensitivity=True, check_jacobian=True, tol=-1e-09, check_metabolite=True) Solve an IVP using the Euler method. :param steps: Perturbation step sizes for enzymes with shape ``(n_steps, n_enzymes)``. :type steps: 2-D numpy.array :param flux_sensitivity: If ``True``, derivatives of steady-state fluxes with respect to enzyme concentrations are also computed. :type flux_sensitivity: bool, optional :param check_jacobian: If ``True``, the maximum real parts of Jacobian eigenvalues are checked during perturbation, and matrix inversion is used. If ``False``, the pseudoinverse is used when the Jacobian is singular or noninvertible. :type check_jacobian: bool, optional :param check_metabolite: If ``True``, metabolite concentrations are checked to remain positive during perturbation. :type check_metabolite: bool, optional :returns: * **x_sol** (*2-D numpy.array*) -- Simulated metabolite concentrations with shape ``(n_steps, self.stoy_mat.shape[0])``. Rows correspond to perturbation steps and columns correspond to metabolites. ``x_sol`` stores values for steps ``1`` through ``n_steps``. An empty array indicates an invalid model at the initial state. * **v_sol** (*2-D numpy.array*) -- Simulated fluxes, including influxes and effluxes, with shape ``(n_steps, self.aug_stoy_mat.shape[1])``. Rows correspond to perturbation steps and columns correspond to reactions. ``v_sol`` stores values for steps ``1`` through ``n_steps``. An empty array indicates an invalid model at the initial state. * **max_reals** (*1-D numpy.array*) -- Maximum real parts of Jacobian eigenvalues for each perturbation step, with shape ``(n_steps,)``. ``max_reals`` stores values for steps ``0`` through ``n_steps - 1``. An empty array indicates an invalid model at the initial state. .. py:method:: _solve_sensitivity(ss_x_ini, e_ini, kparams, vins, vouts, rel_lbs, rel_rbs, n_steps=100, log_spacing=False, flux_sensitivity=True, check_jacobian=True, check_metabolite=True) Solve sensitivity of steady state metabolite concentrations and fluxes with respect to enzyme concentrations based on the continuation method. :param ss_x_ini: Initial steady-state metabolite concentrations ordered according to ``self.stoy_mat.index``. :type ss_x_ini: numpy.array :param e_ini: Initial enzyme concentrations ordered according to ``self.enz_vars``. :type e_ini: numpy.array :param kparams: Kinetic parameters ordered according to ``self.kparams``. :type kparams: numpy.array :param vins: Influx rates for initial substrates ordered according to ``self.ini_subs``. :type vins: numpy.array :param vouts: Efflux rates for final products ordered according to ``self.fin_pros``. :type vouts: numpy.array :param rel_lbs: Relative left and right perturbation bounds for enzyme concentrations ordered according to ``self.enz_vars``. If ``lb == rb``, the corresponding enzyme is not perturbed. :type rel_lbs: numpy.array :param rel_rbs: Relative left and right perturbation bounds for enzyme concentrations ordered according to ``self.enz_vars``. If ``lb == rb``, the corresponding enzyme is not perturbed. :type rel_rbs: numpy.array :param n_steps: Number of integration step. :type n_steps: int :param log_spacing: If ``True``, perturbation points are logarithmically spaced. Otherwise, they are evenly spaced. :type log_spacing: bool, optional :param flux_sensitivity: If ``True``, derivatives of steady-state fluxes with respect to enzyme concentrations are also computed. :type flux_sensitivity: bool, optional :param check_jacobian: If ``True``, verify that all Jacobian eigenvalues have negative real parts. :type check_jacobian: bool, optional :param check_metabolite: If ``True``, enforce positive metabolite concentrations during perturbation. :type check_metabolite: bool, optional .. py:method:: _simulation_worker(ini_x_set, e_conc_set, kparam_set, vin_set, vout_set, rel_lbs, rel_rbs, n_steps=100, log_spacing=False, flux_sensitivity=True, check_jacobian=True, check_metabolite=True) Simulation worker for sensitivity analysis in parallel. :param ini_x_set: Sampled sets of initial metabolite concentrations. :type ini_x_set: pandas.DataFrame :param e_conc_set: Sampled sets of enzyme concentrations. :type e_conc_set: pandas.DataFrame :param kparam_set: Sampled sets of kinetic parameters. :type kparam_set: pandas.DataFrame :param vin_set: Sampled sets of influx for initial substrates. :type vin_set: pandas.DataFrame :param vout_set: Sampled sets of efflux for final products. :type vout_set: pandas.DataFrame :param rel_lbs: Left fold-change perturbation bounds for enzyme concentrations. :type rel_lbs: numpy.array :param rel_rbs: Right fold-change perturbation bounds for enzyme concentrations. :type rel_rbs: numpy.array :param n_steps: Number of integration steps in perturbations toward the left and right directions, respectively. :type n_steps: int :param log_spacing: If ``True``, perturbation points are logarithmically spaced. Otherwise, they are evenly spaced. :type log_spacing: bool, optional :param flux_sensitivity: If ``True``, derivatives of steady-state fluxes with respect to enzyme concentrations are also computed. :type flux_sensitivity: bool, optional :param check_jacobian: If ``True``, verify that all Jacobian eigenvalues have negative real parts. :type check_jacobian: bool, optional :param check_metabolite: If ``True``, enforce positive metabolite concentrations during perturbation. :type check_metabolite: bool, optional .. py:method:: simulate(perturb_enzymes, fold_change, n_steps, log_spacing, n_models, n_jobs, flux_sensitivity=True, check_jacobian=True, check_metabolite=True) Simulate perturbation responses and evaluate the robustness of the metabolic system with respect to enzyme expression perturbations. :param perturb_enzymes: Enzymes perturbed during robustness analysis. :type perturb_enzymes: list of str or "all", optional :param fold_change: Fold-change perturbation bounds for enzyme concentrations. :type fold_change: 2-tuple or dict :param n_steps: Number of integration steps in perturbations toward the left and right directions, respectively. :type n_steps: int :param log_spacing: If ``True``, perturbation points are logarithmically spaced. Otherwise, they are evenly spaced. :type log_spacing: bool, optional :param n_models: Number of sampled models used in the simulation. Increasing this value may improve consensus robustness estimates. Note that the maximum number of models is limited by the number of loaded parameter sets. :type n_models: int :param n_jobs: Number of parallel jobs. :type n_jobs: int :param flux_sensitivity: If ``True``, derivatives of steady-state fluxes with respect to enzyme concentrations are also computed. :type flux_sensitivity: bool, optional :param check_jacobian: If ``True``, verify that all Jacobian eigenvalues have negative real parts. :type check_jacobian: bool, optional :param check_metabolite: If ``True``, enforce positive metabolite concentrations during perturbation. :type check_metabolite: bool, optional