在 `R` 的 `gplots` 中,我们如何调整 `heatmap.2` 函数中 x 标签刻度的位置?
In `gplots` in `R`, how can we adjust the position of the x-label ticks in the `heatmap.2` function?
我正在尝试复制在 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
函数里面有没有可以让每个标签右移的命令?
你必须指定参数 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,
)
结果:
我正在尝试复制在 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
函数里面有没有可以让每个标签右移的命令?
你必须指定参数 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,
)
结果: