-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2_2020-02-05_UMAP_before_Harmony.Rmd
200 lines (169 loc) · 4.34 KB
/
2_2020-02-05_UMAP_before_Harmony.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
---
title: "2 UMAP before Harmony"
author: "Yifang Liu"
date: "`r Sys.Date()`"
output:
rmdformats::html_clean:
code_folding: hide
fig_width: 10
fig_height: 10
highlight: kate
thumbnails: false
lightbox: true
gallery: true
---
```{r knitr_init, echo=FALSE, cache=FALSE}
library(knitr)
library(rmdformats)
options(max.print = 200)
opts_chunk$set(echo = TRUE,
cache = FALSE,
prompt = FALSE,
tidy = TRUE,
comment = NA,
message = FALSE,
warning = FALSE,
dev = c('png', 'pdf'),
fig.width = 10,
fig.height = 10,
fig.align = "center",
fig.path = '2_PDF_2020-02-05_UMAP_before_Harmony/',
dpi = 72)
opts_knit$set(width = 75)
```
```{r setup}
set.seed(123)
npc <- 20
# theta1 <- 2
# theta2 <- 5
# theta <- c(theta1, theta2)
resolution <- 0.1
pt_size <- 1
# alpha <- 0.8
# Suppress loading messages
suppressPackageStartupMessages({
library(Matrix)
library(dplyr)
library(tidyverse)
library(Seurat)
library(cowplot)
library(Rcpp)
library(harmony)
library(SoupX)
})
```
```{r UMAP}
EGFP <- readRDS("Data/2020-02-05_EGFP_seurat_obj_before_Harmony.Rds")
object <- EGFP
dims <- c(1, 2)
reduction <- "umap"
cells <- colnames(x = object)
data <- Embeddings(object = object[[reduction]])[cells, dims]
data <- as.data.frame(x = data)
dims <- paste0(Key(object = object[[reduction]]), dims)
object[['ident']] <- Idents(object = object)
group_by <- "ident"
data[, group_by] <- object[[group_by]][cells, , drop = FALSE]
data[, "LibraryID"] <- object[["LibraryID"]][cells, , drop = FALSE]
data_G0 <- subset(data, LibraryID == "G0")
data_G1 <- subset(data, LibraryID == "G1")
# group_color <- c("#0000EE","#9d009d","#ff7f0e","#ff0078","#05e259","#35bbf8","#c4af00","#686864","#9467bd","#006c00","#1b8c8b","#8d532e","#9f5084","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22")
```
# UMAP plots of combined and separated G0 and G1 {.tabset}
## UMAP combined with legend
```{r UMAP_combined_with_legend}
# range(data$UMAP_1)
# range(data$UMAP_2)
ggplot(data = data) +
geom_point(
mapping = aes_string(
x = dims[1],
y = dims[2],
color = "ident"
),
shape = 16,
size = pt_size
) +
# scale_color_manual(values = alpha(group_color, alpha)) +
coord_cartesian(xlim = c(-10, 5), ylim = c(-14, 8)) +
theme_cowplot()
```
## UMAP combined
```{r UMAP_combined}
ggplot(data = data) +
geom_point(
mapping = aes_string(
x = dims[1],
y = dims[2],
color = "ident"
),
shape = 16,
size = pt_size
) +
# scale_color_manual(values = alpha(group_color, alpha)) +
coord_cartesian(xlim = c(-10, 5), ylim = c(-14, 8)) +
theme_cowplot() +
theme(legend.position = "none")
```
## G0
```{r UMAP_G0}
data <- data_G0
ggplot(data = data) +
geom_point(
mapping = aes_string(
x = dims[1],
y = dims[2],
color = "ident"
),
shape = 16,
size = pt_size
) +
# scale_color_manual(values = alpha(group_color, alpha)) +
coord_cartesian(xlim = c(-10, 5), ylim = c(-14, 8)) +
theme_cowplot() +
theme(legend.position = "none")
```
## G1
```{r UMAP_G1}
# Do some extra work because the number of cluster in G0 is different from
# the number of cluster in G1
gg_color_hue <- function(n) {
hues = seq(15, 375, length = n + 1)
hcl(h = hues, l = 65, c = 100)[1:n]
}
n <- 10
cols <- gg_color_hue(n)
cols <- cols[c(1, 2, 3, 4, 5, 8, 9)]
data <- data_G1
ggplot(data = data) +
geom_point(
mapping = aes_string(
x = dims[1],
y = dims[2],
color = "ident"
),
shape = 16,
size = pt_size
) +
scale_color_manual(values = cols) +
coord_cartesian(xlim = c(-10, 5), ylim = c(-14, 8)) +
theme_cowplot() +
theme(legend.position = "none")
```
# Notes
2020-02-05:
* UMAP before Harmony.
Sun Dec 1, 2019:
* UMAP plots (after SoupX) of combined and separated EGFP and TSC.
Tue Oct 29, 2019:
* use SoupX fixed 0.45 to remove ambient RNA.
Mon Oct 7, 2019:
* Add more sequence depth.
Mon, Sep 30, 2019:
* remove genes: EGFP, Tsc1, gig. Then perform integrate analysis of EGFP, TSC1.
Fri, Sep 20, 2019:
* First version for integrate analysis of EGFP, TSC1.
# Session Info
```{r sessioninfo, message=TRUE}
sessionInfo()
```