cytoflow.operations.color_translation

class cytoflow.operations.color_translation.ColorTranslationOp[source]

Bases: traits.has_traits.HasStrictTraits

Translate measurements from one color’s scale to another, using a two-color or three-color control.

To use, set up the controls dictionary with the channels to convert and the FCS files to compute the mapping. Call estimate() to paramterize the module; check that the plots look good by calling the plot() method of the ColorTranslationDiagnostic instance returned by default_view(); then call apply() to apply the translation to an Experiment.

controls

Two-color controls used to determine the mapping. They keys are tuples of from-channel and to-channel. The values are FCS files containing two-color constitutive fluorescent expression data for the mapping.

Type:Dict((Str, Str), File)
mixture_model

If True, try to model the from channel as a mixture of expressing cells and non-expressing cells (as you would get with a transient transfection), then weight the regression by the probability that the the cell is from the top (transfected) distribution. Make sure you check the diagnostic plots to see that this worked!

Type:Bool (default = False)
linear_model

Set this to True to get a scaling that is strictly multiplicative, mirroring the TASBE approach. Do check the diagnostic plot, though, to see how well (or poorly) your model fits the data.

Type:Bool (default = False)
control_conditions

Occasionally, you’ll need to specify the experimental conditions that the bleedthrough tubes were collected under (to apply the operations in the history.) Specify them here. The key is a tuple of channel names; the value is a dictionary of the conditions (same as you would specify for a Tube )

Type:Dict((Str, Str), Dict(Str, Any))

Notes

In the TASBE workflow, this operation happens after the application of AutofluorescenceOp and BleedthroughLinearOp. The entire operation history of the Experiment that is passed to estimate() is replayed on the control files in controls, so they are also corrected for autofluorescence and bleedthrough, and have metadata for subsetting.

Examples

Create a small experiment:

>>> import cytoflow as flow
>>> import_op = flow.ImportOp()
>>> import_op.tubes = [flow.Tube(file = "tasbe/mkate.fcs")]
>>> ex = import_op.apply()

Create and parameterize the operation

>>> color_op = flow.ColorTranslationOp()
>>> color_op.controls = {("Pacific Blue-A", "FITC-A") : "tasbe/rby.fcs",
...                      ("PE-Tx-Red-YG-A", "FITC-A") : "tasbe/rby.fcs"}
>>> color_op.mixture_model = True

Estimate the model parameters

>>> color_op.estimate(ex)

Plot the diagnostic plot

>>> color_op.default_view().plot(ex)
_images/cytoflow-operations-color_translation-4.png

Apply the operation to the experiment

>>> ex = color_op.apply(ex)
estimate(experiment, subset=None)[source]

Estimate the mapping from the two-channel controls

Parameters:
  • experiment (Experiment) – The Experiment used to check the voltages, etc. of the control tubes. Also the source of the operation history that is replayed on the control tubes.
  • subset (Str) – A Python expression used to subset the controls before estimating the color translation parameters.
apply(experiment)[source]

Applies the color translation to an experiment

Parameters:experiment (Experiment) – the old_experiment to which this op is applied
Returns:a new experiment with the color translation applied. The corrected channels also have the following new metadata:

channel_translation : Str Which channel was this one translated to?

channel_translation_fn : Callable (pandas.Series –> pandas.Series) The function that translated this channel

Return type:Experiment
default_view(**kwargs)[source]

Returns a diagnostic plot to see if the bleedthrough spline estimation is working.

Returns:A diagnostic view, call ColorTranslationDiagnostic.plot() to see the diagnostic plots
Return type:IView
class cytoflow.operations.color_translation.ColorTranslationDiagnostic[source]

Bases: traits.has_traits.HasStrictTraits

name

The instance name (for serialization, UI etc.)

Type:Str
op

The op whose parameters we’re viewing

Type:Instance(ColorTranslationOp)
subset

A Python expression specifying a subset of the events in the control FCS files to plot

Type:str
plot(experiment, **kwargs)[source]

Plot the plots

Parameters:experiment (Experiment)