From aca04dec1cae56c4bf9faa3a0afb6e015500a688 Mon Sep 17 00:00:00 2001 From: aduvermy <arnaud.duvermy@ens-lyon.fr> Date: Thu, 26 Oct 2023 16:18:46 +0200 Subject: [PATCH] Fix NOTE "no visible binding for global variable" linked to ggplot2 --- CHANGELOG | 13 ++++++++++++- NAMESPACE | 1 + R/evaluate_dispersion.R | 3 ++- R/identity_plot.R | 3 ++- R/plot_metrics.R | 4 ++-- R/roc_plot.R | 4 ++-- dev/flat_full.Rmd | 14 ++++++++------ 7 files changed, 29 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2d10b3b..e4ec350 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,4 +13,15 @@ To do: - The identity plot's point shape has been modified, enhancing the visual clarity of comparisons between HTRfit and DESeq2 results. - Similar to the identity plot, the dispersion plot also benefits from improved point shape, contributing to a more effective visual analysis. - Add xlab/ylab to ROC plot - - The vignette section now includes a new topic, "About mixed model evaluation". \ No newline at end of file + - The vignette section now includes a new topic, "About mixed model evaluation". + + +# v1.0.2 : R files reorganization, log file enhancement and versioning + + - R files have been restructured to enhance clarity. + - The log file location has been relocated to the R temporary directory. + - A bug that was causing issues with writing the 'group' information in log files during model update has been fixed. + - Fix NOTE "no visible binding for global variable" linked to ggplot2 + - Fix bug with packageVersion("HTRfit") + + diff --git a/NAMESPACE b/NAMESPACE index 97817f4..bd1c8e3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -162,6 +162,7 @@ importFrom(plotROC,geom_roc) importFrom(reshape2,dcast) importFrom(reshape2,melt) importFrom(rlang,":=") +importFrom(rlang,.data) importFrom(stats,anova) importFrom(stats,as.formula) importFrom(stats,cor) diff --git a/R/evaluate_dispersion.R b/R/evaluate_dispersion.R index a16f96a..f049271 100644 --- a/R/evaluate_dispersion.R +++ b/R/evaluate_dispersion.R @@ -103,6 +103,7 @@ extract_tmbDispersion <- function(list_tmb) { #' @param eval_dispersion A data frame containing actual and inferred dispersion values. #' @param ... Additional arguments to be passed to the ggplot2::aes function. #' @importFrom ggplot2 ggplot geom_point aes geom_abline theme_bw ggtitle scale_x_log10 scale_y_log10 +#' @importFrom rlang .data #' @return A ggplot2 scatter plot. #' #' @export @@ -117,7 +118,7 @@ dispersion_plot <- function(eval_dispersion, ...) { args <- lapply(list(...), function(x) if (!is.null(x)) ggplot2::sym(x)) p <- ggplot2::ggplot(eval_dispersion) + - ggplot2::geom_point(ggplot2::aes(x = actual_dispersion, y = inferred_dispersion, !!!args), size = 3, alpha = 0.6) + + ggplot2::geom_point(ggplot2::aes(x = .data$actual_dispersion, y = .data$inferred_dispersion, !!!args), size = 3, alpha = 0.6) + ggplot2::geom_abline(intercept = 0, slope = 1, lty = 3, col = 'red', linewidth = 1) + ggplot2::theme_bw() + ggplot2::ggtitle("Dispersion evaluation") + diff --git a/R/identity_plot.R b/R/identity_plot.R index 943704f..01b7ed9 100644 --- a/R/identity_plot.R +++ b/R/identity_plot.R @@ -10,6 +10,7 @@ #' @return A ggplot2 identity plot. #' #' @importFrom ggplot2 sym aes geom_point geom_abline facet_wrap theme_bw ggtitle scale_x_log10 scale_y_log10 +#' @importFrom rlang .data #' @export #' @examples #' comparison_data <- data.frame( @@ -24,7 +25,7 @@ identity_plot <- function(comparison_df, ...){ ggplot2::ggplot(comparison_df) + - ggplot2::geom_point(ggplot2::aes(x = actual, y = estimate, !!!args), alpha = 0.6, size = 2) + + ggplot2::geom_point(ggplot2::aes(x = .data$actual, y = .data$estimate, !!!args), alpha = 0.6, size = 2) + ggplot2::geom_abline(intercept = 0, slope = 1, lty = 3, col = 'red', linewidth = 1) + ggplot2::facet_wrap(~description, scales = "free") + ggplot2::theme_bw() + diff --git a/R/plot_metrics.R b/R/plot_metrics.R index 24fbb45..956e2de 100644 --- a/R/plot_metrics.R +++ b/R/plot_metrics.R @@ -44,7 +44,7 @@ subset_glance <- function(glance_df, focus){ #' #' @importFrom reshape2 melt #' @importFrom ggplot2 aes facet_wrap geom_histogram theme_bw theme ggtitle -#' +#' @importFrom rlang .data #' @export #' #' @examples @@ -59,7 +59,7 @@ metrics_plot <- function(list_tmb, focus = NULL) { } long_glance_df <- reshape2::melt(glance_df, variable.name = "metric") p <- ggplot2::ggplot(long_glance_df) + - ggplot2::geom_histogram(ggplot2::aes(x = value, col = metric, fill = metric)) + + ggplot2::geom_histogram(ggplot2::aes(x = .data$value, col = .data$metric, fill = .data$metric)) + ggplot2::facet_wrap(~metric, scales = "free") + ggplot2::theme_bw() + ggplot2::theme(legend.position = 'null') + diff --git a/R/roc_plot.R b/R/roc_plot.R index 1745b02..2b9e063 100644 --- a/R/roc_plot.R +++ b/R/roc_plot.R @@ -48,7 +48,7 @@ getLabelExpected <- function(comparison_df, coeff_threshold, alt_hypothesis) { #' @return A ggplot object representing the ROC curve plot. #' @importFrom plotROC geom_roc #' @importFrom ggplot2 ggtitle theme_bw aes sym xlab ylab -#' +#' @importFrom rlang .data #' @examples #' comparison_data <- data.frame( #' geneID = c("gene1", "gene2", "gene3"), @@ -72,7 +72,7 @@ roc_plot <- function(comparison_df, ...) { args <- lapply(list(...), function(x) if (!is.null(x)) ggplot2::sym(x)) #comparison_df$isDE <- factor(comparison_df$isDE, levels= c(TRUE, FALSE)) - p <- ggplot2::ggplot(comparison_df, ggplot2::aes(d = !isDE , m = p.adj, !!!args )) + + p <- ggplot2::ggplot(comparison_df, ggplot2::aes(d = !.data$isDE , m = .data$p.adj, !!!args )) + plotROC::geom_roc(n.cuts = 0, labels = FALSE) + ggplot2::theme_bw() + ggplot2::ggtitle("ROC curve") + diff --git a/dev/flat_full.Rmd b/dev/flat_full.Rmd index d634a49..0cd2506 100644 --- a/dev/flat_full.Rmd +++ b/dev/flat_full.Rmd @@ -3763,7 +3763,7 @@ subset_glance <- function(glance_df, focus){ #' #' @importFrom reshape2 melt #' @importFrom ggplot2 aes facet_wrap geom_histogram theme_bw theme ggtitle -#' +#' @importFrom rlang .data #' @export #' #' @examples @@ -3778,7 +3778,7 @@ metrics_plot <- function(list_tmb, focus = NULL) { } long_glance_df <- reshape2::melt(glance_df, variable.name = "metric") p <- ggplot2::ggplot(long_glance_df) + - ggplot2::geom_histogram(ggplot2::aes(x = value, col = metric, fill = metric)) + + ggplot2::geom_histogram(ggplot2::aes(x = .data$value, col = .data$metric, fill = .data$metric)) + ggplot2::facet_wrap(~metric, scales = "free") + ggplot2::theme_bw() + ggplot2::theme(legend.position = 'null') + @@ -3936,6 +3936,7 @@ extract_tmbDispersion <- function(list_tmb) { #' @param eval_dispersion A data frame containing actual and inferred dispersion values. #' @param ... Additional arguments to be passed to the ggplot2::aes function. #' @importFrom ggplot2 ggplot geom_point aes geom_abline theme_bw ggtitle scale_x_log10 scale_y_log10 +#' @importFrom rlang .data #' @return A ggplot2 scatter plot. #' #' @export @@ -3950,7 +3951,7 @@ dispersion_plot <- function(eval_dispersion, ...) { args <- lapply(list(...), function(x) if (!is.null(x)) ggplot2::sym(x)) p <- ggplot2::ggplot(eval_dispersion) + - ggplot2::geom_point(ggplot2::aes(x = actual_dispersion, y = inferred_dispersion, !!!args), size = 3, alpha = 0.6) + + ggplot2::geom_point(ggplot2::aes(x = .data$actual_dispersion, y = .data$inferred_dispersion, !!!args), size = 3, alpha = 0.6) + ggplot2::geom_abline(intercept = 0, slope = 1, lty = 3, col = 'red', linewidth = 1) + ggplot2::theme_bw() + ggplot2::ggtitle("Dispersion evaluation") + @@ -5658,7 +5659,7 @@ getLabelExpected <- function(comparison_df, coeff_threshold, alt_hypothesis) { #' @return A ggplot object representing the ROC curve plot. #' @importFrom plotROC geom_roc #' @importFrom ggplot2 ggtitle theme_bw aes sym xlab ylab -#' +#' @importFrom rlang .data #' @examples #' comparison_data <- data.frame( #' geneID = c("gene1", "gene2", "gene3"), @@ -5682,7 +5683,7 @@ roc_plot <- function(comparison_df, ...) { args <- lapply(list(...), function(x) if (!is.null(x)) ggplot2::sym(x)) #comparison_df$isDE <- factor(comparison_df$isDE, levels= c(TRUE, FALSE)) - p <- ggplot2::ggplot(comparison_df, ggplot2::aes(d = !isDE , m = p.adj, !!!args )) + + p <- ggplot2::ggplot(comparison_df, ggplot2::aes(d = !.data$isDE , m = .data$p.adj, !!!args )) + plotROC::geom_roc(n.cuts = 0, labels = FALSE) + ggplot2::theme_bw() + ggplot2::ggtitle("ROC curve") + @@ -5822,6 +5823,7 @@ test_that("Counts plot is generated correctly", { #' @return A ggplot2 identity plot. #' #' @importFrom ggplot2 sym aes geom_point geom_abline facet_wrap theme_bw ggtitle scale_x_log10 scale_y_log10 +#' @importFrom rlang .data #' @export #' @examples #' comparison_data <- data.frame( @@ -5836,7 +5838,7 @@ identity_plot <- function(comparison_df, ...){ ggplot2::ggplot(comparison_df) + - ggplot2::geom_point(ggplot2::aes(x = actual, y = estimate, !!!args), alpha = 0.6, size = 2) + + ggplot2::geom_point(ggplot2::aes(x = .data$actual, y = .data$estimate, !!!args), alpha = 0.6, size = 2) + ggplot2::geom_abline(intercept = 0, slope = 1, lty = 3, col = 'red', linewidth = 1) + ggplot2::facet_wrap(~description, scales = "free") + ggplot2::theme_bw() + -- GitLab