实验室的师弟给了两个材料,36个基因表达的数据,其中一个材料的所有基因表达的量都比另一个材料所有基因的表达量要高,而且在这36个基因中,有几个基因表达量在两个材料中都远大于其他基因。 如何有差别的做出这两列基因数据的heatmap呢? 如果采用传统的pheatmap包中的pheatmap函数,在对行进行标准化的时候,发现每个材料中的基因表达量都是相同的,表达量高的那个材料全是红色,表达量低的那个材料全是蓝色。 达不到区分不同的基因表达有差异的效果。 因此,采用以下标准化的方法,可以有效的展示材料之间的差异,也可以展示不同基因之间的差异。
数据如下:
Colh3gene10.8180751972.398748858gene20.4806274910.926058452gene30.2132185110.408803941gene461.79509635137.4037627gene54.98592017910.09193546gene616.0170630224.19177474gene72.6412306514.721488137gene82.46013928314.49196975gene90.2901864721.103608313gene100.3609955190.808775839gene110.9288634091.491343848gene122.3590844085.967281796gene133.057677795.005372632gene140.2290883130.585076526gene150.6593119531.871574262gene168.7745115416.48388491gene1739.8899069862.90271955gene180.95976242.790069555gene194.64815168811.4454019gene200.2298434840.924642942gene210.3380315490.668446401gene2211.1484684919.54088284gene230.5107375690.897929633gene240.9190226251.646921958gene250.2457249820.430445958gene265.83222868617.82051493gene276.65672221330.58322923gene288.50672423516.65287171gene290.280354870.618129318gene302.7289883036.424190218gene311.285094062.285384937gene321.2841492441.95134906gene330.6891667511.078235097gene342.5932513116.273472703gene351.5713824793.177707529gene360.918274171.837563294
采用pheatmap, scale = "row" 得到的图如下:
很明显,两个材料差别很大,基因之间没有差异。 如果对每行只进行标准化,而不进行中心化,则可以区分出来基因之间的差异。
代码如下:
library(pheatmap) data = read.table(file="~/Downloads/Col.txt",header = T) plot_data = apply(as.matrix(data),1,function(x) scale(x,center = F,scale = T)) plot_data2 = t(plot_data) dimnames(plot_data2) <- list(row.names(data), c("Col","h3")) pheatmap(plot_data2,scale = "none",show_colnames = T,show_rownames = T)因此,如果要展示的是差别较大的两列数据时,可以对数据只进行标准化,而不进行中心化,这样能避免以上所有基因在一个材料中都是一样的情况。