IL15 expression in the bulk data by diagnosis at the time of death: AD (Alzheimer’s Disease), MCI (Mild cognitive impairment) and NCI (no cognitive impairment).

# upload gene list
file_path <- "C:/Users/beker/OneDrive/Documentos/Mestrado/GitHub/Cytokines/list_cytokines/T023/list_cytokines_T023.xlsx"
cytokines_list <- read_excel(file_path)
cytokines <- cytokines_list$symbol
ensembl_id_to_name <- read.table(file = "C:/Users/beker/OneDrive/Documentos/Mestrado/GitHub/Cytokines/bulk_RNAseq/ensembl2symbol.txt", check.names = F, stringsAsFactors = F, header = T)

exprData_DLPFC0<- tibble::rownames_to_column(exprData_DLPFC, "ensgene") # In this dataframe, the row names were transformed into columns, and I used the name of this new column as the same as the 'ensembl2text' file

exprData_DLPFC_gene <- merge(exprData_DLPFC0, ensembl_id_to_name, by = "ensgene", all = TRUE) # Join the two files using the 'ensgene' column as the key.

exprData_DLPFC_gene <- relocate (exprData_DLPFC_gene, symbol, .before = ensgene) # The 'symbol' column is now at the beginning of the dataframe

IL15 expression by diagnosis

# Filter out the rows of interest (genes of interest)
selected_genes <- exprData_DLPFC_gene[exprData_DLPFC_gene$symbol == "IL15", ]

# Melt the selected data to prepare it for the boxplot
melted_data <- reshape2::melt(selected_genes, id.vars = c("symbol", "ensgene"))

# Merge with phenotype data using the 'projid' column
merged_data <- merge(melted_data, pheno_DLPFC, by.x = "variable", by.y = "projid")

merged_data$cogdx_3grp[merged_data$cogdx_3grp == 0] <- "NCI"
merged_data$cogdx_3grp[merged_data$cogdx_3grp == 1] <- "MCI"
merged_data$cogdx_3grp[merged_data$cogdx_3grp == 2] <- "AD"

merged_data$cogdx_3grp <- as.factor(merged_data$cogdx_3grp)
names(merged_data)[names(merged_data) == 'cogdx_3grp'] <- 'Diagnosis'
my_comparisons = list(c("AD", "NCI"),
                      c("AD", "MCI"),
                      c("MCI", "NCI"))
# add points
# https://r-graph-gallery.com/96-boxplot-with-jitter.html
p <- ggplot(na.omit(merged_data[, c("Diagnosis", "value", "symbol")]), aes(x = Diagnosis, y = value, 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 bulk", 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_bulk_T046", ".pdf"), width = 8, height = 8)
print(p)
dev.off()
## png 
##   2
# Save to PNG
png(file = paste0("boxplot_IL15_bulk_T046", ".png"), width = 2000, height = 3000, res = 300)
print(p)
dev.off()
## png 
##   2

Session info

sessionInfo()
## 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     plyr_1.8.9       
## [13] cellranger_1.1.0  jsonlite_1.8.8    backports_1.4.1   fansi_1.0.6      
## [17] scales_1.3.0      jquerylib_0.1.4   abind_1.4-5       cli_3.6.2        
## [21] rlang_1.1.3       munsell_0.5.1     withr_3.0.1       cachem_1.1.0     
## [25] yaml_2.3.10       tools_4.3.2       reshape2_1.4.4    tzdb_0.4.0       
## [29] colorspace_2.1-0  broom_1.0.6       vctrs_0.6.5       R6_2.5.1         
## [33] lifecycle_1.0.4   car_3.1-2         pkgconfig_2.0.3   pillar_1.9.0     
## [37] bslib_0.8.0       gtable_0.3.5      Rcpp_1.0.12       glue_1.7.0       
## [41] highr_0.11        xfun_0.46         tidyselect_1.2.1  rstudioapi_0.16.0
## [45] knitr_1.48        farver_2.1.1      htmltools_0.5.8.1 labeling_0.4.3   
## [49] rmarkdown_2.27    carData_3.0-5     compiler_4.3.2