library(dplyr)
library(ggplot2)
library(ggplotgui)
library(esquisse)
library(effsize)
library(forcats)
library(ggpubr)

# Set this to the folder containing Figure1F_data.csv
setwd("path/to/your/project/folder")

# Read data IN and PN
data1 <- read.table("./Figure1F_data.csv", header = TRUE, sep = ",")


# Rearrange factor levels
data1$area <- factor(data1$area, levels=c("Cg1","M1", "M2", "S1"))
data1$age <- factor(data1$age, levels = c("1M", "10M", "18M"))

# Define comparisons
comparisons <- list(
  c("1M", "10M"),
  c("10M", "18M"),
  c("1M", "18M")
)


# boxPlot NucPolk per area
graph1 <- ggplot(data1, aes(x = age, y = nucPolkPerArea, fill = age)) +
  geom_boxplot(notch = TRUE, alpha = 0.3) +
  scale_y_continuous(breaks = seq(0, 100, by = 20)) + #set ticks every 20, between 0-->100
  stat_compare_means(comparisons = comparisons, method = "wilcox.test") +  # Mann–Whitney U test (implemented in R as wilcox.test)
  facet_grid( area ~ . )+
  labs(colour = 'title legend')+
  scale_colour_brewer(palette = 'Dark2') +
  theme_classic() +
  theme(
    legend.position = 'bottom'
  )
graph1

# boxPlot CytoPolk per area
graph2 <- ggplot(data1, aes(x = age, y = cytoPolkPerArea, fill = age)) +
  geom_boxplot(notch = TRUE, alpha = 0.3) +
  scale_y_continuous(breaks = seq(0, 100, by = 20)) + #set ticks every 20, between 0-->100
  stat_compare_means(comparisons = comparisons, method = "wilcox.test") +  # Mann–Whitney U test (implemented in R as wilcox.test)
  facet_grid( area ~ . )+
  labs(colour = 'title legend')+
  scale_colour_brewer(palette = 'Dark2') +
  theme_classic() +
  theme(
    legend.position = 'bottom'
  )
graph2

