cytoflow.operations.import_op¶
-
class
cytoflow.operations.import_op.
Tube
[source]¶ Bases:
traits.has_traits.HasTraits
Represents a tube or plate well we want to import.
-
file
¶ The file name of the FCS file to import
Type: File
-
conditions
¶ A dictionary containing this tube’s experimental conditions. Keys are condition names, values are condition values.
Type: Dict(Str, Any)
Examples
>>> tube1 = flow.Tube(file = 'RFP_Well_A3.fcs', conditions = {"Dox" : 10.0}) >>> tube2 = flow.Tube(file='CFP_Well_A4.fcs', conditions = {"Dox" : 1.0})
-
-
class
cytoflow.operations.import_op.
ImportOp
[source]¶ Bases:
traits.has_traits.HasStrictTraits
An operation for importing data and making an
Experiment
.To use, set the
conditions
dict to a mapping between condition name and NumPydtype
. Useful dtypes includecategory
,float
,int
,bool
.Next, set
tubes
to a list ofTube
containing FCS filenames and the corresponding conditions.If you would rather not analyze every single event in every FCS file, set
events
to the number of events from each FCS file you want to load.Call
apply()
to load the data. The usualexperiment
parameter can beNone
.-
conditions
¶ A dictionary mapping condition names (keys) to NumPy
dtype``s (values). Useful ``dtype``s include ``category
,float
,int
, andbool
.Type: Dict(Str, Str)
-
tubes
¶ A list of :class:
Tube
instances, which map FCS files to their corresponding experimental conditions. Each :class:Tube
must have a :attr:~Tube.conditions
dict whose keys match those ofconditions
.Type: List(Tube)
-
channels
¶ If you only need a subset of the channels available in the data set, specify them here. Each
(key, value)
pair specifies a channel to include in the output experiment. The key is the channel name in the FCS file, and the value is the name of the channel in the Experiment. You can use this to rename channels as you import data (because flow channel names are frequently not terribly informative.) New channel names must be valid Python identifiers: start with a letter or_
, and all characters must be letters, numbers or_
. Ifchannels
is empty, load all channels in the FCS files.Type: Dict(Str, Str)
-
events
¶ If not None, import only a random subset of events of size
events
. Presumably the analysis will go faster but less precisely; good for interactive data exploration. Then, unsetevents
and re-run the analysis non-interactively.Type: Int
-
name_metadata
¶ Which FCS metadata is the channel name? If
None
, attempt to autodetect.Type: {None, “$PnN”, “$PnS”} (default = None)
-
data_set
¶ The FCS standard allows you to encode multiple data sets in a single FCS file. Some software (such as the Beckman-Coulter software) also encode the same data in two different formats – for example, FCS2.0 and FCS3.0. To access a data set other than the first one, set
data_set
to the 0-based index of the data set you would like to use. This will be used for all FCS files imported by this operation.Type: Int (default = 0)
-
ignore_v
¶ cytoflow
is designed to operate on anExperiment
containing tubes that were all collected under the same instrument settings. In particular, the same PMT voltages ensure that data can be compared across samples.Very rarely, you may need to set up an
Experiment
with different voltage settings on differentTube`s. This is likely only to be the case when you are trying to figure out which voltages should be used in future experiments. If so, set :attr:`ignore_v
to aList
of channel names to ignore particular channels.Warning
THIS WILL BREAK REAL EXPERIMENTS
Type: List(Str)
Examples
>>> tube1 = flow.Tube(file = 'RFP_Well_A3.fcs', conditions = {"Dox" : 10.0}) >>> tube2 = flow.Tube(file='CFP_Well_A4.fcs', conditions = {"Dox" : 1.0}) >>> import_op = flow.ImportOp(conditions = {"Dox" : "float"}, ... tubes = [tube1, tube2]) >>> ex = import_op.apply()
-
apply
(experiment=None, metadata_only=False)[source]¶ Load a new
Experiment
.Parameters: - experiment (Experiment) – Ignored
- metadata_only (bool (default = False)) – Only “import” the metadata, creating an Experiment with all the expected metadata and structure but 0 events.
Returns: The new
Experiment
. New channels have the following metadata:- voltage - int
- The voltage that this channel was collected at. Determined
by the
$PnV
field from the first FCS file.
- range - int
- The maximum range of this channel. Determined by the
$PnR
field from the first FCS file.
New experimental conditions do not have voltage or range metadata, obviously. Instead, they have experiment set to
True
, to distinguish the experimental variables from the conditions that were added by gates, etc.If
ignore_v
is set, it is added as a key to theExperiment
-wide metadata.Return type:
-