Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Spatial Transcriptomics Analysis (Scanpy + Squidpy)

Overview

An end-to-end spatial transcriptomics pipeline built with Scanpy and Squidpy, taking a 10x Genomics Visium slide from raw counts through quality control, clustering, marker-gene analysis, and cell-type annotation, and then mapping the annotated cell types back onto the tissue image.

Pipeline

Step Implementation
Load data sc.datasets.visium_sge(), with var_names_make_unique()
Quality control sc.pp.calculate_qc_metrics
Normalization normalize_total(target_sum=1e4) + log1p
Dimensionality reduction sc.pp.pca -> sc.pp.neighbors -> sc.tl.umap
Clustering sc.tl.leiden
Marker genes sc.tl.rank_genes_groups (cluster vs. rest), dotplot
Annotation Leiden clusters mapped to cell-type labels
Spatial visualization sq.pl.spatial_scatter over the tissue image

Dataset

A public 10x Visium sample loaded directly through Scanpy's visium_sge() dataset loader, so no manual download is needed.

Results

Quality control — total counts and genes detected per spot:

QC violin plots

Leiden clustering in UMAP space:

UMAP Leiden clusters

Marker genes distinguishing each cluster from the rest, as a ranking and as a dotplot of mean expression and the fraction of spots expressing each gene:

Marker gene ranking Marker gene dotplot

Expression of the brain markers SLC17A7 (excitatory neurons), OLIG1 (oligodendrocytes), and GFAP (astrocytes) across the UMAP:

Marker gene UMAPs

Annotated cell types, in UMAP space and mapped back onto the tissue section:

UMAP cell types Spatial cell types

The spatial plot is the point of the whole exercise: clusters that look like abstract blobs in UMAP space resolve into contiguous, anatomically coherent regions once they are placed back on the tissue.

Repository layout

spatial.transcriptomic_Colab/
  src/
    pipeline.py               the pipeline, organized into functions
    pipeline_exploratory.py   the original linear Colab working script
  results/                    generated figures (checked in)
  cosmx_frontal_cortex/       figures from separate CosMx SMI work (see note)
  data/                       input data (not included; fetched by Scanpy)

How to run

pip install scanpy squidpy matplotlib
python src/pipeline.py

pipeline.py is the maintained version. pipeline_exploratory.py keeps the original top-to-bottom Colab script, including the intermediate steps and annotation attempts that led to the final cluster-to-cell-type mapping.

A note on cosmx_frontal_cortex/

Those four figures come from a different experiment — an R/ggplot analysis of a NanoString CosMx SMI Human Frontal Cortex dataset (cell types plotted against FOV pixel coordinates), not from the Scanpy/Squidpy Visium pipeline in this repository. They are kept in their own folder so the Visium results stay unambiguous. The full CosMx work lives in cosmx-spatial-transcriptomics.

About

Scanpy + Squidpy pipeline for 10x Visium spatial transcriptomics: QC, Leiden clustering, marker genes, cell-type annotation, and spatial mapping.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages