Metacells¶

circe.metacells.compute_metacells(adata, k=50, max_overlap_metacells=0.9, max_metacells=None, dim_reduction='lsi', projection=None, method='mean', metric='cosine')¶

Compute metacells by suming/averaging expression of neighbouring cells. Neighbouring cells are identified from umap coordinates, itself obtained from LSI coordinates to reduce dimensionality to topics. (It has been implemented to be close to Cicero/Monocle3 code from Trapnell lab).

Parameters:
  • adata (AnnData) – AnnData object

  • k (int, optional) – Number of neighbours to consider. The default is 50.

  • max_overlap_metacells (float, optional) – Maximum percentage of overlapping cells between two metacells in order to consider them as different. The default is 0.9.

  • max_metacells (int, optional) – Maximum number of metacells to compute. The default is None, which means a metacell is created and centered on each cell.

  • dim_reduction (str, optional) – Dimensionality reduction method to use to compute metacells. The default is ‘lsi’.

  • projection (str, optional) – Projection method to use to compute metacells. The default is ‘umap’.

  • method (str, optional) – Method to use to compute metacells (mean or sum).

  • metric (str, optional) – Distance type used to calculate distance between neighbors. The default is ‘cosine’.

Returns:

metacells_AnnData – AnnData object containing metacells.

Return type:

AnnData

circe.metacells.lsi(adata: AnnData, n_components: int = 20, use_highly_variable: bool | None = None, **kwargs) None¶

LSI analysis (following the Seurat v3 approach) # from scGLUE : https://github.com/gao-lab/GLUE/blob/master/scglue

Parameters:
  • adata – Input dataset

  • n_components – Number of dimensions to use

  • use_highly_variable – Whether to use highly variable features only, stored in adata.var['highly_variable']. By default uses them if they have been determined beforehand.

  • **kwargs – Additional keyword arguments are passed to sklearn.utils.extmath.randomized_svd()

circe.metacells.tfidf(X)¶

TF-IDF normalization (following the Seurat v3 approach) # from scGLUE : https://github.com/gao-lab/GLUE/blob/master/scglue

Parameters:

X – Input matrix

Returns:

TF-IDF normalized matrix

Return type:

X_tfidf