SpaRCL.run_RCL#

SpaRCL.run_RCL(adata, beta=0.01, tol_err=1e-05, n_iters=1000, use_highly_variable=None, random_state=0, device=None, key_added=None, copy=False)[source]#

Relational Contrastive Learning for spatial transcriptomics.

Parameters:
adata : AnnData

Annotated data matrix.

beta : float (default: 0.01)

Parameter to balance the main equation and the constraints.

tol_err : float (default: 1e-05)

Relative error tolerance (convergence criteria).

n_iters : int (default: 1000)

Number of iterations for the optimization.

use_highly_variable : bool | NoneOptional[bool] (default: None)

Whether to use highly variable genes only, stored in adata.var[‘highly_variable’]. By default uses them if they have been determined beforehand.

random_state : int (default: 0)

Change to use different initial states for the optimization.

device : str | NoneOptional[str] (default: None)

The desired device for PyTorch computation. By default uses cuda if cuda is avaliable cpu otherwise.

key_added : str | NoneOptional[str] (default: None)

If not specified, the relational contrastive learning data is stored in adata.uns[‘relation’] and the relation matrix is stored in adata.obsp[‘relation’]. If specified, the relational contrastive learning data is added to adata.uns[key_added] and the relation matrix is stored in adata.obsp[key_added+’_relation’].

copy : bool (default: False)

Return a copy instead of writing to adata.

Return type:

AnnData | NoneOptional[AnnData]

Returns:

Depending on copy, returns or updates adata with the following fields.

See key_added parameter description for the storage path of the relation matrix.

.obsp[‘relation’]csr_matrix

The sample-by-sample relation matrix.

.uns[‘relation’][‘gene_relation’]csr_matrix

The gene-by-gene relation matrix.

.uns[‘relation’][‘gene_names’]ndarray

The gene names of gene relation matrix.