Manipulate the Hierarchy of an AdataDict#

This tutorial demonstrates how to manipulate the hierarchy of an AdataDict.

There are several operations pre-defined. These include:

  1. Set the hierarchy

  2. Add a stratification

  3. Flatten the hierarchy

Set the hierarchy#

An AdataDict is a nested dictionary of anndata.

The .hierarchy attribute describes the current nesting structure of the object.

The .set_hierarchy() method manipulates the nesting structure (aka the hierarchy).

import anndict as adt
import scanpy as sc

# Load an example dataset from scanpy
adata = sc.datasets.pbmc68k_reduced()

# Rename obs column (for legibility)
adata.obs['cell_type'] = adata.obs['bulk_labels']


# Build the AdataDict
adata_dict = adt.build_adata_dict(adata, strata_keys=['cell_type', 'phase']) # Use 'cell_type' and 'phase' because they're already in the .obs... You could use any categorical columns.

adata_dict is now a flat dictionary, where each key is a tuple, and each value in this case has a single cell type-phase group.

We can tell the nesting structure is flat by looking at the .hierarchy attribute

adata_dict.hierarchy
('cell_type', 'phase')

and here’s what the actual object looks like:

adata_dict
{('CD4+/CD25 T Reg',
  'G1'): AnnData object with n_obs × n_vars = 42 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD4+/CD25 T Reg',
  'G2M'): AnnData object with n_obs × n_vars = 10 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD4+/CD25 T Reg',
  'S'): AnnData object with n_obs × n_vars = 16 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD4+/CD45RA+/CD25- Naive T',
  'G1'): AnnData object with n_obs × n_vars = 4 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD4+/CD45RA+/CD25- Naive T',
  'S'): AnnData object with n_obs × n_vars = 4 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD4+/CD45RO+ Memory',
  'G1'): AnnData object with n_obs × n_vars = 9 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD4+/CD45RO+ Memory',
  'S'): AnnData object with n_obs × n_vars = 10 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD8+ Cytotoxic T',
  'G1'): AnnData object with n_obs × n_vars = 30 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD8+ Cytotoxic T',
  'G2M'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD8+ Cytotoxic T',
  'S'): AnnData object with n_obs × n_vars = 23 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD8+/CD45RA+ Naive Cytotoxic',
  'G1'): AnnData object with n_obs × n_vars = 29 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD8+/CD45RA+ Naive Cytotoxic',
  'G2M'): AnnData object with n_obs × n_vars = 2 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD8+/CD45RA+ Naive Cytotoxic',
  'S'): AnnData object with n_obs × n_vars = 12 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD14+ Monocyte',
  'G1'): AnnData object with n_obs × n_vars = 109 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD14+ Monocyte',
  'S'): AnnData object with n_obs × n_vars = 20 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD19+ B',
  'G1'): AnnData object with n_obs × n_vars = 65 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD19+ B',
  'G2M'): AnnData object with n_obs × n_vars = 3 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD19+ B',
  'S'): AnnData object with n_obs × n_vars = 27 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD34+',
  'G1'): AnnData object with n_obs × n_vars = 6 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD34+',
  'S'): AnnData object with n_obs × n_vars = 7 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD56+ NK',
  'G1'): AnnData object with n_obs × n_vars = 11 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD56+ NK',
  'G2M'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('CD56+ NK',
  'S'): AnnData object with n_obs × n_vars = 19 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('Dendritic',
  'G1'): AnnData object with n_obs × n_vars = 196 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('Dendritic',
  'S'): AnnData object with n_obs × n_vars = 44 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities'}

We can re-arrange the structure with the .set_hierarchy() method. To use this method, pass a list that is nested in a way that reflects your desired hierarchy. Here are a few examples, and you can try playing around with it yourself too, to see how it works.

Let’s say we want the top level to be cell_type and the second level to be phase#

This could be useful for a pipeline that expects the input to be a single cell type, with separate adata split by phase

adata_dict.set_hierarchy(['cell_type', ['phase']]) # Note the nesting structure of the input list

And here’s what the adata_dict looks like now:

adata_dict.hierarchy
('cell_type', ('phase',))
adata_dict 
{('CD4+/CD25 T Reg',): {('G1',): AnnData object with n_obs × n_vars = 42 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities',
  ('G2M',): AnnData object with n_obs × n_vars = 10 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities',
  ('S',): AnnData object with n_obs × n_vars = 16 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities'},
 ('CD4+/CD45RA+/CD25- Naive T',): {('G1',): AnnData object with n_obs × n_vars = 4 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities',
  ('S',): AnnData object with n_obs × n_vars = 4 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities'},
 ('CD4+/CD45RO+ Memory',): {('G1',): AnnData object with n_obs × n_vars = 9 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities',
  ('S',): AnnData object with n_obs × n_vars = 10 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities'},
 ('CD8+ Cytotoxic T',): {('G1',): AnnData object with n_obs × n_vars = 30 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities',
  ('G2M',): AnnData object with n_obs × n_vars = 1 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities',
  ('S',): AnnData object with n_obs × n_vars = 23 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities'},
 ('CD8+/CD45RA+ Naive Cytotoxic',): {('G1',): AnnData object with n_obs × n_vars = 29 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities',
  ('G2M',): AnnData object with n_obs × n_vars = 2 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities',
  ('S',): AnnData object with n_obs × n_vars = 12 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities'},
 ('CD14+ Monocyte',): {('G1',): AnnData object with n_obs × n_vars = 109 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities',
  ('S',): AnnData object with n_obs × n_vars = 20 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities'},
 ('CD19+ B',): {('G1',): AnnData object with n_obs × n_vars = 65 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities',
  ('G2M',): AnnData object with n_obs × n_vars = 3 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities',
  ('S',): AnnData object with n_obs × n_vars = 27 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities'},
 ('CD34+',): {('G1',): AnnData object with n_obs × n_vars = 6 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities',
  ('S',): AnnData object with n_obs × n_vars = 7 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities'},
 ('CD56+ NK',): {('G1',): AnnData object with n_obs × n_vars = 11 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities',
  ('G2M',): AnnData object with n_obs × n_vars = 1 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities',
  ('S',): AnnData object with n_obs × n_vars = 19 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities'},
 ('Dendritic',): {('G1',): AnnData object with n_obs × n_vars = 196 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities',
  ('S',): AnnData object with n_obs × n_vars = 44 × 765
      obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
      var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
      uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
      obsm: 'X_pca', 'X_umap'
      varm: 'PCs'
      obsp: 'distances', 'connectivities'}}

Note that adata_dict[(‘CD4+/CD25 T Reg’,)] now gives an AdataDict containing all the phases for that cell type (the AdataDict has a separate key-value for each phase).

adata_dict[('CD4+/CD25 T Reg',)]
{('G1',): AnnData object with n_obs × n_vars = 42 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('G2M',): AnnData object with n_obs × n_vars = 10 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('S',): AnnData object with n_obs × n_vars = 16 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities'}

Note the nested AdataDicts, where only terminal nodes are AnnData:

adata_dict.__class__
anndict.adata_dict.adata_dict.AdataDict
adata_dict[('CD4+/CD25 T Reg',)].__class__
anndict.adata_dict.adata_dict.AdataDict
adata_dict[('CD4+/CD25 T Reg',)][('G1',)].__class__ # Only the terminal nodes are AnnData
anndata._core.anndata.AnnData

While we show the type of each level of the dictionary here, in practice, you can generally ignore this. The main method of an AdataDict (.fapply(), covered by the “Iterate Over AdataDict” tutorial) is meant to abstract this away and handles automatically looping over the nested structure of the AdataDict.

Add a stratification#

Now, let’s say we also wanted to group by another variable (like tissue or is_control). Here, we’ll use the louvain column because it’s already in the dataset.

We can add this as a grouping variable with the .add_stratification() method as follows. This will set ‘louvain’ as the top-level key and nest the existing structure below that.

adata_dict.add_stratification(['louvain'])

Note the new hierarchy:

adata_dict.hierarchy
('louvain', ('cell_type', ('phase',)))
adata_dict
{('0',): {('CD4+/CD25 T Reg',): {('G1',): AnnData object with n_obs × n_vars = 41 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G2M',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('S',): AnnData object with n_obs × n_vars = 12 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD8+/CD45RA+ Naive Cytotoxic',): {('G1',): AnnData object with n_obs × n_vars = 26 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G2M',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('S',): AnnData object with n_obs × n_vars = 9 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD8+ Cytotoxic T',): {('G2M',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('S',): AnnData object with n_obs × n_vars = 6 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 9 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD4+/CD45RA+/CD25- Naive T',): {('S',): AnnData object with n_obs × n_vars = 2 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 2 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD4+/CD45RO+ Memory',): {('G1',): AnnData object with n_obs × n_vars = 8 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('S',): AnnData object with n_obs × n_vars = 6 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD56+ NK',): {('S',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD19+ B',): {('S',): AnnData object with n_obs × n_vars = 2 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 2 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('Dendritic',): {('S',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'}},
 ('3',): {('CD4+/CD25 T Reg',): {('G1',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('S',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD8+/CD45RA+ Naive Cytotoxic',): {('G1',): AnnData object with n_obs × n_vars = 3 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('S',): AnnData object with n_obs × n_vars = 2 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD8+ Cytotoxic T',): {('S',): AnnData object with n_obs × n_vars = 16 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 16 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD56+ NK',): {('G2M',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 11 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('S',): AnnData object with n_obs × n_vars = 18 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD4+/CD45RO+ Memory',): {('S',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'}},
 ('9',): {('CD4+/CD25 T Reg',): {('G2M',): AnnData object with n_obs × n_vars = 9 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('S',): AnnData object with n_obs × n_vars = 3 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD4+/CD45RA+/CD25- Naive T',): {('S',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD8+/CD45RA+ Naive Cytotoxic',): {('G2M',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('S',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD4+/CD45RO+ Memory',): {('S',): AnnData object with n_obs × n_vars = 3 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD19+ B',): {('S',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'}},
 ('8',): {('CD4+/CD45RA+/CD25- Naive T',): {('S',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD19+ B',): {('G2M',): AnnData object with n_obs × n_vars = 3 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('S',): AnnData object with n_obs × n_vars = 3 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 23 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'}},
 ('4',): {('CD4+/CD45RA+/CD25- Naive T',): {('G1',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD8+ Cytotoxic T',): {('S',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 2 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD19+ B',): {('S',): AnnData object with n_obs × n_vars = 21 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 40 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD14+ Monocyte',): {('G1',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'}},
 ('5',): {('CD4+/CD45RO+ Memory',): {('G1',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD14+ Monocyte',): {('S',): AnnData object with n_obs × n_vars = 4 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 17 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('CD8+ Cytotoxic T',): {('G1',): AnnData object with n_obs × n_vars = 3 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('Dendritic',): {('S',): AnnData object with n_obs × n_vars = 8 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 21 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'}},
 ('10',): {('CD34+',): {('G1',): AnnData object with n_obs × n_vars = 6 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('S',): AnnData object with n_obs × n_vars = 7 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'}},
 ('1',): {('CD14+ Monocyte',): {('S',): AnnData object with n_obs × n_vars = 15 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 86 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('Dendritic',): {('S',): AnnData object with n_obs × n_vars = 4 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 18 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'}},
 ('6',): {('CD14+ Monocyte',): {('S',): AnnData object with n_obs × n_vars = 1 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 5 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'},
  ('Dendritic',): {('S',): AnnData object with n_obs × n_vars = 3 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 33 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'}},
 ('2',): {('Dendritic',): {('S',): AnnData object with n_obs × n_vars = 20 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 97 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'}},
 ('7',): {('Dendritic',): {('S',): AnnData object with n_obs × n_vars = 8 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities',
   ('G1',): AnnData object with n_obs × n_vars = 27 × 765
       obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
       var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
       uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
       obsm: 'X_pca', 'X_umap'
       varm: 'PCs'
       obsp: 'distances', 'connectivities'}}}

Note that this AdataDict has 3 levels of nesting, so to access an actual adata, you’d need to do this:

adata_dict[('0',)][('CD4+/CD25 T Reg',)][('S',)]
AnnData object with n_obs × n_vars = 12 × 765
    obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
    var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
    uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
    obsm: 'X_pca', 'X_umap'
    varm: 'PCs'
    obsp: 'distances', 'connectivities'

Flatten the hiearchy#

Sometimes it’s useful to flatten the adata_dict (i.e. remove the nesting). This can be done with the .flatten() method:

adata_dict.flatten()

Note that the hierarchy is now flat:

adata_dict.hierarchy
('louvain', 'cell_type', 'phase')
adata_dict
{('0',
  'CD4+/CD25 T Reg',
  'G1'): AnnData object with n_obs × n_vars = 41 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'CD4+/CD25 T Reg',
  'G2M'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'CD4+/CD25 T Reg',
  'S'): AnnData object with n_obs × n_vars = 12 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'CD8+/CD45RA+ Naive Cytotoxic',
  'G1'): AnnData object with n_obs × n_vars = 26 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'CD8+/CD45RA+ Naive Cytotoxic',
  'G2M'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'CD8+/CD45RA+ Naive Cytotoxic',
  'S'): AnnData object with n_obs × n_vars = 9 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'CD8+ Cytotoxic T',
  'G2M'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'CD8+ Cytotoxic T',
  'S'): AnnData object with n_obs × n_vars = 6 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'CD8+ Cytotoxic T',
  'G1'): AnnData object with n_obs × n_vars = 9 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'CD4+/CD45RA+/CD25- Naive T',
  'S'): AnnData object with n_obs × n_vars = 2 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'CD4+/CD45RA+/CD25- Naive T',
  'G1'): AnnData object with n_obs × n_vars = 2 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'CD4+/CD45RO+ Memory',
  'G1'): AnnData object with n_obs × n_vars = 8 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'CD4+/CD45RO+ Memory',
  'S'): AnnData object with n_obs × n_vars = 6 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'CD56+ NK',
  'S'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'CD19+ B',
  'S'): AnnData object with n_obs × n_vars = 2 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'CD19+ B',
  'G1'): AnnData object with n_obs × n_vars = 2 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('0',
  'Dendritic',
  'S'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('3',
  'CD4+/CD25 T Reg',
  'G1'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('3',
  'CD4+/CD25 T Reg',
  'S'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('3',
  'CD8+/CD45RA+ Naive Cytotoxic',
  'G1'): AnnData object with n_obs × n_vars = 3 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('3',
  'CD8+/CD45RA+ Naive Cytotoxic',
  'S'): AnnData object with n_obs × n_vars = 2 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('3',
  'CD8+ Cytotoxic T',
  'S'): AnnData object with n_obs × n_vars = 16 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('3',
  'CD8+ Cytotoxic T',
  'G1'): AnnData object with n_obs × n_vars = 16 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('3',
  'CD56+ NK',
  'G2M'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('3',
  'CD56+ NK',
  'G1'): AnnData object with n_obs × n_vars = 11 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('3',
  'CD56+ NK',
  'S'): AnnData object with n_obs × n_vars = 18 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('3',
  'CD4+/CD45RO+ Memory',
  'S'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('9',
  'CD4+/CD25 T Reg',
  'G2M'): AnnData object with n_obs × n_vars = 9 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('9',
  'CD4+/CD25 T Reg',
  'S'): AnnData object with n_obs × n_vars = 3 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('9',
  'CD4+/CD45RA+/CD25- Naive T',
  'S'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('9',
  'CD8+/CD45RA+ Naive Cytotoxic',
  'G2M'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('9',
  'CD8+/CD45RA+ Naive Cytotoxic',
  'S'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('9',
  'CD4+/CD45RO+ Memory',
  'S'): AnnData object with n_obs × n_vars = 3 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('9',
  'CD19+ B',
  'S'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('8',
  'CD4+/CD45RA+/CD25- Naive T',
  'S'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('8',
  'CD4+/CD45RA+/CD25- Naive T',
  'G1'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('8',
  'CD19+ B',
  'G2M'): AnnData object with n_obs × n_vars = 3 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('8',
  'CD19+ B',
  'S'): AnnData object with n_obs × n_vars = 3 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('8',
  'CD19+ B',
  'G1'): AnnData object with n_obs × n_vars = 23 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('4',
  'CD4+/CD45RA+/CD25- Naive T',
  'G1'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('4',
  'CD8+ Cytotoxic T',
  'S'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('4',
  'CD8+ Cytotoxic T',
  'G1'): AnnData object with n_obs × n_vars = 2 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('4',
  'CD19+ B',
  'S'): AnnData object with n_obs × n_vars = 21 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('4',
  'CD19+ B',
  'G1'): AnnData object with n_obs × n_vars = 40 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('4',
  'CD14+ Monocyte',
  'G1'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('5',
  'CD4+/CD45RO+ Memory',
  'G1'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('5',
  'CD14+ Monocyte',
  'S'): AnnData object with n_obs × n_vars = 4 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('5',
  'CD14+ Monocyte',
  'G1'): AnnData object with n_obs × n_vars = 17 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('5',
  'CD8+ Cytotoxic T',
  'G1'): AnnData object with n_obs × n_vars = 3 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('5',
  'Dendritic',
  'S'): AnnData object with n_obs × n_vars = 8 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('5',
  'Dendritic',
  'G1'): AnnData object with n_obs × n_vars = 21 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('10',
  'CD34+',
  'G1'): AnnData object with n_obs × n_vars = 6 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('10',
  'CD34+',
  'S'): AnnData object with n_obs × n_vars = 7 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('1',
  'CD14+ Monocyte',
  'S'): AnnData object with n_obs × n_vars = 15 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('1',
  'CD14+ Monocyte',
  'G1'): AnnData object with n_obs × n_vars = 86 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('1',
  'Dendritic',
  'S'): AnnData object with n_obs × n_vars = 4 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('1',
  'Dendritic',
  'G1'): AnnData object with n_obs × n_vars = 18 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('6',
  'CD14+ Monocyte',
  'S'): AnnData object with n_obs × n_vars = 1 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('6',
  'CD14+ Monocyte',
  'G1'): AnnData object with n_obs × n_vars = 5 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('6',
  'Dendritic',
  'S'): AnnData object with n_obs × n_vars = 3 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('6',
  'Dendritic',
  'G1'): AnnData object with n_obs × n_vars = 33 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('2',
  'Dendritic',
  'S'): AnnData object with n_obs × n_vars = 20 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('2',
  'Dendritic',
  'G1'): AnnData object with n_obs × n_vars = 97 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('7',
  'Dendritic',
  'S'): AnnData object with n_obs × n_vars = 8 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities',
 ('7',
  'Dendritic',
  'G1'): AnnData object with n_obs × n_vars = 27 × 765
     obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
     var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
     uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
     obsm: 'X_pca', 'X_umap'
     varm: 'PCs'
     obsp: 'distances', 'connectivities'}
adata_dict[('0', 'CD4+/CD25 T Reg', 'G1')] #AnnData is indexed by a tuple of strings
AnnData object with n_obs × n_vars = 41 × 765
    obs: 'bulk_labels', 'n_genes', 'percent_mito', 'n_counts', 'S_score', 'G2M_score', 'phase', 'louvain', 'cell_type'
    var: 'n_counts', 'means', 'dispersions', 'dispersions_norm', 'highly_variable'
    uns: 'bulk_labels_colors', 'louvain', 'louvain_colors', 'neighbors', 'pca', 'rank_genes_groups'
    obsm: 'X_pca', 'X_umap'
    varm: 'PCs'
    obsp: 'distances', 'connectivities'