-
Notifications
You must be signed in to change notification settings - Fork 0
/
IntegrationAllTissue.R
66 lines (48 loc) · 1.96 KB
/
IntegrationAllTissue.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
library(Seurat)
library(ggplot2)
library(patchwork)
library(harmony)
setwd("/data/Blizard-AlazawiLab/rk")
# Load data
SeuObj <- readRDS("~/Seurat/SeuObj.rds")
#Perform analysis without integration
# Scaling
all.genes <- rownames(SeuObj)
SeuObj <- ScaleData(SeuObj, features = all.genes)
#PCA
SeuObj <- RunPCA(SeuObj)
# Determine dimensionality of the data
ElbowPlot(SeuObj, ndims = 50)
#Clustering and UMAP
SeuObj <- FindNeighbors(SeuObj, dims = 1:30, reduction = "pca")
SeuObj <- FindClusters(SeuObj, resolution = 0.5, cluster.name = "unintegrated_clusters")
SeuObj <- RunUMAP(SeuObj, dims = 1:30, reduction = "pca", reduction.name = "umap.unintegrated")
DimPlot(SeuObj, reduction = "umap.unintegrated", group.by = 'Patient_ID', raster = F)
DimPlot(SeuObj, reduction = "umap.unintegrated", raster = F)
# Harmony integration
SeuObj <- IntegrateLayers(
object = SeuObj, method = HarmonyIntegration,
orig.reduction = "pca", new.reduction = "harmony",
verbose = FALSE
)
# Re-join layers after integration
SeuObj[["RNA"]] <- JoinLayers(SeuObj[["RNA"]])
# Checking clusters of harmony integration
SeuObj <- FindNeighbors(SeuObj, reduction = "harmony", dims = 1:30)
SeuObj <- FindClusters(SeuObj, resolution = 0.5)
SeuObj <- RunUMAP(SeuObj, dims = 1:30, reduction = "harmony")
# Identify markers of each clusters
SeuObj@misc$markers <- FindAllMarkers(SeuObj)
saveRDS(SeuObj, file = "SeuObjI.rds")
# Ploting UMAP
DimPlot(SeuObj, reduction = "umap", raster=FALSE, label = TRUE)
DimPlot(SeuObj, reduction = "umap", split.by = "Tissue", raster=FALSE)
DimPlot(SeuObj, reduction = "umap", group.by = "Stage", raster=FALSE)
DimPlot(SeuObj, reduction = "umap", group.by = "Batch", raster=FALSE)
# Visualisation
features <- c("CD3E", "CD19", "ALB")
FeaturePlot(SeuObj, features = features, reduction = "umap", raster = FALSE)+ RotatedAxis()
DotPlot(SeuObj, features = features)+ RotatedAxis()
DefaultAssay(SeuObj) <- 'ADT'
features <- c("Hu.CD3-UCHT1")
DotPlot(SeuObj, features = features)+ RotatedAxis()