Reputation: 885
I am using heatmap.2 function from the gplots library to plot a heatmap. 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.
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
Upvotes: 0
Views: 1750
Reputation: 1866
By going from matrix
to data.frame
for your input data you can easily use filter statements to select the relevant rows and columns. Let DF
be your 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
Upvotes: 1