简体   繁体   English

R中的Heatmap.2控制轴

[英]Heatmap.2 controlling axis in R

I am using heatmap.2 function from the gplots library to plot a heatmap. 我正在使用gplots库中的heatmap.2函数来绘制热图。 I managed to create the heatmap but have few questions regarding the axis. 我设法创建了热图,但是关于轴的问题很少。 I wanted the heatmap to show only selected values of the axis. 我希望热图仅显示轴的选定值。 Please refer the heatmap imaged attached below. 请参考下面所附的热图。 I would like to know how can I only display points like X76.100, X176.200, X276.300 etc on X axis and Y76.100, Y176.200, Y276.300 on Y axis, while hiding the other points on both axis. 我想知道如何在X轴上仅显示X76.100,X176.200,X276.300等点,而在Y轴上仅显示Y76.100,Y176.200,Y276.300等点,而同时隐藏两个点轴。

Please let me know if the question needs more clarification. 如果问题需要进一步说明,请告诉我。

Code that I have used so far: 我到目前为止使用的代码:

   library(gplots)     
   file=read.table("Heatfile25.txt", sep="\t", header=TRUE, row.names=1)
   file[is.na(file)]<-0
   data_matrix<-as.matrix(file)
   heatmap.2(data_matrix, scale="none",dendrogram="none", col=grey(seq(1,0,-0.01)),      
     trace="none", Rowv=NA, Colv=NA, main="PB2 VS PB1")

Thanks 谢谢 在此处输入图片说明

By going from matrix to data.frame for your input data you can easily use filter statements to select the relevant rows and columns. 通过将输入数据从matrix转到data.frame ,您可以轻松地使用过滤器语句选择相关的行和列。 Let DF be your data.frame : DF为您的data.frame

columnKeeps <- c("X76.100", "X176.200", "X276.300")
DFfiltered <- DF[,(names(DF) %in% columnKeeps)]

rowKeeps <- c("Y76.100", "Y176.200", "Y276.300")
DFfiltered <- DFfiltered [(rownames(DFfiltered) %in% rowKeeps),]

Cannot test right now so I may have swapped column and row but you should manage :) 现在无法测试,因此我可能已交换了列和行,但您应该管理:)

See Drop data frame columns by name for more details 请参阅按名称删除数据框列以了解更多详细信息

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

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