{ "cells": [ { "cell_type": "markdown", "id": "ffe9c42b-4aa3-4471-836d-e41c0afcd43c", "metadata": {}, "source": [ "# Spatial Communication\n", "\n", "Spatial communication is a point of interest for us for the Spatial Transcriptomics Society, and we would like to find the conduction process of spatial communication.\n", "\n", "Here, we introduce two method integrated in omicverse named `COMMOT` and `flowsig`.\n", "\n", "We made three improvements in integrating the `COMMOT` and `flowsig` algorithm in OmicVerse:\n", "\n", "- We reduced the installation conflict of `COMMOT` and `flowsig`, user only need to update OmicVerse to the latest version.\n", "- We optimized the visualization of `COMMOT` and `flowsig` and unified the data preprocessing process so that users don't need to struggle with different data processing flows.\n", "- We have fixed some bugs that could occur during function.\n", "\n", "If you found this tutorial helpful, please cite `COMMOT`, `flowsig` and OmicVerse:\n", "\n", "- Cang, Z., Zhao, Y., Almet, A.A. et al. Screening cell–cell communication in spatial transcriptomics via collective optimal transport. Nat Methods 20, 218–228 (2023). https://doi.org/10.1038/s41592-022-01728-4\n", "- Almet, A.A., Tsai, YC., Watanabe, M. et al. Inferring pattern-driving intercellular flows from single-cell and spatial transcriptomics. Nat Methods (2024). https://doi.org/10.1038/s41592-024-02380-w" ] }, { "cell_type": "code", "execution_count": 1, "id": "76708a06-931c-4e5a-a7a0-8225e75b5f16", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2024-09-25 22:44:46.073641: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:485] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n", "2024-09-25 22:44:46.086703: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:8454] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n", "2024-09-25 22:44:46.090667: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1452] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n", "2024-09-25 22:44:46.797027: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " ____ _ _ __ \n", " / __ \\____ ___ (_)___| | / /__ _____________ \n", " / / / / __ `__ \\/ / ___/ | / / _ \\/ ___/ ___/ _ \\ \n", "/ /_/ / / / / / / / /__ | |/ / __/ / (__ ) __/ \n", "\\____/_/ /_/ /_/_/\\___/ |___/\\___/_/ /____/\\___/ \n", "\n", "Version: 1.6.7, Tutorials: https://omicverse.readthedocs.io/\n", "All dependencies are satisfied.\n" ] } ], "source": [ "import omicverse as ov\n", "#print(f\"omicverse version: {ov.__version__}\")\n", "import scanpy as sc\n", "#print(f\"scanpy version: {sc.__version__}\")\n", "ov.plot_set()" ] }, { "cell_type": "markdown", "id": "853910d2-ad08-4de3-8e24-6ebae25e167a", "metadata": {}, "source": [ "## Preprocess data\n", "\n", "Here we present our re-analysis of 151676 sample of the dorsolateral prefrontal cortex (DLPFC) dataset. Maynard et al. has manually annotated DLPFC layers and white matter (WM) based on the morphological features and gene markers.\n", "\n", "This tutorial demonstrates how to identify spatial domains on 10x Visium data using STAGATE. The processed data are available at https://github.com/LieberInstitute/spatialLIBD. We downloaded the manual annotation from the spatialLIBD package and provided at https://drive.google.com/drive/folders/10lhz5VY7YfvHrtV40MwaqLmWz56U9eBP?usp=sharing." ] }, { "cell_type": "code", "execution_count": 40, "id": "61e4f6ad-27b1-49ca-819e-96336edd0d15", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "reading data/151676_filtered_feature_bc_matrix.h5\n", " (0:00:00)\n" ] } ], "source": [ "adata = sc.read_visium(path='data', count_file='151676_filtered_feature_bc_matrix.h5')\n", "adata.var_names_make_unique()" ] }, { "cell_type": "markdown", "id": "6be9fc9f-67a4-4cc2-b552-6d85832d891a", "metadata": {}, "source": [ "
Note
\n", "\n", " We introduced the spatial special svg calculation module prost in omicverse versions greater than `1.6.0` to replace scanpy's HVGs, if you want to use scanpy's HVGs you can set mode=`scanpy` in `ov.space.svg` or use the following code.\n", "
\n", "Note
\n", "\n", " You can also use Celltype and other annotated results in adata.obs, here is just a randomly selected type, there is no particular significance, in order to facilitate the visualization and study the signal\n", "
\n", "| \n", " | ligand | \n", "receptor | \n", "pathway | \n", "
|---|---|---|---|
| 0 | \n", "NRG3 | \n", "ERBB4 | \n", "NRG | \n", "
| 1 | \n", "FGF1 | \n", "FGFR2 | \n", "FGF | \n", "
| 2 | \n", "FGF1 | \n", "FGFR3 | \n", "FGF | \n", "
| 3 | \n", "PDGFA | \n", "PDGFRA | \n", "PDGF | \n", "
| 4 | \n", "SPP1 | \n", "ITGAV_ITGB1 | \n", "SPP1 | \n", "
| \n", " | Gene | \n", "GEM | \n", "Weight | \n", "
|---|---|---|---|
| 0 | \n", "PVALB | \n", "GEM-5 | \n", "0.716875 | \n", "
| 1 | \n", "CPB1 | \n", "GEM-5 | \n", "0.599011 | \n", "
| 2 | \n", "GPX3 | \n", "GEM-5 | \n", "0.471268 | \n", "
| 3 | \n", "SCRT1 | \n", "GEM-5 | \n", "0.450501 | \n", "
| 4 | \n", "MT-CO2 | \n", "GEM-5 | \n", "0.450483 | \n", "