Skill

Analyze Single-Cell RNA-Seq Data with Scanpy

A skill for complete Scanpy single-cell RNA-seq workflows - QC, clustering, marker genes, and trajectory analysis.

Works with github

79
Spark score
out of 100
Updated 10 days ago
Version 15.1.0

Add to Favorites

Why it matters

Leverage the Scanpy toolkit to perform comprehensive single-cell RNA-sequencing data analysis, from quality control and normalization to dimensionality reduction, clustering, and marker gene identification.

Outcomes

What it gets done

01

Perform quality control and filtering of scRNA-seq datasets.

02

Normalize, log-transform, and identify highly variable genes.

03

Conduct dimensionality reduction (PCA, UMAP, t-SNE) and clustering (Leiden).

04

Identify marker genes, annotate cell types, and generate visualizations.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-scanpy | bash

Overview

Scanpy: Single-Cell Analysis

A skill for complete Scanpy single-cell RNA-seq workflows - QC filtering, normalization, PCA/UMAP dimensionality reduction, Leiden clustering, marker gene identification, and trajectory inference. Use it for end-to-end single-cell RNA-seq analysis - start from the bundled analysis template and QC script rather than building the pipeline from scratch.

What it does

This skill applies Scanpy, a scalable Python toolkit built on AnnData, to complete single-cell RNA-seq workflows: quality control, normalization, dimensionality reduction, clustering, marker gene identification, visualization, and trajectory analysis. It works with .h5ad, 10X, and CSV input formats, and centers on the AnnData object, which holds the expression matrix (adata.X), cell metadata (adata.obs), gene metadata (adata.var), unstructured annotations (adata.uns), and multi-dimensional embeddings like PCA/UMAP (adata.obsm).

The standard workflow runs seven steps. Quality control flags mitochondrial genes, calculates QC metrics, visualizes them with violin plots, then filters low-quality cells and genes:

### Identify mitochondrial genes
adata.var['mt'] = adata.var_names.str.startswith('MT-')

### Calculate QC metrics
sc.pp.calculate_qc_metrics(adata, qc_vars=['mt'], inplace=True)

### Visualize QC metrics
sc.pl.violin(adata, ['n_genes_by_counts', 'total_counts', 'pct_counts_mt'],
             jitter=0.4, multi_panel=True)

### Filter cells and genes
sc.pp.filter_cells(adata, min_genes=200)
sc.pp.filter_genes(adata, min_cells=3)
adata = adata[adata.obs.pct_counts_mt < 5, :]  # Remove high MT% cells

Normalization scales counts per cell, log-transforms, saves raw counts for later reference, selects highly variable genes, and scales the data. Dimensionality reduction runs PCA (checking the variance-ratio elbow plot), computes a neighborhood graph, and projects to UMAP or t-SNE. Clustering uses Leiden (recommended over Louvain) across multiple resolutions to find the right granularity. Marker gene identification runs rank_genes_groups per cluster and visualizes results as heatmaps or dot plots. Cell type annotation maps known marker genes (like CD3D, CD14, MS4A1) to clusters manually. Results get saved as .h5ad plus exported metadata CSVs.

Beyond the standard workflow it covers publication-quality plotting (high-DPI figure settings, custom UMAP styling, heatmaps, dot plots), trajectory inference via PAGA and diffusion pseudotime, differential expression between conditions within a cell type, gene set scoring, and batch correction via ComBat (or pointing to Harmony/scVI as separate packages for more advanced correction). Key tunable parameters include min_genes/min_cells/pct_counts_mt for QC, target_sum for normalization, n_top_genes for feature selection, n_pcs/n_neighbors for dimensionality reduction, and resolution for clustering granularity.

Eight best practices anchor the workflow: always save raw counts before filtering genes, check QC plots carefully rather than using fixed thresholds, prefer Leiden over Louvain, try multiple clustering resolutions, validate cell type annotations against multiple marker genes, use use_raw=True for expression plots, check the PCA variance-ratio plot to pick the number of components, and save intermediate checkpoints since long workflows can fail partway through. It bundles an automated QC script (scripts/qc_analysis.py), a complete analysis template to copy and customize, and three reference docs covering the full step-by-step workflow, the function API by module, and comprehensive plotting patterns.

When to use - and when NOT to

Use it for analyzing single-cell RNA-seq data end to end - quality control, UMAP/t-SNE/PCA visualization, clustering and marker genes, cell type annotation, trajectory or pseudotime analysis, or publication-quality plots. Start from the bundled analysis template and run the QC script first rather than writing the pipeline from scratch each time.

Inputs and outputs

Input is single-cell expression data in .h5ad, 10X, or CSV format. Output is a processed AnnData object with QC filtering, normalization, clustering, and cell-type annotations applied, plus exported metadata CSVs and publication-ready figures.

Integrations

It's built on AnnData and integrates with the broader scverse ecosystem (squidpy, scvi-tools, cellrank) for spatial, deep-generative, and trajectory extensions, plus optional Harmony/scVI packages for advanced batch correction beyond ComBat.

Who it's for

Computational biologists and bioinformaticians running single-cell RNA-seq analysis who need a complete, parameterized workflow from raw counts through QC, clustering, marker genes, and publication-quality figures.

Source README

Scanpy is a scalable Python toolkit for analyzing single-cell RNA-seq data, built on AnnData. Apply this skill for complete single-cell workflows including quality control, normalization, dimensionality reduction, clustering, marker gene identification, visualization, and trajectory analysis.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.