From 7c3824a59176a5c029542065bb5a441b52038ce7 Mon Sep 17 00:00:00 2001 From: WackerO Date: Wed, 8 Nov 2023 14:43:10 +0100 Subject: [PATCH 1/5] Added colors to volcano depending on DE status --- assets/differentialabundance_report.Rmd | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/assets/differentialabundance_report.Rmd b/assets/differentialabundance_report.Rmd index 34521ad2..9b3db8f7 100644 --- a/assets/differentialabundance_report.Rmd +++ b/assets/differentialabundance_report.Rmd @@ -733,8 +733,10 @@ for (i in 1:nrow(contrasts)){ cat("\n##### ", pvt, " p values\n") pval_column <- p_value_types[[pvt]] - full_de$differential_status <- FALSE - full_de$differential_status[abs(full_de[[params$differential_fc_column]]) > log2(params$differential_min_fold_change) & full_de[[pval_column]] < p_value_thresholds[[pvt]]] <- TRUE + full_de$differential_status <- "Not significant" + full_de$differential_status[abs(full_de[[params$differential_fc_column]]) > log2(params$differential_min_fold_change)] <- paste("abs(logFC) >", params$differential_min_fold_change) + full_de$differential_status[full_de[[pval_column]] < p_value_thresholds[[pvt]]] <- paste(pvt, "<=", p_value_thresholds[[pvt]]) + full_de$differential_status[abs(full_de[[params$differential_fc_column]]) > log2(params$differential_min_fold_change) & full_de[[pval_column]] < p_value_thresholds[[pvt]]] <- paste("abs(logFC) >", params$differential_min_fold_change, "&", pvt, "<=", p_value_thresholds[[pvt]]) # Define the thresholds we'll draw @@ -742,7 +744,10 @@ for (i in 1:nrow(contrasts)){ hline_thresholds[[paste(pval_column, '=', p_value_thresholds[[pvt]])]] = -log10(p_value_thresholds[[pvt]]) vline_thresholds[[paste(params$differential_fc_column, '<-', log2(params$differential_min_fold_change))]] = -log2(params$differential_min_fold_change) vline_thresholds[[paste(params$differential_fc_column, '>', log2(params$differential_min_fold_change))]] = log2(params$differential_min_fold_change) - + + palette_volcano <- makeColorScale(4, params$differential_palette_name) + names(palette_volcano) <- c("Not significant", paste("abs(logFC) >", params$differential_min_fold_change), paste(pvt, "<=", p_value_thresholds[[pvt]]), paste("abs(logFC) >", params$differential_min_fold_change, "&", pvt, "<=", p_value_thresholds[[pvt]])) + plot_args <- list( x = full_de[[params$differential_fc_column]], y = -log10(full_de[[pval_column]]), @@ -754,7 +759,7 @@ for (i in 1:nrow(contrasts)){ vline_thresholds = vline_thresholds, show_labels = FALSE, legend_title = "Differential status", - palette = makeColorScale(2, params$differential_palette_name) + palette = palette_volcano ) # Let's equalize the axes @@ -902,4 +907,4 @@ print( htmltools::tagList(datatable(versions_table, caption = "Software versions ```{r, echo=FALSE, results='asis'} htmltools::includeMarkdown(params$citations) -``` +``` \ No newline at end of file From a9a43412fbdfb69b8da8eb429993b55fbaaedd53 Mon Sep 17 00:00:00 2001 From: WackerO <43847497+WackerO@users.noreply.github.com> Date: Thu, 9 Nov 2023 13:30:10 +0100 Subject: [PATCH 2/5] Update assets/differentialabundance_report.Rmd Co-authored-by: Jonathan Manning --- assets/differentialabundance_report.Rmd | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/assets/differentialabundance_report.Rmd b/assets/differentialabundance_report.Rmd index 9b3db8f7..94aa62c8 100644 --- a/assets/differentialabundance_report.Rmd +++ b/assets/differentialabundance_report.Rmd @@ -733,10 +733,17 @@ for (i in 1:nrow(contrasts)){ cat("\n##### ", pvt, " p values\n") pval_column <- p_value_types[[pvt]] + + de_fc <- abs(full_de[[params$differential_fc_column]]) > log2(params$differential_min_fold_change) + de_fc_label <- paste("abs(logFC) >", params$differential_min_fold_change) + + de_pval <- full_de[[pval_column]] < p_value_thresholds[[pvt]]] + de_pval_label <- paste(pvt, "<=", p_value_thresholds[[pvt]]) + full_de$differential_status <- "Not significant" - full_de$differential_status[abs(full_de[[params$differential_fc_column]]) > log2(params$differential_min_fold_change)] <- paste("abs(logFC) >", params$differential_min_fold_change) - full_de$differential_status[full_de[[pval_column]] < p_value_thresholds[[pvt]]] <- paste(pvt, "<=", p_value_thresholds[[pvt]]) - full_de$differential_status[abs(full_de[[params$differential_fc_column]]) > log2(params$differential_min_fold_change) & full_de[[pval_column]] < p_value_thresholds[[pvt]]] <- paste("abs(logFC) >", params$differential_min_fold_change, "&", pvt, "<=", p_value_thresholds[[pvt]]) + full_de$differential_status[de_fc] <- de_fc_label + full_de$differential_status[de_pval] <- de_pval_label + full_de$differential_status[de_fc & de_pval] <- paste(de_fc_label, '&', de_pval_label) # Define the thresholds we'll draw From de51aa562c774e3321e7a866cad8b9d2d6593b3a Mon Sep 17 00:00:00 2001 From: WackerO <43847497+WackerO@users.noreply.github.com> Date: Thu, 9 Nov 2023 13:30:21 +0100 Subject: [PATCH 3/5] Update assets/differentialabundance_report.Rmd Co-authored-by: Jonathan Manning --- assets/differentialabundance_report.Rmd | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/differentialabundance_report.Rmd b/assets/differentialabundance_report.Rmd index 94aa62c8..1ba3036d 100644 --- a/assets/differentialabundance_report.Rmd +++ b/assets/differentialabundance_report.Rmd @@ -753,7 +753,6 @@ for (i in 1:nrow(contrasts)){ vline_thresholds[[paste(params$differential_fc_column, '>', log2(params$differential_min_fold_change))]] = log2(params$differential_min_fold_change) palette_volcano <- makeColorScale(4, params$differential_palette_name) - names(palette_volcano) <- c("Not significant", paste("abs(logFC) >", params$differential_min_fold_change), paste(pvt, "<=", p_value_thresholds[[pvt]]), paste("abs(logFC) >", params$differential_min_fold_change, "&", pvt, "<=", p_value_thresholds[[pvt]])) plot_args <- list( x = full_de[[params$differential_fc_column]], From 24a305c0429b503fcd50001dc31dff88c8da8dc5 Mon Sep 17 00:00:00 2001 From: WackerO Date: Thu, 9 Nov 2023 14:38:32 +0100 Subject: [PATCH 4/5] made non-significant points gray --- CHANGELOG.md | 2 ++ assets/differentialabundance_report.Rmd | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16035d54..ac3647e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### `Changed` +- [[#194](https://github.com/nf-core/differentialabundance/pull/194)] - Change report volcano colors ([@WackerO](https://github.com/WackerO), review by [@pinin4fjords](https://github.com/pinin4fjords)) + ## v1.3.1 - 2023-10-26 ### `Added` diff --git a/assets/differentialabundance_report.Rmd b/assets/differentialabundance_report.Rmd index 1ba3036d..6bc8388c 100644 --- a/assets/differentialabundance_report.Rmd +++ b/assets/differentialabundance_report.Rmd @@ -734,32 +734,32 @@ for (i in 1:nrow(contrasts)){ pval_column <- p_value_types[[pvt]] - de_fc <- abs(full_de[[params$differential_fc_column]]) > log2(params$differential_min_fold_change) - de_fc_label <- paste("abs(logFC) >", params$differential_min_fold_change) + de_fc <- abs(full_de[[params$differential_fc_column]]) >= log2(params$differential_min_fold_change) + de_fc_label <- paste("abs(logFC) >=", params$differential_min_fold_change) - de_pval <- full_de[[pval_column]] < p_value_thresholds[[pvt]]] + de_pval <- full_de[[pval_column]] <= p_value_thresholds[[pvt]] de_pval_label <- paste(pvt, "<=", p_value_thresholds[[pvt]]) full_de$differential_status <- "Not significant" full_de$differential_status[de_fc] <- de_fc_label full_de$differential_status[de_pval] <- de_pval_label full_de$differential_status[de_fc & de_pval] <- paste(de_fc_label, '&', de_pval_label) - + full_de$differential_status <- factor(full_de$differential_status, levels = c("Not significant", de_fc_label, de_pval_label, paste(de_fc_label, '&', de_pval_label)), ordered = TRUE) # Factorize status so that non-significant is always first # Define the thresholds we'll draw hline_thresholds = vline_thresholds = list() hline_thresholds[[paste(pval_column, '=', p_value_thresholds[[pvt]])]] = -log10(p_value_thresholds[[pvt]]) - vline_thresholds[[paste(params$differential_fc_column, '<-', log2(params$differential_min_fold_change))]] = -log2(params$differential_min_fold_change) - vline_thresholds[[paste(params$differential_fc_column, '>', log2(params$differential_min_fold_change))]] = log2(params$differential_min_fold_change) - - palette_volcano <- makeColorScale(4, params$differential_palette_name) + vline_thresholds[[paste(params$differential_fc_column, '<=', log2(params$differential_min_fold_change))]] = -log2(params$differential_min_fold_change) + vline_thresholds[[paste(params$differential_fc_column, '>=', log2(params$differential_min_fold_change))]] = log2(params$differential_min_fold_change) + palette_volcano <- append(c('#999999'), makeColorScale(3, params$differential_palette_name)) # set non-significant to gray + plot_args <- list( x = full_de[[params$differential_fc_column]], y = -log10(full_de[[pval_column]]), colorby = full_de$differential_status, ylab = paste("-log(10)", pval_column), - xlab = xlabel <- paste("higher in", contrasts$reference[i], " <<", params$differential_fc_column, ">> higher in", contrasts$target[i]) , + xlab = xlabel <- paste("higher in", contrasts$reference[i], " <<", params$differential_fc_column, ">> higher in", contrasts$target[i]), labels = full_de[[label_col]], hline_thresholds = hline_thresholds, vline_thresholds = vline_thresholds, From 698a5b9e044e2a3e86563d842491cca303f7fb4c Mon Sep 17 00:00:00 2001 From: WackerO <43847497+WackerO@users.noreply.github.com> Date: Thu, 16 Nov 2023 08:03:06 +0100 Subject: [PATCH 5/5] Update assets/differentialabundance_report.Rmd Co-authored-by: Jonathan Manning --- assets/differentialabundance_report.Rmd | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/assets/differentialabundance_report.Rmd b/assets/differentialabundance_report.Rmd index cda423b6..da839a4b 100644 --- a/assets/differentialabundance_report.Rmd +++ b/assets/differentialabundance_report.Rmd @@ -772,11 +772,13 @@ for (i in 1:nrow(contrasts)){ de_pval <- full_de[[pval_column]] <= p_value_thresholds[[pvt]] de_pval_label <- paste(pvt, "<=", p_value_thresholds[[pvt]]) + de_pval_fc_label <- paste(de_fc_label, '&', de_pval_label) + full_de$differential_status <- "Not significant" full_de$differential_status[de_fc] <- de_fc_label full_de$differential_status[de_pval] <- de_pval_label - full_de$differential_status[de_fc & de_pval] <- paste(de_fc_label, '&', de_pval_label) - full_de$differential_status <- factor(full_de$differential_status, levels = c("Not significant", de_fc_label, de_pval_label, paste(de_fc_label, '&', de_pval_label)), ordered = TRUE) # Factorize status so that non-significant is always first + full_de$differential_status[de_fc & de_pval] <- de_pval_fc_label + full_de$differential_status <- factor(full_de$differential_status, levels = c("Not significant", de_fc_label, de_pval_label, de_pval_fc_label), ordered = TRUE) # Factorize status so that non-significant is always first # Define the thresholds we'll draw hline_thresholds = vline_thresholds = list()