Add missing correlation plot layers
This commit is contained in:
@@ -401,7 +401,6 @@ generate_and_save_plots <- function(output_dir, file_name, plot_configs, grid_la
|
||||
if (!is.null(config$coord_cartesian)) {
|
||||
plot <- plot + coord_cartesian(ylim = config$coord_cartesian)
|
||||
}
|
||||
|
||||
plot
|
||||
},
|
||||
|
||||
@@ -424,13 +423,21 @@ generate_and_save_plots <- function(output_dir, file_name, plot_configs, grid_la
|
||||
if (!is.null(config$suppressor_label)) {
|
||||
plot <- plot + annotate("text", x = config$suppressor_label$x, y = config$suppressor_label$y, label = config$suppressor_label$label)
|
||||
}
|
||||
|
||||
plot
|
||||
},
|
||||
|
||||
"correlation" = plot + geom_point(shape = config$shape %||% 3, color = "gray70") +
|
||||
geom_abline(intercept = config$lm_line$intercept, slope = config$lm_line$slope, color = "tomato3") +
|
||||
annotate("text", x = 0, y = 0, label = config$correlation_text),
|
||||
"correlation" = {
|
||||
plot <- plot + geom_point(shape = config$shape %||% 3, color = "gray70") +
|
||||
geom_abline(intercept = config$lm_line$intercept, slope = config$lm_line$slope, color = "tomato3") +
|
||||
annotate("text", x = config$annotate_position$x, y = config$annotate_position$y, label = config$correlation_text)
|
||||
|
||||
if (!is.null(config$rect)) {
|
||||
plot <- plot + geom_rect(aes(xmin = config$rect$xmin,
|
||||
xmax = config$rect$xmax, ymin = config$rect$ymin, ymax = config$rect$ymax),
|
||||
color = "grey20", size = 0.25, alpha = 0.1, fill = NA, inherit.aes = FALSE)
|
||||
}
|
||||
plot
|
||||
},
|
||||
|
||||
"box" = {
|
||||
plot <- plot + geom_boxplot()
|
||||
@@ -590,8 +597,7 @@ generate_rank_plot_configs <- function(df, rank_var, zscore_var, var, is_lm = FA
|
||||
label = paste("Deletion Suppressors =", nrow(df[df[[zscore_var]] <= -sd_band, ]))
|
||||
),
|
||||
shape = 3,
|
||||
size = 0.1,
|
||||
position = "jitter"
|
||||
size = 0.1
|
||||
)
|
||||
}
|
||||
|
||||
@@ -633,6 +639,8 @@ generate_correlation_plot_configs <- function(df, variables) {
|
||||
correlation_text = paste("R-squared =", round(df[[lm_r_squared_col]][1], 2)),
|
||||
shape = 3,
|
||||
geom_smooth = TRUE,
|
||||
rect = list(xmin = -2, xmax = 2, ymin = -2, ymax = 2), # To add the geom_rect layer
|
||||
annotate_position = list(x = 0, y = 0), # Position for the R-squared text
|
||||
legend_position = "right"
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user