FACSPy.dt.Metadata

Contents

FACSPy.dt.Metadata#

class FACSPy.dt.Metadata(file='', metadata=None, from_fcs=False)#

Metadata class to represent and unify cytometry metadata representations. The structure has to be at least to columns: sample_ID with ascending ints and file_name with the file names. If the metadata are 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.

  • metadata (Optional[DataFrame]) – Optional. If the dataframe has been assembled with pandas, supply this metadata dataframe.

  • from_fcs (bool) – If True, returns an empty Metadata object which will be filled during dataset assembly by fp.create_dataset().

Return type:

The dataset object of Metadata

Examples

>>> import FACSPy as fp
>>> import pandas as pd
>>> metadata = fp.dt.Metadata("metadata.csv") # creates metadata from the local file `metadata.csv`
>>> metadata
Metadata(28 entries with factors ["condition", "organ"])
>>> metadata_frame = pd.DataFrame(
...     data = {
...         "sample_ID": ["1", "2", "3"],
...         "file_name" : ["1.fcs", "2.fcs", "3.fcs"],
...         "condition" : ["healthy", "healthy", "disease"]
...     },
...     index = list(range(3))
... )
>>> metadata = fp.dt.Metadata(metadata = metadata_frame) # creates metadata from a pd.DataFrame
>>> metadata
Metadata(3 entries with factors ["condition"])
>>> metadata = fp.dt.Metadata(from_fcs = True) # creates an empty metadata object
Metadata(0 entries with factors [])

Notes

See further usage examples in the following tutorials: The Metadata object

Methods

annotate([sample_IDs, file_names, column, value])

allows the annotation of new metadata

get_factors()

returns all metadata columns that are not sample_ID, file_name or staining

group_variable(factor, n_groups)

groups continous variables into n_groups

rename_column(current_name, new_name)

renames a column from the metadata dataframe and removes the old column

rename_values(column, replacement)

renames the values of a metadata factor

select_channels(channels)

selects channels and subsets dataframe

subset(column, values)

subsets the metadata based on metadata values

to_df()

returns the dataframe of the object

write([output_directory])

writes the underlying table to disk.