Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Spatial Omics Analysis Pipeline

This project processes spatial transcriptomics data from a .zarr store and prepares it for downstream clustering and spatial analysis workflows.

The pipeline focuses on:

  • Spatial coordinate extraction
  • Gene expression preprocessing
  • PCA-based dimensionality reduction
  • Clustering analysis and validation
  • Spatial embedding preparation

Tech Stack

  • Python
  • Scanpy
  • SpatialData
  • AnnData
  • NumPy
  • Pandas
  • Scikit-learn
  • Shapely
  • Leidenalg

Data Processing Pipeline

1. Spatial Data Loading

Spatial transcriptomics data was loaded from a .zarr store using the SpatialData framework.

spatialdata.read_zarr()

The dataset contained:

  • Cell geometries
  • Gene expression counts
  • Spatial metadata

2. Cell Coordinate Extraction

Cell geometries were stored as WKB (Well-Known Binary) objects.

Using shapely, the geometries were decoded and converted into centroid coordinates:

  • x
  • y

This produced a structured spatial representation for each cell.

Output

File Description
exports/cell_coordinates.csv Cell IDs with centroid coordinates

3. Gene Expression Matrix Extraction

Gene expression counts were extracted from the AnnData table inside the Zarr store.

Dataset Shape

  • Cells: 2,389
  • Genes: 268

The sparse matrix was converted into a dense tabular format for downstream analysis.

Output

File Description
exports/count_matrix.csv Gene expression matrix

PCA-Based Dimensionality Reduction

To prepare the data for clustering, I performed a systematic PCA analysis instead of selecting the number of components arbitrarily.


Variance Analysis

I evaluated cumulative variance explained across multiple thresholds:

Variance Threshold Components Required
50% 43
75% 108
90% 171
95% 203

Diagnostic Evaluation

To determine the optimal PCA dimension, I analyzed:

  • Scree plots
  • Eigenvalue decay
  • Log-scale variance plots
  • Cumulative explained variance
  • Clustering stability across dimensions

Clustering Stability Analysis

I tested clustering performance across multiple PCA dimensions:

PCA Components Variance Captured Clusters Found
5 24.2% 8
10 30.3% 8
15 34.4% 8
30 43.6% 7
50 53.6% 6

Final PCA Selection

I selected:

n_components = 15

Rationale

  • Captured meaningful biological variation
  • Produced stable cluster separation
  • Reduced noise amplification
  • Avoided over-clustering
  • Improved downstream UMAP and Leiden clustering efficiency

This selection balanced:

  • Information retention
  • Computational efficiency
  • Biological interpretability

rather than relying on arbitrary PCA dimensions.


Downstream Analysis

The processed embeddings were used for:

  • UMAP visualization
  • Leiden clustering
  • Spatial embedding analysis

Key Takeaways

This project demonstrates:

  • Working with large spatial omics datasets
  • Spatial transcriptomics preprocessing
  • Dimensionality reduction and clustering validation
  • Data-driven PCA component selection
  • Integration of spatial and gene expression data for downstream ML workflows

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages