简体   繁体   English

将参数传递给heatmap.2内部的add.expr中的函数

[英]Passing parameter to function in add.expr inside heatmap.2

I'm generating clustering heatmap with heatmap.2 function (R gplots package). 我正在使用heatmap.2函数(R gplots软件包)生成集群热图。 I'd like to add a vertical line(s) onto the image at variable location(s) using add.expr parameter. 我想使用add.expr参数在图像的可变位置添加一条垂直线。

For example, 例如,

xx=replicate(10, rnorm(10)) # some random matrix
heatmap.2(xx, trace="none",
          add.expr=abline(v=c(3.5,6.5), lwd=3))

This works great. 这很好。 The problem is it doesn't work if I pass the lines location as a variable: 问题是,如果我将行位置作为变量传递,它将不起作用:

linePosition = c(3.5,6.5)
heatmap.2(...,
          add.expr=abline(v=linePosition, lwd=3))

It looks like abline function is called from inside the heatmap.2 function and doesn't see the external variables. 它看起来像abline功能从heatmap.2函数内部调用,不看外部变量。

Please advice what would be the best approach. 请告知什么是最好的方法。

Of course, I don't want to modify any of the functions except my own. 当然,除我自己的功能外,我不想修改任何功能。

This seems to add the two thick lines: 这似乎增加了两条粗线:

heatmap.2(xx,
       add.expr=eval( abline(v=linePosition, lwd=3))) 

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

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