data_ori <- "Grp_1;Grp_2;Grp_3;Grp_4;Grp_5 a;6.6;20.9;100.1;600.0;5.2 b;20.8;99.8;700.0;3.7;19.2 c;100.0;800.0;6.2;21.4;98.6 d;900;3.3;20.3;101.1;10000" data <- read.table(text=data_ori, header=T, row.names=1, sep=";", quote="") Grp_1 Grp_2 Grp_3 Grp_4 Grp_5 a 6.6 20.9 100.1 600.0 5.2 b 20.8 99.8 700.0 3.7 19.2 c 100.0 800.0 6.2 21.4 98.6 d 900.0 3.3 20.3 101.1 10000.0 pheatmap::pheatmap(data, filename="pheatmap_1.pdf")
pheatmap::pheatmap(data, scale="row", filename="pheatmap_1.pdf")
pheatmap::pheatmap(data, scale="row", cluster_rows=FALSE, cluster_cols=FALSE, filename="pheatmap_1.pdf")
row_anno = data.frame(type=c("TF","Enzyme","Enzyme","TF"), class="c"("clu1","clu1","clu2","clu2"), row.names=rownames(data)) row_anno type class a TF clu1 b Enzyme clu1 c Enzyme clu2 d TF clu2 col_anno = data.frame(grp=c("A","A","A","B","B"), size=1:5, row.names=colnames(data)) col_anno grp size Grp_1 A 1 Grp_2 A 2 Grp_3 A 3 Grp_4 B 4 Grp_5 B 5 pheatmap::pheatmap(data, scale="row", cluster_rows=FALSE, annotation_col=col_anno, annotation_row=row_anno, filename="pheatmap_1.pdf")
# <bias> values larger than 1 will give more color for high end. # Values between 0-1 will give more color for low end. pheatmap::pheatmap(data, scale="row", cluster_rows=FALSE, annotation_col=col_anno, annotation_row=row_anno, color=colorRampPalette(c('green','yellow','red'), bias=1)(50), filename="pheatmap_1.pdf")
# tab鍵分割,每列不加引號 write.table(data, file="heatmap_data.xls", sep="\t", row.names=T, col.names=T, quote=F) # 若是看着第一行少了ID列不爽,能夠填補下。-i參數直接對文件進行操做,1 指定第一行。在行首添加製表符 system("sed -i '1 s/^/ID\t/' heatmap_data.xls") write.table(row_anno, file="heatmap_row_anno.xls", sep="\t", row.names=T, col.names=T, quote=F) write.table(col_anno, file="heatmap_col_anno.xls", sep="\t", row.names=T, col.names=T, quote=F)
# -f: 指定輸入的矩陣文件 # -d:指定是否計算Z-score,<none> (否), <row> (按行算), <col> (按列算) # -P: 行註釋文件 # -Q: 列註釋文件 $ sp_pheatmap.sh -f heatmap_data.xls -d row -P heatmap_row_anno.xls -Q heatmap_col_anno.xls
# -u: 設置寬度,單位是inch
# -v: 設置高度,單位是inch
$ sp_pheatmap.sh -f heatmap_data.xls -d row -P heatmap_row_anno.xls -Q heatmap_col_anno.xls -u 8 -v 12
# -A: 0, X軸標籤選擇0度 # -C: 自定義顏色,注意引號的使用,最外層引號與內層引號不一樣,引號之間無交叉 # -T: 指定給定的顏色的類型;若是給的是vector (以下面的例子), 則-T須要指定爲vector; 不然結果會很怪異,只有倆顏色。 # -t: 指定圖形的題目,注意引號的使用;參數中包含空格或特殊字符等都要用引號引發來做爲一個總體。 $ sp_pheatmap.sh -f heatmap_data.xls -d row -P heatmap_row_anno.xls -Q heatmap_col_anno.xls -u 8 -v 12 -A 0 -C 'c("white", "blue")' -T vector -t "Heatmap of gene expression profile"