Skip to content

Solution

rma_kinetics.models.Solution

Solution returned from simulation.

Attributes:

Name Type Description
_diffsol Solution

Diffrax solution to wrap (returned by diffeqsolve).

time_units Time

Time enum used to format axis in plots.

conc_units Concentration

Concentration enum used to format axis in plots.

Source code in src/rma_kinetics/models/abstract.py
class Solution(EqxModule):
    """
    Solution returned from simulation.

    Attributes:
        _diffsol (diffrax.Solution): Diffrax solution to wrap (returned by `diffeqsolve`).
        time_units (Time): Time enum used to format axis in plots.
        conc_units (Concentration): Concentration enum used to format axis in plots.
    """
    _diffsol: DiffSol
    time_units: Time
    conc_units: Concentration

    def __getattr__(self, name):
        return getattr(self._diffsol, name)

    @property
    def brain_rma(self):
        """Get Brain RMA trajectory as a jax array."""
        return self._get_species("Brain RMA")

    @property
    def plasma_rma(self):
        """Get Plasma RMA trajectory as a jax array."""
        return self._get_species("Plasma RMA")

    @property
    def tta(self):
        """
        Get tTA trajectory as a jax array.

        Available in solutions from `TetRMA` or `ChemogeneticRMA`.
        """
        return self._get_species("tTA")

    @property
    def dox(self):
        """
        Get dox trajectory as a jax array.

        Available in solutions from `TetRMA` or `ChemogeneticRMA`.
        """
        return self._get_species("Dox")

    @property
    def hm3dq(self):
        """
        Get hM3Dq trajectory as a jax array.

        Available in solutions from `ChemogeneticRMA`.
        """
        return self._get_species("hM3Dq")

    @property
    def cno(self):
        """
        Get CNO trajectory as a jax array.

        Available in solutions from `ChemogeneticRMA`.
        """
        return self._get_species("CNO")

    @property
    def clz(self):
        """
        Get CLZ trajectory as a jax array.

        Available in solutions from `ChemogeneticRMA`.
        """
        return self._get_species("CLZ")

    def plot_plasma_rma(self):
        """Plot plasma RMA simulation."""
        self._plot_species("Plasma RMA")

    def plot_brain_rma(self):
        """Plot brain RMA simulation."""
        self._plot_species("Brain RMA")

    def plot_tta(self):
        """
        Plot tTA simulation.

        Available in solutions from `TetRMA` or `ChemogeneticRMA`.
        """
        self._plot_species("tTA")

    def plot_dox(self):
        """
        Plot dox simulation.

        Available in solutions from `TetRMA` or `ChemogeneticRMA`.
        """
        self._plot_species("Dox")

    def plot_hm3dq(self):
        """
        Plot hM3Dq simulation.

        Available in solutions from `ChemogeneticRMA`.
        """

    def plot_cno(self):
        """
        Plot CNO simulation.

        Available in solutions from `ChemogeneticRMA`.
        """
        self._plot_species("CNO")

    def plot_clz(self):
        """
        Plot CLZ simulation.

        Available in solutions from `ChemogeneticRMA`.
        """
        self._plot_species("CLZ")

    def _get_species(self, label: str):
        idx = SPECIES_MAP[label]
        if self._diffsol.ys is not None and len(self._diffsol.ys) >= idx:
            return self._diffsol.ys[idx]
        else:
            raise ValueError("Solution is empty")

    def _plot_species(self, label: str, vd: float | None = None):
        spc_idx = SPECIES_MAP[label]
        if self._diffsol.ys is not None and len(self._diffsol.ys) >= spc_idx:
            plt.plot(self._diffsol.ts, self._diffsol.ys[spc_idx], 'k')
            plt.xlabel(f"Time ({Time[self.time_units]})")
            plt.ylabel(f"{label} ({Concentration[self.conc_units]})")
            plt.tight_layout()
        else:
            raise ValueError("Solution is empty")

brain_rma property

Get Brain RMA trajectory as a jax array.

plasma_rma property

Get Plasma RMA trajectory as a jax array.

tta property

Get tTA trajectory as a jax array.

Available in solutions from TetRMA or ChemogeneticRMA.

dox property

Get dox trajectory as a jax array.

Available in solutions from TetRMA or ChemogeneticRMA.

hm3dq property

Get hM3Dq trajectory as a jax array.

Available in solutions from ChemogeneticRMA.

cno property

Get CNO trajectory as a jax array.

Available in solutions from ChemogeneticRMA.

clz property

Get CLZ trajectory as a jax array.

Available in solutions from ChemogeneticRMA.

plot_brain_rma()

Plot brain RMA simulation.

Source code in src/rma_kinetics/models/abstract.py
def plot_brain_rma(self):
    """Plot brain RMA simulation."""
    self._plot_species("Brain RMA")

plot_plasma_rma()

Plot plasma RMA simulation.

Source code in src/rma_kinetics/models/abstract.py
def plot_plasma_rma(self):
    """Plot plasma RMA simulation."""
    self._plot_species("Plasma RMA")

plot_tta()

Plot tTA simulation.

Available in solutions from TetRMA or ChemogeneticRMA.

Source code in src/rma_kinetics/models/abstract.py
def plot_tta(self):
    """
    Plot tTA simulation.

    Available in solutions from `TetRMA` or `ChemogeneticRMA`.
    """
    self._plot_species("tTA")

plot_dox()

Plot dox simulation.

Available in solutions from TetRMA or ChemogeneticRMA.

Source code in src/rma_kinetics/models/abstract.py
def plot_dox(self):
    """
    Plot dox simulation.

    Available in solutions from `TetRMA` or `ChemogeneticRMA`.
    """
    self._plot_species("Dox")

plot_hm3dq()

Plot hM3Dq simulation.

Available in solutions from ChemogeneticRMA.

Source code in src/rma_kinetics/models/abstract.py
def plot_hm3dq(self):
    """
    Plot hM3Dq simulation.

    Available in solutions from `ChemogeneticRMA`.
    """

plot_cno()

Plot CNO simulation.

Available in solutions from ChemogeneticRMA.

Source code in src/rma_kinetics/models/abstract.py
def plot_cno(self):
    """
    Plot CNO simulation.

    Available in solutions from `ChemogeneticRMA`.
    """
    self._plot_species("CNO")

plot_clz()

Plot CLZ simulation.

Available in solutions from ChemogeneticRMA.

Source code in src/rma_kinetics/models/abstract.py
def plot_clz(self):
    """
    Plot CLZ simulation.

    Available in solutions from `ChemogeneticRMA`.
    """
    self._plot_species("CLZ")