Add correct lm smoothing colors
This commit is contained in:
@@ -494,20 +494,22 @@ generate_scatter_plot <- function(plot, config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Add Smooth Line if specified
|
# Add Smooth Line if specified
|
||||||
if (!is.null(config$add_smooth) && config$add_smooth) {
|
if (!is.null(config$smooth) && config$smooth) {
|
||||||
|
smooth_color <- if (!is.null(config$smooth_color)) config$smooth_color else "blue"
|
||||||
|
|
||||||
if (!is.null(config$lm_line)) {
|
if (!is.null(config$lm_line)) {
|
||||||
plot <- plot +
|
plot <- plot +
|
||||||
geom_abline(
|
geom_abline(
|
||||||
intercept = config$lm_line$intercept,
|
intercept = config$lm_line$intercept,
|
||||||
slope = config$lm_line$slope,
|
slope = config$lm_line$slope,
|
||||||
color = "blue"
|
color = smooth_color
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
plot <- plot +
|
plot <- plot +
|
||||||
geom_smooth(
|
geom_smooth(
|
||||||
method = "lm",
|
method = "lm",
|
||||||
se = FALSE,
|
se = FALSE,
|
||||||
color = "blue"
|
color = smooth_color
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -851,27 +853,25 @@ generate_rank_plot_configs <- function(df_filtered, variables, is_lm = FALSE, ov
|
|||||||
|
|
||||||
# Avg ZScore and Rank Avg ZScore Plots for r, L, K, and AUC
|
# Avg ZScore and Rank Avg ZScore Plots for r, L, K, and AUC
|
||||||
for (variable in variables) {
|
for (variable in variables) {
|
||||||
for (plot_type in c("Avg_Zscore_vs_lm", "Rank_Avg_Zscore_vs_lm")) {
|
for (plot_type in c("Avg Zscore vs lm", "Rank Avg Zscore vs lm")) {
|
||||||
|
|
||||||
|
title <- paste(plot_type, variable)
|
||||||
|
|
||||||
# Define specific variables based on plot type
|
# Define specific variables based on plot type
|
||||||
if (plot_type == "Avg_Zscore_vs_lm") {
|
if (plot_type == "Avg Zscore vs lm") {
|
||||||
x_var <- paste0("Avg_Zscore_", variable)
|
x_var <- paste0("Avg_Zscore_", variable)
|
||||||
y_var <- paste0("Z_lm_", variable)
|
y_var <- paste0("Z_lm_", variable)
|
||||||
title <- paste("Avg Zscore vs lm", variable)
|
|
||||||
rectangles <- list(
|
rectangles <- list(
|
||||||
list(xmin = -2, xmax = 2, ymin = -2, ymax = 2,
|
list(xmin = -2, xmax = 2, ymin = -2, ymax = 2,
|
||||||
fill = NA, color = "grey20", alpha = 0.1
|
fill = NA, color = "grey20", alpha = 0.1
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else if (plot_type == "Rank Avg Zscore vs lm") {
|
||||||
x_var <- paste0("Rank_", variable)
|
x_var <- paste0("Rank_", variable)
|
||||||
y_var <- paste0("Rank_lm_", variable)
|
y_var <- paste0("Rank_lm_", variable)
|
||||||
title <- paste("Rank Avg Zscore vs lm", variable)
|
|
||||||
rectangles <- NULL
|
rectangles <- NULL
|
||||||
}
|
}
|
||||||
|
|
||||||
print(summary(df_filtered[[x_var]]))
|
|
||||||
print(summary(df_filtered[[y_var]]))
|
|
||||||
|
|
||||||
# Fit linear model
|
# Fit linear model
|
||||||
lm_model <- lm(as.formula(paste(y_var, "~", x_var)), data = df_filtered)
|
lm_model <- lm(as.formula(paste(y_var, "~", x_var)), data = df_filtered)
|
||||||
lm_summary <- summary(lm_model)
|
lm_summary <- summary(lm_model)
|
||||||
@@ -904,7 +904,8 @@ generate_rank_plot_configs <- function(df_filtered, variables, is_lm = FALSE, ov
|
|||||||
),
|
),
|
||||||
shape = 3,
|
shape = 3,
|
||||||
size = 0.1,
|
size = 0.1,
|
||||||
add_smooth = TRUE,
|
smooth = TRUE,
|
||||||
|
smooth_color = "black",
|
||||||
lm_line = list(intercept = intercept, slope = slope),
|
lm_line = list(intercept = intercept, slope = slope),
|
||||||
legend_position = "right",
|
legend_position = "right",
|
||||||
color_var = if (overlap_color) "Overlap" else NULL,
|
color_var = if (overlap_color) "Overlap" else NULL,
|
||||||
@@ -955,7 +956,8 @@ generate_correlation_plot_configs <- function(df) {
|
|||||||
color = "black"
|
color = "black"
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
add_smooth = TRUE, # Add regression line
|
smooth = TRUE,
|
||||||
|
smooth_color = "tomato3",
|
||||||
lm_line = list(intercept = coef(lm_model)[1], slope = coef(lm_model)[2]),
|
lm_line = list(intercept = coef(lm_model)[1], slope = coef(lm_model)[2]),
|
||||||
legend_position = "right",
|
legend_position = "right",
|
||||||
shape = 3,
|
shape = 3,
|
||||||
|
|||||||
Reference in New Issue
Block a user