Neither Color Key nor Main Title appear (properly) on heat map (heat map.2 in r)

672 Views Asked by At

I'm learning how to use R and for an exercise I'm using an experimental ExpresionSet from Bioconductor: http://bioconductor.org/packages/release/data/experiment/html/leukemiasEset.html

As simple as that: My heat map doesn't display the color key and the main title appears chopped off on the left site. I had given up with the no color key problem after searching on the web how to solve it and not really finding a solution. But then I added the title and since it doesn't appear properly either, I thought that maybe both things are due to the same (unknown for me) reason...

Here is my code:

difexp <- exprs(leukemiasEset)[c(which(adjPval < 0.01)),c(1:12, 25:36)]
heatmap.2(difexp,
      trace = "none",
      cexCol = 0.6,
      ColSideColors =     as.character(as.numeric(factor(leukemiasEset$LeukemiaType[c(1:12, 25:36)]))),
      main = "Differentially expressed genes in ALL and CLL samples",
      cex.main = 1.5,
      key = TRUE,
      keysize = 1.5,
      density.info = "histogram")

Where:

pvalues <- c()
for(i in 1:nrow(exprs(leukemiasEset))) { 
R <- t.test(exprs(leukemiasEset)[i, leukemiasEset$LeukemiaType == "ALL"],
          exprs(leukemiasEset)[i, leukemiasEset$LeukemiaType == "CLL"], 
          var.equal = TRUE) 
pvalues <- c(pvalues, R$p.value)
}
adjPval <- p.adjust(pvalues, method = "fdr")

And this is how it looks like:

enter image description here

Since I am a beginner, I think this is probably an "easy peasy" for the experts... thank you very much in advance!

1

There are 1 best solutions below

0
Ben Ernest On

Use "\n" to insert a newline in your title and put half of it on a second line.

heatmap.2(difexp,
      trace = "none",
      cexCol = 0.6,
      ColSideColors = as.character(as.numeric(factor(leukemiasEset$LeukemiaType[c(1:12, 25:36)]))),
      main = "Differentially expressed genes\nin ALL and CLL samples",
      cex.main = 1.5,
      key = TRUE,
      keysize = 1.5,
      density.info = "histogram")