-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCu_1_10ppm_noNorm.R
More file actions
53 lines (45 loc) · 1.49 KB
/
Cu_1_10ppm_noNorm.R
File metadata and controls
53 lines (45 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
library(dplyr)
library(tidyr)
library(ggplot2)
# ------------------------------
# Combine datasets
# ------------------------------
df_all <- bind_rows(df_10, df_5, df_2.5, df_1)
# ------------------------------
# Convert to long format (NO NORMALIZATION)
# ------------------------------
df_long <- df_all %>%
pivot_longer(
cols = c(Supernatant, Pellet),
names_to = "Fraction",
values_to = "Value"
)
# ------------------------------
# Reorder facets so 10 ppm is on top
# ------------------------------
df_long$Condition <- factor(df_long$Condition,
levels = c("10 ppm", "5 ppm", "2.5 ppm", "1 ppm"))
# Optional: control stacking order
df_long$Fraction <- factor(df_long$Fraction,
levels = c("Pellet", "Supernatant"))
# ------------------------------
# Stacked bar plot (ppm scale)
# ------------------------------
p <- ggplot(df_long, aes(x = Strain, y = Value, fill = Fraction)) +
geom_bar(stat = "identity", position = "stack") +
labs(
title = "Cu²⁺ Incubation Comparison (1 ppm, 2.5 ppm, 5 ppm, 10 ppm)",
x = "",
y = "Cu²⁺ (ppm)"
) +
facet_wrap(~ Condition, ncol = 1, scales = "free_y") +
theme_bw(base_size = 14) +
theme(
axis.text.x = element_text(angle = 45, hjust = 1),
strip.text = element_text(size = 14, face = "bold")
)
# ------------------------------
# Export PNG at 300 dpi
# ------------------------------
print (p)
ggsave("Cu_1_10ppm_noNorm_faceted.png", p, width = 10, height = 8, dpi = 300)