#Figure 4 Plots

#4A - Western blots

#4B - Western blot quantification

library(ggplot2)
library(scales)
library(tidyverse)
library(ggpubr)

#Define colors
hex <- hue_pal()(5)

#Load data
oxphos <- read.csv("~/Desktop/Purcell 2023 dataset/Fig. 4/mouse_oxphos_blots.csv")
oxphos$Complex <- factor(oxphos$Complex, levels = c("I", "II", "III", "IV", "V"))

ox <- ggplot(oxphos, aes(x=Complex, y=Expression)) +
  geom_hline(yintercept = 1, color = "grey") +
  geom_boxplot(aes(fill=Complex), 
               outlier.shape = NA, 
               size = 0.3, 
               width = 0.6, 
               position = position_dodge(0.9), 
               alpha=1, 
               weight=0.5) +
  scale_fill_manual(values = hex) + 
  geom_point(aes(color=Complex), 
             position = position_jitterdodge(jitter.width = 0.1, dodge.width = 0.9), 
             size = 3, alpha=0.8, shape=21, fill="white") +
  scale_color_manual(values = hex) +
  labs(x="Complex", y="Expression 3q29/Control", title="") +
  theme_classic() +
  theme(text = element_text(size = 20)) +
  theme(axis.text.x = element_text(color = c("#F8766D", "#A3A500", "#00BF7D", "#00B0F6", "#E76BF3"))) +
  theme(legend.position = "none") +
  ylim(0, 2) +
  theme(aspect.ratio = 4/4)
ox

#4C - Mitochondrial protein interaction data - 3q29

#4D - Western blots - CTRL, 3q29, PAK2 cells for PAK2 and Actin
pak <- read.csv("~/Desktop/Purcell 2023 dataset/Fig. 4/hek_protein_pak2.csv")
pak$Genotype <- factor(pak$Genotype, levels = c("CTRL", "3q29", "PAK2"))
pak_bxplt <- ggplot(pak, aes(x=Genotype, y=PAK2)) + 
  geom_boxplot(aes(fill=Genotype), outlier.shape = NA, size = 0.3, width = 0.6, position = position_dodge(0.9), alpha=1, weight=0.5) +
  scale_fill_manual(values = c("#47b88b", "#4774b8", "#FD9902")) + 
  geom_point(aes(color = Genotype), 
             position = position_jitterdodge(jitter.width = 0.1, dodge.width = 0.9), 
             size = 3, alpha=0.8, shape=21, fill="white") +
  scale_color_manual(values = c("#47b88b", "#4774b8", "#FD9902")) +
  labs(x="", y="PAK2 Protein", title="") +
  theme_classic() +
  theme(text = element_text(size = 20)) +
  theme(axis.text.x = element_text(face = "italic")) +
  ylim(0, 1.5) +
  theme(legend.position = "none") +
  ggpubr::rotate_x_text(angle = 45) +
  theme(aspect.ratio = 4/2)
pak_bxplt

#4E - HEK Control ECAR vs OCR
#load data (compiled from Wave software export into single .csv file)
ocr_data <- read.csv("~/Desktop/Purcell 2023 dataset/Fig. 4/hek_seahorse_ocr_ecar.csv")
ocr_data$Genotype <- factor(ocr_data$Genotype, levels = c("Control", "del3q29", "PAK2"), labels = c("CTRL", "3q29", "PAK2"))
ocr_data$Medium <- factor(ocr_data$Medium, levels = c("Glucose", "Galactose"))
a <- ocr_data %>%
  filter(Genotype == "CTRL" & Time < 2) %>%
  group_by(Medium) %>%
  summarise(
    OCR_mean = mean(OCR),
    OCR_sd = sd(OCR),
    OCR_se = OCR_sd / 2,
    n = n(),
    ECAR_mean = mean(ECAR),
    ECAR_sd = sd(ECAR),
    ECAR_se = ECAR_sd / 2
  )
p <- ggplot(a, aes(x=OCR_mean, y=ECAR_mean)) +
  geom_errorbarh(aes(xmin=OCR_mean-OCR_se,
                     xmax=OCR_mean+OCR_se, color = Medium),
                 height=0.3, size = 0.3)+
  geom_errorbar(aes(ymin=ECAR_mean-ECAR_se,
                    ymax=ECAR_mean+ECAR_se, color = Medium),
                width=0.8, size = 0.3) +
  geom_point(aes(color = Medium), size = 3.5, shape = 21, fill = "white") +    
  theme_classic() + 
  scale_x_continuous(limits = c(0,35)) +
  scale_y_continuous(limits = c(0,8)) +
  geom_text(aes(label = Medium, color = Medium), nudge_y = 0.5, size = 6) +
  scale_color_manual(values = c("#47b88b", "#B847AD")) +
  labs(x="OCR (pmol/min/ug)", y="ECAR (mpH/min/ug)", title = "") + 
  annotate(geom="text", x=5, y=0, label="Quiescent",
           color="grey40", size = 5) +
  annotate(geom="text", x=5, y=8, label="Glycolytic",
           color="grey40", size = 5) +
  annotate(geom="text", x=31, y=8, label="Energetic",
           color="grey40", size = 5) +
  annotate(geom="text", x=31, y=0, label="Aerobic",
           color="grey40", size = 5) +
  theme(text = element_text(size = 20)) +
  theme(legend.position = "none") +
  theme(panel.border = element_rect(colour = "black", fill=NA, linewidth=1)) +
  theme(aspect.ratio = 3/3)
p

#4F - HEK OCR by genotype
#calculate OCR summary statistics
o <- ocr_data %>%
  group_by(Genotype, Medium, Time) %>%
  summarise(
    OCR_mean = mean(OCR),
    OCR_sd = sd(OCR),
    n = n(),
    OCR_se = OCR_sd / sqrt(n)
  )

ocr_ctrl <- ggplot(subset(o, o$Genotype == "CTRL"), aes(x=Time, y=OCR_mean)) + 
  geom_line(aes(color = Medium)) +
  geom_errorbar(aes(ymin=OCR_mean-OCR_se, ymax=OCR_mean+OCR_se, color = Medium), width=2, size = 0.4) +
  geom_point(aes(color = Medium), shape=21, fill="white", size=4) +
  scale_color_manual(values = c("#47b88b", "#B847AD")) +
  labs(x="Time (min.)", y="OCR (pmol/min/ug)", title="") +
  theme_classic() +
  theme(legend.position = "none") +
  theme(text = element_text(size = 20)) +
  ylim(0, 30) +
  theme(aspect.ratio = 3/2)
ocr_ctrl

ocr_3q29 <- ggplot(subset(o, o$Genotype == "3q29"), aes(x=Time, y=OCR_mean)) + 
  geom_line(aes(color = Medium)) +
  geom_errorbar(aes(ymin=OCR_mean-OCR_se, ymax=OCR_mean+OCR_se, color = Medium), width=2, size = 0.4) +
  geom_point(aes(color = Medium), shape=21, fill="white", size=4) +
  scale_color_manual(values = c("#4774b8", "#FC6666")) +
  labs(x="Time (min.)", y="OCR (pmol/min/ug)", title="") +
  theme_classic() +
  theme(legend.position = "none") +
  theme(text = element_text(size = 20)) +
  ylim(0, 30) +
  theme(aspect.ratio = 3/2)
ocr_3q29

ocr_PAK2 <- ggplot(subset(o, o$Genotype == "PAK2"), aes(x=Time, y=OCR_mean)) + 
  geom_line(aes(color = Medium)) +
  geom_errorbar(aes(ymin=OCR_mean-OCR_se, ymax=OCR_mean+OCR_se, color = Medium), width=2, size = 0.4) +
  geom_point(aes(color = Medium), shape=21, fill="white", size=4) +
  scale_color_manual(values = c("#FD9902", "#66CCFF")) +
  labs(x="Time (min.)", y="OCR (pmol/min/ug)", title="") +
  theme_classic() +
  theme(legend.position = "none") +
  theme(text = element_text(size = 20)) +
  ylim(0, 30) +
  theme(aspect.ratio = 3/2)
ocr_PAK2

#4G - Baseline OCR means
b <- ocr_data %>%
  filter(Medium == "Glucose" & Time < 15) %>%
  group_by(Genotype, Experiment) %>%
  summarise(
    baseline_OCR_mean = mean(OCR),
    baseline_OCR_sd = sd(OCR),
    baseline_OCR_se = baseline_OCR_sd / 2
  )

base_bxplt <- ggplot(b, aes(x=Genotype, y=baseline_OCR_mean)) + 
  geom_boxplot(aes(fill=Genotype), outlier.shape = NA, size = 0.3, width = 0.6, position = position_dodge(0.9), alpha=1, weight=0.5) +
  scale_fill_manual(values = c("#47b88b", "#4774b8", "#FD9902")) + 
  geom_point(aes(color = Genotype), 
             position = position_jitterdodge(jitter.width = 0.1, dodge.width = 0.9), 
             size = 3, alpha=0.8, shape=21, fill="white") +
  scale_color_manual(values = c("#47b88b",  "#4774b8", "#FD9902")) +
  labs(x="", y="Baseline OCR Mean", title="") +
  theme_classic() +
  theme(text = element_text(size = 20)) +
  theme(axis.text.x = element_text(face = "italic")) +
  theme(legend.position = "none") +
  ylim(10, 25) +
  ggpubr::rotate_x_text(angle = 45) +
  theme(aspect.ratio = 4/2)
base_bxplt

#4H - Galactose Response
#Load Seahorse measures data
meas <- read.csv("~/Desktop/Purcell 2023 dataset/Fig. 4/hek_seahorse_measures.csv")
meas$Genotype <- factor(meas$Genotype, levels = c("CTRL", "del3q29", "PAK2"), labels = c("CTRL", "3q29", "PAK2"))
meas$Medium <- factor(meas$Medium, levels = c("Glucose", "Galactose"),  labels = c("GLU", "GAL"))

fold_change <- ggplot(subset(meas, meas$Medium == "GAL"), aes(x=Genotype, y=Galactose_Response)) +
  geom_boxplot(aes(fill=Genotype), outlier.shape = NA, size = 0.3, width = 0.6, position = position_dodge(0.9), alpha=1, weight=0.5) +
  scale_fill_manual(values = c("#B847AD", "#FC6666", "#66CCFF")) + 
  geom_point(aes(color = Genotype), 
             position = position_jitterdodge(jitter.width = 0.1, dodge.width = 0.9), 
             size = 3, alpha=0.8, shape=21, fill="white") +
  scale_color_manual(values = c("#B847AD", "#FC6666", "#66CCFF")) +
  labs(x="", y="Galactose Response", title="") +
  theme_classic() +
  theme(text = element_text(size = 20)) +
  theme(axis.text.x = element_text(face = "italic")) +
  theme(legend.position = "none") +
  ylim(1, 2.5) +
  ggpubr::rotate_x_text(angle = 45) +
  theme(aspect.ratio = 4/2)
fold_change

#4I - Spare Capacity
spare_bxplt <- ggplot(meas, aes(x=Medium, y=Spare_Respiratory_Capacity.pct., group = interaction(Medium, Genotype))) + 
  geom_boxplot(aes(fill=interaction(Medium, Genotype)), outlier.shape = NA, size = 0.3, width = 0.6, position = position_dodge(0.9), alpha=1, weight=0.5) +
  scale_fill_manual(values = c("#47b88b", "#B847AD", "#4774b8", "#FC6666","#FD9902", "#66CCFF")) + 
  geom_point(aes(color = interaction(Medium, Genotype)), 
             position = position_jitterdodge(jitter.width = 0.1, dodge.width = 0.9), 
             size = 3, alpha=0.8, shape=21, fill="white") +
  scale_color_manual(values = c("#47b88b", "#B847AD", "#4774b8", "#FC6666","#FD9902", "#66CCFF")) +
  labs(x="", y="Spare Capacity", title="") +
  theme_classic() +
  theme(text = element_text(size = 20)) +
  theme(legend.position = "none") +
  ylim(0, 1.6) +
  theme(aspect.ratio = 3/2.5)
spare_bxplt

#4J - ATP Production
atp_bxplt <- ggplot(meas, aes(x=Medium, y=ATP_Production, group = interaction(Medium, Genotype))) + 
  geom_boxplot(aes(fill=interaction(Medium, Genotype)), outlier.shape = NA, size = 0.3, width = 0.6, position = position_dodge(0.9), alpha=1, weight=0.5) +
  scale_fill_manual(values = c("#47b88b", "#B847AD", "#4774b8", "#FC6666","#FD9902", "#66CCFF")) + 
  geom_point(aes(color = interaction(Medium, Genotype)), 
             position = position_jitterdodge(jitter.width = 0.1, dodge.width = 0.9), 
             size = 3, alpha=0.8, shape=21, fill="white") +
  scale_color_manual(values = c("#47b88b", "#B847AD", "#4774b8", "#FC6666","#FD9902", "#66CCFF")) +
  labs(x="", y="ATP Production\n(pmol/min/μg protein)", title="") +
  theme_classic() +
  theme(text = element_text(size = 20)) +
  theme(legend.position = "none") +
  ylim(0, 20) +
  theme(aspect.ratio = 3/2.5)
atp_bxplt

#4K - Proton Leak
proton_bxplt <- ggplot(meas, aes(x=Medium, y=Proton_Leak, group = interaction(Medium, Genotype))) + 
  geom_boxplot(aes(fill=interaction(Medium, Genotype)), outlier.shape = NA, size = 0.3, width = 0.6, position = position_dodge(0.9), alpha=1, weight=0.5) +
  scale_fill_manual(values = c("#47b88b", "#B847AD", "#4774b8", "#FC6666","#FD9902", "#66CCFF")) + 
  geom_point(aes(color = interaction(Medium, Genotype)), 
             position = position_jitterdodge(jitter.width = 0.1, dodge.width = 0.9), 
             size = 3, alpha=0.8, shape=21, fill="white") +
  scale_color_manual(values = c("#47b88b", "#B847AD", "#4774b8", "#FC6666","#FD9902", "#66CCFF")) +
  labs(x="", y="Proton Leak\n(pmol/min/ug protein)", title="") +
  theme_classic() +
  theme(text = element_text(size = 20)) +
  theme(legend.position = "none") +
  ylim(0, 6) +
  theme(aspect.ratio = 3/2.5)
proton_bxplt

#4L - Maximal Respiration
max_bxplt <- ggplot(meas, aes(x=Medium, y=Maximal_Respiration, group = interaction(Medium, Genotype))) + 
  geom_boxplot(aes(fill=interaction(Medium, Genotype)), outlier.shape = NA, size = 0.3, width = 0.6, position = position_dodge(0.9), alpha=1, weight=0.5) +
  scale_fill_manual(values = c("#47b88b", "#B847AD", "#4774b8", "#FC6666","#FD9902", "#66CCFF")) + 
  geom_point(aes(color = interaction(Medium, Genotype)), 
             position = position_jitterdodge(jitter.width = 0.1, dodge.width = 0.9), 
             size = 3, alpha=0.8, shape=21, fill="white") +
  scale_color_manual(values = c("#47b88b", "#B847AD", "#4774b8", "#FC6666","#FD9902", "#66CCFF")) +
  labs(x="", y="Maximal Respiration\n(pmol/min/ug protein)", title="") +
  theme_classic() +
  theme(text = element_text(size = 20)) +
  theme(legend.position = "none") +
  ylim(0, 25) +
  theme(aspect.ratio = 3/2.5)
max_bxplt


