7.1.1.2.1.5. pta.sampling.uniform
Uniform sampling of the flux space of a metabolic network.
7.1.1.2.1.5.1. Module Contents
- class pta.sampling.uniform.UniformSamplingModel(polytope: PolyRound.api.Polytope, reaction_ids: List[str])[source]
Bases:
pta.sampling.primitives.FluxSpaceSamplingModelObject holding the information necessary to run uniform sampling on a flux space.
- Parameters:
polytope (Polytope) – Polytope object describing the flux space.
reaction_ids (List[str]) – Identifiers of the reactions in the flux space.
- classmethod from_cobrapy_model(model: cobra.Model, infinity_flux_bound: float = default_flux_bound) UniformSamplingModel[source]
Builds a uniform sampler model from a cobrapy model.
- Parameters:
model (cobra.Model) – The input cobra model.
infinity_flux_bound (float, optional) – Default bound to use for unbounded fluxes.
- Returns:
The constructed model.
- Return type:
- simulate(settings: _pta_python_binaries.SamplerSettings, initial_points: numpy.ndarray, directions_transform: numpy.ndarray) numpy.ndarray[source]
Run the sampler with the given parameters.
- Parameters:
settings (pb.SamplerSettings) – Sampling settings.
initial_points (np.ndarray) – The initial points for the chains.
directions_transform (np.ndarray) – The transform for the directions sampler.
- compute_psrf(result: numpy.ndarray) pandas.Series[source]
Compute the potential scale reduction factors for the variables of interest on a given set of chains.
- Parameters:
result (np.ndarray) – The result of the sampling function.
- Returns:
The computed potential scale reduction factors.
- Return type:
pd.Series
- get_chains(result: numpy.ndarray) numpy.ndarray[source]
Extract the simulated chains from a given result.
- Parameters:
result (np.ndarray) – The result of the native sampling function.
- Returns:
The simulated chains.
- Return type:
np.ndarray
- pta.sampling.uniform.sample_flux_space_uniform(model: Union[cobra.Model, UniformSamplingModel], num_samples: int = default_num_samples, max_steps: int = -1, max_psrf: float = default_max_psrf, num_chains: int = -1, initial_points: numpy.array = None, num_initial_steps: int = -1, max_threads: int = default_max_threads, convergence_manager: pta.sampling.convergence_manager.ConvergenceManager = None) pta.sampling.commons.SamplingResult[source]
Sample steady state fluxes in the given model. The sampler run until either max_steps or max_psrf is reached.
- Parameters:
model (Union[cobra.Model, UniformSamplingModel]) – The model to sample.
num_samples (int, optional) – Number of samples to draw.
max_steps (int, optional) – The maximum number fo steps to simulate.
max_psrf (float, optional) – Maximum value of the PSRFs for convergence.
num_chains (int, optional) – The number of chains to simulate.
initial_points (np.array, optional) – The initial points for the chains.
num_initial_steps (int, optional) – Initial chains length.
max_threads (int, optional) – The maximum number of parallel threads to use.
convergence_manager (ConvergenceManager, optional) – The object to use to monitor and improve convergence.
- Returns:
The sampling result.
- Return type:
- Raises:
SamplingException – If sampling fails.