forked from yigewu/ccRCC_sn_publication
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.Rhistory
129 lines (129 loc) · 6.17 KB
/
.Rhistory
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
# set up libraries and output directory -----------------------------------
## set working directory
dir_base = "~/Library/CloudStorage/Box-Box/Ding_Lab/Projects_Current/RCC/ccRCC_snRNA"
setwd(dir_base)
source("./ccRCC_snRNA_analysis/load_pkgs.R")
# input dependencies ------------------------------------------------------
## input cell type per barcode table
# barcode2celltype_df <- fread(input = "../ccRCC_snATAC/Resources/snATAC_Processed_Data/Barcode_Annotation/UMAP/UMAP_data_13_snATAC_Normal_epithelialCells_reclustered.20201209.tsv", data.table = F)
barcode2celltype_df <- fread(input = "./Resources/snATAC_Processed_Data/Barcode_Annotation/28_snATAC.ManualReviwed.UMAP_data.20210709.tsv", data.table = F)
View(barcode2celltype_df)
# Manuscript: Epigenetic and transcriptomic characterization reveals progression markers and essential pathways in clear cell renal cell carcinoma
# Author: Yige Wu
# Description: UMAP visualization of merged snATAC-seq data
# Section: Results - Overview of clinical features and datasets
#=======================================================================================
# Load libraries and set working directory -----------------------------------
## load libraries
packages = c(
"data.table",
"dplyr",
"Polychrome",
"ggrastr",
"ggplot2"
)
for (pkg_name_tmp in packages) {
if (!(pkg_name_tmp %in% installed.packages()[,1])) {
install.packages(pkg_name_tmp, dependencies = T)
}
if (!(pkg_name_tmp %in% installed.packages()[,1])) {
if (!requireNamespace("BiocManager", quietly=TRUE))
install.packages("BiocManager")
BiocManager::install(pkg_name_tmp)
}
library(package = pkg_name_tmp, character.only = T)
}
## set working directory
dir_base = "~/Library/CloudStorage/Box-Box/Ding_Lab/Projects_Current/RCC/ccRCC_snRNA/Submissions/ccRCC_sn_publication/"
setwd(dir_base)
# input -------------------------------------------------------------------
plot_data_df <- fread(data.table = F, input = "./data/snATAC.UMAPCoordinate.CellType.ByBarcode.tsv.gz")
View(plot_data_df)
# Manuscript: Epigenetic and transcriptomic characterization reveals progression markers and essential pathways in clear cell renal cell carcinoma
# Author: Yige Wu
# Description: UMAP visualization of merged snATAC-seq data
# Section: Results - Overview of clinical features and datasets
#=======================================================================================
# Load libraries and set working directory -----------------------------------
## load libraries
packages = c(
"data.table",
"dplyr",
"ggrastr",
"ggplot2"
)
for (pkg_name_tmp in packages) {
if (!(pkg_name_tmp %in% installed.packages()[,1])) {
install.packages(pkg_name_tmp, dependencies = T)
}
if (!(pkg_name_tmp %in% installed.packages()[,1])) {
if (!requireNamespace("BiocManager", quietly=TRUE))
install.packages("BiocManager")
BiocManager::install(pkg_name_tmp)
}
library(package = pkg_name_tmp, character.only = T)
}
## set working directory
dir_base = "~/Library/CloudStorage/Box-Box/Ding_Lab/Projects_Current/RCC/ccRCC_snRNA/Submissions/ccRCC_sn_publication/"
setwd(dir_base)
# input -------------------------------------------------------------------
plot_data_df <- fread(data.table = F, input = "./data/snATAC.UMAPCoordinate.CellType.ByBarcode.tsv.gz")
# process data ------------------------------------------------------------
plot_data_df <- plot_data_df %>%
mutate(Cell_group = ifelse(cell_type %in% c("EMT tumor cells", "Tumor"), "Tumor cells", cell_type))
# make colors -------------------------------------------------------------
colors_cellgroup <- c("#E7298A", "#E69F00", "#56B4E9", "#F0E442", "#D55E00", "#0072B2", "#FB9A99", "#B2DF8A", "#000000",
"#1B9E77", "#B15928", "#7570B3", "#90AD1C", "#AA0DFE", "#85660D", "#BDCDFF", "grey80", "grey50")
names(colors_cellgroup) <- c("Tumor cells", "CD4+ T-cells", "CD8+ T-cells", "Macrophages", "NK cells", "DC", "Fibroblasts", "Myofibroblasts", "B-cells",
"Proximal tubule", "Loop of Henle", "Distal convoluted tubule",
'Principle cells', "Intercalated cells", "Podocytes", "Endothelial cells",
"Unknown", "Immune others")
# plot --------------------------------------------------------------------
p <- ggplot()
p <- p + geom_point_rast(data = plot_data_df,
mapping = aes(x = UMAP_1, y = UMAP_2, color = Cell_group),
alpha = 1, size = 0.05, shape = 16)
p <- p + scale_color_manual(values = colors_cellgroup)
p <- p + guides(colour = guide_legend(override.aes = list(size=4), title = NULL))
p <- p + theme_void()
p <- p + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_blank())
# axis.line = element_line(colour = "black"))
p <- p + theme(axis.text.x=element_blank(),
axis.ticks.x=element_blank())
p <- p + theme(axis.text.y=element_blank(),
axis.ticks.y=element_blank())
p <- p + theme(legend.position="bottom", aspect.ratio=1)
#Print extended figure 2b
dir_out <- paste0(dir_base, "outputs/"); dir.create(dir_out)
file2write <- paste0(dir_out,"F1.UMAP.snATAC.pdf")
pdf(file = file2write, width = 8, height = 9, useDingbats = F)
print(p)
dev.off()
# process data ------------------------------------------------------------
plot_data_df <- plot_data_df %>%
mutate(Cell_group = ifelse(cell_type %in% c("EMT tumor cells", "Tumor"), "Tumor cells",
ifelse(cell_type == "PT", "Proximal tubule", cell_type)))
p <- ggplot()
p <- p + geom_point_rast(data = plot_data_df,
mapping = aes(x = UMAP_1, y = UMAP_2, color = Cell_group),
alpha = 1, size = 0.05, shape = 16)
p <- p + scale_color_manual(values = colors_cellgroup)
p <- p + guides(colour = guide_legend(override.aes = list(size=4), title = NULL))
p <- p + theme_void()
p <- p + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_blank())
# axis.line = element_line(colour = "black"))
p <- p + theme(axis.text.x=element_blank(),
axis.ticks.x=element_blank())
p <- p + theme(axis.text.y=element_blank(),
axis.ticks.y=element_blank())
p <- p + theme(legend.position="bottom", aspect.ratio=1)
#Print extended figure 2b
dir_out <- paste0(dir_base, "outputs/"); dir.create(dir_out)
file2write <- paste0(dir_out,"F1.UMAP.snATAC.pdf")
pdf(file = file2write, width = 8, height = 9, useDingbats = F)
print(p)
dev.off()