<?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; ES score</title>
	<atom:link href="http://www.bio-info-trainee.com/tag/es-score/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>java版本GSEA软件的ES score图片的修改</title>
		<link>http://www.bio-info-trainee.com/2105.html</link>
		<comments>http://www.bio-info-trainee.com/2105.html#comments</comments>
		<pubDate>Thu, 01 Dec 2016 16:53:10 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[基础软件]]></category>
		<category><![CDATA[ES score]]></category>
		<category><![CDATA[GSEA]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=2105</guid>
		<description><![CDATA[首先要明白这个ES score图片里面的数据是什么，这样才能修改它，因为java &#8230; <a href="http://www.bio-info-trainee.com/2105.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>首先要明白这个ES score图片里面的数据是什么，这样才能修改它，因为java是一个封闭打包好的软件，所以我们没办法在里面修改它没有提供的参数，运行完GSEA，默认输出的图就是下面这样：<span id="more-2105"></span></p>
<div style="width: 513px" class="wp-caption alignnone"><img class="" src="http://note.youdao.com/yws/api/group/23785548/noteresource/9ED49F972A0F4980AE784E76A7DFFC29/version/256?method=get-resource&amp;shareToken=DBDB0277A315444BBBAB2024190208AE&amp;entryId=123732909" alt="" width="503" height="504" /><p class="wp-caption-text">ES score</p></div>
<p>这个图片在发表的时候，就会发现其实蛮模糊的， 所以有可能需要自己重新制作这个图，那么就需要明白这个图后面的数据。</p>
<p>其中最下面的数据是量方法测到了2万个基因，那么这两万个基因在case和control组的差异度量(六种差异度量，默认是signal 2 noise，GSEA官网有提供公式，也可以选择大家熟悉的foldchange)肯定不一样,那么根据它们的差异度量，就可以对它们进行排序，并且Z-score标准化的结果。</p>
<p>而中间的就是该gene set在测到了的已经根据signal2noise排好序的2万个基因的位置。</p>
<p>最上面的图，就是所有的基因的ES score都要一个个加起来，叫做running  ES score，在加的过程中，什么时候ES score达到了最大值，就是这个gene set最终的ES score！</p>
<p>我这里全面解析了GSEA官网提供的R代码的绘图函数，如下：</p>
<p><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/12/ES-SCORE图的画法.png"><img class="alignnone size-full wp-image-2106" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/12/ES-SCORE图的画法.png" alt="es-score%e5%9b%be%e7%9a%84%e7%94%bb%e6%b3%95" width="1574" height="650" /></a></p>
<p>这个函数本身也被我抽离出来了：</p>
<p>这个知识点有点复杂，<strong><span style="color: #ff0000;">我解释的很清楚数据是什么，但是数据如何来的（就是下面代码读取的txt文件）</span></strong>，我没办法用博客写清楚，需要修改一个2500行的源代码才能获取数据！</p>
<blockquote><p>setwd('data')<br />
<strong><span style="color: #ff0000;">Obs.RES=read.table('Obs.RES.txt') </span></strong><br />
<strong><span style="color: #ff0000;">Obs.RES=t(Obs.RES) ## 每个基因在每个gene set里面的running ES score，一个矩阵</span></strong><br />
<strong><span style="color: #ff0000;">Obs.indicator=read.table('Obs.indicator.txt') </span></strong><br />
<strong><span style="color: #ff0000;">Obs.indicator=t(Obs.indicator) ## 每个基因是否属于每个gene set，一个0/1矩阵</span></strong><br />
<strong><span style="color: #ff0000;">obs.s2n=read.table('obs.s2n.txt')[,1]  ## 每个基因的signal 2 noise值，已经Z-score化，而且排好序了。</span></strong><br />
<strong><span style="color: #ff0000;">size.G=read.table('size.G.txt')[,1]  ## 每个gene set的基因数量，在图中需要显示</span></strong><br />
<strong><span style="color: #ff0000;">gs.names=read.table('gs.names.txt')[,1] ## 每个gene set的名字，在图中需要显示</span></strong><br />
<strong><span style="color: #ff0000;">Obs.arg.ES=read.table('Obs.arg.ES.txt')[,1]## 每个gene set的最大ES score出现在排序基因的位置</span></strong><br />
<strong><span style="color: #ff0000;">Obs.ES.index=read.table('Obs.ES.index.txt')[,1]## 这个用不着的，我也忘记是什么了</span></strong><br />
<strong><span style="color: #ff0000;">Obs.ES=read.table('Obs.ES.txt')[,1]  ##每个gene set的最大ES score是多少，如果是正值，用红色表示富集在case组，如果是负值，用蓝色，表示富集在control组。</span></strong></p>
<p>plot_ES_score &lt;- function(Ng=12,N=34688,phen1='control',phen2='case',Obs.RES,Obs.indicator,obs.s2n,size.G,gs.names,Obs.arg.ES,Obs.ES.index){<br />
for (i in 1:Ng) {<br />
png(paste0('number_',gs.names[i],'.png'))<br />
ind &lt;- 1:N<br />
min.RES &lt;- min(Obs.RES[i,])<br />
max.RES &lt;- max(Obs.RES[i,])<br />
if (max.RES &lt; 0.3) max.RES &lt;- 0.3<br />
if (min.RES &gt; -0.3) min.RES &lt;- -0.3<br />
delta &lt;- (max.RES - min.RES)*0.50<br />
min.plot &lt;- min.RES - 2*delta<br />
max.plot &lt;- max.RES<br />
max.corr &lt;- max(obs.s2n)<br />
min.corr &lt;- min(obs.s2n)<br />
Obs.correl.vector.norm &lt;- (obs.s2n - min.corr)/(max.corr - min.corr)*1.25*delta + min.plot<br />
zero.corr.line &lt;- (- min.corr/(max.corr - min.corr))*1.25*delta + min.plot<br />
col &lt;- ifelse(Obs.ES[i] &gt; 0, 2, 4)</p>
<p># Running enrichment plot</p>
<p>sub.string &lt;- paste("Number of genes: ", N, " (in list), ", size.G[i], " (in gene set)", sep = "", collapse="")</p>
<p>main.string &lt;- paste("Gene Set ", i, ":", gs.names[i])</p>
<p>plot(ind, Obs.RES[i,], main = main.string, sub = sub.string, xlab = "Gene List Index", ylab = "Running Enrichment Score (RES)", xlim=c(1, N), ylim=c(min.plot, max.plot), type = "l", lwd = 2, cex = 1, col = col)<br />
for (j in seq(1, N, 20)) {<br />
lines(c(j, j), c(zero.corr.line, Obs.correl.vector.norm[j]), lwd = 1, cex = 1, col = colors()[12]) # shading of correlation plot<br />
}<br />
lines(c(1, N), c(0, 0), lwd = 1, lty = 2, cex = 1, col = 1) # zero RES line<br />
lines(c(Obs.arg.ES[i], Obs.arg.ES[i]), c(min.plot, max.plot), lwd = 1, lty = 3, cex = 1, col = col) # max enrichment vertical line<br />
for (j in 1:N) {<br />
if (Obs.indicator[i, j] == 1) {<br />
lines(c(j, j), c(min.plot + 1.25*delta, min.plot + 1.75*delta), lwd = 1, lty = 1, cex = 1, col = 1) # enrichment tags<br />
}<br />
}<br />
lines(ind, Obs.correl.vector.norm, type = "l", lwd = 1, cex = 1, col = 1)<br />
lines(c(1, N), c(zero.corr.line, zero.corr.line), lwd = 1, lty = 1, cex = 1, col = 1) # zero correlation horizontal line<br />
temp &lt;- order(abs(obs.s2n), decreasing=T)<br />
arg.correl &lt;- temp[N]<br />
lines(c(arg.correl, arg.correl), c(min.plot, max.plot), lwd = 1, lty = 3, cex = 1, col = 3) # zero crossing correlation vertical line</p>
<p>leg.txt &lt;- paste("\"", phen1, "\" ", sep="", collapse="")<br />
text(x=1, y=min.plot, adj = c(0, 0), labels=leg.txt, cex = 1.0)</p>
<p>leg.txt &lt;- paste("\"", phen2, "\" ", sep="", collapse="")<br />
text(x=N, y=min.plot, adj = c(1, 0), labels=leg.txt, cex = 1.0)</p>
<p>adjx &lt;- ifelse(Obs.ES[i] &gt; 0, 0, 1)</p>
<p>leg.txt &lt;- paste("Peak at ", Obs.arg.ES[i], sep="", collapse="")<br />
text(x=Obs.arg.ES[i], y=min.plot + 1.8*delta, adj = c(adjx, 0), labels=leg.txt, cex = 1.0)</p>
<p>leg.txt &lt;- paste("Zero crossing at ", arg.correl, sep="", collapse="")<br />
text(x=arg.correl, y=min.plot + 1.95*delta, adj = c(adjx, 0), labels=leg.txt, cex = 1.0)<br />
dev.off()<br />
}</p>
<p>}</p>
<p>&nbsp;</p></blockquote>
<p>通过这个代码，就可以把当前所有gese set的 ES score图给重新画一下，如果需要调整字体大小，就去代码里面慢慢调整。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/2105.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GSEA的统计学原理试讲</title>
		<link>http://www.bio-info-trainee.com/2102.html</link>
		<comments>http://www.bio-info-trainee.com/2102.html#comments</comments>
		<pubDate>Thu, 01 Dec 2016 16:39:21 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[基础软件]]></category>
		<category><![CDATA[生信基础]]></category>
		<category><![CDATA[ES score]]></category>
		<category><![CDATA[foldchange]]></category>
		<category><![CDATA[GSEA]]></category>
		<category><![CDATA[RES]]></category>
		<category><![CDATA[signal2noise]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=2102</guid>
		<description><![CDATA[GSEA这个java软件使用非常方便，只需要根据要求做好GCT/CLS格式的in &#8230; <a href="http://www.bio-info-trainee.com/2102.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>GSEA这个java软件使用非常方便，只需要根据要求做好GCT/CLS格式的input文件就好了。我以前也写个用法教程：</p>
<div><a href="http://www.bio-info-trainee.com/1282.html">用GSEA来做基因集富集分析</a></div>
<div><a href="http://www.bio-info-trainee.com/1334.html">批量运行GSEA，命令行版本</a></div>
<div>但说到统计学原理，就有点麻烦了，我试着用自己的思路阐释一下：</div>
<div>假设芯片或者其它测量方法测到了2万个基因，那么这两万个基因在case和control组的差异度量(六种差异度量，默认是signal 2 noise，GSEA官网有提供公式，也可以选择大家熟悉的foldchange)肯定不一样,那么根据它们的差异度量，就可以对它们进行排序，并且Z-score标准化，在下图的最底端展示的就是</div>
<p><span id="more-2102"></span></p>
<div><img class="alignnone" src="http://note.youdao.com/yws/api/group/23785548/noteresource/9ED49F972A0F4980AE784E76A7DFFC29/version/256?method=get-resource&amp;shareToken=DBDB0277A315444BBBAB2024190208AE&amp;entryId=123732909" alt="" width="503" height="504" /></div>
<div>那么图中间，就是我们每个gene set里面的基因在所有的2万个排序好基因的位置，如果gene set里面的基因集中在2万个基因的前面部分，就是在case里面富集，如果集中在后面部分，就是在control里面富集着。</div>
<div>而最上面的那个ES score的算法，大概如下：</div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/12/1.png"><img class="alignnone  wp-image-2103" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/12/1.png" alt="1" width="725" height="581" /></a></div>
<div>仔细看，其实还是能看明白的，每个基因在每个gene set里面的ES score取决于这个基因是否属于该gene set，还有就是它的差异度量，上图的差异度量就是FC（foldchange）,对每个gene set来说，所有的基因的ES score都要一个个加起来，叫做running  ES score，在加的过程中，什么时候ES score达到了最大值，就是这个gene set最终的ES score！</div>
<div>
<div>算法解读我参考的PPT，反正我是看懂了，但不一定能讲清楚：</div>
<div><a href="http://bioinformatics.mdanderson.org/MicroarrayCourse/Lectures09/gsea1_bw.pdf">http://bioinformatics.mdanderson.org/MicroarrayCourse/Lectures09/gsea1_bw.pdf</a></div>
<div><a href="https://bioinformatics.cancer.gov/sites/default/files/course_material/GSEA_Theory.pptx">https://bioinformatics.cancer.gov/sites/default/files/course_material/GSEA_Theory.pptx</a></div>
<div><a href="http://compbio.ucdenver.edu/Hunter_lab/Phang/downloads/files/GSEA.ppt">http://compbio.ucdenver.edu/Hunter_lab/Phang/downloads/files/GSEA.ppt</a></div>
<div><a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1239896/">https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1239896/</a></div>
<div><a href="http://www.baderlab.org/CancerStemCellProject/VeroniqueVoisin/AdditionalResources/GSEA">http://www.baderlab.org/CancerStemCellProject/VeroniqueVoisin/AdditionalResources/GSEA</a></div>
<div>软件还有大把的参数可以调整：<a href="http://www.baderlab.org/CancerStemCellProject/VeroniqueVoisin/AdditionalResources/GSEA/parameters">http://www.baderlab.org/CancerStemCellProject/VeroniqueVoisin/AdditionalResources/GSEA/parameters</a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/2102.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
