dynamo.tl.reduceDimension

dynamo.tl.reduceDimension(adata, X_data=None, genes=None, layer=None, basis='pca', dims=None, n_pca_components=30, n_components=2, n_neighbors=30, reduction_method='umap', embedding_key=None, neighbor_key=None, enforce=False, cores=1, copy=False, **kwargs)[source]

Compute a low dimension reduction projection of an AnnData object first with PCA, followed by non-linear dimension reduction methods

Parameters:
  • adata (AnnData) – An AnnData object.

  • X_data (Optional[ndarray]) – The user supplied data that will be used for dimension reduction directly. Defaults to None.

  • genes (Optional[List[str]]) – The list of genes that will be used to subset the data for dimension reduction and clustering. If None, all genes will be used. Defaults to None.

  • layer (Optional[str]) – The layer that will be used to retrieve data for dimension reduction and clustering. If None, .X is used. Defaults to None.

  • basis (Optional[str]) – The space that will be used for clustering. Valid names includes, for example, pca, umap, velocity_pca (that is, you can use velocity for clustering), etc. Defaults to “pca”.

  • dims (Optional[List[int]]) – The list of dimensions that will be selected for clustering. If None, all dimensions will be used. Defaults to None.

  • n_pca_components (int) – Number of input PCs (principal components) that will be used for further non-linear dimension reduction. If n_pca_components is larger than the existing #PC in adata.obsm[‘X_pca’] or input layer’s corresponding pca space (layer_pca), pca will be rerun with n_pca_components PCs requested. Defaults to 30.

  • n_components (int) – The dimension of the space to embed into. Defaults to 2.

  • n_neighbors (int) – The number of nearest neighbors when constructing adjacency matrix. Defaults to 30.

  • reduction_method (str) – Non-linear dimension reduction method to further reduce dimension based on the top n_pca_components PCA components. Currently, PSL (probabilistic structure learning, a new dimension reduction by us), tSNE (fitsne instead of traditional tSNE used) or umap are supported. Defaults to “umap”.

  • embedding_key (Optional[str]) – The str in .obsm that will be used as the key to save the reduced embedding space. By default, it is None and embedding key is set as layer + reduction_method. If layer is None, it will be “X_neighbors”. Defaults to None.

  • neighbor_key (Optional[str]) – The str in .uns that will be used as the key to save the nearest neighbor graph. By default it is None and neighbor_key key is set as layer + “_neighbors”. If layer is None, it will be “X_neighbors”. Defaults to None.

  • enforce (bool) – Whether to re-perform dimension reduction even if there is reduced basis in the AnnData object. Defaults to False.

  • cores (int) – The number of cores used for calculation. Used only when tSNE reduction_method is used. Defaults to 1.

  • copy (bool) – Whether to return a copy of the AnnData object or update the object in place. Defaults to False.

  • kwargs – Other kwargs that will be passed to umap.UMAP. for umap, min_dist is a noticeable kwargs that would significantly influence the reduction result.

Return type:

Optional[AnnData]

Returns:

An updated AnnData object updated with reduced dimension data for data from different layers, returned if copy is true.