scmorph.pp.neighbors#
- scmorph.pp.neighbors(adata, n_neighbors=15, n_pcs=None, use_rep='X_pca', copy=False, **kwargs)[source]#
Compute a neighborhood graph of observations using the PCA representation.
This function wraps the higher-level function
neighbors()([Wolf et al., 2018].)- Parameters:
- adata
AnnData AnnData object
- n_neighbors
int(default:15) The size of local neighborhood (in terms of number of neighboring data points) used for manifold approximation. Larger values result in more global views of the manifold, while smaller values result in more local data being preserved. In general values should be in the range 2 to 100. If
knnisTrue, number of nearest neighbors to be searched. IfknnisFalse, a Gaussian kernel width is set to the distance of then_neighborsneighbor.- n_pcs
int|None(default:None) Use this many PCs. If
n_pcs==0use.Xifuse_rep is not None.- use_rep
str(default:'X_pca') Use the indicated representation. ‘X’ or any key for .obsm is valid. If None, the representation is chosen automatically: For .n_vars < N_PCS, .X is used, otherwise
X_pcais used. IfX_pcais not present, it`s computed with default parameters or n_pcs if present.- copy
bool(default:False) Return a copy instead of writing to adata.
- kwargs
Any Additional arguments passed to
neighbors().
- adata
- Return type:
AnnData|None- Returns:
Returns
Noneifcopy=False, else returns anAnnDataobject. Sets the following fields:adata.obsp['distances' | key_added+'_distances']scipy.sparse.csr_matrix(dtypefloat)Distance matrix of the nearest neighbors search. Each row (cell) has
n_neighbors-1 non-zero entries. These are the distances to theirn_neighbors-1 nearest neighbors (excluding the cell itself).adata.obsp['connectivities' | key_added+'_connectivities']scipy.sparse._csr.csr_matrix(dtypefloat)Weighted adjacency matrix of the neighborhood graph of data points. Weights should be interpreted as connectivities.
adata.uns['neighbors' | key_added]dictneighbors parameters.