Patient-specific modeling (pasmopy.patient_model)

class pasmopy.patient_model.PatientModelSimulations(path_to_models, patients, biomass_kws=None)

Run simulations of patient-specific models.

biomass_kws

Keyword arguments to pass to biomass.run_simulation.

Type

dict, optional

response_characteristics

A dictionary containing functions to extract dynamic response characteristics from time-course simulations.

Type

dict[str, Callable[[1d-array], int ot float]]

run(n_proc=None, context='spawn', progress=True)

Run simulations of multiple patient-specific models in parallel.

Parameters
  • n_proc (int, optional) – The number of worker processes to use.

  • context (Literal["spawn", "fork", "forkserver"] (default: "spawn")) – The context used for starting the worker processes.

  • progress (bool (default: True)) – If True, the progress indicator will be shown.

Return type

None

subtyping(fname, dynamical_features, normalization=None, progress=True, *, clustermap_kws=None)

Classify patients based on dynamic characteristics extracted from simulation results.

Parameters
  • fname (str, path-like or None) – The clustermap is saved as fname if it is not None.

  • dynamical_features (Dict[str, Dict[str, List[str]]]) – {"observable": {"condition": ["metric", ...], ...}, ...}. Characteristics in the signaling dynamics used for classification.

  • normalization (dict, optional (default: None)) –

    • ‘timepoint’Optional[int]

      The time point at which simulated values are normalized. If None, the maximum value will be used for normalization.

    • ’condition’list of strings

      The experimental conditions to use for normalization. If empty, all conditions defined in sim.conditions will be used.

  • progress (bool (default: True)) – If True, the progress indicator will be shown.

  • clustermap_kws (dict, optional) – Keyword arguments to pass to seaborn.clustermap().

Examples

Subtype classification

>>> with open("models/breast/sample_names.txt", mode="r") as f:
...    TCGA_ID = f.read().splitlines()
>>> from pasmopy import PatientModelSimulations
>>> simulations = PatientModelSimulations("models.breast", TCGA_ID)
>>> simulations.subtyping(
...    "subtype_classification.pdf",
...    {
...        "Phosphorylated_Akt": {"EGF": ["max"], "HRG": ["max"]},
...        "Phosphorylated_ERK": {"EGF": ["max"], "HRG": ["max"]},
...        "Phosphorylated_c-Myc": {"EGF": ["max"], "HRG": ["max"]},
...    },
...    {
...        "Phosphorylated_Akt": {"timepoint": None, "condition": ["EGF", "HRG"]},
...        "Phosphorylated_ERK": {"timepoint": None, "condition": ["EGF", "HRG"]},
...        "Phosphorylated_c-Myc": {"timepoint": None, "condition": ["EGF", "HRG"]},
...    },
...    clustermap_kws={"figsize": (9, 12)}
... )

Add new characteristics

>>> import numpy as np
>>> def get_droprate(time_course: np.ndarray) -> float:
...     return - (time_course[-1] - np.max(time_course)) / (len(time_course) - np.argmax(time_course))
>>> simulations.response_characteristics["droprate"] = get_droprate
class pasmopy.patient_model.PatientModelAnalyses(path_to_models, patients, biomass_kws=None)

Run analyses of patient-specific models.

biomass_kws

Keyword arguments to pass to biomass.run_analysis.

Type

dict, optional

run(n_proc=None, context='spawn', progress=True)

Run analyses of multiple patient-specific models in parallel.

Parameters
  • n_proc (int, optional) – The number of worker processes to use.

  • context (Literal["spawn", "fork", "forkserver"] (default: "spawn")) – The context used for starting the worker processes.

  • progress (bool (default: True)) – If True, the progress indicator will be shown.

Return type

None