anndict.adata_dict.adata_dict.AdataDict#
- class anndict.adata_dict.adata_dict.AdataDict(data=None, hierarchy=None)[source]#
AdataDictis a dictionary-like container where values areAnnDataobjects.AdataDictinherits fromdict.This class provides three main functionalities:
It has the
set_hierarchymethod to restructure the nesting hierarchy, and thehierarchyattribute to keep track.It behaves like an
AnnDataobject by passing methods through to eachAnnDatain the dictionary.It has methods
fapply(func, kwargs)andfapply_return(func, kwargs)that apply a given functionfuncwith argumentskwargsto eachAnnDataobject in theAdataDict.
- Parameters:
- data
dict[tuple[int,...],any] |None(default:None) Dictionary with keys as tuples of indices.
- hierarchy
tuple|list|None(default:None) Tuple or list indicating the order of indices in the keys of
data.
- data
- __init__(data=None, hierarchy=None)[source]#
Initialize the
AdataDictwith data and hierarchy.- Parameters:
- data
dict[tuple[int,...],any] |None(default:None) Dictionary with keys as tuples of indices.
- hierarchy
tuple|list|None(default:None) Tuple or list indicating the order of indices.
- data
- Returns:
None Initializes the
AdataDictobject.- Return type:
None
Methods
__init__([data, hierarchy])Initialize the
AdataDictwith data and hierarchy.clear()copy()Copy the
AdataDict.fapply(func, *[, use_multithreading, ...])Applies
functo eachAnnDatainadata_dict, with error handling, retry mechanism, and the option to use either threading or sequential execution.fapply_return(func, *[, use_multithreading, ...])Legacy wrapper for adata_dict_fapply.
flatten()Flatten the hierarchy of
AdataDict.flatten_nesting_list(nesting_list)Flatten a nested list or tuple into a single list.
fromkeys([value])Create a new dictionary with keys from iterable and values set to value.
get(key[, default])Return the value for key if key is in the dictionary, else default.
get_levels(nesting_list[, levels, depth])Get the levels of hierarchy based on the nesting structure.
items()keys()pop(k[,d])If the key is not found, return the default if given; otherwise, raise a KeyError.
popitem()Remove and return a (key, value) pair as a 2-tuple.
set_hierarchy(nesting_list)Rearrange the hierarchy of
AdataDictbased on the provided nesting structure.set_obs_index(column)Set the index of adata.obs to the specified column for each AnnData object in adata_dict.
set_var_index(column)Set the index of
adata.varto the specified column for eachAnnDatainadata_dict.setdefault(key[, default])Insert key with a value of default if key is not in the dictionary.
update([E, ]**F)If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()Attributes
hierarchyThe hierarchy of the
AdataDict.