terra.get_spatial_score#
- terra.get_spatial_score(dataset, model_folder_path, emb_layer=None, cell_gene_ensembl_id=[], neighborhood_gene_ensembl_id=[], batch_size=128, pin_memory=False, num_workers=12, compute_cosine_with_list=['cell', 'neighborhood'])#
Compute and return cosine similarity matrix for specified gene IDs.
- Parameters:
dataset (
Dataset) – Tokenized Hugging Face dataset.model_folder_path (
str) – Path to the folder containing the model config, token dictionary, and normalization factors.emb_layer (
Optional[int] (default:None)) – Layer for which to retrieve the embedding.cell_gene_ensembl_id (
list(default:[])) – List with gene IDs for which cell gene embeddings will be retrieved.neighborhood_gene_ensembl_id (
list(default:[])) – List with gene IDs for which neighborhood gene embeddings will be retrieved.batch_size (
int(default:128)) – Dataloader param.pin_memory (
bool(default:False)) – Dataloader param.num_workers (
int(default:12)) – Number of workers used.compute_cosine_with_list (
list[str] (default:['cell', 'neighborhood'])) – Items with which to compute cosine similarity; may contain'cell'and/or'neighborhood'.
- Return type:
- Returns:
-cos_sim_dict (
dict) Dictionary containing cosine similarity statistics as numpy arrays.