cellflow.preprocessing.compute_wknn¶
- cellflow.preprocessing.compute_wknn(ref_adata=None, query_adata=None, n_neighbors=30, ref_rep_key='X_pca', query_rep_key='X_pca', uns_key_added='wknn', query2ref=True, ref2query=False, weighting_scheme='jaccard_square', top_n=None, copy=False)[source]¶
Compute the weighted k-nearest neighbors graph between the reference and query datasets
- Parameters:
ref_adata (
AnnData) – AnAnnDataobject with the reference representation to build ref-query neighbor graphquery_adata (
AnnData) – AnAnnDataobject with the query representation to build ref-query neighbor graphn_neighbors (
int) – Number of neighbors per cellref_rep_key (
str) – Key inobsmofref_adatacontaining the reference representationquery_rep_key (
str) – Key inobsmofquery_adatacontaining the query representationuns_key_added (
str) – Key to store the weighted k-nearest neighbors graph inunsquery2ref (
bool) – Consider query-to-ref neighborsref2query (
bool) – Consider ref-to-query neighborsweighting_scheme (
Optional[Literal['top_n','jaccard','jaccard_square']]) –How to weight edges in the ref-query neighbor graph. Options are:
None: No weighting'top_n': Binaries edges based on the top top_n neighbors.'jaccard': Weight edges based on the Jaccard index.'jaccard_square': Weight edges based on the square of the Jaccard index.
top_n (
int|None) – The number of top neighbors to considercopy (
bool) – Return a copy ofref_adatainstead of updating it in place
- Return type:
AnnData|None- Returns:
: If
copyisTrue, returns a newAnnDataobject with the weighted k-nearest neighbors stored inuns. Otherwise, updatesadatain place.Sets the following fields:
.uns[uns_key_added]: Weighted k-nearest neighbors graph