FACSPy.dt.CofactorTable#
- class FACSPy.dt.CofactorTable(file='', cofactors=None, from_fcs=False)#
CofactorTable class to represent and unify cytometry cofactor representations. The structure has to be at least two columns: fcs_colname with the antigen names (e.g. CD3) and cofactors with the corresponding cofactors. If the table is supposed to be constructed from the read-in files directly, set the flag from_fcs to True.
- Parameters:
file (
str) – The path or filename pointing to the table. Can be .txt, .csv.cofactors (
Optional[DataFrame]) – Optional. If the dataframe has been assembled with pandas, supply this metadata dataframe.from_fcs (
bool) – If True, returns an empty CofactorTable object which will be filled during cofactor_calculation byfp.calculate_cofactors().
- Return type:
The dataset object of
CofactorTable
Examples
>>> import FACSPy as fp >>> import pandas as pd
>>> cof_table = fp.dt.CofactorTable("cofactors.csv") # creates table from the local file `cofactors.csv` >>> cof_table CofactorTable(12 channels, loaded as provided file)
>>> cof_table_frame = pd.DataFrame( ... data = { ... "fcs_colname": ["CD3", "CD4", "CD5"], ... "cofactors" : [200, 400, 200], ... }, ... index = list(range(3)) ... ) >>> cof_table = fp.dt.CofactorTable(cofactors = cof_table_frame) # creates table from a pd.DataFrame >>> cof_table CofactorTable(3 channels, loaded as provided dataframe)
Notes
See further usage examples in the following tutorials: The CofactorTable object
Methods
get_cofactor(channel_name)returns cofactor of a given channel
rename_channel(current_name, new_name)select_channels(channels)selects channels and subsets dataframe
set_cofactor(channel_name, cofactor)sets cofactor of a given channel
set_cofactors([cofactors, cytof])sets cofactors.
set_columns(columns)converts a column to fcs_colname column
to_df()returns the dataframe of the object
write([output_directory])writes the underlying table to disk.