cytoflow.operations.xform_stat¶
Transforms a statistic. xform_stat has one class:
TransformStatisticOp – apply a function to a statistic, making a new statistic.
- class cytoflow.operations.xform_stat.TransformStatisticOp[source]¶
Bases:
traits.has_traits.HasStrictTraitsApply a function to a statistic, creating a new statistic. The function can be applied to the entire statistic, or it can be applied individually to groups of the statistic. The function should take a
pandas.Seriesas its only argument. Return type is arbitrary, but a to be used with the rest ofcytoflowit should probably be a numeric type or an iterable of numeric types.As a special case, if the function returns a
pandas.Serieswith the same index that it was passed, it is interpreted as a transformation. The resulting statistic will have the same length, index names and index levels as the original statistic.- name¶
The operation name. Becomes the first element in the
Experiment.statisticskey tuple.- Type
Str
- statistic¶
The statistic to apply the function to.
- Type
Tuple(Str, Str)
- function¶
The function used to transform the statistic.
functionmust take apandas.Seriesas its only parameter. The return type is arbitrary, but to work with the rest ofcytoflowit should probably be a numeric type or an iterable of numeric types.. Ifstatistic_nameis unset, the name of the function becomes the second in element in theExperiment.statisticskey tuple.- Type
Callable
- statistic_name¶
The name of the function; if present, becomes the second element in the
Experiment.statisticskey tuple.- Type
Str
- by¶
A list of metadata attributes to aggregate the input statistic before applying the function. For example, if the statistic has two indices
TimeandDox, settingby = ["Time", "Dox"]will applyfunctionseparately to each subset of the data with a unique combination ofTimeandDox.- Type
List(Str)
- fill¶
Value to use in the statistic if a slice of the data is empty.
- Type
Any (default = 0)
Examples
>>> stats_op = ChannelStatisticOp(name = "Mean", ... channel = "Y2-A", ... function = np.mean, ... by = ["Dox"]) >>> ex2 = stats_op.apply(ex) >>> log_op = TransformStatisticOp(name = "LogMean", ... statistic = ("Mean", "mean"), ... function = np.log) >>> ex3 = log_op.apply(ex2)
- apply(experiment)[source]¶
Applies
functionto a statistic.- Parameters
experiment (
Experiment) – TheExperimentto apply the operation to- Returns
The same as the old experiment, but with a new statistic that results from applying
functionto the statistic specified instatistic.- Return type