-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlung_seurat_integration.Rmd
158 lines (123 loc) · 3.58 KB
/
lung_seurat_integration.Rmd
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
---
title: "GSE118614 10x"
output: html_notebook
---
This is an analysis for the dataset [GSE118614](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE118614) made available by Clark BS et al. in their paper [_Single-cell RNA-Seq Analysis of Retinal Development Identifies NFI Factors as Regulating Mitotic Exit and Late-Born Cell Specification_](https://www.sciencedirect.com/science/article/abs/pii/S0896627319303459).
```{r}
rm(list=ls())
gc()
library(Matrix)
library(Seurat)
```
```{r}
library(clusterCrit)
```
# Overview of the dataset
We first overview the dataset.
```{r}
#data <- read.csv("../data/miller20/expr.csv")
#rownames(data) <- data$index
#data <- data[-1]
#data <- as.matrix(data)
```
```{r}
#saveRDS(object = data, file = "data.RDS")
```
```{r}
data <- readRDS("data.RDS")
```
```{r}
meta.data <- read.csv("../data/miller20/meta.data.csv", row.names = 1)
```
```{r}
obj <- CreateSeuratObject(t(data), meta.data = meta.data)
```
```{r}
rm(data)
gc()
```
```{r}
obj
```
```{r}
table(obj$Cell_type)
```
```{r}
table(obj$Age)
```
```{r}
table(obj$Sample)
```
```{r}
objs <- SplitObject(obj, split.by = "Sample")
```
```{r}
rm(obj)
gc()
```
```{r}
for (i in names(objs)) {
objs[[i]] <- NormalizeData(objs[[i]], verbose=FALSE)
objs[[i]] <- FindVariableFeatures(objs[[i]], selection.method = "vst", nfeatures = 2000, verbose=FALSE)
objs[[i]] <- ScaleData(objs[[i]], verbose=FALSE)
objs[[i]] <- RunPCA(objs[[i]], features = VariableFeatures(object = objs[[i]]), verbose=FALSE)
}
ptm = proc.time()
anchors <- FindIntegrationAnchors(object.list = objs, dims = 1:30)
obj <- IntegrateData(anchorset = anchors, dims = 1:30)
proc.time() - ptm
```
```{r}
obj <- ScaleData(obj, verbose = FALSE)
obj <- RunPCA(obj, npcs = 30, verbose = FALSE)
```
```{r}
obj <- RunUMAP(obj, dims = 1:30, verbose=FALSE)
```
```{r}
saveRDS(obj, "lung_seurat.RDS")
```
```{r}
#obj <- readRDS("lung_seurat.RDS")
```
```{r}
DimPlot(obj, reduction = "umap", group.by = "Cell_group", label = T, repel=T, label.size = 5, pt.size = 0) +
theme(axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank(),
text=element_text(size=18))
ggsave("lung_seurat_group.pdf")
DimPlot(obj, reduction = "umap", group.by = "Cell_group", label = T, repel=T, label.size = 8, pt.size = 0) +
theme(axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank(),
text=element_text(size=30))
ggsave("lung_seurat_group.png", height=12, width=18, dpi = 100)
```
```{r fig.height=8, fig.width=18}
DimPlot(obj, reduction = "umap", group.by = "Cell_type", label = T, repel=T, label.size = 4, pt.size = 0) +
theme(axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank(),
text=element_text(size=18))
ggsave("lung_seurat_label.pdf")
```
```{r}
DimPlot(obj, reduction = "umap", group.by = "Sample", label.size = 5, pt.size = 0) +
theme(axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank(),
text=element_text(size=18))
ggsave("lung_seurat_sample.pdf")
p<-DimPlot(obj, reduction = "umap", group.by = "Sample", label.size = 12, pt.size = 0) +
theme(axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank(),
text=element_text(size=30))
ggsave("lung_seurat_sample.png", height=12, width=18, dpi = 100)
```