anndict.AdataDict.flatten

anndict.AdataDict.flatten#

AdataDict.flatten()[source]#

Flatten the hierarchy of AdataDict.

Examples

Case 1: Nested hierarchy

#start with a nested hierarchy
adata_dict.hierarchy
> ('donor', ('tissue'))
print(adata_dict)
> {
>     ("Donor1",): {
>         ("Tissue1",): adata1,
>         ("Tissue2",): adata2,
>     },
>     ("Donor2",): {
>         ("Tissue1",): adata3,
>     },
> }

#flatten adata_dict
adata_dict.flatten()
addata_dict.hierarchy
> ('donor', 'tissue') #now the hierarchy is flat
print(adata_dict)
> {
>     ("Donor1", "Tissue1"): adata1,
>     ("Donor1", "Tissue2"): adata2,
>     ("Donor2", "Tissue1"): adata3,
> }