Skip to content

Commit

Permalink
change colormap when proportion
Browse files Browse the repository at this point in the history
  • Loading branch information
lldelisle committed Jan 15, 2020
1 parent 442d538 commit 2578f68
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion R/plottingFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -609,17 +611,23 @@ 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,
main = paste0(inputsGRWhat[[i]], "\n", line2, "\n", what1, " vs ", what2,
"\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))
}
}

Expand Down

0 comments on commit 2578f68

Please sign in to comment.