Matrix Class

class flowkit.Matrix(matrix_id, spill_data_or_file, detectors, fluorochromes=None, null_channels=None)

Represents a single compensation matrix from a CSV/TSV file, NumPy array or pandas DataFrame.

Parameters:
  • matrix_id – Text string used to identify the matrix (cannot be ‘uncompensated’ or ‘fcs’)

  • spill_data_or_file – matrix data array, can be either: - text string from FCS $SPILL or $SPILLOVER metadata value - a file path or file handle to a CSV/TSF file - a pathlib Path object to a CSV/TSF file - a NumPy array of spill data

  • detectors – A list of strings to use for the detector labels.

  • fluorochromes – A list of strings to use for the fluorochrome labels.

  • null_channels – List of PnN labels for channels that were collected but do not contain useful data. Note, this should only be used if there were truly no fluorochromes used targeting those detectors and the channels do not contribute to compensation.

Public Methods:

__init__(matrix_id, spill_data_or_file, ...)

__repr__()

Return repr(self).

apply(sample)

Apply compensation matrix to given Sample instance.

inverse(sample)

Apply compensation matrix to given Sample instance.

as_dataframe([fluoro_labels])

Returns the compensation matrix as a pandas DataFrame.


apply(sample)

Apply compensation matrix to given Sample instance.

Parameters:

sample – Sample instance with matching set of detectors

Returns:

NumPy array of compensated events

inverse(sample)

Apply compensation matrix to given Sample instance.

Parameters:

sample – Sample instance with matching set of detectors

Returns:

NumPy array of compensated events

as_dataframe(fluoro_labels=False)

Returns the compensation matrix as a pandas DataFrame.

Parameters:

fluoro_labels – If True, the fluorochrome names are used as the column headers & row indices, else the detector names are used (default).

Returns:

pandas DataFrame