Interactive stLearn¶
In this tutorial, we introduce several functions for interactive plotting to explore the progression of Ductal Carcinoma in situ (DCIS) - Invasive Ductal Cancer (IDC)
Source: https://support.10xgenomics.com/spatial-gene-expression/datasets
If you are using jupyter lab, then you need to run these two lines of code:
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install @bokeh/jupyter_bokeh
[1]:
import stlearn as st
# Ingore all warnings
import warnings
warnings.filterwarnings("ignore")
[5]:
### If encounter issues with Bokeh loading, below may be helpful ####
import os
os.environ["BOKEH_ALLOW_WS_ORIGIN"] = "localhost:8889"
We created a processed Visium data and you can now plot all interactive plots with stLearn.
[2]:
#data = st.dataset.example_bcba() # TODO update this function
import scanpy as sc
data = sc.read_h5ad('/Volumes/GML001-Q1851/Brad/breast_LRCCIResults.h5ad')
[3]:
data
[3]:
AnnData object with n_obs × n_vars = 3813 × 20687
obs: 'in_tissue', 'array_row', 'array_col', 'imagecol', 'imagerow', 'cell_type'
var: 'gene_ids', 'feature_types', 'genome', 'n_cells'
uns: 'cell_type', 'cell_type_colors', 'lr_cci_cell_type', 'lr_cci_raw_cell_type', 'lr_spot_indices', 'lr_summary', 'lrfeatures', 'per_lr_cci_cell_type', 'per_lr_cci_pvals_cell_type', 'per_lr_cci_raw_cell_type', 'spatial', 'spot_neighbours'
obsm: '-log10(p_adjs)', 'lr_scores', 'lr_sig_scores', 'p_adjs', 'p_vals', 'spatial', 'spot_neighbours'
Interactive gene plot¶
We provide several options:
Gene
: Choose the available gene in the datasetSpot alpha
: Choose the opacity value of spotsTissue alpha
: Choose the opacity of H&E imageSpot size
: Choose the size of the spots
[ ]:
st.pl.gene_plot_interactive(data)
Interactive cluster plot with Pseudo-time-space results¶
We provide several options:
Spot alpha
: Choose the opacity value of spotsTissue alpha
: Choose the opacity of H&E imageSpot size
: Choose the size of the spotsChoose clusters
: Choose clusters to be displayedShow spatial trajectories
: Option to show spatial trajectories
[5]:
st.pl.cluster_plot_interactive(data, use_label="louvain")
Ligand-receptor interactions plot¶
Displays the LRs score for significant spots.
Note that need to perform stLearn LR analysis first.
Options:
Ligand receptor
: Choose the ligand-receptor results to view; ranked from most no. of significant spots to leastTissue alpha
: Choose the opacity of H&E imageSpot size
: Choose the size of the spots
[ ]:
st.pl.lr_plot_interactive(data)
Cell-cell interaction spatial plot¶
Displays significant Cell type-cell type interactions for selected ligand-receptor pairs in their spatial context.
Note that need to performed stlearn cci analysis first.
Options:
Cell-type annotation select
: Choose the cell type labels for which CCI permutation has been performed.Ligand receptor
: Choose the ligand-receptor that facilitates the CCIs; ranked from most no. of significant spots to leastTissue alpha
: Choose the opacity of H&E imageSpot size
: Choose the size of the spotsArrow size
: The size of the arrows; direction indicates predicted direction of interaction (ligand->receptor)
[ ]:
st.pl.spatialcci_plot_interactive(data)