Mask R-squared annotation

This commit is contained in:
2024-10-05 05:30:00 -04:00
parent 274eec2814
commit e6f5aab81f

View File

@@ -675,7 +675,7 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs, page_width
color = config$error_bar_params$color, color = config$error_bar_params$color,
linewidth = 0.1 linewidth = 0.1
) )
} else { } else {
# If no custom error bar formula, use the default or dynamic ones # If no custom error bar formula, use the default or dynamic ones
if (!is.null(config$color_var) && is.null(config$error_bar_params$color)) { if (!is.null(config$color_var) && is.null(config$error_bar_params$color)) {
@@ -703,14 +703,25 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs, page_width
# Add the center point if the option is provided # Add the center point if the option is provided
if (!is.null(config$error_bar_params$mean_point) && config$error_bar_params$mean_point) { if (!is.null(config$error_bar_params$mean_point) && config$error_bar_params$mean_point) {
plot <- plot + geom_point( if (!is.null(config$color_var) && is.null(config$error_bar_params$color)) {
aes( plot <- plot + geom_point(
x = .data[[config$x_var]], aes(
y = .data[[y_mean_col]] x = .data[[config$x_var]],
), y = .data[[y_mean_col]],
color = config$error_bar_params$color, color = .data[[config$color_var]]
shape = 16 ),
) shape = 16
)
} else {
plot <- plot + geom_point(
aes(
x = .data[[config$x_var]],
y = .data[[y_mean_col]]
),
color = config$error_bar_params$color,
shape = 16
)
}
} }
} }
@@ -1067,8 +1078,8 @@ generate_interaction_plot_configs <- function(df_summary, df_interaction, type)
coord_cartesian = y_limits, coord_cartesian = y_limits,
annotations = list( annotations = list(
list(x = 1, y = y_limits[2] - 0.1 * y_span, label = paste(" ZShift =", round(Z_Shift_value, 2))), list(x = 1, y = y_limits[2] - 0.1 * y_span, label = paste(" ZShift =", round(Z_Shift_value, 2))),
list(x = 1, y = y_limits[2] - 0.2 * y_span, label = paste(" lm ZScore =", round(Z_lm_value, 2))), list(x = 1, y = y_limits[2] - 0.2 * y_span, label = paste(" lm ZScore =", round(Z_lm_value, 2))),
list(x = 1, y = y_limits[2] - 0.3 * y_span, label = paste(" R-squared =", round(R_squared_value, 2))), # list(x = 1, y = y_limits[2] - 0.3 * y_span, label = paste(" R-squared =", round(R_squared_value, 2))),
list(x = 1, y = y_limits[1] + 0.1 * y_span, label = paste("NG =", NG_value)), list(x = 1, y = y_limits[1] + 0.1 * y_span, label = paste("NG =", NG_value)),
list(x = 1, y = y_limits[1] + 0.05 * y_span, label = paste("DB =", DB_value)), list(x = 1, y = y_limits[1] + 0.05 * y_span, label = paste("DB =", DB_value)),
list(x = 1, y = y_limits[1], label = paste("SM =", SM_value)) list(x = 1, y = y_limits[1], label = paste("SM =", SM_value))