1.数据如图,8列表示8个样本,每一行是一个基因。
library(pheatmap)
library(gplots)
library(permute)
library(lattice)
library(vegan)
data<-read.table("data.txt",header=T,sep="\t",row.names=1)
data<-as.matrix(data)
![](https://img.haomeiwen.com/i11134057/8f3fdffe1c90591d.png)
2.样本分组信息,excel中弄成这样,每个样本,后面一列给成你要的分组类别,保存为txt文件,读入R
![](https://img.haomeiwen.com/i11134057/0336d88bd5c8ba06.png)
sample_class<-read.table("sample_class.txt",header=T,sep="\t",row.names=1)#样本分组文件读入
ann_colors=list(class=c(L='#009933',R='#CC33CC',F='#FDDCA9')) ##给你的分类指定一下颜色
3.画图,样本就分成了三个组,每个组一个色块。
pheatmap(data,scale="none",cluster_cols=F,cluster_rows=F,show_rownames=T,annotation_col=sample_class,annotation_colors=ann_colors)
![](https://img.haomeiwen.com/i11134057/d00648105898a0cd.png)
4.如果想给基因分组,同样的excel里面把每个基因的分类给出来,放到txt里面,读到R,并给每个分组指定颜色。
![](https://img.haomeiwen.com/i11134057/3314177e05f3a795.png)
gene_class<-read.table("gene_class.txt",header=T,sep="\t",row.names=1)
ann_colors=list(gene_class=c(group1='#CC6666',group2='#3366FF',group3='#FDDCA9',group4="#FF6600"))
pheatmap(data,scale="none",cluster_cols=F,cluster_rows=F,show_rownames=T,annotation_row=gene_class,annotation_colors=ann_colors)
![](https://img.haomeiwen.com/i11134057/bdfea904d6ca79e6.png)
网友评论