Introduction to �single cell data science and tidyomics
Stephanie Hicks, PhD | Associate Professor
Biostatistics, Bloomberg School of Public Health
Biomedical Engineering, Whiting School of Engineering
Faculty member, Malone Center for Engineering in Healthcare��stephaniehicks.com/talks �Twitter: @stephaniehicks
How are genomic data generated?
ACTGACCTAGATCAGTCGATCGATCGTATACGATTACAAAATCATCGGCAT
DNA
data generation
data generation
GATCGATCGTATACGAT
Fragments
ACTGACCTAGATCAGTC
TACAAAATCATCGGCAT
ACTGACCTAGATCAGTCGATCGATCGTATACGATTACAAAATCATCGGCAT
DNA
data generation
GATCGATCGTATACGAT
Fragments
ACTGACCTAGATCAGTC
TACAAAATCATCGGCAT
Reads
TACAAAATCA
AGATCAGTC
GATCGATCG
ACTGACCTAGATCAGTCGATCGATCGTATACGATTACAAAATCATCGGCAT
DNA
@22:16362385-16362561W:ENST00000440999:2:177:-40:244:S/2
CCAGCCCACCTGAGGCTTCTTTTTCCTTCCCAAGCCACATCACCATCCTGGTGGAACTCTCCTGTGAGGACAGCCA
+
GGFF<BB=>GBGIIIIIIIIIIIIIIEGEHGHHIIIIIIIIHFHBB2/:=??EGGGEGFHHIHHEDBD?@@DDHHD
@22:16362385-16362561W:ENST00000440999:3:177:-56:294:S/2
GCGTGAGCCACAGGGCCCAGCCCACCTGAGGCTTCTTTTTCCTTCCCAAGCCACATCACCATCCTGGTGGAACTCT
+
@=ABBBBIIIIIIIIHHGGGGIIDBDIIIIIIGIIIIHIIIIHFDD@BBDBGGFIDEE8DCC/29>BGFCGHHHGF
@22:16362385-16362561W:ENST00000440999:4:177:137:254:S/1
TCACCATCCTGGTGGAACTCTCCTGTGAGGACAGCCAAGGCCTGAACTACCTGCaGTGGGGAGCACCTCAGGGTTT
+
DDGBBCGGGIGGGBDDDHIIGGDGD77=BDIIIIIIIIFHHHHIIIHEFFHGGDD8A>DEGHHIFDDHH8@BEDDI
@22:16362385-16362561W:ENST00000440999:5:177:68:251:S/2
AGGGTTTGCCCAGGCAACCAGCCAGCCCTGGTCCAAGGCATCCTGGAGCGAGTTGTGGATGGCAAAAAGACNCGCC
+
HIGHIHFHEGE4111:.;8@?@HDIIIIIIIEGGIHHHIIGA?=:FIIIDD8.02506A8=AC#############
@22:16362385-16362561W:ENST00000440999:6:177:348:453:S/1
AAGGCCTGAACTACCTGCGGTGGGGAGCACCTCAGGGTTTGCCCAGGCAACCAGCCAGCCCTGGTCCAAGGCATCC
+
B9?@8=42:E@GDEDIIIIIGGHIIIFBEEAGIIDIIDHHGGHIIEGEIIIIIHIHFHFFEEFGGGGGB88>:DGH
@22:51205934-51222090C:ENST00000464740:132:612:223:359:S/2
GGAAGTATGATGCTGATGACAACGTGAAGATCATCTGCCTGGGAGACAGCGCAGTGGGCAAATCCAAACTCATGGA
+
IIEHHHHHIIIIIIIHGGDGHHEDDG8=;?==19;<<>D@@GGGIIHIIHGGDDHGBA=ABEG@@DFCCAA<:=>8
@22:51205934-51222090C:ENST00000464740:125:612:-1:185:S/1
TGGAGTGCGCTGCGGCGCGAGCTGGGCCGGCGGGCGTGGTTCGAGAGCGCGCAGAGTCCAGACTGGCGGCAGGGCC
+
GGFF<BB=>GBGIIIIIIIIIIIIIIEGEHGHHIIIIIIIIHFHBB2/:=??EGGGEGFHHIHHEDBD?@@DDHHD
@22:16362385-16362561W:ENST00000440999:3:177:-56:294:S/2
GCGTGAGCCACAGGGCCCAGCCCACCTGAGGCTTCTTTTTCCTTCCCAAGCCACATCACCATCCTGGTGGAACTCT
+
GGFF<BB=>GBGIIIIIIIIIIIIIIEGEHGHHIIIIIIIIHFHBB2/:=??EGGGEGFHHIHHEDBD?@@DDHHD
@22:16362385-16362561W:ENST00000440999:3:177:-56:294:S/2
GCGTGAGCCACAGGGCCCAGCCCACCTGAGGCTTCTTTTTCCTTCCCAAGCCACATCACCATCCTGGTGGAACTCT
+
billions more
Let’s talk about one type of genomic data:
�Gene expression (or RNA)
Reads��Need to figure out what part of the DNA they came from →
Reference genome (DNA)
ACTGACCTAGATCAGTCGATCGATCGTATACGA
Gene XYZ
Sum reads
23 reads from �Gene XYZ
23
0 4 4 6 1 2
9 2 1 0 10 3
Gene 1
Gene 2
Gene G
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Sample 1
Sample 6
Sample 2
.
.
.
Chr Start End ��chr1 10 500��chr1 400 882��������chr22 12 100
Important �bookkeeping
Data we typically analyze
10 15 3 0 1
How can we analyze this genomic data?
(and open development)
Standard Bioconductor data structure
Lee et al. (2019) Genome Biology
GenomicRanges (GRanges)
Create GRanges object
Things you can do with GRanges objects
Tidy data" is organized for programming
The pipe
command | command | command > output.txt
"Pipes rank alongside the hierarchical file system and regular expressions as one of the most powerful yet elegant features of Unix-like operating systems." (http://www.linfo.org/pipe)��(In R we use '|>' instead of '|' to chain operations)
Verb-based operations
In the R package dplyr:
Summarize after grouping
A useful paradigm is to group data and then summarize:
Summarize after grouping
A useful paradigm is to group data and then summarize:
And genomic range data are often already tidy
Tidy advantages
```{r eval=FALSE}� dat3 <- dat2[dat2$signal > x]� ```
Why "tidy analysis" for genomics?
Genomic verbs / action + �tidy data = plyranges
Michael Lawrence
Di Cook
Stuart Lee
Recall non-tidy code with GRanges object
Piping directly into plots!
Lee et al. (2019) Genome Biology
(source)
Single-cell transcriptomics (gene expression)
A “typical” single-cell analysis workflow
Amezquita et al. 2020, Nature Methods
Amezquita et al. 2020, Nature Methods
Amezquita et al. 2020, Nature Methods
Standardized ways to store single-cell data
Amezquita et al. 2020, Nature Methods
Demo
Extra slides
Quality control
Motivation for Quality Control
Low-quality scRNA-seq libraries can come from many places:
These manifest as “cells” with
Often form their own distinct cluster(s) (complicating interpretation of results)
Example QC metric: library size
Library size (= total number of reads/UMIs across relevant features per cell)
Common choices for QC metrics
Can calculate these QC metrics from the scater R/Bioc package using
Common choices for QC metrics
Can calculate these QC metrics from the scater R/Bioc package using
Normalization
Normalization and log-transformation
Now that we've removed problematic cells, need to put counts on a comparable scale before/during downstream analysis
Main factors to account for:
Most common approaches:
Library size normalization
Library size = the total sum of counts across all genes for each cell�
Feature selection
Motivation for feature selection
Often a primary goal of scRNA-seq analysis is to characterize heterogeneity across cells
Dim reduction & clustering combine per-gene diffs into a similarity metric btw cells
The choice of which genes to use can heavily impact downstream analyses
Feature selection aims to keep #1 and remove #2 to reduce the size of the data��Idea: select most variable genes based on expression across the population
Mean-Variance of log-normalized expression values
Simplest approach: Quantify per-gene variation by computing the variance of the log-normalized expression values (i.e. “log-counts”) for each gene across all cells
Feature selection and downstream analysis both on same log-scale
Idea: just rank genes by the empirical variance (most to least)
Mean-Variance of log-normalized expression values
Total var = biological var (interesting) + � technical var (uninteresting)
Mean-Variance of log-normalized expression values
Selecting highly variable genes (HVGs)
Dimensionality reduction
Motivation for dimensionality reduction
A common task in scRNA-seq analysis is to compare cells based on their expression values across multiple genes.
For example, clustering aims to identify cells with similar transcriptomic profiles by computing Euclidean distances across genes.
In these applications, each individual gene represents a dimension of the data.
More intuitively, if we had a scRNA-seq data set with two genes, we could make a two-dimensional plot where each axis represents the expression of one gene and each point in the plot represents a cell.
This concept can be extended to data sets with thousands of genes where each cell’s expression profile defines its location in the high-dimensional expression space.
Motivation for dimensionality reduction
Dimensionality reduction aims to reduce the number of dimensions in the data.
This is possible because different genes are correlated if they are affected by the same biological process (i.e. don’t need to store separate info for individual genes)
Instead can compress multiple features into a single dimension, e.g., an “eigengene”
This reduces computational work in downstream analyses like clustering, as
Principal Components Analysis (PCA)
Principal components analysis (PCA)
How do we apply PCA to scRNA-seq data?
Apply PCA on the the log-normalized expression values using the fixedPCA() function from the scran R/Bioconductor package.
Default: computes first 50 PCs and stores in reducedDims() slot of a SCE object
Also can compute approximate PCA methods!
Things slow down with large numbers!
Remedies:
Visualizing the PCs
Non-linear methods for visualization