- dynamo.tl.moments(adata, X_data=None, genes=None, group=None, conn=None, use_gaussian_kernel=False, normalize=True, use_mnn=False, layers='all', n_pca_components=30, n_neighbors=30, copy=False)
- Calculate kNN based first and second moments (including uncentered covariance) for
different layers of data.
AnnData) – AnnData object.
X_data (np.ndarray (default: None)) – The user supplied data that will be used for constructing the nearest neighbor graph directly.
genes (np.array (default: None)) –
- The one-dimensional numpy array of the genes that you want to perform pca analysis (if adata.obsm[‘X’] is
not available). X keyname (instead of X_pca) was used to enable you use a different set of genes for flexible connectivity graph construction. If None, by default it will select genes based use_for_pca key in .var attributes if it exists otherwise it will also all genes stored in adata.X
group (str or None (default: None)) – The column key/name that identifies the grouping information (for example, clusters that correspond to different cell types or different time points) of cells. This will be used to compute kNN graph for each group (i.e cell-type/time-point). This is important, for example, we don’t want cells from different labeling time points to be mixed when performing the kNN graph for calculating the moments.
conn (csr_matrix or None (default: None)) – The connectivity graph that will be used for moment calculations.
use_gaussian_kernel (bool (default: True)) – Whether to normalize the kNN graph via a Guasian kernel.
normalize (bool (default: True)) – Whether to normalize the connectivity matrix so that each row sums up to 1. When use_gaussian_kernel is False, this will be reset to be False because we will already normalize the connectivity matrix matrix by dividing each row the total number of connections.
use_mnn (bool (default: False)) – Whether to use mutual kNN across different layers as for the moment calculation.
layers (str or a list of str (default: str)) – The layers that will be used for calculating the moments.
n_pca_components (int (default: 30)) – The number of pca components to use for constructing nearest neighbor graph and calculating 1/2-st moments.
n_neighbors (int (default: 30)) – The number of neighbors for constructing nearest neighbor graph used to calculate 1/2-st moments.
- If copy is set to False, annData object is updated with with calculated first/second moments (including
If copy is set to True, a deep copy of the original adata object is returned.
- Return type