harreman.tools.compute_knn_graph#
- harreman.tools.compute_knn_graph(adata, compute_neighbors_on_key=None, distances_obsp_key=None, weighted_graph=False, neighborhood_radius=None, n_neighbors=None, neighborhood_factor=3, sample_key=None, tree=None, verbose=False)[source]#
Computes the spatial proximity graph.
- Parameters:
adata (
AnnData) – AnnData object.compute_neighbors_on_key (
Optional[str] (default:None)) – Key in adata.obsm to use for computing neighbors. If None, use neighbors stored in adata. If no neighbors have been previously computed an error will be raised.distances_obsp_key (
Optional[str] (default:None)) – Distances encoding cell-cell similarities directly. Shape is (cells x cells). Input is key in adata.obsp.weighted_graph (
Optional[bool] (default:False)) – Whether or not to create a weighted graph.neighborhood_radius (
Optional[int] (default:None)) – Neighborhood radius.n_neighbors (
Optional[int] (default:None)) – Neighborhood size.neighborhood_factor (
Optional[int] (default:3)) – Used when creating a weighted graph. Sets how quickly weights decay relative to the distances within the neighborhood. The weight for a cell with a distance d will decay as exp(-d^2/D) where D is the distance to the n_neighbors/neighborhood_factor-th neighbor.sample_key (
Optional[str] (default:None)) – Sample information in case the data contains different samples or samples from different conditions. Input is key in adata.obs.tree (default:
None) – Root tree node. Can be created using ete3.Treeverbose (
Optional[bool] (default:False)) – Whether to print progress and status messages.