Examples: Visium Brain
The test data file locates at https://github.com/bioinfo-biols/RidgeSpace/tree/main/tests/test.h5ad.
[1]:
import RidgeSpace
import anndata as ad
import seaborn as sns
sns.set(style="ticks", font_scale=1.5)
adata = ad.read_h5ad('./tests/test.h5ad')
Preproccess
Only need run once.
[2]:
RidgeSpace.tl_mesh(adata, mesh_optimization=True, save_address='test')
Radius Count
366.531036 2322
365.005479 1946
365.001370 1910
366.772409 1760
367.266933 807
dtype: int64
Use default radius 373.8616562312856
Triangles mesh saved in ./Ridge_tmp/test/
Mesh optimization done
[3]:
RidgeSpace.tl_HE(adata, save_address='test', filter_background=True, threshold_scale= 1.1)
Using CytAssist_FreshFrozen_Mouse_Brain
HE information saved in ./Ridge_tmp/test/
Denoising for each gene for ploting later. Only need run once.
[4]:
RidgeSpace.tl_denoise(adata, plot_name = 'Mbp', save_address='test')
Denoised value for Mbp saved in ./Ridge_tmp/test/
[5]:
RidgeSpace.tl_denoise(adata, plot_name = 'Tnnt1', save_address='test')
Denoised value for Tnnt1 saved in ./Ridge_tmp/test/
[6]:
RidgeSpace.tl_denoise(adata, plot_name = 'Tnnt2', save_address='test')
Denoised value for Tnnt2 saved in ./Ridge_tmp/test/
[7]:
RidgeSpace.tl_denoise(adata, plot_name = 'Baiap2', save_address='test')
Denoised value for Baiap2 saved in ./Ridge_tmp/test/
[8]:
RidgeSpace.tl_denoise(adata, plot_name = 'Baiap3', save_address='test')
Denoised value for Baiap3 saved in ./Ridge_tmp/test/
Single gene
Close view
[6]:
RidgeSpace.pl_single(adata, plot_name = 'Mbp', obs_cluster='Clusters', save_address='test', elev=40, view=160, lw=1, normalize_z=True, return_ax=True)
[6]:
<Axes3DSubplot:xlabel='Spatial 1', ylabel='Spatial 2'>
Distant view
[5]:
RidgeSpace.pl_single(adata, plot_name = 'Mbp', obs_cluster='Clusters', save_address='test', elev=60, view=160, bg_alpha=5, normalize_z=True, return_ax=True)
[5]:
<Axes3DSubplot:xlabel='Spatial 1', ylabel='Spatial 2'>
Overlay Histology
[9]:
RidgeSpace.pl_single(adata, plot_name = 'Mbp', obs_cluster='Clusters', save_address='test', elev=30, view=160,\
plot_HE=True, plot_clustering=True, clustering_alpha=0.2)
Multiple genes
[10]:
RidgeSpace.pl_multipleOUT(adata, plot_nameA = 'Tnnt1', plot_nameB = 'Tnnt2', obs_cluster='Clusters', normalize_z=True, save_address='test', \
elev=20, view=160, plot_HE=True, z_height=1.5, lw=1, select_c=['#aa40fc', '#8e584d', '#b0c9ea', '#ff8110', '#2179b6', '#29a06a'])
[14]:
RidgeSpace.pl_multipleOUT(adata, plot_nameA = 'Tnnt2', plot_nameB = 'Tnnt1', obs_cluster='Clusters', normalize_z=True, normlabels=False, save_address='test',\
elev=20, view=160, plot_HE=True, bg_alphaA=1, z_height=1.5, lw=1, select_c=['#aa40fc', '#8e584d', '#b0c9ea', '#ff8110', '#2179b6', '#29a06a'])
[16]:
RidgeSpace.pl_multipleIN(adata, plot_nameA = 'Baiap3', plot_nameB = 'Baiap2', obs_cluster='Clusters', save_address='test',\
normlabels=False, elev=20, view=10, height=120, plot_HE=True, HE_slice=4, plot_clustering=True, clustering_alpha=0.2, lw=1, ylim_min=800)
Trajectory
[17]:
RidgeSpace.pl_trajectory(adata, plot_name = 'Pseudotime', obs_cluster='Clusters', elev=45, view=165, HE_z=10, save_address='test',\
min_length=0.2, density_arrow=0.3, lw_arrow=1.2, zlim_min=0, xlim_min=1000, ylim_min=1000)
No file named Pseudotime in ./Ridge_tmp/test/
Using noisy information in adata