4  Figure 5

Author

Danyang Zhao

4.1 set-up

pkgs <- c("fs", "futile.logger", "configr", "stringr", "ggpubr", "ggthemes", 
          "jhtools", "glue", "ggsci", "patchwork", "tidyverse", "dplyr", "Seurat", 
          "paletteer", "viridis", "ComplexHeatmap", "circlize", "CellChat")  
for (pkg in pkgs){
  suppressPackageStartupMessages(library(pkg, character.only = T))
}
project <- "panlab"
dataset <- "wangchao"
species <- "mouse"
workdir <- glue("~/projects/{project}/output/{dataset}/{species}/tenx/figures_260414")
workdir %>% fs::dir_create() %>% setwd()

config_fn <- "/cluster/home/danyang_jh/projects/panlab/output/wangchao/mouse/tenx/rds/config.yaml"
mph_cols <- jhtools::show_me_the_colors(config_fn, "mph_cols")
trends_cols <- jhtools::show_me_the_colors(config_fn, "trends_cols")
mmu_cols <- jhtools::show_me_the_colors(config_fn, "mmu_cols")
mmu_neu_cols <- jhtools::show_me_the_colors(config_fn, "neutro_cols")

my_theme1 <- theme_classic(base_size = 8) +
  theme(legend.key.size = unit(3, "mm"), axis.text = element_text(color = "black"),
        axis.line = element_blank(), axis.ticks = element_line(color = "black"), 
        panel.border = element_rect(linewidth = .5, color = "black", fill = NA))

glue("{workdir}/fig5") %>% fs::dir_create() %>% setwd()

4.2 fig5a: Cell interaction of Cd138+ Mph to Neutrophil

### fig5a: cellchat between Sdc1+ Mph and Neutrophil -----
rds_fn1 <- "/cluster/home/danyang_jh/projects/panlab/output/wangchao/mouse/tenx/rds/fig5a_sce_cellchat_obj.rds"
sce_cellchat <- read_rds(rds_fn1)
groupSize <- as.numeric(table(sce_cellchat@idents))
mat <- sce_cellchat@net$weight
cols_cellchat <- mmu_cols[sort(levels(sce_cellchat@idents))]
pdf("fig5a_cellchat_netVisual_circle_every_weight_secret_signal.pdf", width = 7, height = 4)
par(mfrow = c(2, 3), xpd = TRUE, mar = c(1, 1, 1, 1), oma = c(2, 2, 2, 2))
for (i in 1:nrow(mat)) {
  mat2 <- matrix(0, nrow = nrow(mat), ncol = ncol(mat), dimnames = dimnames(mat))
  mat2[i, ] <- mat[i, ]
  netVisual_circle(mat2, vertex.weight = groupSize, weight.scale = T, arrow.width = .2, 
                   color.use = cols_cellchat, arrow.size = 0.5, edge.weight.max = max(mat), 
                   title.name = rownames(mat)[i]) +
    theme(axis.line.x = element_line(linetype = 1, color = "black", size = 1), 
          axis.line.y = element_line(linetype = 1, color = "black", size = 1),
          axis.ticks.y = element_line(color = "black", size = 1, lineend = 1), 
          axis.ticks.x = element_line(color = "black", size = 1, lineend = 1))
  
}
dev.off()

####### result of Mphs was then selected and exported as .png format ############

cellchat results from Mphs to Neutrophils

4.3 fig5b-c: Overview of neutrophil in scRNAseq

### fig5b-d: UMAP, marker heatmap & GSEA -----
rds_fn1 <- 
  "~/projects/panlab/analysis/wangchao/mouse/tenx/merged_new/neutrophil/gsea_anot_manual4/hsa_neu_sub/neu_fin/mmu_neu_anot_fin.rds"
mmu_neu <- read_rds(rds_fn1)

# fig5b: WT mouse neutrophil umap ----
dim1 <- Seurat::DimPlot(mmu_neu, reduction = "umap", pt.size = 1e-2) + 
  my_theme1 + Seurat::NoAxes() + 
  ggplot2::coord_fixed() + scale_color_manual(values = mmu_neu_cols)
ggsave("fig5b_mouse_neu_dim1.pdf", dim1, width = 3, height = 2)
ggsave("fig5b_mouse_neu_dim1.png", dim1, width = 3, height = 2)

### fig5c: heatmap -----
mks_hm_lst <- list(
  MN1 = c("Ltc4s", "Siglecf", "Ptgs1", "Cysltr1", "Scimp"), 
  MN2 = c("Hspa1b", "Hspa1a", "Hilpda", "Inhba", "Hsp90aa1"), 
  MN3 = c("Ifit3", "Ifit1", "Gbp5", "Lrg1", "Rsad2", "Gbp2", "Irf7"), 
  MN4 = c("S100a8", "S100a9", "Rps26", "Rps12", "Rpl23")) 
avg_exps <- 
  Seurat::AverageExpression(mmu_neu, assays = "RNA", features = unlist(mks_hm_lst)) %>% 
  .[[1]] %>% as.matrix() %>% t() %>% scale()
df1 <- avg_exps %>% as.data.frame() %>% rownames_to_column("type") %>% 
  pivot_longer(cols = -1, names_to = "gene", values_to = "expr") %>% 
  mutate(gene = fct(as.character(gene), levels = unlist(mks_hm_lst)), 
         type = fct(as.character(type), levels = paste0("MN", 1:4)))

tile1 <- ggplot2::ggplot(df1, aes(x = gene, y = type, fill = expr)) + 
  ggplot2::geom_tile() + my_theme1 + Seurat::RotatedAxis() + 
  paletteer::scale_fill_paletteer_c("grDevices::Viridis") + 
  labs(y = "", x = "", fill = "Z-score") + 
  theme(legend.position = "right", axis.line = element_blank(), 
        axis.ticks.x = element_blank(), axis.text = element_text(size = 8), 
        panel.border = element_rect(fill = NA, color = "black", linewidth = .5)) + 
  theme(legend.position = "bottom", text = element_text(family = "sans"))
ggsave("fig5c_mmu_neu_sel_mks_heatmap.pdf", tile1, width = 9, height = 5, unit = "cm")
ggsave("fig5c_mmu_neu_sel_mks_heatmap.png", tile1, width = 9, height = 5, unit = "cm")

mouse neutrophil UMAP

mouse neutrophil marker heatmap

4.4 fig5d: Consistence of specific treatment with Siglecf+ Neutrophils

## fig5d: GSEA results of bulk to sce -----
csv_fn3 <- "/cluster/home/danyang_jh/projects/panlab/output/wangchao/mouse/tenx/rds/fig5d_gsea_neutro_bulk2sce.csv"
gsea_res <- read_csv(csv_fn3) %>%  dplyr::arrange((NES)) %>% 
  mutate(celltype = fct(as.character(celltype)))
dot2 <- ggplot2::ggplot(gsea_res, aes(x = NES, y = celltype, size = -log10(p.adjust), color = NES)) + 
  geom_point() + labs(y = "") + my_theme1 + 
  ggplot2::scale_x_continuous(limits = c(-4, 4)) + 
  paletteer::scale_color_paletteer_c("grDevices::Blue-Red 3") + 
  theme(legend.position = "right")
ggsave(glue("fig5d_gsea_neutro_bulk2sce.pdf"), dot2, width = 8, height = 6, units = "cm")
ggsave(glue("fig5d_gsea_neutro_bulk2sce.png"), dot2, width = 8, height = 6, units = "cm")

mouse neutrophil GSEA