我正在尝试复制在pg上找到的here情节。 4:
它的可复制代码是:
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)
如果您在上面的图中注意到,则x标签在左侧稍微偏离中心。 heatmap.2
函数中是否有一个命令可以将每个标签向右移动?
答案 0 :(得分:1)
您必须指定参数adjCol
(c(1, 0.5)
)会得到想要的结果(c(1, 0)
会将其向左移动,c(1, 1)
会将其向右移动)。
代码(使用OP提供的软件包和数据):
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,
)
结果: