<jupyter_start><jupyter_text>Neighbors enrichment analysis=============================This example shows how to run the neighbors enrichment analysis routine.It calculates an enrichment score based on proximity on the connectivitygraph of cell clusters. The number of observed events is comparedagainst $N$ permutations and a *z-score* is computed.<jupyter_code>import squidpy as sq

adata = sq.datasets.visium_fluo_adata()
adata<jupyter_output><empty_output><jupyter_text>This dataset contains cell type annotations in anndata.Anndata.obs whichare used for calculation of the neighborhood enrichment. First, we needto compute a connectivity matrix from spatial coordinates.<jupyter_code>sq.gr.spatial_neighbors(adata)<jupyter_output><empty_output><jupyter_text>Then we can calculate the neighborhood enrichment score withsquidpy.gr.nhood\_enrichment<jupyter_code>sq.gr.nhood_enrichment(adata, cluster_key="cluster")<jupyter_output><empty_output><jupyter_text>And visualize the results with squidpy.pl.nhood\_enrichment<jupyter_code>sq.pl.nhood_enrichment(adata, cluster_key="cluster")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09587813620071685, 'fraction_numerical': 0.0, 'mean_word_length': 9.154545454545454, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '303429', 'license': 'MIT', 'n_tokens_mistral': 349, 'n_tokens_neox': 323, 'n_words': 86, 'path': 'docs/source/auto_examples/graph/compute_nhood_enrichment.ipynb', 'repo_name': 'softbear/squidpy_notebooks', 'size': '1116'}