Analysis Guides/

Getting Started with Xenium In Situ Downstream Analysis in R: A Tutorial in Google Colab

May 22, 2025
Share via:

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.

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 the Xenium In Situ data analysis tutorials in R hosted in Google Colab.

A few notes before you start exploring the Google Colab tutorials:

  • The tutorials use Xenium Prime 5K datasets, but similar analysis flows can be used for Xenium v1 data as well.
  • In this vignette, we cover some popular Xenium data analysis steps that we hope inspire your own data analysis journey. New and exciting tools and algorithms are published by the community on a regular basis and we encourage researchers to explore them as well.
  1. Select R as the programming language: Click Runtime, then ensure "Runtime type" is set to "R". We recommend selecting "v2-8 TPU" for this Google Colab tutorial.
  2. Click the "Connect" button on the top-right corner. Now, you are ready to run the tutorial.
  3. 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

2. Xenium data visualization and analysis (for one sample)

  • 2.1 Downloading Xenium Prime Breast Cancer data
  • 2.2 Loading Xenium Data
  • Tip: How can I convert transcripts.parquet to transcripts.csv.gz?
  • 2.3 Transcript plotting functions for Xenium data
  • 2.4 Select sub-region of interest
    • 2.4.1 Select sub-region by coordinates
    • 2.4.2 Select sub-region by cell IDs
  • 2.5 Xenium data downstream analysis
    • 2.5.1 Data preprocessing
    • 2.5.2 Plot clustering results in UMAP
    • 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

3. Xenium Prime multi-sample integration using Seurat sketch and Harmony

  • 3.1 Loading R packages
  • 3.2 Downloading breast and cervical Xenium Prime data
  • 3.3 Create on-disk representation for both Xenium data
  • Tip: What if I have multiple samples in one slide and their outputs are in one Xenium output bundle (one ROI)?
  • 3.4 Create a Seurat object (with both Xenium samples) with on-disk matrix
  • 3.5 "Sketch" subsampled cells and load these cells in memory
  • 3.6 Conventional data processing
  • 3.7 Batch correction by Harmony
  • 3.8 Project results from "sketch" 50k cells to all cells
  • 3.9 Export all cell clustering results in CSV and import to Xenium Explorer
  • 3.10 Find cluster marker genes for cell annotation
  • Tip: How to save this Seurat object (with 50k cells in memory and all cells on disk)?
  • 3.11 Subset Seurat object for macrophages

Additional Topics: 4. Spatially-informed clustering

  • 4.1 Data loading and preprocessing
  • 4.2 Running Banksy
  • 4.3 Export Banksy clustering results and visualize in Xenium Explorer
Stay connected with latest technical workflow and software updatesSubscribe to newsletter