Skip to content
Snippets Groups Projects
Commit 5cf6da46 authored by pswain's avatar pswain
Browse files

minor doc changes

parent 90a06eec
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@ from postprocessor.core.abc import PostProcessABC
class LineageProcessParameters(ParametersABC):
"""Parameters."""
"""Parameters - none are necessary."""
_defaults = {}
......@@ -21,7 +21,7 @@ class LineageProcess(PostProcessABC):
"""
To analyse lineage data.
Currently bare bones, but extracts lineage information from a signal or a Cells object.
Currently bare bones, but extracts lineage information from a Signal or Cells object.
"""
def __init__(self, parameters: LineageProcessParameters):
......@@ -35,7 +35,7 @@ class LineageProcess(PostProcessABC):
lineage: np.ndarray,
*args,
):
"""Implement method required by PostProcessABC."""
"""Implement method required by PostProcessABC - undefined."""
pass
@classmethod
......@@ -47,9 +47,9 @@ class LineageProcess(PostProcessABC):
**kwargs,
):
"""
Override PostProcess.as_function classmethod.
Override PostProcesABC.as_function method.
Lineage functions require lineage information to be passed if run as functions.
Lineage functions require lineage information to be run as functions.
"""
parameters = cls.default_parameters(**kwargs)
return cls(parameters=parameters).run(
......
......@@ -13,16 +13,10 @@ from postprocessor.core.lineageprocess import (
class buddingsParameters(LineageProcessParameters):
"""Parameter class to obtain budding events.
Parameters
----------
LineageProcessParameters : lineage_location
Location of lineage matrix to be used for calculations.
"""
Parameter class to obtain budding events.
Examples
--------
FIXME: Add docs.
Define the location of lineage information in the h5 file.
"""
......@@ -31,45 +25,44 @@ class buddingsParameters(LineageProcessParameters):
class buddings(LineageProcess):
"""
Calculate buddings in a trap assuming one mother per trap
returns a pandas series with the buddings.
Calculate buddings in a trap assuming one mother per trap.
Return a pandas series with the buddings.
We define a budding event as the moment in which a bud was identified for
the first time, even if the bud is not considered one until later
in the experiment.
We define a budding event as when a bud is first identified.
This bud may not be considered a bud until later in the experiment.
"""
def __init__(self, parameters: buddingsParameters):
"""Initialise buddings."""
super().__init__(parameters)
def run(
self, signal: pd.DataFrame, lineage: np.ndarray = None
) -> pd.DataFrame:
"""TODO."""
lineage = lineage or self.lineage
# Get time of first appearance for all cells
fvi = signal.apply(lambda x: x.first_valid_index(), axis=1)
# Select mother cells in a given dataset
# select traps and mother cells in a given signal
traps_mothers: t.Dict[tuple, list] = {
tuple(mo): [] for mo in lineage[:, :2] if tuple(mo) in signal.index
}
for trap, mother, daughter in lineage:
if (trap, mother) in traps_mothers.keys():
traps_mothers[(trap, mother)].append(daughter)
mothers = signal.loc[
set(signal.index).intersection(traps_mothers.keys())
]
# Create a new dataframe with dimensions (n_mother_cells * n_timepoints)
# create a new dataframe with dimensions (n_mother_cells * n_timepoints)
buddings = pd.DataFrame(
np.zeros((mothers.shape[0], signal.shape[1])).astype(bool),
index=mothers.index,
columns=signal.columns,
)
buddings.columns.names = ["timepoint"]
# Fill the budding events
# get time of first appearance for every cell using Pandas
fvi = signal.apply(lambda x: x.first_valid_index(), axis=1)
# fill the budding events
for mother_id, daughters in traps_mothers.items():
daughters_idx = set(
fvi.loc[
......@@ -82,5 +75,4 @@ class buddings(LineageProcess):
mother_id,
daughters_idx,
] = True
return buddings
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment