Last updated: 2025-08-12
Checks: 6 1
Knit directory: Paul_CX_2025/
This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
The R Markdown is untracked by Git. To know which version of the R
Markdown file created these results, you’ll want to first commit it to
the Git repo. If you’re still working on the analysis, you can ignore
this warning. When you’re finished, you can run
wflow_publish
to commit the R Markdown file and build the
HTML.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20250129)
was run prior to running
the code in the R Markdown file. Setting a seed ensures that any results
that rely on randomness, e.g. subsampling or permutations, are
reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version d7ddd3a. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for
the analysis have been committed to Git prior to generating the results
(you can use wflow_publish
or
wflow_git_commit
). workflowr only checks the R Markdown
file, but you know if there are other scripts or data files that it
depends on. Below is the status of the Git repository when the results
were generated:
Ignored files:
Ignored: .RData
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: 0.1 box.svg
Ignored: Rplot04.svg
Untracked files:
Untracked: analysis/Figure_S15.Rmd
Unstaged changes:
Modified: analysis/index.Rmd
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
There are no past versions. Publish this analysis with
wflow_publish()
to start tracking its development.
# Load libraries
library(dplyr)
library(ggplot2)
library(reshape2)
# Load response group files
prob_1_0.1 <- as.character(read.csv("data/prob_1_0.1.csv")$Entrez_ID)
# Load expression dataset
boxplot1 <- read.csv("data/boxplot1.csv", check.names = FALSE)
boxplot1 <- as.data.frame(boxplot1)
# Choose a gene from the non-response group
target_entrez <- 92342 # Ensure this is from prob_1_0.1
# Stop if the gene is not in the non-response group
if (!(target_entrez %in% prob_1_0.1)) {
stop("Selected gene is not in the non-response group for 0.1 micromolar.")
}
# Filter for selected gene
gene_data <- boxplot1[boxplot1$ENTREZID == target_entrez, ]
if(nrow(gene_data) == 0) stop("No data found for selected ENTIREZID.")
# Reshape to long format
gene_data_long <- melt(gene_data,
id.vars = c("ENTREZID", "SYMBOL", "GENENAME"),
variable.name = "Sample",
value.name = "log2CPM")
# Extract metadata from sample names
gene_data_long <- gene_data_long %>%
mutate(
Time = sub(".*_(\\d+)$", "\\1", Sample),
Concentration = sub(".*_(0\\.\\d)_\\d+$", "\\1", Sample),
Drug = sub(".*_(CX\\.5461|DOX|VEH)_.*", "\\1", Sample),
Indv = sub("^([0-9]+\\.[0-9]+)_.*", "\\1", Sample)
)
# Filter for 0.1 micromolar only
gene_data_long <- gene_data_long %>% filter(Concentration == "0.1")
# Convert to factors
gene_data_long$Time <- factor(gene_data_long$Time, levels = c("3", "24", "48"))
gene_data_long$Concentration <- factor(gene_data_long$Concentration, levels = "0.1")
# Map individual IDs
indv_mapping <- c("75.1" = "1", "78.1" = "2", "87.1" = "3",
"17.3" = "4", "84.1" = "5", "90.1" = "6")
gene_data_long <- gene_data_long %>%
mutate(Indv = ifelse(Indv %in% names(indv_mapping), indv_mapping[Indv], "Unknown"))
# Define color palette for drugs
drug_palette <- c("CX.5461" = "#08306B", "DOX" = "#E7298A", "VEH" = "green")
# Extract gene symbol for labeling
gene_symbol <- unique(gene_data_long$SYMBOL)[1]
# Create the boxplot
ggplot(gene_data_long, aes(x = Drug, y = log2CPM, fill = Drug)) +
geom_boxplot(outlier.shape = NA) +
scale_fill_manual(values = drug_palette) +
facet_grid(. ~ Time, labeller = label_both) + # Only facets by Time now
geom_point(aes(color = Indv), size = 2, alpha = 0.5,
position = position_jitter(width = -0.3, height = 0)) +
ggtitle("Non response (0.1 micromolar)") +
labs(
x = "Drugs",
y = paste(gene_symbol, " log2CPM")
) +
ylim(0, NA) +
theme_bw() +
theme(
plot.title = element_text(size = rel(1.5), hjust = 0.5),
axis.title = element_text(size = 15, color = "black"),
axis.ticks = element_line(linewidth = 1.5),
axis.line = element_line(linewidth = 1.5),
axis.text.y = element_text(size = 10, color = "black"),
axis.text.x = element_text(size = 10, color = "black", angle = 45, hjust = 1),
strip.text = element_text(size = 12, face = "bold")
)
## 📌 CX-DOX Mid-Late Response (0.1 micromolar)
# Load libraries
library(dplyr)
library(ggplot2)
library(reshape2)
# Load response group Entrez IDs
prob_2_0.1 <- as.character(read.csv("data/prob_2_0.1.csv")$Entrez_ID)
# Load expression matrix
boxplot1 <- read.csv("data/boxplot1.csv", check.names = FALSE) %>% as.data.frame()
# Define gene by Entrez ID
target_entrez <- "9319" # Replace with desired gene from prob_2_0.1
# Check gene membership in the response group
if (!(target_entrez %in% prob_2_0.1)) {
stop("Selected gene is not in the CX-DOX mid-late response group for 0.1 micromolar.")
}
# Extract gene expression
gene_data <- boxplot1[boxplot1$ENTREZID == target_entrez, ]
if (nrow(gene_data) == 0) stop("No data found for selected ENTREZID.")
# Reshape to long format
gene_data_long <- reshape2::melt(gene_data,
id.vars = c("ENTREZID", "SYMBOL", "GENENAME"),
variable.name = "Sample",
value.name = "log2CPM")
# Annotate metadata
gene_data_long <- gene_data_long %>%
mutate(
Time = sub(".*_(\\d+)$", "\\1", Sample),
Concentration = sub(".*_(0\\.\\d)_\\d+$", "\\1", Sample),
Drug = sub(".*_(CX\\.5461|DOX|VEH)_.*", "\\1", Sample),
Indv = sub("^([0-9]+\\.[0-9]+)_.*", "\\1", Sample)
) %>%
filter(Concentration == "0.1") # Filter to 0.1 µM only
# Convert factors
gene_data_long$Time <- factor(gene_data_long$Time, levels = c("3", "24", "48"))
gene_data_long$Concentration <- factor(gene_data_long$Concentration, levels = "0.1")
# Map individual IDs
indv_mapping <- c("75.1" = "1", "78.1" = "2", "87.1" = "3",
"17.3" = "4", "84.1" = "5", "90.1" = "6")
gene_data_long$Indv <- ifelse(gene_data_long$Indv %in% names(indv_mapping),
indv_mapping[gene_data_long$Indv], "Unknown")
# Color palette
drug_palette <- c("CX.5461" = "#08306B", "DOX" = "#E7298A", "VEH" = "green")
# Extract gene symbol
gene_symbol <- unique(gene_data_long$SYMBOL)[1]
# Plot
ggplot(gene_data_long, aes(x = Drug, y = log2CPM, fill = Drug)) +
geom_boxplot(outlier.shape = NA) +
scale_fill_manual(values = drug_palette) +
facet_grid(. ~ Time, labeller = label_both) +
geom_point(aes(color = Indv), size = 2, alpha = 0.5,
position = position_jitter(width = -0.3, height = 0)) +
ggtitle("CX_DOX_1") +
labs(
x = "Drugs",
y = paste0(gene_symbol, " log2CPM")
) +
ylim(0, NA) +
theme_bw() +
theme(
plot.title = element_text(size = rel(1.5), hjust = 0.5),
axis.title = element_text(size = 15, color = "black"),
axis.ticks = element_line(linewidth = 1.5),
axis.line = element_line(linewidth = 1.5),
axis.text.y = element_text(size = 10, color = "black"),
axis.text.x = element_text(size = 10, color = "black", angle = 45, hjust = 1),
strip.text = element_text(size = 12, face = "bold")
)
# Load libraries
library(dplyr)
library(ggplot2)
library(reshape2)
# Load response group files
prob_3_0.1 <- as.character(read.csv("data/prob_3_0.1.csv")$Entrez_ID)
# Load expression dataset
boxplot1 <- read.csv("data/boxplot1.csv", check.names = FALSE)
boxplot1 <- as.data.frame(boxplot1)
# Choose a gene from the DOX-only mid-late response group
target_entrez <- 1674 # Replace with your desired Entrez ID from prob_3_0.1
# Stop if the gene is not in the DOX-only mid-late response group
if (!(target_entrez %in% prob_3_0.1)) {
stop("Selected gene is not in the DOX-only mid-late response group for 0.1 micromolar.")
}
# Filter for selected gene
gene_data <- boxplot1[boxplot1$ENTREZID == target_entrez, ]
if(nrow(gene_data) == 0) stop("No data found for selected ENTREZID.")
# Reshape to long format
gene_data_long <- reshape2::melt(gene_data,
id.vars = c("ENTREZID", "SYMBOL", "GENENAME"),
variable.name = "Sample",
value.name = "log2CPM")
# Extract metadata from sample names
gene_data_long <- gene_data_long %>%
mutate(
Time = sub(".*_(\\d+)$", "\\1", Sample),
Concentration = sub(".*_(0\\.\\d)_\\d+$", "\\1", Sample),
Drug = sub(".*_(CX\\.5461|DOX|VEH)_.*", "\\1", Sample),
Indv = sub("^([0-9]+\\.[0-9]+)_.*", "\\1", Sample)
)
# Filter for 0.1 micromolar only
gene_data_long <- gene_data_long %>% filter(Concentration == "0.1")
# Convert to factors
gene_data_long$Time <- factor(gene_data_long$Time, levels = c("3", "24", "48"))
gene_data_long$Concentration <- factor(gene_data_long$Concentration, levels = "0.1")
# Map individual IDs
indv_mapping <- c("75.1" = "1", "78.1" = "2", "87.1" = "3",
"17.3" = "4", "84.1" = "5", "90.1" = "6")
gene_data_long <- gene_data_long %>%
mutate(Indv = ifelse(Indv %in% names(indv_mapping), indv_mapping[Indv], "Unknown"))
# Define color palette for drugs
drug_palette <- c("CX.5461" = "#08306B", "DOX" = "#E7298A", "VEH" = "green")
# Extract gene symbol for labeling
gene_symbol <- unique(gene_data_long$SYMBOL)[1]
# Create the boxplot
ggplot(gene_data_long, aes(x = Drug, y = log2CPM, fill = Drug)) +
geom_boxplot(outlier.shape = NA) +
scale_fill_manual(values = drug_palette) +
facet_grid(. ~ Time, labeller = label_both) +
geom_point(aes(color = Indv), size = 2, alpha = 0.5,
position = position_jitter(width = -0.3, height = 0)) +
ggtitle("DOX_sp_1") +
labs(
x = "Drugs",
y = paste(gene_symbol, " log2CPM")
) +
ylim(0, NA) +
theme_bw() +
theme(
plot.title = element_text(size = rel(1.5), hjust = 0.5),
axis.title = element_text(size = 15, color = "black"),
axis.ticks = element_line(linewidth = 1.5),
axis.line = element_line(linewidth = 1.5),
axis.text.y = element_text(size = 10, color = "black"),
axis.text.x = element_text(size = 10, color = "black", angle = 45, hjust = 1),
strip.text = element_text(size = 12, face = "bold")
)
# Load libraries
library(dplyr)
library(ggplot2)
library(reshape2)
# Load response group: Non response (0.5 µM)
prob_1_0.5 <- as.character(read.csv("data/prob_1_0.5.csv")$Entrez_ID)
# Load expression dataset
boxplot1 <- read.csv("data/boxplot1.csv", check.names = FALSE)
boxplot1 <- as.data.frame(boxplot1)
# Choose a gene from the non-response group (0.5 µM)
target_entrez <- 9446 # Replace with your desired Entrez ID from prob_1_0.5
# Check if it's in the group
if (!(target_entrez %in% prob_1_0.5)) {
stop("Selected gene is not in the Non response group for 0.5 micromolar.")
}
# Filter for selected gene
gene_data <- boxplot1[boxplot1$ENTREZID == target_entrez, ]
if(nrow(gene_data) == 0) stop("No data found for selected ENTREZID.")
# Reshape to long format
gene_data_long <- melt(gene_data,
id.vars = c("ENTREZID", "SYMBOL", "GENENAME"),
variable.name = "Sample",
value.name = "log2CPM")
# Extract metadata from sample names
gene_data_long <- gene_data_long %>%
mutate(
Time = sub(".*_(\\d+)$", "\\1", Sample),
Concentration = sub(".*_(0\\.\\d)_\\d+$", "\\1", Sample),
Drug = sub(".*_(CX\\.5461|DOX|VEH)_.*", "\\1", Sample),
Indv = sub("^([0-9]+\\.[0-9]+)_.*", "\\1", Sample)
)
# Filter for 0.5 micromolar only
gene_data_long <- gene_data_long %>% filter(Concentration == "0.5")
# Convert to factors
gene_data_long$Time <- factor(gene_data_long$Time, levels = c("3", "24", "48"))
gene_data_long$Concentration <- factor(gene_data_long$Concentration, levels = "0.5")
# Map individual IDs
indv_mapping <- c("75.1" = "1", "78.1" = "2", "87.1" = "3",
"17.3" = "4", "84.1" = "5", "90.1" = "6")
gene_data_long <- gene_data_long %>%
mutate(Indv = ifelse(Indv %in% names(indv_mapping), indv_mapping[Indv], "Unknown"))
# Define color palette for drugs
drug_palette <- c("CX.5461" = "#08306B", "DOX" = "#E7298A", "VEH" = "green")
# Extract gene symbol for labeling
gene_symbol <- unique(gene_data_long$SYMBOL)[1]
# Create the boxplot
ggplot(gene_data_long, aes(x = Drug, y = log2CPM, fill = Drug)) +
geom_boxplot(outlier.shape = NA) +
scale_fill_manual(values = drug_palette) +
facet_grid(. ~ Time, labeller = label_both) +
geom_point(aes(color = Indv), size = 2, alpha = 0.5,
position = position_jitter(width = -0.3, height = 0)) +
ggtitle("Non response (0.5 micromolar)") +
labs(
x = "Drugs",
y = paste(gene_symbol, " log2CPM")
) +
ylim(0, NA) +
theme_bw() +
theme(
plot.title = element_text(size = rel(1.5), hjust = 0.5),
axis.title = element_text(size = 15, color = "black"),
axis.ticks = element_line(linewidth = 1.5),
axis.line = element_line(linewidth = 1.5),
axis.text.y = element_text(size = 10, color = "black"),
axis.text.x = element_text(size = 10, color = "black", angle = 45, hjust = 1),
strip.text = element_text(size = 12, face = "bold")
)
## 📌 DOX_sp_2
# Load libraries
library(dplyr)
library(ggplot2)
library(reshape2)
# Load response group: DOX-specific response (0.5 µM)
prob_2_0.5 <- as.character(read.csv("data/prob_2_0.5.csv")$Entrez_ID)
# Load expression dataset
boxplot1 <- read.csv("data/boxplot1.csv", check.names = FALSE)
boxplot1 <- as.data.frame(boxplot1)
# Choose a gene from the DOX-specific response group (0.5 µM)
target_entrez <- 114821 # Replace with your desired Entrez ID from prob_2_0.5
# Check membership
if (!(target_entrez %in% prob_2_0.5)) {
stop("Selected gene is not in the DOX-specific response group for 0.5 micromolar.")
}
# Filter for selected gene
gene_data <- boxplot1[boxplot1$ENTREZID == target_entrez, ]
if(nrow(gene_data) == 0) stop("No data found for selected ENTREZID.")
# Reshape to long format
gene_data_long <- melt(gene_data,
id.vars = c("ENTREZID", "SYMBOL", "GENENAME"),
variable.name = "Sample",
value.name = "log2CPM")
# Extract metadata from sample names
gene_data_long <- gene_data_long %>%
mutate(
Time = sub(".*_(\\d+)$", "\\1", Sample),
Concentration = sub(".*_(0\\.\\d)_\\d+$", "\\1", Sample),
Drug = sub(".*_(CX\\.5461|DOX|VEH)_.*", "\\1", Sample),
Indv = sub("^([0-9]+\\.[0-9]+)_.*", "\\1", Sample)
)
# Filter for 0.5 micromolar only
gene_data_long <- gene_data_long %>% filter(Concentration == "0.5")
# Convert to factors
gene_data_long$Time <- factor(gene_data_long$Time, levels = c("3", "24", "48"))
gene_data_long$Concentration <- factor(gene_data_long$Concentration, levels = "0.5")
# Map individual IDs
indv_mapping <- c("75.1" = "1", "78.1" = "2", "87.1" = "3",
"17.3" = "4", "84.1" = "5", "90.1" = "6")
gene_data_long <- gene_data_long %>%
mutate(Indv = ifelse(Indv %in% names(indv_mapping), indv_mapping[Indv], "Unknown"))
# Define color palette for drugs
drug_palette <- c("CX.5461" = "#08306B", "DOX" = "#E7298A", "VEH" = "green")
# Extract gene symbol for labeling
gene_symbol <- unique(gene_data_long$SYMBOL)[1]
# Create the boxplot
ggplot(gene_data_long, aes(x = Drug, y = log2CPM, fill = Drug)) +
geom_boxplot(outlier.shape = NA) +
scale_fill_manual(values = drug_palette) +
facet_grid(. ~ Time, labeller = label_both) +
geom_point(aes(color = Indv), size = 2, alpha = 0.5,
position = position_jitter(width = -0.3, height = 0)) +
ggtitle("DOX_sp_2") +
labs(
x = "Drugs",
y = paste(gene_symbol, " log2CPM")
) +
ylim(0, NA) +
theme_bw() +
theme(
plot.title = element_text(size = rel(1.5), hjust = 0.5),
axis.title = element_text(size = 15, color = "black"),
axis.ticks = element_line(linewidth = 1.5),
axis.line = element_line(linewidth = 1.5),
axis.text.y = element_text(size = 10, color = "black"),
axis.text.x = element_text(size = 10, color = "black", angle = 45, hjust = 1),
strip.text = element_text(size = 12, face = "bold")
)
# Load libraries
library(dplyr)
library(ggplot2)
library(reshape2)
# Load response group: DOX only mid-late response (0.5 µM)
prob_3_0.5 <- as.character(read.csv("data/prob_3_0.5.csv")$Entrez_ID)
# Load expression dataset
boxplot1 <- read.csv("data/boxplot1.csv", check.names = FALSE)
boxplot1 <- as.data.frame(boxplot1)
# Choose a gene from the DOX only mid-late response group (0.5 µM)
target_entrez <- 4892 # Replace with your desired Entrez ID from prob_3_0.5
# Check membership
if (!(target_entrez %in% prob_3_0.5)) {
stop("Selected gene is not in the DOX only mid-late response group for 0.5 micromolar.")
}
# Filter for selected gene
gene_data <- boxplot1[boxplot1$ENTREZID == target_entrez, ]
if(nrow(gene_data) == 0) stop("No data found for selected ENTREZID.")
# Reshape to long format
gene_data_long <- melt(gene_data,
id.vars = c("ENTREZID", "SYMBOL", "GENENAME"),
variable.name = "Sample",
value.name = "log2CPM")
# Extract metadata from sample names
gene_data_long <- gene_data_long %>%
mutate(
Time = sub(".*_(\\d+)$", "\\1", Sample),
Concentration = sub(".*_(0\\.\\d)_\\d+$", "\\1", Sample),
Drug = sub(".*_(CX\\.5461|DOX|VEH)_.*", "\\1", Sample),
Indv = sub("^([0-9]+\\.[0-9]+)_.*", "\\1", Sample)
)
# Filter for 0.5 micromolar only
gene_data_long <- gene_data_long %>% filter(Concentration == "0.5")
# Convert to factors
gene_data_long$Time <- factor(gene_data_long$Time, levels = c("3", "24", "48"))
gene_data_long$Concentration <- factor(gene_data_long$Concentration, levels = "0.5")
# Map individual IDs
indv_mapping <- c("75.1" = "1", "78.1" = "2", "87.1" = "3",
"17.3" = "4", "84.1" = "5", "90.1" = "6")
gene_data_long <- gene_data_long %>%
mutate(Indv = ifelse(Indv %in% names(indv_mapping), indv_mapping[Indv], "Unknown"))
# Define color palette for drugs
drug_palette <- c("CX.5461" = "#08306B", "DOX" = "#E7298A", "VEH" = "green")
# Extract gene symbol for labeling
gene_symbol <- unique(gene_data_long$SYMBOL)[1]
# Create the boxplot
ggplot(gene_data_long, aes(x = Drug, y = log2CPM, fill = Drug)) +
geom_boxplot(outlier.shape = NA) +
scale_fill_manual(values = drug_palette) +
facet_grid(. ~ Time, labeller = label_both) +
geom_point(aes(color = Indv), size = 2, alpha = 0.5,
position = position_jitter(width = -0.3, height = 0)) +
ggtitle("DOX_sp_2") +
labs(
x = "Drugs",
y = paste(gene_symbol, " log2CPM")
) +
ylim(0, NA) +
theme_bw() +
theme(
plot.title = element_text(size = rel(1.5), hjust = 0.5),
axis.title = element_text(size = 15, color = "black"),
axis.ticks = element_line(linewidth = 1.5),
axis.line = element_line(linewidth = 1.5),
axis.text.y = element_text(size = 10, color = "black"),
axis.text.x = element_text(size = 10, color = "black", angle = 45, hjust = 1),
strip.text = element_text(size = 12, face = "bold")
)
# ----------------- Load Libraries -----------------
library(dplyr)
library(ggplot2)
library(reshape2)
# ----------------- Load Response Group -----------------
prob_4_0.5 <- as.character(read.csv("data/prob_4_0.5.csv")$Entrez_ID)
# ----------------- Load Expression Dataset -----------------
boxplot1 <- read.csv("data/boxplot1.csv", check.names = FALSE)
boxplot1 <- as.data.frame(boxplot1)
# ----------------- Choose a Target Gene -----------------
target_entrez <- 100996485 # Replace this with any valid Entrez ID from prob_4_0.5
# Check if gene is valid
if (!(target_entrez %in% prob_4_0.5)) {
stop("Selected gene is not in the CX total + DOX early response group for 0.5 micromolar.")
}
# ----------------- Filter Data for Selected Gene -----------------
gene_data <- boxplot1[boxplot1$ENTREZID == target_entrez, ]
if (nrow(gene_data) == 0) stop("No data found for selected ENTREZID.")
# ----------------- Reshape to Long Format -----------------
gene_data_long <- melt(gene_data,
id.vars = c("ENTREZID", "SYMBOL", "GENENAME"),
variable.name = "Sample",
value.name = "log2CPM")
# ----------------- Extract Metadata -----------------
gene_data_long <- gene_data_long %>%
mutate(
Time = sub(".*_(\\d+)$", "\\1", Sample),
Concentration = sub(".*_(0\\.\\d)_\\d+$", "\\1", Sample),
Drug = sub(".*_(CX\\.5461|DOX|VEH)_.*", "\\1", Sample),
Indv = sub("^([0-9]+\\.[0-9]+)_.*", "\\1", Sample)
)
# ----------------- Filter for 0.5 µM Only -----------------
gene_data_long <- gene_data_long %>% filter(Concentration == "0.5")
# ----------------- Convert to Factors -----------------
gene_data_long$Time <- factor(gene_data_long$Time, levels = c("3", "24", "48"))
gene_data_long$Concentration <- factor(gene_data_long$Concentration, levels = "0.5")
# ----------------- Map Individual IDs -----------------
indv_mapping <- c("75.1" = "1", "78.1" = "2", "87.1" = "3",
"17.3" = "4", "84.1" = "5", "90.1" = "6")
gene_data_long <- gene_data_long %>%
mutate(Indv = ifelse(Indv %in% names(indv_mapping), indv_mapping[Indv], "Unknown"))
# ----------------- Define Drug Color Palette -----------------
drug_palette <- c("CX.5461" = "#08306B", "DOX" = "#E7298A", "VEH" = "green")
# ----------------- Extract Gene Symbol -----------------
gene_symbol <- unique(gene_data_long$SYMBOL)[1]
# ----------------- Plot -----------------
ggplot(gene_data_long, aes(x = Drug, y = log2CPM, fill = Drug)) +
geom_boxplot(outlier.shape = NA) +
scale_fill_manual(values = drug_palette) +
facet_grid(. ~ Time, labeller = label_both) +
geom_point(aes(color = Indv), size = 2, alpha = 0.5,
position = position_jitter(width = -0.3, height = 0)) +
ggtitle("CX_DOX_2") +
labs(
x = "Drugs",
y = paste(gene_symbol, " log2CPM")
) +
ylim(0, NA) +
theme_bw() +
theme(
plot.title = element_text(size = rel(1.5), hjust = 0.5),
axis.title = element_text(size = 15, color = "black"),
axis.ticks = element_line(linewidth = 1.5),
axis.line = element_line(linewidth = 1.5),
axis.text.y = element_text(size = 10, color = "black"),
axis.text.x = element_text(size = 10, color = "black", angle = 45, hjust = 1),
strip.text = element_text(size = 12, face = "bold")
)
# Load libraries
library(dplyr)
library(ggplot2)
library(reshape2)
# Load response group: DOX early + CX-DOX mid-late response (0.5 µM)
prob_5_0.5 <- as.character(read.csv("data/prob_5_0.5.csv")$Entrez_ID)
# Load expression dataset
boxplot1 <- read.csv("data/boxplot1.csv", check.names = FALSE)
boxplot1 <- as.data.frame(boxplot1)
# Choose a gene from the DOX early + CX-DOX mid-late response group (0.5 µM)
target_entrez <- 672 # Replace with your desired Entrez ID from prob_5_0.5
# Check membership
if (!(target_entrez %in% prob_5_0.5)) {
stop("Selected gene is not in the DOX early + CX-DOX mid-late response group for 0.5 micromolar.")
}
# Filter for selected gene
gene_data <- boxplot1[boxplot1$ENTREZID == target_entrez, ]
if(nrow(gene_data) == 0) stop("No data found for selected ENTREZID.")
# Reshape to long format
gene_data_long <- melt(gene_data,
id.vars = c("ENTREZID", "SYMBOL", "GENENAME"),
variable.name = "Sample",
value.name = "log2CPM")
# Extract metadata from sample names
gene_data_long <- gene_data_long %>%
mutate(
Time = sub(".*_(\\d+)$", "\\1", Sample),
Concentration = sub(".*_(0\\.\\d)_\\d+$", "\\1", Sample),
Drug = sub(".*_(CX\\.5461|DOX|VEH)_.*", "\\1", Sample),
Indv = sub("^([0-9]+\\.[0-9]+)_.*", "\\1", Sample)
)
# Filter for 0.5 micromolar only
gene_data_long <- gene_data_long %>% filter(Concentration == "0.5")
# Convert to factors
gene_data_long$Time <- factor(gene_data_long$Time, levels = c("3", "24", "48"))
gene_data_long$Concentration <- factor(gene_data_long$Concentration, levels = "0.5")
# Map individual IDs
indv_mapping <- c("75.1" = "1", "78.1" = "2", "87.1" = "3",
"17.3" = "4", "84.1" = "5", "90.1" = "6")
gene_data_long <- gene_data_long %>%
mutate(Indv = ifelse(Indv %in% names(indv_mapping), indv_mapping[Indv], "Unknown"))
# Define color palette for drugs
drug_palette <- c("CX.5461" = "#08306B", "DOX" = "#E7298A", "VEH" = "green")
# Extract gene symbol for labeling
gene_symbol <- unique(gene_data_long$SYMBOL)[1]
# Create the boxplot
ggplot(gene_data_long, aes(x = Drug, y = log2CPM, fill = Drug)) +
geom_boxplot(outlier.shape = NA) +
scale_fill_manual(values = drug_palette) +
facet_grid(. ~ Time, labeller = label_both) +
geom_point(aes(color = Indv), size = 2, alpha = 0.5,
position = position_jitter(width = -0.3, height = 0)) +
ggtitle("CX_DOX_3") +
labs(
x = "Drugs",
y = paste(gene_symbol, " log2CPM")
) +
ylim(0, NA) +
theme_bw() +
theme(
plot.title = element_text(size = rel(1.5), hjust = 0.5),
axis.title = element_text(size = 15, color = "black"),
axis.ticks = element_line(linewidth = 1.5),
axis.line = element_line(linewidth = 1.5),
axis.text.y = element_text(size = 10, color = "black"),
axis.text.x = element_text(size = 10, color = "black", angle = 45, hjust = 1),
strip.text = element_text(size = 12, face = "bold")
)
sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 26100)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8
[2] LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
time zone: America/Chicago
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] reshape2_1.4.4 ggplot2_3.5.2 dplyr_1.1.4
loaded via a namespace (and not attached):
[1] gtable_0.3.6 jsonlite_2.0.0 compiler_4.3.0 promises_1.3.2
[5] tidyselect_1.2.1 Rcpp_1.0.12 stringr_1.5.1 git2r_0.36.2
[9] later_1.3.2 jquerylib_0.1.4 scales_1.3.0 yaml_2.3.10
[13] fastmap_1.2.0 plyr_1.8.9 R6_2.6.1 labeling_0.4.3
[17] generics_0.1.3 workflowr_1.7.1 knitr_1.50 tibble_3.2.1
[21] munsell_0.5.1 rprojroot_2.0.4 bslib_0.9.0 pillar_1.10.2
[25] rlang_1.1.3 cachem_1.1.0 stringi_1.8.3 httpuv_1.6.15
[29] xfun_0.52 fs_1.6.3 sass_0.4.10 cli_3.6.1
[33] withr_3.0.2 magrittr_2.0.3 digest_0.6.34 grid_4.3.0
[37] rstudioapi_0.17.1 lifecycle_1.0.4 vctrs_0.6.5 evaluate_1.0.3
[41] glue_1.7.0 farver_2.1.2 colorspace_2.1-0 rmarkdown_2.29
[45] tools_4.3.0 pkgconfig_2.0.3 htmltools_0.5.8.1