mirror of
https://github.com/the-jordan-lab/docs.git
synced 2025-05-09 21:32:38 +00:00
217 lines
7.3 KiB
R
217 lines
7.3 KiB
R
# EXP-0226 Co-IP Western Blot Quantification Script
|
||
# Analysis of YBX1-CEBPA protein interaction in early adipogenesis
|
||
# Authors: james-m-jordan, linda-onsei
|
||
# Date: 2025-05-11
|
||
|
||
# Load required libraries
|
||
library(tidyverse)
|
||
library(readxl)
|
||
library(ggplot2)
|
||
library(cowplot)
|
||
library(rstatix)
|
||
|
||
# Set paths
|
||
experiment_id <- "EXP-0226"
|
||
data_dir <- file.path("Data", experiment_id, "raw")
|
||
output_dir <- file.path("Data", experiment_id, "figures")
|
||
dir.create(output_dir, showWarnings = FALSE, recursive = TRUE)
|
||
|
||
# PLACEHOLDER: Load band intensity data
|
||
# This would typically come from ImageJ/FIJI quantification of Western blot TIFFs
|
||
# For now, we'll create a placeholder data structure
|
||
|
||
# Function to read ImageJ quantification data
|
||
# In a real scenario, this would parse data exported from ImageJ
|
||
read_imagej_data <- function(filepath) {
|
||
# If real data exists, uncomment and use:
|
||
# read_csv(filepath)
|
||
|
||
# For now, simulate with placeholder data
|
||
tibble(
|
||
lane = 1:12,
|
||
condition = rep(c("Control", "Control", "Control", "Adipogenic", "Adipogenic", "Adipogenic"), 2),
|
||
antibody = c(rep("YBX1_IP", 6), rep("CEBPA_IP", 6)),
|
||
sample_type = rep(c("Input", "IP", "IgG"), 4),
|
||
intensity = c(
|
||
# YBX1 IP probed for CEBPA
|
||
1000, 120, 10, # Control (Input, IP, IgG)
|
||
1200, 450, 15, # Adipogenic (Input, IP, IgG)
|
||
|
||
# CEBPA IP probed for YBX1
|
||
900, 100, 5, # Control (Input, IP, IgG)
|
||
950, 320, 8 # Adipogenic (Input, IP, IgG)
|
||
)
|
||
)
|
||
}
|
||
|
||
# Process and analyze Co-IP data
|
||
analyze_coip_data <- function(df) {
|
||
# Background subtraction (IgG control)
|
||
df_bg <- df %>%
|
||
group_by(condition, antibody) %>%
|
||
mutate(
|
||
# Find IgG value for this group
|
||
igg_intensity = intensity[sample_type == "IgG"],
|
||
# Subtract IgG background
|
||
corrected_intensity = intensity - igg_intensity,
|
||
# Set negative values to zero
|
||
corrected_intensity = ifelse(corrected_intensity < 0, 0, corrected_intensity)
|
||
)
|
||
|
||
# Calculate enrichment (IP signal relative to input)
|
||
df_enrichment <- df_bg %>%
|
||
group_by(condition, antibody) %>%
|
||
mutate(
|
||
# Find input value for this group
|
||
input_intensity = corrected_intensity[sample_type == "Input"],
|
||
# Calculate enrichment as IP / Input
|
||
enrichment = corrected_intensity / input_intensity,
|
||
# For fold change calculations later
|
||
IP_intensity = corrected_intensity[sample_type == "IP"]
|
||
) %>%
|
||
filter(sample_type == "IP") %>% # Only keep IP samples for further analysis
|
||
ungroup()
|
||
|
||
# Calculate fold change in interaction (Adipogenic vs Control)
|
||
fold_changes <- df_enrichment %>%
|
||
group_by(antibody) %>%
|
||
summarize(
|
||
control_enrichment = enrichment[condition == "Control"],
|
||
adipogenic_enrichment = enrichment[condition == "Adipogenic"],
|
||
fold_change = adipogenic_enrichment / control_enrichment,
|
||
percent_increase = (fold_change - 1) * 100
|
||
)
|
||
|
||
# Prepare and return results
|
||
list(
|
||
raw_data = df,
|
||
background_corrected = df_bg,
|
||
enrichment = df_enrichment,
|
||
fold_changes = fold_changes
|
||
)
|
||
}
|
||
|
||
# Generate plots
|
||
create_coip_plots <- function(results) {
|
||
# Extract data
|
||
enrichment_data <- results$enrichment
|
||
|
||
# Bar plot of YBX1-CEBPA interaction by condition
|
||
p1 <- ggplot(enrichment_data, aes(x = condition, y = enrichment, fill = condition)) +
|
||
geom_bar(stat = "identity", width = 0.6) +
|
||
facet_wrap(~antibody, scales = "free_y",
|
||
labeller = labeller(antibody = c(
|
||
"YBX1_IP" = "YBX1 IP (probed for CEBPα)",
|
||
"CEBPA_IP" = "CEBPα IP (probed for YBX1)"
|
||
))) +
|
||
labs(
|
||
title = "YBX1-CEBPα Interaction in 3T3 Cells",
|
||
subtitle = "With or without adipogenic stimulation (24h)",
|
||
x = NULL,
|
||
y = "Relative Enrichment (IP/Input)"
|
||
) +
|
||
scale_fill_manual(values = c("Control" = "#99BBDD", "Adipogenic" = "#FF7755")) +
|
||
theme_cowplot() +
|
||
theme(
|
||
legend.position = "bottom",
|
||
strip.background = element_rect(fill = "white"),
|
||
strip.text = element_text(face = "bold")
|
||
)
|
||
|
||
# Fold change summary
|
||
fold_change_data <- results$fold_changes
|
||
|
||
p2 <- ggplot(fold_change_data, aes(x = antibody, y = fold_change, fill = antibody)) +
|
||
geom_bar(stat = "identity", width = 0.6) +
|
||
geom_hline(yintercept = 1, linetype = "dashed", color = "gray50") +
|
||
labs(
|
||
title = "Fold Change in YBX1-CEBPα Interaction",
|
||
subtitle = "Adipogenic vs Control",
|
||
x = NULL,
|
||
y = "Fold Change (Adipogenic/Control)"
|
||
) +
|
||
scale_x_discrete(labels = c(
|
||
"YBX1_IP" = "YBX1 IP\n(probed for CEBPα)",
|
||
"CEBPA_IP" = "CEBPα IP\n(probed for YBX1)"
|
||
)) +
|
||
scale_fill_manual(values = c("YBX1_IP" = "#3377BB", "CEBPA_IP" = "#DD5544")) +
|
||
theme_cowplot() +
|
||
theme(legend.position = "none")
|
||
|
||
# Return plot objects
|
||
list(
|
||
interaction_by_condition = p1,
|
||
fold_change = p2
|
||
)
|
||
}
|
||
|
||
# Create a summary table
|
||
create_summary_table <- function(results) {
|
||
# Extract fold change data
|
||
fold_data <- results$fold_changes
|
||
|
||
# Create a formatted table
|
||
summary_table <- fold_data %>%
|
||
mutate(
|
||
Antibody = case_when(
|
||
antibody == "YBX1_IP" ~ "YBX1 IP (probed for CEBPα)",
|
||
antibody == "CEBPA_IP" ~ "CEBPα IP (probed for YBX1)"
|
||
),
|
||
Control = round(control_enrichment, 2),
|
||
Adipogenic = round(adipogenic_enrichment, 2),
|
||
`Fold Change` = round(fold_change, 2),
|
||
`% Increase` = round(percent_increase, 1)
|
||
) %>%
|
||
select(Antibody, Control, Adipogenic, `Fold Change`, `% Increase`)
|
||
|
||
# Return the formatted table
|
||
summary_table
|
||
}
|
||
|
||
# Main execution
|
||
# PLACEHOLDER: In a real scenario, we would load actual data from ImageJ quantification files
|
||
# imagej_data_path <- file.path(data_dir, "western_blot_quantification.csv")
|
||
# band_data <- read_imagej_data(imagej_data_path)
|
||
|
||
# For demonstration, use our simulated data
|
||
band_data <- read_imagej_data(NULL)
|
||
|
||
# Analyze the data
|
||
results <- analyze_coip_data(band_data)
|
||
|
||
# Create plots
|
||
plots <- create_coip_plots(results)
|
||
|
||
# Save plots
|
||
# ggsave(file.path(output_dir, "YBX1_CEBPA_interaction.pdf"), plots$interaction_by_condition, width = 8, height = 6)
|
||
# ggsave(file.path(output_dir, "YBX1_CEBPA_fold_change.pdf"), plots$fold_change, width = 6, height = 5)
|
||
|
||
# Create summary table
|
||
summary_table <- create_summary_table(results)
|
||
|
||
# Print summary
|
||
cat("\n")
|
||
cat("========================================\n")
|
||
cat("EXP-0226 YBX1-CEBPα Interaction Analysis\n")
|
||
cat("========================================\n\n")
|
||
|
||
cat("Experiment: YBX1-CEBPA Protein Interaction in Early Adipogenesis\n")
|
||
cat("Date: 2025-05-11\n")
|
||
cat("Researchers: james-m-jordan, linda-onsei\n\n")
|
||
|
||
cat("SUMMARY OF RESULTS (PLACEHOLDER DATA):\n\n")
|
||
print(summary_table)
|
||
|
||
cat("\nNotes:\n")
|
||
cat("- Both YBX1 and CEBPα show increased interaction after adipogenic induction\n")
|
||
cat("- The interaction appears to be reciprocal and specific (minimal IgG background)\n")
|
||
cat("- For actual results, replace the placeholder data with real ImageJ quantification\n\n")
|
||
|
||
cat("Plots saved to:", output_dir, "\n")
|
||
cat("========================================\n")
|
||
|
||
# IMPORTANT NOTES FOR REAL ANALYSIS:
|
||
# 1. Replace the simulated data with actual ImageJ/FIJI quantification of Western blots
|
||
# 2. Consider adding statistical analysis (t-tests between conditions)
|
||
# 3. Uncomment the ggsave commands to save the plots
|
||
# 4. Consider additional normalization strategies if needed (e.g., for input variation) |