Lab 3: QC for snRNA-seq data

scRNA-seq Analysis Pipeline

Notes

The estimated time for this lab is around 1h.

Aims

  • Load 10X Genomics data into R.
  • Create a Seurat object.
  • Perform quality control (QC) on single-cell data.
  • Prepare the object for the standard Seurat workflow.

3.1 Connect to RStudio Server

Open a browser and copy-paste the following address:

URL

http://10.35.229.71:8787/

Or click here: http://10.35.229.71:8787/

An RStudio log in page will appear; to log in, use your user ID for both ID and password.

3.2 Load Libraries and Data

We will use the Seurat package together with hdf5r to read the 10X Genomics HDF5 output produced by Cell Ranger.

3.2.1 (RStudio env)

Load libraries and read the 10X data

# Load
library(Seurat)
library(hdf5r)

h5     <- "/data/processed/cellranger/E4_Dev/filtered_feature_bc_matrix.h5"
txt_mt <- "/data/processed/cellranger/E4_Dev/Ens110_MT.txt"

inputdata.10x.filtered <- Read10X_h5(h5)
MT_Genes <- readLines(txt_mt)

# get GE
rna_counts <- inputdata.10x.filtered$`Gene Expression`

3.3 Create Seurat Object

3.3.1 (RStudio env)

Create the Seurat object

# Create seurat object
Obj_prefiltered <- CreateSeuratObject(counts = rna_counts, min.cells = 5)

3.4 Quality Control (QC)

3.4.1 (RStudio env)

Score mitochondrial content, etc

# Scoring for QC
MT_Genes_present <- MT_Genes[MT_Genes %in% rownames(Obj_prefiltered)]
Obj_prefiltered[["percent.mt"]] <- PercentageFeatureSet(Obj_prefiltered, features = MT_Genes_present)
3.4.2 (RStudio env)

QC plots before filtering

# QC plots | Before
before <- VlnPlot(Obj_prefiltered, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3)
before
3.4.3 (RStudio env)

Filter cells and compare QC plots

# QC plots: E4
Obj_filtered <- subset(Obj_prefiltered, subset = nFeature_RNA > 514 &
                             nFeature_RNA < 6000 & percent.mt < 20 &
                             nCount_RNA > 692 & nCount_RNA < 20000)

later_e4 <- VlnPlot(Obj_filtered, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3)
later_e4

before/later_e4

3.5 RNA Standard Workflow

3.5.1 (RStudio env)

Set the default assay

# RNA standar workflow
DefaultAssay(Obj_filtered) <- "RNA"

For the full standard workflow, follow the official Seurat tutorial: https://satijalab.org/seurat/articles/pbmc3k_tutorial.html