IL15 expression in microglia by diagnosis at the time of death: AD (Alzheimer’s Disease), MCI (Mild cognitive impairment) and NCI (no cognitive impairment).
#celltype_exp$mic[1:5, 1:5]
cell_i = "mic"
dt_res = as.data.frame(celltype_exp[[cell_i]], check.names = F)
dt_res_selected = dt_res[rownames(dt_res) %in% ensembls, ]
# long format for the plot
dt_res_selected_l = dt_res_selected %>%
rownames_to_column("ensembl") %>%
pivot_longer(-ensembl, values_to = "expression", names_to = "projid") %>%
mutate(celltype = cell_i)
# join to get the gene_name
dt_res_selected_l = dt_res_selected_l %>%
left_join(cytokines, by = "ensembl")
# join to get the phenotype
dt_res_selected_l_meta = dt_res_selected_l %>%
left_join(pheno_SN, by = "projid") %>%
filter(symbol == "IL15")
# By diagnosis
dt_res_selected_l_meta$cogdx_3grp[dt_res_selected_l_meta$cogdx_3grp == 0] <- "NCI"
dt_res_selected_l_meta$cogdx_3grp[dt_res_selected_l_meta$cogdx_3grp == 1] <- "MCI"
dt_res_selected_l_meta$cogdx_3grp[dt_res_selected_l_meta$cogdx_3grp == 2] <- "AD"
dt_res_selected_l_meta$cogdx_3grp = as.factor(dt_res_selected_l_meta$cogdx_3grp)
names(dt_res_selected_l_meta)[names(dt_res_selected_l_meta) == 'cogdx_3grp'] <- 'Diagnosis'
my_comparisons = list(c("AD", "NCI"),
c("AD", "MCI"),
c("MCI", "NCI"))
p <- ggplot(na.omit(dt_res_selected_l_meta[, c("Diagnosis", "expression", "symbol")]), aes(x = Diagnosis, y = expression, fill = Diagnosis)) +
geom_boxplot(outlier.shape = NA) +
geom_jitter(position = position_jitter(width = 0.2), size = 1, alpha = 0.7) +
stat_compare_means(comparisons = my_comparisons, method = "t.test", size = 7, bracket.size = 0.65) +
facet_wrap(~ symbol, scales = "free") +
scale_fill_manual(values = c("AD" = "#BB5566", "MCI" = "#DDAA33", "NCI" = "#004488")) +
labs(y = "IL15 expression in microglia", x = "Final consensus diagnosis") +
theme_classic()+
theme(
text = element_text(size = 22),
axis.title = element_text(size = 22),
axis.text = element_text(size = 18),
legend.position = "none"
)
print(p)
# Save to PDF
pdf(file = paste0("boxplot_IL15_mic_T047", ".pdf"), width = 8, height = 8)
print(p)
dev.off()
## png
## 2
# Save to PNG
png(file = paste0("boxplot_IL15_mic_T047", ".png"), width = 2000, height = 2800, res = 300)
print(p)
dev.off()
## png
## 2
## R version 4.3.2 (2023-10-31 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 11 x64 (build 26100)
##
## Matrix products: default
##
##
## locale:
## [1] LC_COLLATE=Portuguese_Brazil.utf8 LC_CTYPE=Portuguese_Brazil.utf8
## [3] LC_MONETARY=Portuguese_Brazil.utf8 LC_NUMERIC=C
## [5] LC_TIME=Portuguese_Brazil.utf8
##
## time zone: America/Sao_Paulo
## tzcode source: internal
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] readxl_1.4.3 ggsignif_0.6.4 ggeasy_0.1.4 ggpubr_0.6.0
## [5] lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1 purrr_1.0.2
## [9] tidyr_1.3.1 tibble_3.2.1 tidyverse_2.0.0 ggplot2_3.5.0
## [13] readr_2.1.5 rstatix_0.7.2 dplyr_1.1.4
##
## loaded via a namespace (and not attached):
## [1] sass_0.4.9 utf8_1.2.4 generics_0.1.3 stringi_1.8.3
## [5] hms_1.1.3 digest_0.6.36 magrittr_2.0.3 evaluate_0.24.0
## [9] grid_4.3.2 timechange_0.3.0 fastmap_1.2.0 cellranger_1.1.0
## [13] jsonlite_1.8.8 backports_1.4.1 fansi_1.0.6 scales_1.3.0
## [17] jquerylib_0.1.4 abind_1.4-5 cli_3.6.2 rlang_1.1.3
## [21] munsell_0.5.1 withr_3.0.1 cachem_1.1.0 yaml_2.3.10
## [25] tools_4.3.2 tzdb_0.4.0 colorspace_2.1-0 broom_1.0.6
## [29] vctrs_0.6.5 R6_2.5.1 lifecycle_1.0.4 car_3.1-2
## [33] pkgconfig_2.0.3 pillar_1.9.0 bslib_0.8.0 gtable_0.3.5
## [37] glue_1.7.0 highr_0.11 xfun_0.46 tidyselect_1.2.1
## [41] rstudioapi_0.16.0 knitr_1.48 farver_2.1.1 htmltools_0.5.8.1
## [45] labeling_0.4.3 rmarkdown_2.27 carData_3.0-5 compiler_4.3.2