spateo.tools.cell_communication

Functions

niches(→ anndata.AnnData)

Performing cell-cell transformation on an anndata object, while also

predict_ligand_activities(→ pandas.DataFrame)

Function to predict the ligand activity.

predict_target_genes(→ pandas.DataFrame)

Function to predict the target genes.

Module Contents

spateo.tools.cell_communication.niches(adata: anndata.AnnData, path: str, layer: Tuple[None, str] = None, weighted: bool = False, spatial_neighbors: str = 'spatial_neighbors', spatial_distances: str = 'spatial_distances', species: Literal['human', 'mouse', 'drosophila', 'zebrafish', 'axolotl'] = 'human', system: Literal['niches_c2c', 'niches_n2c', 'niches_c2n', 'niches_n2n'] = 'niches_n2n', method: Literal['gmean', 'mean', 'sum'] = 'sum') anndata.AnnData[source]
Performing cell-cell transformation on an anndata object, while also

limiting the nearest neighbor per cell to k. This function returns another anndata object, in which the columns of the matrix are bucket -bucket pairs, while the rows ligand-receptor mechanisms. This resultant anndated object allows flexible downstream manipulations such as the dimensional reduction of the row or column of this object.

Our method is adapted from: Micha Sam Brickman Raredon, Junchen Yang, Neeharika Kothapalli, Naftali Kaminski, Laura E. Niklason, Yuval Kluger. Comprehensive visualization of cell-cell interactions in single-cell and spatial transcriptomics with NICHES. doi: https://doi.org/10.1101/2022.01.23.477401

Parameters:
adata

An Annodata object.

path

Path to ligand_receptor network of NicheNet (prior lr_network).

layer

the key to the layer. If it is None, adata.X will be used by default.

weighted

‘False’ (defult) whether to supply the edge weights according to the actual spatial distance(just as weighted kNN). Defult is ‘False’, means all neighbor edge weights equal to 1, others is 0.

spatial_neighbors

neighbor_key {spatial_neighbors} in adata.uns.keys(),

spatial_distances

neighbor_key {spatial_distances} in adata.obsp.keys().

system

‘niches_n2n’(defult) cell-cell signaling (‘niches_c2c’), defined as the signals passed between cells, determined by the product of the ligand expression of the sending cell and the receptor expression of the receiving cell, and system-cell signaling (‘niches_n2c’), defined as the signaling input to a cell, determined by taking the geometric mean of the ligand profiles of the surrounding cells and the receptor profile of the receiving cell.similarly, ‘niches_c2n’,’niches_n2n’.

Returns:

An anndata of Niches, which rows are mechanisms and columns are all possible cell x cell interactions.

spateo.tools.cell_communication.predict_ligand_activities(adata: anndata.AnnData, path: str, sender_cells: List[str] | None = None, receiver_cells: List[str] | None = None, geneset: List[str] | None = None, ratio_expr_thresh: float = 0.01, species: Literal['human', 'mouse'] = 'human') pandas.DataFrame[source]

Function to predict the ligand activity.

Our method is adapted from: Robin Browaeys, Wouter Saelens & Yvan Saeys. NicheNet: modeling intercellular communication by linking ligands to target genes. Nature Methods volume 17, pages159–162 (2020).

Parameters:
path

Path to ligand_target_matrix, lr_network (human and mouse).

adata

An Annodata object.

sender_cells

Ligand cells.

receiver_cells

Receptor cells.

geneset

The genes set of interest. This may be the differentially expressed genes in receiver cells (comparing cells in case and control group). Ligands activity prediction is based on this gene set. By default, all genes expressed in receiver cells is used.

ratio_expr_thresh

The minimum percentage of buckets expressing the ligand (target) in sender(receiver) cells.

Returns:

A pandas DataFrame of the predicted activity ligands.

spateo.tools.cell_communication.predict_target_genes(adata: anndata.AnnData, path: str, sender_cells: List[str] | None = None, receiver_cells: List[str] | None = None, geneset: List[str] | None = None, species: Literal['human', 'mouse'] = 'human', top_ligand: int = 20, top_target: int = 300) pandas.DataFrame[source]

Function to predict the target genes.

Parameters:
lt_matrix_path

Path to ligand_target_matrix of NicheNet.

adata

An Annodata object.

sender_cells

Ligand cells.

receiver_cells

Receptor cells.

geneset

The genes set of interest. This may be the differentially expressed genes in receiver cells (comparing cells in case and control group). Ligands activity prediction is based on this gene set. By default, all genes expressed in receiver cells is used.

top_ligand

int (default=20) select 20 top-ranked ligands for further biological interpretation.

top_target

int (default=300) Infer target genes of top-ranked ligands, and choose the top targets according to the general prior model.

Returns:

A pandas DataFrame of the predict target genes.