Skip to content

Commit

Permalink
fixed grey regions when signal is above/below plotting limit in ggplo…
Browse files Browse the repository at this point in the history
…t heatmap
  • Loading branch information
Przemol committed Dec 24, 2014
1 parent 93edea2 commit b01ada9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions R/int_ggHeatmapPlotWrapper.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ggHeatmapPlotWrapper <- function(MAT, axhline=NULL, titles=rep('', length(MAT)),
cex.legend=12.0, xlab='', ylab="", Leg=TRUE, autoscale=TRUE, zmin=0,
zmax=10, xlim=NULL, ln.v=TRUE, e=NULL, s = 0.01, indi=TRUE,
o_min=NA, o_max=NA, colvec=NULL, colorspace=NULL, pointsize=12,
embed=FALSE, raster=TRUE, main='The heatmap', cex.title=20, ...) {
embed=FALSE, raster=TRUE, main='', cex.title=20, ...) {

datapoints <- unlist(MAT)
NP=length(MAT)
Expand All @@ -74,15 +74,21 @@ ggHeatmapPlotWrapper <- function(MAT, axhline=NULL, titles=rep('', length(MAT)),
max <- max(datapoints, na.rm=TRUE)

if (!indi) {
MAT <- lapply(MAT, function(x) {colnames(x) <- bins; return(x)} )
names(MAT) <- titles

if (autoscale) {
zlim <- quantile(datapoints, c(s,1-s), na.rm=TRUE)
zmin<-zlim[1]
zmax<-zlim[2]
}

MAT <- lapply(MAT, function(x) {
colnames(x) <- bins
x[x<zmin] <- zmin
x[x>zmax] <- zmax
return(x)
})
names(MAT) <- titles

p <- ggplot(melt(MAT), aes(Var2, Var1, fill = value))
if(raster) {
p <- p + geom_raster()
Expand Down

0 comments on commit b01ada9

Please sign in to comment.