Figure 3 (A B)
# Load the library
library(Seurat)
library(ggplot2)
library(ggprism)
library(ggfun)
library(aplot)
#set the color
celltype_colors <- c(
"Epithelial_Airway" = "#FFE7E6",
"Epithelial_Alveolar" = "#F7C4C4",
"Endothelial_Main" = "#9BB8DB",
"Endothelial_Capillary" = "#6076AF",
"Immune_Lymphoid" = "#CFD6E4",
"Immune_Myeloid" = "#ED9D98",
"Mesenchymal_Airway/Vascular" = "#C3C6E3",
"Mesenchymal_Alveolar" = "#E0C999",
"Mesenchymal_Pleura" = "#C6ADDE"
)
platform_colors <- c(
"Lung NV" = "#F07204",
"Lung SF" = "#43A3CB"
)
# Define parameters
base_theme <- theme_prism(base_size = 10) +
theme(
axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
axis.line = element_blank(),
plot.margin = margin(5, 5, 5, 5)
)
legend_guide <- guide_legend(
override.aes = list(size = 5),
title.theme = element_text(size = 15, face = "bold"),
label.theme = element_text(size = 12, face = "bold")
)
# Load the data and plot figure
load("10b_2l.RData")
p1 <- DimPlot(merged_Lung, reduction = "umap", group.by = "Main_cell_type",label = FALSE, label.size = 4) +
scale_color_manual(values = celltype_colors) +
base_theme +
NoLegend() +
ggtitle(NULL)
merged_Lung$platform_group <- ifelse(grepl("NV", merged_Lung$orig.ident),"Lung NV", "Lung SF")
p2 <- DimPlot(merged_Lung, reduction = "umap", group.by = "orig.ident", label = FALSE) +
scale_color_manual(values = platform_colors) +
base_theme +
guides(color = legend_guide) +
ggtitle(NULL)
p <- plot_list(p1, p2, ncol = 2)
p

Figure 3 (E)
# Load the data
Idents(merged_Lung) <- merged_Lung@meta.data$Main_cell_type
selected_genes <- c("Col3a1","Trpc6", "Pdgfra", "Mrc1", "Ptprc", "Ptprb", "Lama5", "Sftpc", "Scgb1a1")
plot_data <- DotPlot(merged_Lung, features = selected_genes)$data
celltype_order <- c(
"Epithelial_Airway",
"Epithelial_Alveolar",
"Endothelial_Main",
"Endothelial_Capillary",
"Immune_Lymphoid",
"Immune_Myeloid",
"Mesenchymal_Airway/Vascular",
"Mesenchymal_Alveolar",
"Mesenchymal_Pleura"
)
plot_data$id <- factor(plot_data$id, levels = celltype_order)
plot_data$combined_score <- plot_data$avg.exp.scaled * (plot_data$pct.exp/100)
# Show the figure
ggplot(plot_data, aes(x = features.plot, y = id,
size = combined_score,
color = avg.exp.scaled)) +
geom_point() +
scale_size_continuous(range = c(2, 15)) +
scale_color_gradient(low = "#FFFFFF",
high = "#AD1C42",
breaks = c(0, max(plot_data$avg.exp.scaled)/2, max(plot_data$avg.exp.scaled)),
labels = function(x) sprintf("%.1f", x)) +
theme_minimal() +
theme(
axis.text.x = element_text(angle = 30,
hjust = 1,
size = 26,
face = "bold",
color = "#333333"),
axis.text.y = element_text(size = 26,
face = "bold",
color = "#333333"),
legend.text = element_text(size = 22,
face = "bold",
color = "#333333"),
legend.title = element_text(size = 24,
face = "bold",
color = "#333333"),
axis.title = element_blank(),
legend.position = "bottom",
plot.margin = unit(c(0.8, 2, 1.2, 2), "cm"),
panel.grid.major = element_line(color = "grey90"),
panel.grid.minor = element_blank(),
legend.spacing.x = unit(1, 'cm'),
legend.box.margin = margin(-10, -300, 0, -300)
) +
coord_flip() +
guides(
size = guide_legend(title = "Expression Score",
title.position = "top",
title.hjust = 0.5,
nrow = 1),
color = guide_colorbar(title = "Scaled Expression",
title.position = "top",
title.hjust = 0.5,
barwidth = 15,
barheight = 1,
nrow = 1,
ticks.linewidth = 1,
label.theme = element_text(size = 20,
face = "bold",
color = "#333333"))
)

# package version
library(sessioninfo)
pi <- package_info(pkgs = "attached")
pi_df <- as.data.frame(pi)[, c("package", "loadedversion", "source")]
pi_df
## package loadedversion source
## aplot aplot 0.2.8 CRAN (R 4.3.3)
## dplyr dplyr 1.1.4 CRAN (R 4.3.3)
## ggfun ggfun 0.1.8 CRAN (R 4.3.3)
## ggplot2 ggplot2 3.5.2 CRAN (R 4.3.3)
## ggprism ggprism 1.0.6 CRAN (R 4.3.3)
## MetaNeighbor MetaNeighbor 1.22.0 Bioconductor
## sessioninfo sessioninfo 1.2.3 CRAN (R 4.3.3)
## Seurat Seurat 5.1.0 CRAN (R 4.3.3)
## SeuratObject SeuratObject 5.1.0 CRAN (R 4.3.3)
## sp sp 2.2-0 CRAN (R 4.3.3)
## tidyr tidyr 1.3.1 CRAN (R 4.3.1)