<- c("fs", "futile.logger", "configr", "stringr", "ggpubr", "ggthemes",
pkgs "vroom", "jhtools", "glue", "openxlsx", "ggsci", "patchwork", "cowplot",
"tidyverse", "dplyr", "Seurat", "harmony", "ggpubr", "GSVA", "EnhancedVolcano",
"monocle")
suppressMessages(conflicted::conflict_scout())
for (pkg in pkgs){
suppressPackageStartupMessages(library(pkg, character.only = T))
}<- "./results/sup_figure13" %>% checkdir
res_dir <- "./data" %>% checkdir
dat_dir <- "./config" %>% checkdir
config_dir
#colors config
<- glue::glue("{config_dir}/configs.yaml")
config_fn <- jhtools::show_me_the_colors(config_fn, "scrna_cells")
scrna_cols <- jhtools::show_me_the_colors(config_fn, "scmac_type")
scmac_type
#read in coldata
<- read_rds(glue::glue("{dat_dir}/sce_mac_DNp50_retsne.rds"))
sce_mac <- read_rds(glue::glue("{dat_dir}/sce_all_merge.rds"))
sce_all <- read_rds(glue::glue("{dat_dir}/sc_mac_monocle2.rds")) monocle2_obj
sup_figure13
sup_figure13a
set.seed(2024)
<- sample(1:dim(sce_all)[2], 10000)
ids <- sce_all[,ids]
sesub
<- DimPlot(sesub, reduction = "tsne", group.by = "cell_types2",
p label = F, cols = scrna_cols, combine = F, pt.size = .001)
<- p[[1]] +
p guides(color = guide_legend(keywidth = unit(0, "cm"),
keyheight = unit(0, "cm"),
nrow = 3, byrow = T)) +
theme(plot.title = element_blank(),
axis.text = element_blank(),
axis.title = element_text(size = 8),
axis.line = element_blank(),
axis.ticks = element_blank(),
panel.background = element_blank(),
panel.border = element_blank(),
panel.spacing = unit(0, "mm"),
plot.margin = margin(0,0,0,0),
plot.background = element_blank(),
legend.margin = margin(0,0,0,0),
legend.box.margin = margin(0,0,0,0),
legend.spacing.y = unit(0, "mm"),
legend.spacing.x = unit(0, "mm"),
legend.position = "top",
legend.text = element_text(size = 6, margin = margin(-.5,-5,0,1)))
print(p)
sup_figure13b
Idents(sce_all) <- "cell_types2"
<- DotPlot(sce_all, features = c('EPCAM', 'KRT19', 'CPA1', 'VWF', 'ACTA2','PTPRC',
p 'CD3D', 'CD4', 'CD8A', 'CD79A', 'MS4A1','XBP1',
'CD68', 'HLA-DRA', 'HLA-DRB5', 'CD163', 'CD14',
'FCGR3A', 'FCGR3B', 'CEACAM3', 'CD1C',
'BATF3', 'TPSAB1','KIT'), #scale = F,
dot.scale = 3) + RotatedAxis() + theme_bmbdc() +
scale_colour_gradientn(colours = c("grey", "#ffe5e5", "#ff7f7f", "#ff6666", "#ff0000"),
values = scales::rescale(x = c(0, 1, 2, 3, 3.5), from = c(0, 3.5))) +
guides(size = guide_legend(title = "Percent Expressed", keywidth = unit(1, "cm"),
keyheight = unit(.2, "cm"), nrow = 2, byrow = T)) +
guides(color = guide_colorbar(title = "Expression", barwidth = unit(1, "cm"), barheight = unit(.2, "cm"))) +
theme(axis.text = element_text(size = 6),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.background = element_blank(),
panel.border = element_blank(),
panel.spacing = unit(0, "mm"),
plot.margin = margin(0,0,0,0),
plot.background = element_blank(),
legend.box.margin = margin(0,0,0,0),
legend.spacing.y = unit(0, "mm"),
legend.spacing.x = unit(0, "mm"),
legend.key.size = unit(.2, 'cm'),
axis.text.x = element_text(angle = 25, vjust = 1, hjust = 1),
#axis.text.y = element_text(angle = 10),
axis.line.x = element_line(linewidth = 0.4),
axis.line.y = element_line(linewidth = 0.4),
legend.margin = margin(0,0,0,0),
legend.title = element_text(size=6, margin = margin(-.5,-5,0,1)),
legend.text = element_text(size=6, margin = margin(-.5,-5,0,1)),
legend.position = "top")
print(p)
sup_figure13c
<- c("#5D9D58", "#7E9A51", "#a9d169", "#BBA082",
smplec_col "#BEA278", "#FFA428", "#F4C321", "#db9721",
"#ecd400", "#A56F95", "#BAA4CB", "#BCBDDC",
"#DDBE91", "#404BA5", "#568AC2", "#86BBDA",
"#B9E0EE", "#E6939F", "#B61932", "#F98354",
"#dbdb8d", "#74DA00", "#49BADB", "#d9d9d9")
Idents(sce_mac) <- "cell_types3"
$orig.ident <- str_replace_all(sce_mac$orig.ident, "DAC_TISSUE_", "")
sce_mac
<- DimPlot(sce_mac, reduction = "tsne", group.by = "orig.ident", pt.size = .001,
p1 label = F, cols = smplec_col, combine = F)
<- p1[[1]] +
p1 guides(color = guide_legend(keywidth = unit(0, "cm"),
keyheight = unit(0, "cm"),
nrow = 2, byrow = T)) +
theme(plot.title = element_blank(),
axis.text = element_blank(),
axis.title = element_text(size = 8),
axis.line = element_blank(),
axis.ticks = element_blank(),
panel.background = element_blank(),
panel.border = element_blank(),
panel.spacing = unit(0, "mm"),
plot.background = element_blank(),
plot.margin = margin(1,1,1,1),
legend.margin = margin(0,0,0,0),
legend.box.margin = margin(0,0,0,0),
legend.spacing.y = unit(0, "mm"),
legend.spacing.x = unit(0, "mm"),
legend.position = "top",
legend.text = element_text(size = 6, margin = margin(-2,-5,0,1)))
<- DimPlot(sce_mac, reduction = "tsne", group.by = "cell_types3", pt.size = .001,
p2 label = F, cols = scmac_type, combine = F)
<- p2[[1]] +
p2 guides(color = guide_legend(keywidth = unit(0, "cm"),
keyheight = unit(0, "cm"),
nrow = 2, byrow = T)) +
theme(plot.title = element_blank(),
axis.text = element_blank(),
axis.title = element_text(size = 8),
axis.line = element_blank(),
axis.ticks = element_blank(),
panel.background = element_blank(),
panel.border = element_blank(),
panel.spacing = unit(0, "mm"),
plot.background = element_blank(),
plot.margin = margin(1,1,1,1),
legend.margin = margin(0,0,0,0),
legend.box.margin = margin(0,0,0,0),
legend.spacing.y = unit(0, "mm"),
legend.spacing.x = unit(0, "mm"),
legend.position = "top",
legend.text = element_text(size = 6, margin = margin(-4,-5,0,1)))
| p2 p1
sup_figure13d
<- list()
pl for (i in c("CD68", "SPP1", "C1QC", "FCN1", "CCL18", "MT1G")) {
#pdf(glue::glue("{res_dir}/sfig13d_sce_mac_{i}_exp_featureplot.pdf"), width = 2.5, height = 2)
<- FeaturePlot(sce_mac, reduction = "tsne", features = i,
pl[[i]] order = T, pt.size = .001, combine = F)
<- pl[[i]][[1]] +
pl[[i]] guides(color = guide_colourbar(barwidth = unit(.1, "cm"),
barheight = unit(.6, "cm"),
title = i,
title.position = "top")) +
theme(plot.title = element_blank(),
axis.text = element_blank(),
axis.title = element_text(size = 8),
axis.line = element_blank(),
axis.ticks = element_blank(),
panel.spacing = unit(0, "mm"),
panel.border = element_rect(fill = NA, colour = NA),
plot.background = element_rect(fill = NA, colour = NA),
plot.margin = margin(0,0,0,0),
legend.position = c(0,.8),
legend.margin = margin(0,0,0,0),
legend.title = element_text(size = 6),
legend.text = element_text(size = 6))
#print(pl[[i]])
#dev.off()
}1]] | pl[[2]])/(pl[[3]] | pl[[4]])/(pl[[5]] | pl[[6]]) (pl[[
sup_figure13e
#monocle2
#pdf(glue::glue("{res_dir}/sfig13e1_monocle2.pdf"),width = 3,height = 3)
<- plot_cell_trajectory(monocle2_obj, color_by="Pseudotime", cell_size=.1,
p1 show_backbone=TRUE, cell_name_size = .5, state_number_size = 1) +
theme(axis.text = element_text(size = 6, colour = "black"),
axis.title = element_text(size = 8, colour = "black"),
axis.line.x = element_line(linewidth = 0.4, colour = "black"),
axis.line.y = element_line(linewidth = 0.4, colour = "black"),
legend.key.height = unit(.2, "cm"),
legend.key.width = unit(.15, "cm"),
legend.title = element_text(size = 8),
legend.text = element_text(size = 6))
#pdf(glue::glue("{res_dir}/sfig13e2_monocle2.pdf"),width = 3, height = 3)
<- plot_cell_trajectory(monocle2_obj, color_by="cell_types3", cell_size=.1,
p2 show_backbone=TRUE) +
scale_color_manual(values = scmac_type) + theme(legend.position = "right") +
theme(axis.text = element_text(size = 6, colour = "black"),
axis.title = element_text(size = 8, colour = "black"),
axis.line.x = element_line(linewidth = 0.4, colour = "black"),
axis.line.y = element_line(linewidth = 0.4, colour = "black"),
legend.key.height = unit(.2, "cm"),
legend.key.width = unit(.15, "cm"),
legend.position = "top",
legend.margin = margin(0,0,0,0),
legend.box.margin = margin(0,0,0,0),
legend.spacing.y = unit(0, "mm"),
legend.spacing.x = unit(0, "mm"),
legend.title = element_text(size = 8),
legend.text = element_text(size = 6, margin = margin(-5,-5,0,1)))
#pdf(glue::glue("{res_dir}/sfig13e3_monocle2.pdf"),width = 8, height = 8)
<- plot_cell_trajectory(monocle2_obj, cell_size=.1, color_by = "cell_types3") +
p3 facet_wrap("~cell_types3", nrow = 3) +
scale_color_manual(values = scmac_type) +
theme(axis.text = element_text(size = 6, colour = "black"),
axis.title = element_text(size = 8, colour = "black"),
axis.line.x = element_line(linewidth = 0.4, colour = "black"),
axis.line.y = element_line(linewidth = 0.4, colour = "black"),
legend.position = "none")
<- (p1|p2)/(p3) + plot_layout(heights = c(0.8, 3))
p print(p)