# Example data: bacterial strain growth rate control vs antibiotic treated
growth_data <- data.frame(
strain = rep(paste0("Strain", 1:13), each = 6),
condition = rep(c("Control", "Treated"), each = 3, times = 13),
growth_rate = c(
rnorm(39, mean = 0.85, sd = 0.12), # Control
rnorm(39, mean = 0.45, sd = 0.10) # Treated (reduced growth)
)
)
# Basic rank shift plot
gg_rankshift(
data = growth_data,
id = "strain",
group = "condition",
value = "growth_rate",
)
# With barplots instead of boxplots
gg_rankshift(
data = growth_data,
id = "strain",
group = "condition",
value = "growth_rate",
style = "bar"
)
# Custom styling
gg_rankshift(
data = growth_data,
id = "strain",
group = "condition",
value = "growth_rate",
fill = c("#e41a1c", "#377eb8"),
rank_change_colors = c(
increase = "#1b9e77",
decrease = "#d95f02",
no_change = "#7570b3"
),
panel_ratio = 0.5,
point_size = 2.5,
line_width = 1,
decreasing = TRUE
)
Run the code above in your browser using DataLab