繁体   English   中英

R中的新gplots更新无法在heatmap.2中找到函数distfun

[英]New gplots update in R cannot find function distfun in heatmap.2

我有一些R代码可以从相关矩阵制作热图,该矩阵在我上次使用它时有效(在2013年10月17日gplots更新之前;在更新为R版本3.0.2之后)。 这使我认为在最新的gplots更新中有所更改,但是我不知道是什么。

现在,用来显示漂亮图的内容给了我这个错误:

“ hclustfun(distfun(x))中的错误:找不到函数” distfun“”

不会策划任何事情 下面是重现该图的代码(在我用来指导本科生如何为项目使用热图的过程中,它受到了很大的评论)。 我尝试添加最后一行以显式设置功能,但这无助于解决问题。

编辑:我将代码的最后一行更改为:,distfun = function(c){as.dist(1-c,upper = FALSE)},hclustfun = hclust),它可以正常工作。 当我只使用“ dist = as.dist”时,我得到了一个图,但是它没有正确排序,并且一些树状图分支没有连接到树。 不知道发生了什么,或者为什么它起作用了,但是看起来确实如此。

任何帮助将不胜感激。

提前致谢,

library(gplots)
set.seed(12345)

randData <- as.data.frame(matrix(rnorm(600),ncol=6))

randDataCorrs <- randData+(rnorm(600))
names(randDataCorrs) <- paste(names(randDataCorrs),"_c",sep="")
randDataExtra <- cbind(randData,randDataCorrs)

randDataExtraMatrix <- cor(randDataExtra)


heatmap.2(randDataExtraMatrix, # sets the correlation matrix to use
          symm=TRUE, #tells whether it is symmetrical or not
          main= "Correlation matrix\nof Random Data Cor", # Names plot
          xlab= "x groups",ylab="", # Sets the x and y labels
          scale="none", # Tells it not to scale the data
          col=redblue(256),# Sets the colors (can be manual, see below) 
          trace="none", # tells it not to add a trace
          symkey=TRUE,symbreaks=TRUE, # Tells it to keep things symmetric around 0
          density.info = "none"#) # can be "histogram" if you want a hist of your corr values here
          #,distfun=dist, hclustfun=hclust)
          ,distfun =function(c) {as.dist(1-c,upper=FALSE)}, hclustfun=hclust) # new last line

我遇到了同样的错误,然后我注意到我做了一个名为dist的变量,这是distfun= dist的默认调用。 我重命名了变量,然后一切正常。 由于更改了distfun的默认调用,您的新代码正在运行时,您可能会犯同样的错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM