Plot the Results of the Mouse Spleen Dataset
Packages Loading
[1]:
import warnings
warnings.filterwarnings('ignore')
import matplotlib.pyplot as plt
import scanpy as sc
from sklearn.metrics.cluster import adjusted_rand_score
import sys
sys.path.append(r'../../../../')
from Model.utils import reorder_categories
Results Loading
[2]:
slice_id = 1 # 1, 2
adata_results = sc.read_h5ad(f'../../../Mouse_Spleen_Replicate{slice_id}.h5ad')
[3]:
adata_results
[3]:
AnnData object with n_obs × n_vars = 2568 × 0
obs: 'SpatialCOC', 'SpatialGlue', 'STAGATE', 'SpaGCN', 'Modality1', 'Modality2', 'MultiMAP', 'MultiVI', 'Seurat', 'COSMOS'
uns: 'COSMOS_colors', 'MultiMAP_colors', 'Seurat_colors'
obsm: 'COSMOS', 'Modality1', 'Modality2', 'MultiMAP', 'MultiVI', 'STAGATE', 'Seurat', 'SpatialCOC', 'SpatialGlue', 'spatial'
Plot the Spatial Domain Identifications
[8]:
## define the plot parameters
colors_domain = {
'SpatialCOC': [ '#fdf0d5', '#f9c74f', '#83c5be', '#99582a', '#3f5e66', '#ee6055' ],
'COSMOS': [ '#ee6055', '#f9c74f', '#83c5be', '#3f5e66', '#99582a', '#fdf0d5' ],
'SpatialGlue': [ '#fdf0d5', '#f9c74f', '#99582a', '#83c5be', '#ee6055', '#3f5e66' ],
'Seurat': [ '#83c5be', '#99582a', '#fdf0d5', '#f9c74f', '#ee6055', '#3f5e66' ],
'MultiMAP': [ '#ee6055', '#99582a', '#83c5be', '#fdf0d5', '#f9c74f', '#3f5e66' ],
'MultiVI': [ '#ee6055', '#99582a', '#83c5be', '#fdf0d5', '#f9c74f', '#3f5e66' ],
'SpaGCN': [ '#ee6055', '#99582a', '#f9c74f', '#fdf0d5', '#83c5be', '#3f5e66' ],
'STAGATE': [ '#fdf0d5', '#99582a', '#f9c74f', '#ee6055', '#83c5be', '#3f5e66' ],
'Modality1': [ '#ee6055', '#99582a', '#fdf0d5', '#f9c74f', '#3f5e66', '#83c5be' ],
'Modality2': [ '#99582a', '#83c5be', '#fdf0d5', '#ee6055', '#f9c74f', '#3f5e66' ],
}
font_size = 24
save_path = f'../../Mouse_Spleen/replicate{slice_id}/'
result_key = ['SpatialCOC', 'COSMOS', 'SpatialGlue', 'Seurat', 'MultiMAP', 'MultiVI', 'SpaGCN', 'STAGATE', 'Modality1', 'Modality2']
[9]:
plt.rcParams['font.sans-serif'] = ['Arial']
plt.rcParams['font.size'] = font_size
for result in result_key:
fig, ax = plt.subplots(1, 1, figsize=(6, 6))
sc.pl.embedding(adata_results, basis='spatial', color=[result], ax=ax, s=140, show=False, palette=colors_domain[result])
ax.set_title(f"")
ax.set_xlabel('')
ax.set_ylabel('')
ax.get_legend().remove()
# Hide axis borders
for spine in ax.spines.values():
spine.set_visible(False)
# Adjust subplot parameters
plt.subplots_adjust(left=0, right=1, top=1, bottom=0)
plt.tight_layout()
plt.savefig(f'{result}.png', dpi=500)
plt.savefig(f'{result}.eps')
plt.show()