From 37c29f734304a2857f93de8529964ea1f9114fb9 Mon Sep 17 00:00:00 2001 From: aduvermy <arnaud.duvermy@ens-lyon.fr> Date: Thu, 4 Apr 2024 10:38:10 +0200 Subject: [PATCH] coord_fixed Former-commit-id: 2399c691da97853016d58199537d5fcfa2a01abc Former-commit-id: fc8f2aabe57e467786f58ea148410a5ccc961a71 Former-commit-id: d0fa8a56710786744eb88353cf5fe0624b2cefce --- R/evaluation_identity.R | 2 +- R/precision_recall.R | 10 ++++------ R/receiver_operating_characteristic.R | 9 +++++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/R/evaluation_identity.R b/R/evaluation_identity.R index 74c1b95..f69e212 100644 --- a/R/evaluation_identity.R +++ b/R/evaluation_identity.R @@ -65,7 +65,7 @@ eval_identityTerm <- function(data_identity, palette_color = c(DESeq2 = "#500472 ggplot2::ggtitle("Identity plot") + ggplot2::scale_color_manual(values = palette_color ) + ggplot2::scale_shape_manual(values = palette_shape ) - + p$plot_env <- rlang::new_environment() obj_idTerm <- list(R2 = data_metrics, p = p ) diff --git a/R/precision_recall.R b/R/precision_recall.R index 920b403..f175876 100644 --- a/R/precision_recall.R +++ b/R/precision_recall.R @@ -99,7 +99,7 @@ get_pr_object <- function(evaldata_params, col_param = "description", col_truth #' @param palette_color list of colors used. #' @param ... Additional arguments to be passed to \code{ggplot2::geom_path}. #' @return A ggplot object representing the precision-recall curve. -#' @importFrom ggplot2 ggplot geom_path geom_text theme_bw xlim ylim scale_color_manual aes sym +#' @importFrom ggplot2 ggplot geom_path geom_text theme_bw coord_fixed scale_color_manual aes sym #' @export build_gg_pr_curve <- function(data_curve, data_auc, palette_color = c("#500472", "#79cbb8"), ...){ @@ -118,8 +118,7 @@ build_gg_pr_curve <- function(data_curve, data_auc, palette_color = c("#500472", label = paste("AUC :", round(pr_AUC, 2) , sep = ""), col = from ) ) + ggplot2::theme_bw() + - ggplot2::xlim( 0, 1 ) + - ggplot2::ylim( 0, 1 ) + + ggplot2::coord_fixed() + ggplot2::scale_color_manual(values = palette_color) } @@ -133,7 +132,7 @@ build_gg_pr_curve <- function(data_curve, data_auc, palette_color = c("#500472", #' @param pr_obj precision-recall object. #' @param ... Additional arguments to be passed to \code{ggplot2::geom_path}. #' @return precision-recall curves and AUCs for both aggregated and individual parameters. -#' @importFrom ggplot2 facet_wrap coord_fixed +#' @importFrom ggplot2 facet_wrap #' @export get_pr_curve <- function(pr_obj, ...){ @@ -146,8 +145,7 @@ get_pr_curve <- function(pr_obj, ...){ data_curve <- pr_obj$byparams$pr_curve data_auc <- pr_obj$byparams$pr_auc pr_obj$byparams$pr_curve <- build_gg_pr_curve(data_curve, data_auc, col = from , ... ) + - ggplot2::facet_wrap(~description) + - ggplot2::coord_fixed() + ggplot2::facet_wrap(~description) return(pr_obj) } diff --git a/R/receiver_operating_characteristic.R b/R/receiver_operating_characteristic.R index 4dd2891..c17cfdc 100644 --- a/R/receiver_operating_characteristic.R +++ b/R/receiver_operating_characteristic.R @@ -124,6 +124,8 @@ get_roc_object <- function(evaldata_params, col_param = "description", col_truth #' @param palette_color List of colors used. #' @param ... Additional arguments to be passed to ggplot2::geom_path. #' @return A ggplot object representing the ROC curve. +#' @importFrom ggplot2 ggplot geom_path geom_text theme_bw coord_fixed scale_color_manual aes + #' @export build_gg_roc_curve <- function(data_curve, data_auc, palette_color = c("#500472", "#79cbb8") , ...){ @@ -137,8 +139,7 @@ build_gg_roc_curve <- function(data_curve, data_auc, palette_color = c("#500472" label = paste("AUC :", round(roc_AUC, 2) , sep = ""), col = from) ) + ggplot2::theme_bw() + - ggplot2::xlim( 0, 1 ) + - ggplot2::ylim( 0, 1 ) + + ggplot2::coord_fixed() + ggplot2::scale_color_manual(values = palette_color) } @@ -171,6 +172,7 @@ get_label_y_position <- function(data_auc){ #' @param roc_obj ROC object. #' @param ... Additional arguments to be passed to \code{ggplot2::geom_path}. #' @return ROC curves and AUCs for both aggregated and individual parameters. +#' @importFrom ggplot2 facet_wrap #' @export get_roc_curve <- function(roc_obj, ...){ @@ -183,8 +185,7 @@ get_roc_curve <- function(roc_obj, ...){ data_curve <- roc_obj$byparams$roc_curve data_auc <- roc_obj$byparams$roc_auc roc_obj$byparams$roc_curve <- build_gg_roc_curve(data_curve, data_auc, col = from, ... ) + - ggplot2::facet_wrap(~description) + - ggplot2::coord_fixed() + ggplot2::facet_wrap(~description) return(roc_obj) } -- GitLab