R/heatmapDE.r

Defines functions heatmapDE

Documented in heatmapDE

#' Heatmap of DE features
#'
#' Heatmap of DE features
#'
#' @param counts.trans \code{matrix} of transformed counts (VST or rlog for DESeq2 or CPM for edgeR)
#' @param complete list of results from \code{exportComplete.DESeq2()} or \code{exportComplete.edgeR()}
#' @param alpha significance threshold
#' @param out \code{TRUE} to export the figure
#' @param versionName versionName of the project
#' @param ... other arguments to be passed in \code{pheatmap()}
#' @return A heatmap
#' @author Hugo Varet


heatmapDE <- function(counts.trans, complete, alpha=0.05, out = TRUE, versionName=".", ...){
  features <- NULL
  for (name in names(complete)) features <- c(features,as.character(complete[[name]][which(complete[[name]][,"padj"] <= alpha),"Id"]))
  features <- unique(features)
  if (out) pdf(file=paste0("figures/", versionName, "-heatmap.pdf"))
	pheatmap(counts.trans[features,], scale="row", clustering_distance_rows = "correlation",
	         clustering_distance_cols = "euclidean", clustering_method = "ward.D",
	         main=paste0(versionName, " - Heatmap on\n", length(features)," DE features"),
	         color=colorRampPalette(rev(brewer.pal(9, "RdBu")))(200))
  if (out) dev.off()
}
biomics-pasteur-fr/RNADiff documentation built on Aug. 27, 2020, 12:44 a.m.