scirpy.util.DataHandler#
- class scirpy.util.DataHandler(data, airr_mod=None, airr_key=None, chain_idx_key=None)#
Transparent access to airr modality in both AnnData and MuData objects.
Performs a plausibility check of the input data for public scirpy functions.
Provides convenient accessors to the airr data that is stored somewhere in the input AnnData/MuData.
DataHandler may be called with another DataHandler instance as
data
attribute. In that case all attributes are taken from the existing DataHandler instance and all keyword attributes are ignored.- Parameters:
adata – AnnData or MuData object that contains AIRR information.
airr_mod (
Optional
[str
] (default:None
)) – Name of the modality with AIRR information is stored in theMuData
object. if anAnnData
object is passed to the function, this parameter is ignored.airr_key (
Optional
[str
] (default:None
)) – Key under which the AIRR information is stored in adata.obsm as an awkward array.chain_idx_key (
Optional
[str
] (default:None
)) – Key under which the chain indices are stored in adata.obsm. If chain indices are not present,index_chains()
is run with default parameters.
Attributes table#
Methods table#
|
Raise an error if AnnData is in pre scirpy v0.7 format. |
|
Initailize a DataHandler object with default keys. |
|
Get one or multiple obs columns from either MuData or AIRR AnnData |
|
Inject parameter documentation into a function docstring |
|
Store results in .obs of AnnData and MuData. |
Convert strings to categoricals. |
Attributes#
- DataHandler.data#
Get the outermost container. If MuData is defined, return the MuData object. Otherwise the AnnData object.
- DataHandler.adata#
Reference to the AnnData object of the AIRR modality.
- DataHandler.mdata#
Reference to the MuData object.
Raises an attribute error if only AnnData is available.
- DataHandler.airr#
Reference to the awkward array with AIRR information.
- DataHandler.chain_indices#
Reference to the chain indices
Raises an AttributeError if chain indices are not available.
- DataHandler.TYPE#
Supported Data types
alias of
AnnData
|MuData
|DataHandler
Methods#
- static DataHandler.check_schema_pre_v0_7(adata)#
Raise an error if AnnData is in pre scirpy v0.7 format.
- static DataHandler.default(data)#
Initailize a DataHandler object with default keys. Returns None if
data
is None. Particularly useful for testing.
- DataHandler.get_obs(columns)#
Get one or multiple obs columns from either MuData or AIRR AnnData
Checks if the column is available in
MuData.obs
. If it can’t be found or DataHandler is initalized without MuData object,AnnData.obs
is tried.The returned object always has the dimensions and index of MuData, even if only columns from AnnData are used. It is easy to subset to AnnData if required:
params.get_obs([col1, col2]).reindex(params.adata.obs_names)
- static DataHandler.inject_param_docs(**kwargs)#
Inject parameter documentation into a function docstring
- DataHandler.set_obs(key, value)#
Store results in .obs of AnnData and MuData.
If
value
is not a Series, if the length is equal to the params.mdata, we assume it aligns to the MuData object. Otherwise, if the length is equal to the params.adata, we assume it aligns to the AnnData object. Otherwise, a ValueError is thrown.The result will be written to
mdata.obs["{airr_mod}:{key}"]
and toadata.obs[key]
.- Return type:
- DataHandler.strings_to_categoricals()#
Convert strings to categoricals. If MuData is not defined, perform this on AnnData