1

I am trying to duplicate a plot found here on pg. 4:

enter image description here

The reproducible code for it is:

require(devtools)
install_git("https://github.com/marchion/git.switchBox", subdir="switchBox")
require(switchBox)
require(gplots)
data(trainingData)    
classifier <- SWAP.KTSP.Train(matTraining, trainingGroup)
kappa <- SWAP.KTSP.Statistics(matTraining, classifier)
mat <- t(1*kappa$comparisons)
rownames(mat) <- gsub(">", "\n more express than\n", rownames(mat))

heatmap.2(mat,
scale="none", Rowv=F, Colv=F, dendrogram="none",
trace="none", key=FALSE,
col=c("lightsteelblue2", "pink3"),
labCol=toupper(paste(trainingGroup, "Prognosis")),
sepwidth=c(0.075,0.075), sepcolor="black",
rowsep=1:ncol(kappa$comparisons),
colsep=1:nrow(kappa$comparisons),
lmat=rbind( c(0, 3), c(2, 1), c(0, 4) ), lhei=c(0.1, 5, 0.5), lwid=c(0.15, 5),
mar=c(7.5, 12), cexRow=0.85, cexCol=0.9)

If you notice in the plot above, the x-labels are slightly off-center to the left. Is there a command inside the heatmap.2 function that can shift each label to the right?

user321627
  • 2,350
  • 4
  • 20
  • 43

1 Answers1

1

You have to specify argument adjCol (c(1, 0.5)) would give you wanted result (c(1, 0) would move it to the left and c(1, 1) would move it more to the right).

Code (using OPs provided packages and data):

heatmap.2(
  mat,
  adjCol = c(1, 0.5), 
  scale = "none", Rowv = FALSE, Colv = FALSE, dendrogram = "none",
  trace = "none", key = FALSE,
  col = c("lightsteelblue2", "pink3"),
  labCol = toupper(paste(trainingGroup, "Prognosis")),
  sepwidth = c(0.075,0.075), sepcolor = "black",
  rowsep = 1:ncol(kappa$comparisons),
  colsep = 1:nrow(kappa$comparisons),
  lmat = rbind( c(0, 3), c(2, 1), c(0, 4) ),
  lhei = c(0.1, 5, 0.5), lwid = c(0.15, 5),
  mar = c(7.5, 12), cexRow = 0.85, cexCol = 0.9,
)

Result:

enter image description here

pogibas
  • 27,303
  • 19
  • 84
  • 117