Note: 10x Genomics does not provide support for community-developed tools and makes no guarantees regarding their function or performance. Please contact tool developers with any questions. If you have feedback about Analysis Guides, please email analysis-guides@10xgenomics.com.
The spatialdata
/scverse
Python ecosystem offers a comprehensive and unified framework for analyzing Xenium In Situ data. It addresses the challenges of large and multimodal spatial omics datasets through its core spatialdata
object, which efficiently stores and manages images, labels, points, shapes, and tabular data (AnnData) in a common coordinate system. Key Python libraries like spatialdata
(for core data structures and operations), spatialdata-io
(for importing Xenium data) and spatialdata-plot
(for static plotting) facilitate data handling, analysis, and visualization. Furthermore, its seamless integration with the scverse
ecosystem (e.g., scanpy
for single cell analysis and squidpy
for spatial statistics) and bidirectional interoperability with 10x Genomics Xenium Explorer enable a complete workflow from data loading and quality control to advanced spatial analysis, multimodal integration, and interactive visualization.
Once a Xenium Analyzer run is complete, the on-instrument pipeline provides a list of output files that are ready for downstream analysis. This Analysis Guide article outlines how to use the spatialdata
, scanpy
, and squidpy
libraries to load and analyze Xenium data. It shows how to read and load Xenium data, plot transcripts and cells, select sub-regions of interest, single cell preprocessing and integration, and optional downstream analysis like neighborhood enrichment analysis.
- Select Python as the programming language: Click Runtime, then ensure "Runtime type" is set to "Python". We recommend selecting "v2-8 TPU" for this Google Colab tutorial.
- Click the "Connect" button on the top-right corner. Now, you are ready to run the tutorial.
- You can run the analysis using the data we provided in the code. Alternatively, you can also load your own data by following the instructions at the beginning of each section.
-
1. Install packages and download the data
- 1.2 Download and preprocess the Xenium data (optional)
- 1.2.1 Download data and convert to spatialdata zarr format
- 1.2 Download and preprocess the Xenium data (optional)
-
2. Xenium data visualization and analysis (for one sample)
- Section 2.1 Introduction to SpatialData
- Section 2.2 Loading objects for Xenium data
- Section 2.3 Transcript and cell plotting functions for Xenium data
- Section 2.4 Select sub-region of interest
- 2.4.1 Select sub-region by coordinates
- 2.4.2 Select sub-region by cell IDs
- Section 2.5 Downstream Xenium data analysis of count matrix (
sdata['table']
)- 2.5.1 Quick introduction to anndata
- 2.5.2 Standard data preprocessing
- Run UMAP
- Load processed data if you skip the above step
- 2.5.3 Plot clustering results spatially in slide
- 2.5.4 Export clustering results and visualize in Xenium Explorer
- 2.5.5 Find marker genes for each cluster (for cell annotation)
- 2.5.6 Cell annotation based on marker genes in each cluster
- 2.5.7 Saving the processed data
-
3. Xenium Prime multi-sample integration using sketch and Harmony
- Section 3.1 Downloading breast and cervical Xenium Prime data
- Section 3.2 Conventional data processing by processing in memory
- Section 3.3 Sketching of data for faster visualization (Optional)
- Section 3.4 Batch correction by Harmony
- Load processed data if you skip the above step
- Section 3.5 Export all cell clustering results in CSV and import to Xenium Explorer
- Section 3.6 Find cluster marker genes for cell annotation
- Section 3.7 Subset for macrophages
-
4. [Additional Topics] Neighbors enrichment analysis
- Section 4.1 Building a spatial neighborhood graph
- 4.1.1 Compute centrality scores
- Section 4.2 Neighbors enrichment analysis
- Section 4.3 Identify Spatially Variable genes/features (SVF) by Moran's I score
- Section 4.1 Building a spatial neighborhood graph
- Understanding Xenium Outputs
- Introduction to 10x Genomics Xenium In Situ Data Analysis Tools: Continuing Your Journey after Xenium Analyzer
- Getting Started with Xenium In Situ Downstream Analysis in R: A Tutorial in Google Colab
- Annotating Cell Types in Xenium In Situ Data with Label Transfer
- How do you integrate multiple samples for Xenium analysis?
- To help decide whether R or Python is the best tool for your Xenium data analysis, please refer to this blog post.