如何在 pheatmap 标题中使用 plotmeth?

huangapple go评论64阅读模式
英文:

How to use plotmeth in pheatmap title?

问题

我想在pheatmap的标题中添加上标字符串,例如“+/-”。

我尝试了很多方法,但都没有成功。要同时添加特殊字符串如“+/-”有点困难。

英文:

I want to add superscript string,such as "+/-" in the tile in pheatmap.

I tried my best to come up with some ideas but it doesn't work.

Here is my reproducible code:

library(pheatmap)
main<- expression(ABC^'+/-')
pheatmap(matrix(runif(100,0,1),10,10),
main = main)

It can add only the single expression string in the title.

But I want to add other information with a blank line not only the expression information like this:

main&lt;- paste(expression(ABC^&#39;+/-&#39;),&quot;\nABCDEFG&quot;)
pheatmap(matrix(runif(100,0,1),10,10),
         main = main)

It is a little bit difficult to me to solve it.

I hope somebody could help me deal with this problem.

Thanks in advance.

######## update:

I tried many methods. But it still doesn't work. It is a little difficult to add special string like &quot;+/-&quot; together.

答案1

得分: 0

最后,我找到了一个更好但不是完美的方法:

这是我的解决方案:

pheatmap(mat, 
         main =expression(atop(ABC^'+/-'',
                               "ABCDEFG")))

只需使用"atop"而不是"\n"。因为"\n"在表达式函数中不起作用。

我说这不是完美的,因为如果你想要paste/paste0包含表达式的任何字符串,然后在它之后添加一些信息,可能不会表达得很清楚。

例如:

pheatmap(mat, 
         main =expression(atop(ABC^'+/-'',
                               paste("ABCDEFG,总数 = ",dim[mat][1],))))

这里paste()不起作用,因为表达式()。

所以如果你是这个领域的专家,或者我可能忽略了一些详细信息,希望能给我一些建议或解决方案。

提前感谢。

英文:

Finally, I find a better but not perfect method:

Here is my solution:

pheatmap(mat, 
         main =expression(atop(ABC^&#39;+/-&#39;,
                               &quot;ABCDEFG&quot;))

Just use &quot;atop&quot; instead of &quot;\n&quot;. Because &quot;\n&quot; doesn't work in an expression function.

I said that it is not perfect because if you want to paste/paste0 any strings which contains with an expression and after it, some information may not express clearly.

For example:

pheatmap(mat, 
         main =expression(atop(ABC^&#39;+/-&#39;,
                               paste(&quot;ABCDEFG,the total number = &quot;,dim[mat][1],)))

Here the paste() doesn't work because of expression().

So somebody could give me some advice or solution if you are expert in this region.

Or maybe I ignored some information in detail.

Thank in advance.

huangapple
  • 本文由 发表于 2023年7月7日 01:12:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76631139.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定