<- c("fs", "futile.logger", "configr", "stringr", "ggpubr", "ggthemes", "clusterProfiler",
pkgs "vroom", "jhtools", "glue", "openxlsx", "ggsci", "patchwork", "cowplot",
"tidyverse", "dplyr", "Seurat", "harmony", "ggpubr", "GSVA", "EnhancedVolcano")
suppressMessages(conflicted::conflict_scout())
for (pkg in pkgs){
suppressPackageStartupMessages(library(pkg, character.only = T))
}<- "./results/sup_figure14" %>% 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, "rctd_colors")
rctd_cols
#read in coldata
<- read_rds(glue::glue("{dat_dir}/sce_mac_DNp50_retsne.rds"))
sce_mac <- read_rds(glue::glue("{dat_dir}/spatial_mac_tumor.rds")) spatial_mac_tumor
sup_figure14
sup_figure14b
<- list()
pl for (i in c("S100A9", "RPL17", "DUSP6", "CDC42EP3")) {
pdf(glue::glue("{res_dir}/sfig14b_sce_mac_{i}_exp_featureplot.pdf"), width = 2.5, height = 2)
<- FeaturePlot(sce_mac, reduction = "tsne", features = i,
pl[[i]] order = F, 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[[
sup_figure14c
$cell_types2 <- factor(sce_mac$cell_types2, levels = c("DN-mp", "Other-mp"))
sce_macIdents(sce_mac) <- "cell_types2"
#pdf(glue::glue("{res_dir}/sfig14c_sce_mac_S100A9_vlnplot.pdf"), width = 3, height = 3)
<- VlnPlot(sce_mac, features = "S100A9", pt.size = 0,
p cols = c("DN-mp" = "#BC3C29FF", "Other-mp" = "#0072B5FF"), combine = F)
<- p[[1]] + ylab("S100A9") +
p theme(plot.title = element_blank(),
axis.text = element_text(size = 6),
axis.title.y = element_text(size = 8, margin = margin(0,0,0,0)),
axis.title.x = element_blank(),
axis.text.x = element_text(size = 8, angle = 10),
axis.line.x = element_line(linewidth = 0.4),
axis.line.y = element_line(linewidth = 0.4),
legend.text=element_text(size = 4),
legend.key.size = unit(.2, "cm"))
print(p)
sup_figure14d
$DN_any <- factor(spatial_mac_tumor$DN_any, levels = c("DN-mac enriched", "Other-mac enriched"))
spatial_mac_tumorIdents(spatial_mac_tumor) <- "DN_any"
#pdf(glue::glue("{res_dir}/sfig14d_seu_mactumor_s100a9.pdf"), width = 3, height = 3)
<- VlnPlot(spatial_mac_tumor, features = "S100A9", pt.size = 0, combine = F,
p cols = c("DN-mac enriched" = "#BC3C29FF", "Other-mac enriched" = "#0072B5FF"))
<- p[[1]] + ylab("S100A9") +
p theme(plot.title = element_blank(),
axis.text = element_text(size = 6),
axis.title.y = element_text(size = 8),
axis.title.x = element_blank(),
axis.text.x = element_text(size = 8, angle = 10),
axis.line.x = element_line(linewidth = 0.4),
axis.line.y = element_line(linewidth = 0.4),
legend.text=element_text(size = 4),
legend.key.size = unit(.2, "cm"))
print(p)
sup_figure14e
<- read_csv(glue::glue("{dat_dir}/df_knn_exp.csv"))
df_k_exp
<- df_k_exp %>%
df_k_exp_dnm ::mutate(DN_any = case_when(CD68 > 0 & if_any(contains("HLA"), ~ .x == 0) &
dplyr== 0 ~ "DN-Mp enriched",
CD163 == 0 ~ "NoMp_enriched",
CD68 TRUE ~ "Other-Mp enriched"))
<- df_k_exp_dnm %>% dplyr::filter(DN_any != "NoMp_enriched")
df_spotmac
<- df_spotmac %>% group_by(k, DN_any) %>%
df_spotmac_mean ::transmute(across(CD68:S100A9, mean, .names = "mean_{.col}")) %>%
dplyrungroup() %>% distinct() %>% pivot_longer(cols = mean_CD68:mean_S100A9, names_to = "gene", values_to = "exp")
<- ggplot(df_spotmac_mean[df_spotmac_mean$gene == "mean_S100A9" & df_spotmac_mean$k != 0,],
p aes(x=k, y=exp, color=DN_any, group = DN_any)) +
geom_point() + geom_line() + xlab("k") + ylab(glue::glue("Mean expression of S100A9")) +
scale_color_manual(values=c("DN-Mp enriched" = "#BC3C29FF", "Other-Mp enriched" = "#0072B5FF")) +
xlab("Near<- Neighboring spots of tumor spots ->Far") +
theme_bmbdc() +
theme(plot.title = element_blank(),
plot.subtitle = element_blank(),
text = element_text(size = 6),
axis.text = element_text(size = 6),
axis.title.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
axis.line.x = element_line(linewidth = 0.4),
axis.line.y = element_line(linewidth = 0.4),
legend.key.size = unit(.2, 'cm'),
legend.title = element_blank(),
legend.text = element_text(size=6),
legend.position = "top")
ggsave(glue::glue("{res_dir}/sfig14e_visium_spotmac_mean_s100a9_k24610.pdf"), p, width = 3, height = 3.3)
p