美文网首页
pheatmap行列分组颜色/annotation_row/an

pheatmap行列分组颜色/annotation_row/an

作者: SCU十一 | 来源:发表于2022-04-12 21:00 被阅读0次

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)

2.样本分组信息,excel中弄成这样,每个样本,后面一列给成你要的分组类别,保存为txt文件,读入R

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)

4.如果想给基因分组,同样的excel里面把每个基因的分类给出来,放到txt里面,读到R,并给每个分组指定颜色。

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)

相关文章

网友评论

      本文标题:pheatmap行列分组颜色/annotation_row/an

      本文链接:https://www.haomeiwen.com/subject/tltzsrtx.html