cytoflow.operations.mst#
Apply a polygon gate to a minimum spanning tree.
mst has two classes:
ConditionSelectionOp– Applies a gate to a (categorical) condition, creatinga new (boolean) condition that is
Trueif the event’s value for the categorical condition is in thevaluesattribute.
MSTOp – Applies a gate based on a polygon drawn on an MST.
MSTSelectionView – an IView that allows you to view the
polygon and/or interactively set the vertices on an MST.
- class cytoflow.operations.mst.ConditionSelectionOp[source]#
Bases:
HasTraitsApply a gate to a categorical condition. Creates a new boolean condition named
name, which isTrueif the event’s value forconditionis incondition_values.- name#
The operation name. Used to name the new metadata field in the experiment that’s created by
apply- Type:
Str
- condition#
The condition to apply the gate to.
- Type:
Str
Notes
This is intended to be a base class for
MSTOp. I’m not sure if it will be useful for additional derived classes, but I figured I’d architect it to make that straightforward.- apply(experiment)[source]#
Applies the gate to an experiment.
- Parameters:
experiment (Experiment) – the old
Experimentto which this op is applied- Returns:
a new ‘Experiment`, the same as
experimentbut with a new column of typeboolwith the same as the operation name. The bool isTrueif the event’s value of theconditioncondition is incondition_values, andFalseotherwise.- Return type:
- Raises:
CytoflowOpError – if for some reason the operation can’t be applied to this experiment. The reason is in the
argsattribute.
- class cytoflow.operations.mst.MSTOp[source]#
Bases:
ConditionSelectionOpApply a gate to a polygon drawn around a minimum spanning tree.
The only attribute is
name– everything else is set by the default view, which inheritsMSTView.- name#
The operation name. Used to name the new metadata field in the experiment that’s created by
apply- Type:
Str
- condition#
The condition to apply the gate to.
- Type:
Str
- apply(experiment)[source]#
Applies the gate to an experiment.
- Parameters:
experiment (Experiment) – the old
Experimentto which this op is applied- Returns:
a new ‘Experiment`, the same as
experimentbut with a new column of typeboolwith the same as the operation name. The bool isTrueif the event’s value of theconditioncondition is incondition_values, andFalseotherwise.- Return type:
- Raises:
CytoflowOpError – if for some reason the operation can’t be applied to this experiment. The reason is in the
argsattribute.
- class cytoflow.operations.mst.MSTSelectionView[source]#
Bases:
MSTView- op#
The
IOperationthat this view is associated with. If you created the view usingdefault_view, this is already set.- Type:
Instance(
IOperation)
- statistic#
The statistic to plot. Must be a key in
Experiment.statistics.- Type:
Str
- locations#
A statistic whose levels are the same as
statisticand whose features are the dimensions of the locations of each node to plot.- Type:
Str
- .. note
same as the levels of
locations. Ifstyleispieorpetal, the levels ofstatisticmust be the levels oflocationsplusvariable.
- locations_level#
Which level in the
locationsstatistic is different at each location? The values of the others must be specified in theplot_nameparameter ofplot. Optional if there is only one level inlocations.- Type:
Str
- locations_features#
Which features in
locationsto use. By default, use all of them.- Type:
List(Str)
- .. warning
The
KMeansOpstatistic is mostly locations, but also has the a Proportion feature. You likely don’t want to use it as a location for laying out the minimum spanning tree!- Type:
:
- variable#
The variable used for plotting pie and petal plots. Must be left empty for a heatmap.
- Type:
Str
- feature#
The column in the statistic to plot (often a channel name.)
- Type:
Str
- style#
What kind of plot to make?
- Type:
Enum(
heat,pie,petal) (default =heat)
- scale#
For a heat map, how should the color of
featurebe scaled before plotting? For pie and petal maps, how should the input data be normalized to [0,1] before plotting?- Type:
{‘linear’, ‘log’, ‘logicle’}
- size_function#
If set, separate the
Experimentinto subsets by levels oflocations, compute a function on them, and scale the size of each tree node by those values. The callable should take a singlepandas.DataFrameargument and return a positivefloator value that can be cast tofloat(such asint). Of particular use islen, which will scale the cells by the number of events in each subset.- Type:
Callable (default: None)
- metric#
What metric should be used to compute distance in the tree? Must be one of
braycurtis,canberra,chebyshev,cityblock,correlation,cosine,dice,euclidean,hamming,jaccard,jensenshannon,kulczynski1,mahalanobis,matching,minkowski,rogerstanimoto,russellrao,seuclidean,sokalmichener,sokalsneath,sqeuclidean,yule. Suggestion: useeuclideanfor small numbers of dimensions (location features) andcosinefor larger numbers.- Type:
Str (default:
euclidean)
- subset#
An expression that specifies the subset of the statistic to plot. Passed unmodified to
pandas.DataFrame.query.- Type:
- plot(experiment, **kwargs)[source]#
Plot a chart of a variable’s values against a statistic.
- Parameters:
experiment (Experiment) – The
Experimentto plot using this view.plot_name (str) – If this
IViewcan make multiple plots,plot_nameis the name of the plot to make. Must be one of the values retrieved fromenum_plots.title (str) – Set the plot title
legend (bool) – Plot a legend or color bar? Defaults to
True.legendlabel (str) – Set the label for the color bar or legend
palette (palette name) – Colors to use for the different levels of the hue variable. Should be something that can be interpreted by
seaborn.color_palette. If plotting a heat map, this should be a continuous color map (‘viridis’ is the default.) Otherwise, choose either a discrete color map (‘deep’ is the default) or a continuous color map from which equi-spaced colors will be drawn.radius (float) – The radius of the circle or pie plots, on a scale from 0 to 1.
All other parameters are passed to the `matplotlib.patches.Circle` or
`matplotlib.patches.Wedge` construtors (ie, they should be patch attributes).