Skip to content
Snippets Groups Projects
Commit 048d4c47 authored by Alán Muñoz's avatar Alán Muñoz
Browse files

update to latest format and document

Former-commit-id: 7704b4f09669e8610b9a7ca49e3d200c4ec9bcca
parent 38dd18be
No related branches found
No related tags found
No related merge requests found
......@@ -12,18 +12,22 @@ class aggregateParameters(ParametersABC):
reduction: str to be passed to a dataframe for collapsing across columns
"""
def __init__(self, reductions):
def __init__(self, reductions, axis, ranges):
super().__init__()
self.reductions = reductions
self.axis = axis
self.ranges = ranges
@classmethod
def default(cls):
return cls.from_dict({"reductions": ["mean", "median", "max"]})
return cls.from_dict(
{"reductions": ["mean", "median", "max"], "axis": 1, "ranges": None}
)
class aggregate(ProcessABC):
"""
aggregate multiple datasets
Aggregate multiple datasets for cell-to-cell feature comparison.
"""
def __init__(self, parameters: aggregateParameters):
......@@ -62,13 +66,25 @@ class aggregate(ProcessABC):
]
concat = pd.concat(
[
getattr(signal, red)(axis=1)
getattr(signal, red)(axis=self.parameters.axis)
for signal in signals
for red in self.parameters.reductions
],
names=signals[0].index.names,
axis=1,
axis=self.parameters.axis,
)
concat.columns = colnames
if self.parameters.axis:
concat.columns = colnames
else:
concat.columns = pd.MultiIndex.from_product(
(
colnames,
[
"_".join((str(start), str(stop)))
for x in self.parameters.ranges
for start, stop in x
],
)
)
return concat
#!/usr/bin/env python3
import pandas as pd
from agora.io.base import ParametersABC, ProcessABC
class birthsParameters(ParametersABC):
"""
:window: Number of timepoints to consider for signal.
"""
def __init__(self):
pass
@classmethod
def default(cls):
return cls.from_dict({})
class births(ProcessABC):
"""
Calculate the change in a signal depending on a window
"""
def __init__(self, parameters: birthsParameters):
super().__init__(parameters)
def run(self, signal: pd.DataFrame):
pass
import pandas as pd
from postprocessor.core.processes.base import ParametersABC, ProcessABC
from agora.base import ParametersABC, ProcessABC
class dsignalParameters(ParametersABC):
......
......@@ -123,9 +123,6 @@ class PostProcessorParameters(ParametersABC):
return cls(targets=targets, parameters=parameters, outpaths=outpaths)
def to_dict(self):
return {k: _if_dict(v) for k, v in self.__dict__.items()}
class PostProcessor:
def __init__(self, filename, parameters):
......@@ -162,8 +159,8 @@ class PostProcessor:
@staticmethod
def get_parameters(process):
"""
Dynamically import a process class from the 'processes' folder.
Assumes process filename and class name are the same
Dynamically import parameters from the 'processes' folder.
Assumes parameter is the same name as the file with 'Parameters' added at the end.
"""
return locate(
"postprocessor.core.processes." + process + "." + process + "Parameters"
......
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