Squidpy comparative statistics

We’re looking to use squidpy to generate comparative spatial statistics across multiple samples.
I see we can supply the sample key by library_key in squidpy.gr.spatial_neighbors so that the spatial graph is generated for each sample independently, but how does one then use squidpy.gr.nhood_enrichment, sq.gr.interaction_matrix, sq.gr.centrality_scores functions to generate ‘per sample’ statistics to compare between samples.

the adata.uns output from the ```.gr.` functions returns np.ndarray - how does one access the column names for these arrays?


Hi @jamesmo

If I understand your question correctly, you just want to access individual arrays in the 2D arrays stored in adata.uns?

For example squidpy.gr.nhood_enrichment modifies adata.uns such that adata.uns['{cluster_key}_nhood_enrichment] stores the zscore and count array as values. These are 2D arrays so if you want to access an individual column then it would work like this (since adata.uns is a dictionary):


Thanks @LLehner . Appreciate the input.
We’ve still been trying to address how to normalise these zscores across samples to compare groups. The only solution so far has been to concatenate all the adata.uns objects and scale again. Wondering if anyone else had addressed the issue differently