Question regarding spatial sparsity for TMA's
Hello,
We are attempting to use Tangram on a spatial dataset containing multiple tissue sections within a TMA. Because of this tissues from individual samples contain white space between them which we've noticed has an effect on the spatial sparsity.
We are wondering if it is recommended to run tangram in a loop individually for each sample to retain the spatial distributions belonging to each sample.
Our current loop looks as such but we would appreciate feedback on if this approach is necessary or if Tangrams deep learning can overcome this challenge.
#create empty list for mapped adata's mapped_adatas = [] samples = adata_spatial.obs['sample_id'].unique()
Loop throgh each sample and append
for sample in tqdm(samples, desc="Processing Tangram per sample"): print(f"Processing sample: {sample}")
# Subset the spatial dataset for the current sample
adata_spatial_sample = adata_spatial[adata_spatial.obs['sample_id'] == sample].copy()
# Preprocess the single-cell and spatial data
tg.pp_adatas(reference_single_cell, adata_spatial_sample, genes=markers)
# Run Tangram mapping
ad_map = tg.map_cells_to_space(
reference_single_cell, adata_spatial_sample,
mode="clusters",
cluster_label='cell_type',
density_prior='rna_count_based',
num_epochs=500,
device='cpu', # Set to 'cuda:0' for GPU
)
# Project cell annotations onto spatial data
tg.project_cell_annotations(ad_map, adata_spatial_sample, annotation="cell_type")
mapped_adatas.append(adata_spatial_sample)
Merge all mapped AnnData objects
adata_spatial_map = sc.concat(mapped_adatas, join='outer', merge='same')
Thanks!