Functions

flowkit.load_samples(fcs_samples)
Returns a list of Sample instances from a variety of input types (fcs_samples), such as file or

directory paths, a Sample instance, or lists of the previous types.

Parameters:

fcs_samples – Sample, str, or list. Allowed types: a Sample instance, list of Sample instances, a directory or file path, or a list of directory or file paths. If a directory, any .fcs files in the directory will be loaded. If a list, then it must be a list of file paths or a list of Sample instances. Lists of mixed types are not supported.

Returns:

list of Sample instances

flowkit.read_multi_dataset_fcs(filename_or_handle, ignore_offset_error=False, ignore_offset_discrepancy=False, use_header_offsets=False, cache_original_events=False)

Utility function for reading all data sets in an FCS file containing multiple data sets.

Parameters:
  • filename_or_handle – a path string or a file handle for an FCS file

  • ignore_offset_error – option to ignore data offset error (see above note), default is False

  • ignore_offset_discrepancy – option to ignore discrepancy between the HEADER and TEXT values for the DATA byte offset location, default is False

  • use_header_offsets – use the HEADER section for the data offset locations, default is False. Setting this option to True also suppresses an error in cases of an offset discrepancy.

  • cache_original_events – Original events are the unprocessed events as stored in the FCS binary, meaning they have not been scaled according to channel gain, corrected for proper lin/log display, or had the time channel scaled by the ‘timestep’ keyword value (if present). By default, these events are not retained by the Sample class as they are typically not useful. To retrieve the original events, set this to True and call the get_events() method with source=’orig’.

  • cache_original_events – Original events are the unprocessed events as stored in the FCS binary, meaning they have not been scaled according to channel gain, corrected for proper lin/log display, or had the time channel scaled by the ‘timestep’ keyword value (if present). By default, these events are not retained by the Sample class as they are typically not useful. To retrieve the original events, set this to True and call the get_events() method with source=’orig’.

Returns:

list of Sample instances

flowkit.parse_gating_xml(xml_file_or_path)

Parse a GatingML 20 document and return as a GatingStrategy.

Parameters:

xml_file_or_path – file handle or file path to a GatingML 2.0 document

Returns:

GatingStrategy instance

flowkit.export_gatingml(gating_strategy, file_handle, sample_id=None)

Exports a valid GatingML 2.0 document from given GatingStrategy instance. Specify the sample ID to use that sample’s custom gates in the exported file, otherwise the template gates will be exported.

Parameters:
  • gating_strategy – A GatingStrategy instance

  • file_handle – File handle for exported GatingML 2.0 document

  • sample_id – an optional text string representing a Sample instance

Returns:

None

flowkit.parse_wsp(workspace_file_or_path)

Converts a FlowJo 10 workspace file (.wsp) into a nested Python dictionary with the following structure:

wsp_dict = {
    'groups': {
        group_name: {
            'samples': sample list,
            'group_gates': list of common group gates (may not be the complete tree)
        },
        ...
    },
    'samples': {
        sample_name: {
            'keywords': dict of FJ sample keywords,
            'compensation': matrix,
            'transforms': dict of transforms (key is parameter name),
            'custom_gate_ids': set of gate IDs,
            'gating_strategy': {gate_id: gate_instance, ...}
        },
        ...
    }
}
Parameters:

workspace_file_or_path – A FlowJo .wsp file or file path

Returns:

dict

flowkit.extract_wsp_sample_data(workspace_file_or_path)

Parses a FlowJo 10 workspace file (.wsp) and extracts Sample metadata (keywords) into a Python dictionary with the following structure:

wsp_sample_dict[sample_name] = {
    'keywords': {gate_id: gate_instance, ...},
    'transforms': transforms_list,
    'compensation': matrix
}
Parameters:

workspace_file_or_path – A FlowJo .wsp file or file path

Returns:

dict