ai didi

r - 如何减少 R 中树状图和热图之间的差距

转载 作者:行者123 更新时间:2023-12-02 03:37:57 24 4
gpt4 key购买 nike

下图 enter image description here

是用这段代码生成的

library(gplots)
setwd("~/Desktop/");
data <- read.table(file='http://pastebin.com/raw.php?i=ZaGkPTGm',
header=TRUE, row.names=1)

mat <- as.matrix(data[,-1])
z <- t(scale(t(mat)))


# set custom distance and clustering functions
hclustfunc <- function(x) hclust(x, method="complete")
distfunc <- function(x) dist(x,method="maximum")

# obtain the clusters
fit <- hclustfunc(distfunc(z))
clusters <- cutree(fit, 5)

# require(gplots)
pdf(file='heatmap.pdf', height=50, width=90)
heatmap.2(z, trace='none', dendrogram='row', Colv=F, scale='row',
hclust=hclustfunc, distfun=distfunc, col=greenred(256), symbreak=T,
margins=c(10,20), keysize=0.5, labRow=data$Gene.symbol,
lwid=c(1,0.05,1), lhei=c(0.03,1), lmat=rbind(c(5,0,4),c(3,1,2)),
RowSideColors=as.character(clusters))
dev.off()

我要做的是缩小树状图和热图行边颜色之间的差距。我怎样才能做到这一点?

唯一的要求是树状图的尺寸和纸张尺寸必须保持原样。

最佳答案

一种解决方案是全局调整 x 轴,使其适合数据范围:

par(xaxs="i")
heatmap.2(z, trace='none', dendrogram='row', Colv=F, scale='row',
hclust=hclustfunc, distfun=distfunc, col=greenred(256), symbreak=T,
margins=c(10,20), keysize=0.5, labRow=data$Gene.symbol,
lwid=c(1,0.05,1), lhei=c(0.03,1), lmat=rbind(c(5,0,4),c(3,1,2)),
RowSideColors=as.character(clusters))

关于r - 如何减少 R 中树状图和热图之间的差距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22089651/

24 4 0
文章推荐: google-maps - 谷歌地图 - GeoJSON.js - 替换光标
文章推荐: magento - 如何在另一个 block phtml 文件中调用自定义模块 block
文章推荐: Cordova WP8 bootstrap 字形图标未显示
文章推荐: angularjs - 打开时在 AngularUI 模式的输入字段中选择文本
行者123
个人简介

我是一名优秀的程序员,十分优秀!

滴滴打车优惠券免费领取
滴滴打车优惠券
全站热门文章
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com