我已經用函數pheatmap創建了36個熱圖,並且我只想在一個圖中顯示它們。我試圖使用函數par(),但它不起作用,我不知道爲什麼。有人能告訴我該怎麼辦?非常感謝你。這是我的代碼:如何將信號圖中使用R的幾個熱圖組合起來
require(graphics);require(grDevices);library("pheatmap", lib.loc="D:/Program Files/R/R-3.1.1/library");library(gplots)
filenames<-list.files("D:/Project/bladder cancer/heatmap0829/heatmap/"); # detect all of the files in the fold
filename2<-strtrim(filenames,nchar(filenames)-4); # all of the filenames without extension names
par(mfrow=c(18,2)) #divide the graphics windows into a 18x2 matrix
for(i in 1:length(filename2)){
rt<-read.table(paste("D:/Project/bladder cancer/heatmap0829/heatmap/",filenames[i],sep = ""), header = T, sep = '\t') # Import the data with the ith file name
size=dim(rt) # the dimensional of the datafram
cw=400/size[1] #the width of the cell in the heatmap
rt<-log10(rt)
x <- t(data.matrix(rt))
pheatmap(x,color=greenred(256),main=filename2[i],cluster_rows = F, cluster_cols = T,cellwidth = cw, cellheight = 60,border_color =F,fontsize = 8,fontsize_col = 15)}
這是一個數據集
ScaBER 5637
1 1.010001e+02
1.341186e+00 2.505067e+01
1.669456e+01 8.834190e+01
7.141351e+00 3.897474e+01
1.585592e+04 5.858210e+04
1 3.137979e+01
1.498863e+01 7.694948e+01
1.115443e+02 3.642917e+02
1.157677e+01 5.036716e+01
4.926492e+02 8.642784e+03
3.047117e+00 1.872154e+01
我36 TXT這樣的文件,但我不能把所有的人都在這裏 「ScaBER 5637」是列名此數據集
大部分的熱圖functi的ons覆蓋了通常的par()設置。你應該使用像'image'這樣的更原始的函數,或者包含數據,並且在你想要的方面更加清晰。 – 2014-08-31 04:52:05
非常感謝您的寶貴意見,我在代碼後添加了一個數據集。 – 2014-08-31 08:33:14
熱圖或圖像的輸入可以是具有指定x和y向量的矩陣或z向量。你還沒有描述你期望看到那個小的兩列數據例子。 – 2014-08-31 16:36:09