<?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; 重抽样</title>
	<atom:link href="http://www.bio-info-trainee.com/tag/%e9%87%8d%e6%8a%bd%e6%a0%b7/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>用重抽样+主成分方法来做富集分析</title>
		<link>http://www.bio-info-trainee.com/1237.html</link>
		<comments>http://www.bio-info-trainee.com/1237.html#comments</comments>
		<pubDate>Mon, 21 Dec 2015 14:20:40 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[生信基础]]></category>
		<category><![CDATA[主成分]]></category>
		<category><![CDATA[统计]]></category>
		<category><![CDATA[重抽样]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1237</guid>
		<description><![CDATA[之前我们用超几何分布检验的方法做了富集分析，使用的是GSE63067.diffe &#8230; <a href="http://www.bio-info-trainee.com/1237.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>之前我们用<strong>超几何分布检验</strong>的方法做了富集分析，使用的是GSE63067.diffexp.NASH-normal.txt的logFC的绝对值大于0.5，并且P-value小雨0.05的基因作为<strong>差异基因</strong>来检验kegg的pathway的富集情况</p>
<p>结果是这样的</p>
<p><a href="http://www.bio-info-trainee.com/wp-content/uploads/2015/12/image0017.png"><img class="alignnone size-full wp-image-1238" src="http://www.bio-info-trainee.com/wp-content/uploads/2015/12/image0017.png" alt="image001" width="858" height="395" /></a></p>
<p>我们接下来用另外一种方法来做富集分析，顺便检验一下，是不是超几何分布统计检验的富集分析方法就是最好的呢？</p>
<p><strong>这种方法是</strong><strong>-</strong><strong>重抽样</strong><strong>+</strong><strong>主成分分析</strong></p>
<p><strong>大概的原理是，比如对上图中的，</strong><strong>04380</strong><strong>这条</strong><strong>pathway</strong><strong>来说，总共有</strong><strong>128</strong><strong>个基因，</strong>那么我从原来的表达矩阵里面<strong>随机抽取</strong><strong>128</strong><strong>个基因</strong>的表达矩阵<strong>做主成分分析</strong>，并且抽取一千次，每次主成分分析都可以得到<strong>第一主成分的贡献度值</strong>。那么，当我并不是随机抽取的时候，我就抽04380这条pathway的128个基因，也做主成分分析，并且计算得到第一主成分分析的重要性值。我们看看这个值，跟随机抽1000次得到的值差别大不大。</p>
<p>这时候就需要用到表达矩阵啦！</p>
<p>setwd("D:\\my_tutorial\\补\\用limma包对芯片数据做差异分析")</p>
<p>exprSet=read.table("GSE63067_series_matrix.txt.gz",comment.char = "!",stringsAsFactors=F,header=T)</p>
<p>rownames(exprSet)=exprSet[,1]</p>
<p>exprSet=exprSet[,-1]</p>
<p>我们根据ncbi里面对GSE63067的介绍可以知道，对应NASH和normal的样本的ID号，就可以提取我们需要的表达矩阵</p>
<p>把前面两属于Steatosis的样本去掉即可，exprSet=exprSet[,-c(1:2)]</p>
<p>然后再把芯片探针的id转换成entrez id</p>
<p>exprSet=exprSet[,-c(1:2)]</p>
<p>library(hgu133plus2.db)</p>
<p>library(annotate)</p>
<p>platformDB="hgu133plus2.db";</p>
<p>probeset &lt;- rownames(exprSet)</p>
<p>rowMeans &lt;- rowMeans(exprSet)</p>
<p>EGID &lt;- as.numeric(lookUp(probeset, platformDB, "ENTREZID"))</p>
<p>match_row=aggregate(rowMeans,by=list(EGID),max)</p>
<p>colnames(match_row)=c("EGID","rowMeans")</p>
<p>dat=data.frame(EGID,rowMeans,probeset)</p>
<p>tmp_prob=merge(dat,match_row,by=c("EGID","rowMeans"))</p>
<p>relevantProbesets=as.character(tmp_prob$probeset)</p>
<p>length(relevantProbesets) #hgu133plus2.db  20156</p>
<p>exprSet=exprSet[relevantProbesets,]</p>
<p>EGID_name=as.numeric(lookUp(relevantProbesets, platformDB, "ENTREZID"))</p>
<p>rownames(exprSet)=as.character(EGID_name)</p>
<p>d=exprSet</p>
<p>最后得到表达矩阵表格</p>
<p><a href="http://www.bio-info-trainee.com/wp-content/uploads/2015/12/image0027.png"><img class="alignnone size-full wp-image-1239" src="http://www.bio-info-trainee.com/wp-content/uploads/2015/12/image0027.png" alt="image002" width="666" height="304" /></a></p>
<p>我们首先得到1000次随机挑选128个基因的表达矩阵的主成分分析，第一主成分贡献度值。</p>
<p>gene128=sapply(1:1000,function(y) {</p>
<p>dat=t(d[<strong>sample</strong>(row.names(d), 128, replace=TRUE), ]);</p>
<p>round(100*summary(fast.prcomp(dat))$importance[2,1],2)</p>
<p>}</p>
<p>)</p>
<p>很快就能得到结果，可以看到数据如下</p>
<p>&gt;  summary(gene128)</p>
<p>Min. 1st Qu.  Median    Mean 3rd Qu.    Max.</p>
<p>19.1    25.8    28.8    29.8    32.5    59.7</p>
<p><a href="http://www.bio-info-trainee.com/wp-content/uploads/2015/12/image0034.png"><img class="alignnone size-full wp-image-1240" src="http://www.bio-info-trainee.com/wp-content/uploads/2015/12/image0034.png" alt="image003" width="680" height="255" /></a></p>
<p>&nbsp;</p>
<p>那么接下来我们挑选这个<strong>04380</strong><strong>这条</strong><strong>pathway</strong><strong>特有</strong><strong>128</strong><strong>个基因</strong>来算第一主成分贡献度值</p>
<p>path_04380_gene=intersect(rownames(d),as.character(Path2GeneID[['04380']]))</p>
<p>dat=t(d[path_04380_gene,]);</p>
<p>round(100*summary(fast.prcomp(dat))$importance[2,1],2)</p>
<p><a href="http://www.bio-info-trainee.com/wp-content/uploads/2015/12/image0043.png"><img class="alignnone size-full wp-image-1241" src="http://www.bio-info-trainee.com/wp-content/uploads/2015/12/image0043.png" alt="image004" width="703" height="265" /></a></p>
<p>得到的值是<strong>38.83</strong>，然后看看我们的这个38.83在之前随机得到的1000个数里面是否正常，就按照正态分布检验来算</p>
<p>1-pnorm((38.83-mean(gene128))/sd(gene128))</p>
<p>[1] <strong>0.0625</strong></p>
<p>可以看到已经非常显著的不正常了，可以说明这条通路被富集了。</p>
<p>至少说明<strong>超几何分布检验</strong>的方法得到的富集分析结果跟我们这次的<strong>重抽样</strong><strong>+</strong><strong>主成分分析结果是一致的，当然，也有不一致的，不然就不用发明一种新的方法了。</strong></p>
<p>如果写一个循环同样可以检验所有的通路，但是这样就不需要事先准备好差异基因啦！！！这是这个分析方法的特点！</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1237.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
