From 2578f6881d12540c0120a115c877515ce7816133 Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Wed, 15 Jan 2020 08:54:34 +0100 Subject: [PATCH] change colormap when proportion --- DESCRIPTION | 2 +- NAMESPACE | 2 ++ R/plottingFunctions.R | 10 +++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 684dcc2..ff9d146 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: analysePeaks Title: Compare, annotate your peaks -Version: 1.0.2 +Version: 1.0.3 Authors@R: person(given = "Lucille", family = "Lopez-Delisle", diff --git a/NAMESPACE b/NAMESPACE index 516576a..2fdb400 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,6 +18,8 @@ importFrom(GenomicRanges,findOverlaps) importFrom(GenomicRanges,flank) importFrom(GenomicRanges,mcols) importFrom(GenomicRanges,start) +importFrom(RColorBrewer,brewer.pal) +importFrom(grDevices,colorRampPalette) importFrom(grDevices,rainbow) importFrom(grDevices,rgb) importFrom(graphics,barplot) diff --git a/R/plottingFunctions.R b/R/plottingFunctions.R index e23a743..79495bd 100644 --- a/R/plottingFunctions.R +++ b/R/plottingFunctions.R @@ -511,6 +511,8 @@ plotAllBarPlotForCategoriesFromMyGR <- function(myGRs, nameOfColWithCate, #' @param plotProportion logical whether to display the pheatmap 1, 2, and 4 should be plot as proportion of pheatmap 3 and 5 (default is FALSE) #' @return Plot but do not return anything #' @importFrom pheatmap pheatmap +#' @importFrom RColorBrewer brewer.pal +#' @importFrom grDevices colorRampPalette #' @export plotAllPheatmapsFor2CategoriesFromMyGR <- function(myGRs, nameOfColWithCate1, cateNames1, what1, @@ -609,9 +611,13 @@ plotAllPheatmapsFor2CategoriesFromMyGR <- function(myGRs, nameOfColWithCate1, t1 <- t1 / t2 t1[is.nan(t1)] <- 0 number_format <- "%.2f" + breaks <- seq(0, 1, length.out = 101) + colors.name <- "PiYG" } else { line2 <- paste0(sum(t1), " peaks") number_format <- "%d" + breaks <- NA + colors.name <- "RdYlBu" } # We plot it pheatmap::pheatmap(t1, cluster_rows = F, cluster_cols = F, @@ -619,7 +625,9 @@ plotAllPheatmapsFor2CategoriesFromMyGR <- function(myGRs, nameOfColWithCate1, "\nset:", stringSet, "\nref:", nameOfRef), display_numbers = T, number_format = number_format, - fontsize = fontsize) + fontsize = fontsize, + breaks = breaks, + color = colorRampPalette(rev(brewer.pal(n = 7, name = color.name)))(100)) } }