FACSPy.dt.transform#
- FACSPy.dt.transform(adata, transform, transform_kwargs=None, cofactor_table=None, key_added=None, layer='compensated', copy=False)#
Transforms the data. The data are transformed by either asinh, log, logicle or hyperlog. If asinh is selected, a cofactor table can be supplied mapping the channel names to their respective cofactor. If there is no cofactor table, the cofactors will be calculated.
- Parameters:
adata (
AnnData) – The anndata object of shape n_obs x n_vars where Rows correspond to cells and columns to the channelstransform (
Literal['asinh','logicle','hyperlog','log']) – The transform method to be used. Can be any of asinh, log, logicle or hyperlog. If log, values below 1 are set to 1.transform_kwargs (
Optional[dict]) – Keyword arguments passed to the respective transform function as a dictionary. Please refer to their documentationcofactor_table (
Optional[CofactorTable]) – A table mapping the channels (e.g. CD3) to their respective cofactors. Please refer to the documentation of the CofactorTable class for further information. Note that missing cofactors will be set to 1. This is mostly relevant for the scatter/time channels where there is no reasonable cofactor to be set.key_added (
Optional[str]) – The name of the layer that is created. Defaults to transformed.layer (
str) – The name of the layer that stores the data to be transformed. Defaults to compensated.copy (
bool) – Whether to copy the dataset and return the copy.
- Returns:
Returns adata if copy = True, otherwise adds fields to the anndata object:
- .uns[layer]
The transformed data
- .var[‘cofactors’]
added cofactors from the cofactor table if provided.
- Return type:
AnnDataor None
Examples
>>> import FACSPy as fp >>> cof_table = CofactorTable("cofactors.csv") >>> dataset = fp.create_dataset(...) >>> dataset AnnData object with n_obs × n_vars = 615936 × 22 obs: 'sample_ID', 'file_name', 'condition' var: 'pns', 'png', 'pne', 'pnr', 'type', 'pnn' uns: 'metadata', 'panel', 'workspace', 'gating_cols', 'dataset_status_hash' obsm: 'gating' layers: 'compensated' >>> fp.transform( ... dataset, ... transform = "asinh", ... cofactor_table = cof_table, ... key_added = "transformed" ... ) >>> dataset AnnData object with n_obs × n_vars = 615936 × 22 obs: 'sample_ID', 'file_name', 'condition' var: 'pns', 'png', 'pne', 'pnr', 'type', 'pnn' uns: 'metadata', 'panel', 'workspace', 'gating_cols', 'dataset_status_hash' obsm: 'gating' layers: 'compensated', 'transformed'