omics.co.in logo omics.co.in

12: Single-Cell RNA-Seq Analysis with Seurat

Tested Stacks: GATK 4.6.1 Samtools 1.21 Nextflow 24.10 Seurat v5.1 Python 3.12
Prerequisites: Basic Linux CLI & Sequencing Formats
📚 Chapter 12 of 13 0% Course Completed
📊 Downloadable Lesson R Script 4.7 KB

r12_single_cell_seurat_pipeline.R

10x Genomics UMI matrix processing, cell QC (nUMI, nGene, percent.mt), apoptotic filtering, log-normalization (10k scale), PCA reduction, and cluster biomarker identification.

$ Rscript r12_single_cell_seurat_pipeline.R

Chapter 12: Introduction to Single-Cell RNA-Seq Analysis with Seurat

Bulk RNA-Seq averages expression across heterogeneous tissue samples. Single-cell RNA-Seq (scRNA-seq) profiles individual cellular transcriptomes using microfluidic droplet technologies (10x Genomics Chromium). Seurat is the preeminent R toolkit for single-cell genomics.

1. Seurat Object Creation & Cell Quality Control

library(Seurat)

# Create Seurat object from 10x matrix
pbmc <- CreateSeuratObject(counts = raw_counts, project = "PBMC_Immune", min.cells = 3, min.features = 200)

# Calculate mitochondrial fraction
pbmc[["percent.mt"]] <- PercentageFeatureSet(pbmc, pattern = "^MT-")

# Filter low-quality / apoptotic cells
pbmc <- subset(pbmc, subset = nFeature_RNA > 200 & nFeature_RNA < 2500 & percent.mt < 10)

2. Normalization & Variable Feature Selection

pbmc <- NormalizeData(pbmc, normalization.method = "LogNormalize", scale.factor = 10000)
pbmc <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = 2000)

3. Dimensionality Reduction & Cell Clustering

pbmc <- ScaleData(pbmc)
pbmc <- RunPCA(pbmc, features = VariableFeatures(pbmc))
pbmc <- FindNeighbors(pbmc, dims = 1:15)
pbmc <- FindClusters(pbmc, resolution = 0.5)
pbmc <- RunUMAP(pbmc, dims = 1:15)

# Visualize clusters in 2D UMAP space
DimPlot(pbmc, reduction = "umap", label = TRUE)

4. Cluster Biomarker Discovery

# Identify marker genes for each cluster
pbmc_markers <- FindAllMarkers(pbmc, only.pos = TRUE, min.pct = 0.25, logfc.threshold = 0.25)
head(pbmc_markers)
⚠️

Common Pitfalls & Troubleshooting Checklist

  • Java Heap Exhaustion (GATK / Picard): If processes terminate with java.lang.OutOfMemoryError, set your environment variable explicitly: export _JAVA_OPTIONS="-Xmx16g -Djava.io.tmpdir=/tmp".
  • Index Timestamp Mismatch: If tools complain that a BAM index is missing or out of date, regenerate with samtools index -@ 4 sample.bam.
  • Conda Channel Conflicts: Avoid ABI incompatibilities between bioconda and conda-forge by setting strict priority: conda config --set channel_priority strict.
  • Chromosome Naming Contamination: Always verify whether reference FASTA headers use chr1 or 1; divergent naming causes silent alignment drops.
Was this guide helpful to your research?
Help us maintain 100% accurate, peer-reviewed bioinformatics standards.
📝 Propose Edit on GitHub ↗