FlowCytometryTools.FCOrderedCollection

class FlowCytometryTools.FCOrderedCollection(ID, measurements, position_mapper, shape=(8, 12), positions=None, row_labels=None, col_labels=None)

A dict-like class for holding flow cytometry samples that are arranged in a matrix.

Methods

apply(func[, ids, applyto, output_format, ...]) Apply func to each of the specified measurements.
clear(() -> None.  Remove all items from D.)
clear_measurement_data([ids]) Clear the data in all specified measurements (all if None given).
clear_measurement_meta([ids]) Clear the metadata in all specified measurements (all if None given).
copy([deep]) Make a copy of this object
counts([ids, setdata, output_format]) Return the counts in each of the specified measurements.
dropna() Remove rows and cols that have no assigned measurements.
filter(criteria[, applyto, ID]) Filter measurements according to given criteria.
filter_by_IDs(ids[, ID]) Keep only Measurements with given IDs.
filter_by_attr(attr, criteria[, ID])
filter_by_cols(cols[, ID]) Keep only Measurements in corresponding columns.
filter_by_key(keys[, ID]) Keep only Measurements with given keys.
filter_by_meta(criteria[, ID])
filter_by_rows(rows[, ID]) Keep only Measurements in corresponding rows.
from_dir(ID, path[, file_to_key_parser, ...]) Create a Collection of measurements from data files contained in a directory.
from_files(ID, datafiles[, parser, ...]) Create an OrderedCollection of measurements from a set of data files.
gate(gate[, ID]) Applies the gate to each Measurement in the Collection, returning a new Collection with gated data.
get((k[,d]) -> D[k] if k in D, ...)
get_measurement_metadata(fields[, ids, ...]) Get the metadata fields of specified measurements (all if None given).
get_positions([copy]) Get a dictionary of measurement positions.
grid_plot(func[, applyto, ids, row_labels, ...]) Creates subplots for each well in the plate.
items(() -> list of D’s (key, value) pairs, ...)
iteritems(() -> an iterator over the (key, ...)
iterkeys(() -> an iterator over the keys of D)
itervalues(...)
keys(() -> list of D’s keys)
load(path) Loads object from a pickled file.
plot(channel_names[, kind, transform, ...]) Produces a grid plot with each subplot corresponding to the data at the given position.
pop((k[,d]) -> v, ...) If key is not found, d is returned if given, otherwise KeyError is raised.
popitem(() -> (k, v), ...) as a 2-tuple; but raise KeyError if D is empty.
save(path) Saves objec to a pickled file.
set_data([ids]) Set the data for all specified measurements (all if None given).
set_positions([positions, parser, ids]) checks for position validity & collisions,
setdefault((k[,d]) -> D.get(k,d), ...)
transform(transform[, direction, ...]) Apply transform to each Measurement in the Collection.
update(([E, ...) If E present and has a .keys() method, does: for k in E: D[k] = E[k]
values(() -> list of D’s values)

A dictionary-like container for holding multiple Measurements in a 2D array.

Note that the collection keys are not necessarily identical to the Measurements IDs. Additionally, like a dict, measurement keys must be unique.

Parameters:

ID : hashable

Collection ID

measurements : mappable | iterable

values are measurements of appropriate type (type is explicitly checked for).

position_mapper : [None, callable, mapping, ‘name’, ‘number’]

Accepts a key (which is extracted by the parser), and returns the coordinates in a matrix (measurement collection) that correspond to the key.

For example, the key ‘A1’ corresponds to the matrix coordinate (0, 0).

  • None : use the parser value, if it is a string.
  • callable : gets key and returns position
  • mapping : key:pos
  • ‘name’ : parses things like ‘A1’, ‘G12’
  • ‘number’ : converts number to positions, going over rows first.

shape : 2-tuple

Shape of the 2D array of measurements (rows, cols).

positions : dict | None

Mapping of measurement_key:(row,col) If None is given set positions as specified by the position_mapper arg.

row_labels : iterable of str

If None is given, rows will be labeled ‘A’,’B’,’C’, ...

col_labels : iterable of str

If None is given, columns will be labeled 1,2,3, ...

Methods

apply(func[, ids, applyto, output_format, ...]) Apply func to each of the specified measurements.
clear(() -> None.  Remove all items from D.)
clear_measurement_data([ids]) Clear the data in all specified measurements (all if None given).
clear_measurement_meta([ids]) Clear the metadata in all specified measurements (all if None given).
copy([deep]) Make a copy of this object
counts([ids, setdata, output_format]) Return the counts in each of the specified measurements.
dropna() Remove rows and cols that have no assigned measurements.
filter(criteria[, applyto, ID]) Filter measurements according to given criteria.
filter_by_IDs(ids[, ID]) Keep only Measurements with given IDs.
filter_by_attr(attr, criteria[, ID])
filter_by_cols(cols[, ID]) Keep only Measurements in corresponding columns.
filter_by_key(keys[, ID]) Keep only Measurements with given keys.
filter_by_meta(criteria[, ID])
filter_by_rows(rows[, ID]) Keep only Measurements in corresponding rows.
from_dir(ID, path[, file_to_key_parser, ...]) Create a Collection of measurements from data files contained in a directory.
from_files(ID, datafiles[, parser, ...]) Create an OrderedCollection of measurements from a set of data files.
gate(gate[, ID]) Applies the gate to each Measurement in the Collection, returning a new Collection with gated data.
get((k[,d]) -> D[k] if k in D, ...)
get_measurement_metadata(fields[, ids, ...]) Get the metadata fields of specified measurements (all if None given).
get_positions([copy]) Get a dictionary of measurement positions.
grid_plot(func[, applyto, ids, row_labels, ...]) Creates subplots for each well in the plate.
items(() -> list of D’s (key, value) pairs, ...)
iteritems(() -> an iterator over the (key, ...)
iterkeys(() -> an iterator over the keys of D)
itervalues(...)
keys(() -> list of D’s keys)
load(path) Loads object from a pickled file.
plot(channel_names[, kind, transform, ...]) Produces a grid plot with each subplot corresponding to the data at the given position.
pop((k[,d]) -> v, ...) If key is not found, d is returned if given, otherwise KeyError is raised.
popitem(() -> (k, v), ...) as a 2-tuple; but raise KeyError if D is empty.
save(path) Saves objec to a pickled file.
set_data([ids]) Set the data for all specified measurements (all if None given).
set_positions([positions, parser, ids]) checks for position validity & collisions,
setdefault((k[,d]) -> D.get(k,d), ...)
transform(transform[, direction, ...]) Apply transform to each Measurement in the Collection.
update(([E, ...) If E present and has a .keys() method, does: for k in E: D[k] = E[k]
values(() -> list of D’s values)
plot(channel_names, kind='histogram', transform=(None, None), gates=None, transform_first=True, apply_gates=True, plot_gates=True, gate_colors=None, ids=None, row_labels=None, col_labels=None, xlim=None, ylim=None, autolabel=True, **kwargs)

Produces a grid plot with each subplot corresponding to the data at the given position.

Parameters:

transform : [valid transform | tuple of valid transforms | None]

Transform to be applied to corresponding channels using the FCMeasurement.transform function. If a single transform is given, it will be applied to all plotted channels.

gates : [None | Gate | iterable of Gate]

Gate should be in [ThresholdGate, IntervalGate, QuadGate, PolyGate ]. When supplied, the gates are drawn on the plot. The gates are applied by default.

transform_first : bool

Apply transforms before gating.

channel_names : [str | iterable of str]

The name (or names) of the channels to plot. When one channel is specified, then a 1d histogram is plotted.

kind : [‘scatter’ | ‘histogram’]

Specifies the kind of plot to use for plotting the data (only applies to 2D plots).

autolabel : [False | True]

If True the x and y axes are labeled automatically.

colorbar : [False | True]

Adds a colorbar. Only relevant when plotting a 2d histogram.

xlabel_kwargs : dict

kwargs to be passed to the xlabel() command

ylabel_kwargs : dict

kwargs to be passed to the ylabel() command

Returns:

(ax_main, ax_subplots) :

ax_main : reference to the main axes ax_subplots : matrix of references to the subplots (e.g., ax_subplots[0, 3] references the subplot in row 0 and column 3.)

Examples

Below, plate is an instance of the FCOrderedCollection

>>> plate.plot(['SSC-A', 'FSC-A'], kind='histogram', transform='hlog', autolabel=True)
>>> plate.plot(['SSC-A', 'FSC-A'], transform='hlog', xlim=(0, 10000))
>>> plate.plot(['B1-A', 'Y2-A'], transform='hlog', kind='scatter', color='red', s=1, alpha=0.3)