将参数传递给heatmap.2内部的add.expr中的函数 [英] Passing parameter to function in add.expr inside heatmap.2

查看:100
本文介绍了将参数传递给heatmap.2内部的add.expr中的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用heatmap.2函数(R gplots软件包)生成聚类热图.我想使用add.expr参数在图像的可变位置添加一条垂直线.

I'm generating clustering heatmap with heatmap.2 function (R gplots package). I'd like to add a vertical line(s) onto the image at variable location(s) using add.expr parameter.

例如,

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))

看起来abline函数是从heatmap.2函数内部调用的,看不到外部变量.

It looks like abline function is called from inside the heatmap.2 function and doesn't see the external variables.

请告知什么是最佳方法.

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))) 

这篇关于将参数传递给heatmap.2内部的add.expr中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆