cytoflow.operations.frame_stat#
The frame_stat module contains one class:
FrameStatisticOp – applies a function to subsets of a data set,
and adds the resulting statistic to the Experiment. Unlike
ChannelStatisticOp, which operates on a single channel, this operation
operates on entire pandas.DataFrame.
- class cytoflow.operations.frame_stat.FrameStatisticOp[source]#
Bases:
HasStrictTraitsApply a function to subsets of a data set, and add it as a statistic to the experiment.
The
applyfunction groups the data by the variables inby, then applies thefunctioncallable to eachpandas.DataFramesubset. The callable should take apandas.DataFrameas its only parameter and return apandas.Serieswhose values arefloat. The columns of the resulting statistic come from the index (ie, the row names) of the firstpandas.Seriesto be returned.- name#
The operation name. Becomes the first element in the
Experiment.statisticskey tuple.- Type:
Str
- function#
The function used to compute the statistic. Must take a
pandas.DataFrameas its only argument and return apandas.Seriescontainingfloatvalues. The row names of this series will become the column names of the new statistic.- Type:
Callable
- by#
A list of metadata attributes to aggregate the data before applying the function. For example, if the experiment has two pieces of metadata,
TimeandDox, settingby = ["Time", "Dox"]will applyfunctionseparately to each subset of the data with a unique combination ofTimeandDox.- Type:
List(Str)
- subset#
A Python expression sent to Experiment.query() to subset the data before computing the statistic.
- Type:
Str
Examples
>>> stats_op = FrameStatisticOp(name = "MeanByDox", ... function = lambda x: x.mean, ... by = ["Dox"]) >>> ex2 = stats_op.apply(ex)