-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path04_2integrate_harmony.R
47 lines (38 loc) · 1.23 KB
/
04_2integrate_harmony.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# script to integrate across conditions using Harmony
# set seed for reproducibility
set.seed(42)
library(harmony)
library(Seurat)
# install.packages("devtools")
# library(devtools)
# devtools::install_github('satijalab/seurat-data',force = TRUE)
library(SeuratData)
library(tidyverse)
library(ggplot2)
# get data -------------------------
AvailableData()
# install dataset
InstallData("ifnb")
# load dataset
LoadData("ifnb")
str(ifnb)
# QC and filtering
ifnb[["percent.mt"]] <- PercentageFeatureSet(object=ifnb, pattern = '^MT-')
View([email protected])
# explore QC
# filter
ifnb
ifnb.filtered <- subset(ifnb, subset = nCount_RNA > 800 &
nFeature_RNA > 200 &
percent.mt < 5)
# standard workflow steps
ifnb.filtered <- NormalizeData(ifnb.filtered)
ifnb.filtered <- FindVariableFeatures(ifnb.filtered)
all.genes <- rownames(ifnb.filtered)
ifnb.filtered <- ScaleData(ifnb.filtered, features=all.genes)
ifnb.filtered <- RunPCA(ifnb.filtered, features=VariableFeatures(object = ifnb.filtered))
ElbowPlot(ifnb.filtered)
ifnb.filtered <- RunUMAP(ifnb.filtered, dims = 1:20, reduction = 'pca')
# run Harmony -----------
# Do UMAP and clustering using ** Harmony embeddings instead of PCA **
# visualize