cytopy.data.read_write¶
The read_write module contains tools for accessing *.fcs files and relies on the Python library FlowIO by Scott White. This is used by Experiment to population FileGroups.
Projects also house the subjects (represented by the Subject class; see cytopy.data.subject) of an analysis which can contain multiple meta-data.
Copyright 2020 Ross Burton
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Classes:
|
Utilising FlowIO to generate an object for representing an FCS file |
Functions:
|
Yield successive n-sized chunks from l. |
|
Given a directory, explore all fcs files and find all permutations of channel/marker mappings |
|
Fetch channel mappings from fcs file. |
|
Given a directory, return file paths for all fcs files in directory and subdirectories contained within |
|
Generate a standard dictionary object of fcs files in given directory :param fcs_dir: target directory for search :type fcs_dir: str :param control_names: names of expected control files (names must appear in filenames) :type control_names: list :param ctrl_id: global identifier for control file e.g. |
-
class
cytopy.data.read_write.
FCSFile
(filepath, comp_matrix=None)¶ Utilising FlowIO to generate an object for representing an FCS file
-
filepath
¶ location of fcs file to parse
- Type
str
-
comp_matrix
¶ csv file containing compensation matrix (optional, not required if a spillover matrix is already linked to the file)
- Type
str
Methods:
Apply compensation to event data
-
compensate
()¶ Apply compensation to event data
- Returns
- Return type
None
-
-
cytopy.data.read_write.
chunks
(df_list: list, n: int) → pandas.core.frame.DataFrame¶ Yield successive n-sized chunks from l. ref: https://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks
- Parameters
df_list (list) – list of DataFrames to generated ‘chunks’ from
n (int) – number of chunks to generate
- Returns
Yields successive n-sized DataFrames
- Return type
generator
-
cytopy.data.read_write.
explore_channel_mappings
(fcs_dir: str, exclude_comps: bool = True) → list¶ Given a directory, explore all fcs files and find all permutations of channel/marker mappings
- Parameters
fcs_dir (str) – root directory to search
exclude_comps (bool, (default=True)) – exclude compentation files (must have ‘comp’ in filename)
- Returns
list of all unique channel/marker mappings
- Return type
List
-
cytopy.data.read_write.
fcs_mappings
(path: str) → list¶ Fetch channel mappings from fcs file.
- Parameters
path (str) – path to fcs file
- Returns
List of channel mappings. Will return None if file fails to load.
- Return type
List or None
-
cytopy.data.read_write.
filter_fcs_files
(fcs_dir: str, exclude_comps: bool = True, exclude_dir: str = 'DUPLICATES') → list¶ Given a directory, return file paths for all fcs files in directory and subdirectories contained within
- Parameters
fcs_dir (str) – path to directory for search
exclude_comps (bool) – if True, compensation files will be ignored (note: function searches for ‘comp’ in file name for exclusion)
exclude_dir (str (default = 'DUPLICATES')) – Will ignore any directories with this name
- Returns
list of fcs file paths
- Return type
List
-
cytopy.data.read_write.
get_fcs_file_paths
(fcs_dir: str, control_names: list, ctrl_id: str, ignore_comp: bool = True, exclude_dir: str = 'DUPLICATE') → dict¶ Generate a standard dictionary object of fcs files in given directory :param fcs_dir: target directory for search :type fcs_dir: str :param control_names: names of expected control files (names must appear in filenames) :type control_names: list :param ctrl_id: global identifier for control file e.g. ‘FMO’ (must appear in filenames) :type ctrl_id: str :param ignore_comp: If True, files with ‘compensation’ in their name will be ignored (default = True) :type ignore_comp: bool, (default=True) :param exclude_dir: Will ignore any directories with this name :type exclude_dir: str (default = ‘DUPLICATES’)
- Returns
standard dictionary of fcs files contained in target directory
- Return type
dict