cellcharter.gr.diff_nhood_enrichment#
- cellcharter.gr.diff_nhood_enrichment(adata, cluster_key, condition_key, condition_groups=None, connectivity_key=None, pvalues=False, library_key='library_id', n_perms=1000, n_jobs=None, copy=False, **nhood_kwargs)#
Differential neighborhood enrichment between conditions.
- Parameters:
adata (
AnnData
) – Annotated data object.cluster_key (
str
) – Key inanndata.AnnData.obs
where clustering is stored.condition_key (
str
) – Key inanndata.AnnData.obs
where the sample condition is stored.condition_groups (
Optional
[tuple
[str
,str
]] (default:None
)) – The condition groups to compare. IfNone
, all conditions incondition_key
will be used.connectivity_key (
Optional
[str
] (default:None
)) – Key inanndata.AnnData.obsp
where spatial connectivities are stored. Default is:anndata.AnnData.obsp
['spatial_connectivities']
.pvalues (
bool
(default:False
)) – IfTrue
, compute the p-values for each differential neighborhood enrichment through permutation of the condition key for each Z-dimension.library_key (
str
|None
(default:'library_id'
)) – If multiple library_id, column in anndata.AnnData.obs which stores mapping between library_id and obs. Used only ifpvalues
isTrue
to permute the condition labels.n_perms (
int
(default:1000
)) – Number of permutations to use to compute the expected neighborhood enrichment ifpvalues
isTrue
.n_jobs (
Optional
[int
] (default:None
)) – Number of jobs to run in parallel ifpvalues
isTrue
.-1
means using all processors.copy (
bool
(default:False
)) – IfTrue
, return the result, otherwise save it to theadata
object.nhood_kwargs –
- Keyword arguments for
gr.nhood_enrichment()
. The following arguments are not allowed: n_perms
pvalues
n_jobs
- Keyword arguments for
- Return type:
- Returns:
If
copy = True
, returns adict
of all pairwise differential neighborhood enrichments between conditions stored as{condition1}_{condition2}
. The differential neighborhood enrichment is adict
with the following keys:'enrichment'
- the differential neighborhood enrichment.'pvalue'
- the enrichment pvalues (ifpvalues
isTrue
).