cytoflow.operations.xform_stat¶

class
cytoflow.operations.xform_stat.
TransformStatisticOp
[source]¶ Bases:
traits.has_traits.HasStrictTraits
Apply 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.Series
as its only argument. Return type is arbitrary, but a to be used with the rest ofcytoflow
it should probably be a numeric type or an iterable of numeric types.As a special case, if the function returns a
pandas.Series
with 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
statistics
key tuple.Type: Str

statistic
¶ The statistic to apply the function to.
Type: Tuple(Str, Str)

function
¶ The function used to transform the statistic.
function
must take apandas.Series
as its only parameter. The return type is arbitrary, but to work with the rest ofcytoflow
it should probably be a numeric type or an iterable of numeric types.. Ifstatistic_name
is unset, the name of the function becomes the second in element in thestatistics
key tuple.Type: Callable

statistic_name
¶ The name of the function; if present, becomes the second element in the
statistics
key 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
Time
andDox
, settingby = ["Time", "Dox"]
will applyfunction
separately to each subset of the data with a unique combination ofTime
andDox
.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 = "Y2A", ... 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
function
to a statistic.Parameters: experiment (Experiment) – The experiment to apply the operation to Returns: The same as the old experiment, but with a new statistic that results from applying function
to the statistic specified instatistic
.Return type: Experiment
