<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>生信菜鸟团 &#187; pheatmap</title>
	<atom:link href="http://www.bio-info-trainee.com/tag/pheatmap/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bio-info-trainee.com</link>
	<description>欢迎去论坛biotrainee.com留言参与讨论，或者关注同名微信公众号biotrainee</description>
	<lastBuildDate>Sat, 28 Jun 2025 14:30:13 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.33</generator>
	<item>
		<title>热图最佳实践-pheatmap</title>
		<link>http://www.bio-info-trainee.com/1980.html</link>
		<comments>http://www.bio-info-trainee.com/1980.html#comments</comments>
		<pubDate>Thu, 03 Nov 2016 02:30:21 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[基础软件]]></category>
		<category><![CDATA[pheatmap]]></category>
		<category><![CDATA[热图]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1980</guid>
		<description><![CDATA[用pheatmap来绘图首先要安装这个包，它就一个功能，画出热图即可，号称是pr &#8230; <a href="http://www.bio-info-trainee.com/1980.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p style="text-align: center;">用pheatmap来绘图首先要安装这个包，它就一个功能，画出热图即可，号称是pretty heatmap，的确比其它的好用很多。我以前写过《<strong><span style="color: #ff0000;">一步一步学习heatmap.2</span></strong>》的教程，很简单的那种，所以就没有公布在博客上面，结果发现很多其它博客居然能先我一步发出。其实包括本次的pheatmap指南，都没什么好发，的在R里面也是傻瓜式出图，无法就是自己熟练一下参数而已，又不是开发一个包，没什么技术含量。我这里单独提一下pheatmap是因为它的确非常好用，将会是我画热图的不二之选。比如下面这个，是我最喜欢的：<span id="more-1980"></span></p>
<p><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/11/pheatmap-best-practise.png"><img class=" size-full wp-image-1981 aligncenter" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/11/pheatmap-best-practise.png" alt="pheatmap-best-practise" width="651" height="541" /></a></p>
<p>&nbsp;</p>
<p>里面该有的信息一应俱全了，包括基因可以分成上下调来显色，基因和样本都可以单独聚类，单独排序，样本也可以具体再分组。热图也可以调整配色方案，单元格的宽度和高度都可以自由调整。把它说明书的代码一句句运行一遍就明白了：<a href="ftp://cran.r-project.org/pub/R/web/packages/pheatmap/pheatmap.pdf" target="_blank">ftp://cran.r-project.org/pub/R/web/packages/pheatmap/pheatmap.pdf</a></p>
<blockquote><p>代码如下：</p>
<p>## PS：我代码复制到博客就中英文标点被弄混了，请不要直接复制我的点，一行行点敲到R里面</p>
<p>## ftp://cran.r-project.org/pub/R/web/packages/pheatmap/pheatmap.pdf<br />
# Create test matrix<br />
## Just replace the test matrix with your own data.<br />
test = matrix(rnorm(200), 20, 10)<br />
test[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)] + 3<br />
test[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)] + 2<br />
test[15:20, seq(2, 10, 2)] = test[15:20, seq(2, 10, 2)] + 4<br />
colnames(test) = paste("Test", 1:10, sep = "")<br />
rownames(test) = paste("Gene", 1:20, sep = "")<br />
# Draw heatmaps<br />
pheatmap(test)<br />
pheatmap(test, kmeans_k = 2)<br />
pheatmap(test, scale = "row", clustering_distance_rows = "correlation")<br />
pheatmap(test, color = colorRampPalette(c("navy", "white", "firebrick3"))(50) )<br />
pheatmap(test, cluster_row = FALSE)<br />
pheatmap(test, legend = FALSE)<br />
# Show text within cells<br />
pheatmap(test, display_numbers = TRUE)<br />
pheatmap(test, display_numbers = TRUE, number_format = "\%.1e")<br />
pheatmap(test, display_numbers = matrix(ifelse(test &gt; 5, "*", ""), nrow(test)))<br />
pheatmap(test, cluster_row = FALSE, legend_breaks = -1:4, legend_labels = c("0",<br />
"1e-4", "1e-3", "1e-2", "1e-1", "1"))<br />
# Fix cell sizes and save to file with correct size<br />
pheatmap(test, cellwidth = 15, cellheight = 12, main = "Example heatmap")<br />
pheatmap(test, cellwidth = 15, cellheight = 12, fontsize = 8, filename = "test.pdf")<br />
# Generate annotations for rows and columns<br />
annotation_col = data.frame(<br />
CellType = factor(rep(c("CT1", "CT2"), 5)),<br />
Time = 1:5<br />
)<br />
rownames(annotation_col) = paste("Test", 1:10, sep = "")<br />
annotation_row = data.frame(<br />
GeneClass = factor(rep(c("Path1", "Path2", "Path3"), c(10, 4, 6)))<br />
)<br />
rownames(annotation_row) = paste("Gene", 1:20, sep = "")<br />
# Display row and color annotations<br />
pheatmap(test, annotation_col = annotation_col)<br />
pheatmap(test, annotation_col = annotation_col, annotation_legend = FALSE)<br />
pheatmap(test, annotation_col = annotation_col, annotation_row = annotation_row)<br />
# Specify colors<br />
ann_colors = list(<br />
Time = c("white", "firebrick"),<br />
CellType = c(CT1 = "#1B9E77", CT2 = "#D95F02"),<br />
GeneClass = c(Path1 = "#7570B3", Path2 = "#E7298A", Path3 = "#66A61E")<br />
)<br />
pheatmap(test, annotation_col = annotation_col, annotation_colors = ann_colors, main = "Title")<br />
pheatmap(test, annotation_col = annotation_col, annotation_row = annotation_row,<br />
annotation_colors = ann_colors)<br />
pheatmap(test, annotation_col = annotation_col, annotation_colors = ann_colors[2])<br />
# Gaps in heatmaps<br />
pheatmap(test, annotation_col = annotation_col, cluster_rows = FALSE, gaps_row = c(10, 14))<br />
pheatmap(test, annotation_col = annotation_col, cluster_rows = FALSE, gaps_row = c(10, 14),<br />
cutree_col = 2)<br />
# Show custom strings as row/col names<br />
labels_row = c("", "", "", "", "", "", "", "", "", "", "", "", "", "", "",<br />
"", "", "Il10", "Il15", "Il1b")<br />
pheatmap(test, annotation_col = annotation_col, labels_row = labels_row)<br />
# Specifying clustering from distance matrix<br />
drows = dist(test, method = "minkowski")<br />
dcols = dist(t(test), method = "minkowski")<br />
pheatmap(test, clustering_distance_rows = drows, clustering_distance_cols = dcols)<br />
# Modify ordering of the clusters using clustering callback option<br />
callback = function(hc, mat){<br />
sv = svd(t(mat))$v[,1]<br />
dend = reorder(as.dendrogram(hc), wts = sv)<br />
as.hclust(dend)<br />
}<br />
pheatmap(test, clustering_callback = callback)<br />
## Not run:<br />
# Same using dendsort package<br />
library(dendsort)<br />
callback = function(hc, ...){dendsort(hc)}<br />
pheatmap(test, clustering_callback = callback)<br />
## End(Not run)</p></blockquote>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1980.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
