<?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/%e7%94%9f%e5%ad%98%e5%88%86%e6%9e%90/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>用TCGA数据做cox生存分析的风险因子（比例风险模型）</title>
		<link>http://www.bio-info-trainee.com/1371.html</link>
		<comments>http://www.bio-info-trainee.com/1371.html#comments</comments>
		<pubDate>Fri, 22 Jan 2016 13:25:17 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[cancer]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[TCGA]]></category>
		<category><![CDATA[生存分析]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1371</guid>
		<description><![CDATA[再次强调一下，R里面实现生存分析非常简单！ 用my.surv &#60;- sur &#8230; <a href="http://www.bio-info-trainee.com/1371.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div>再次强调一下，R里面实现生存分析非常简单！</div>
<blockquote>
<div>用my.surv &lt;- surv(OS_MONTHS,OS_STATUS=='DECEASED')构建<span style="color: #ff0000;"><strong>生存曲线。</strong></span></div>
<div>用kmfit2 &lt;- survfit(my.surv~TUMOR_STAGE_2009)来做<span style="color: #ff0000;"><strong>某一个因子的KM生存曲线。</strong></span>用 survdiff(my.surv~type, data=dat)来看看这个因子的不同水平是否有显著差异，其中默认用是的<span style="color: #ff0000;"><strong>logrank test 方法。</strong></span></div>
<div>用coxph(Surv(time, status) ~ ph.ecog + tt(age), data=lung) 来检测自己<span style="color: #ff0000;"><strong>感兴趣的因子是否受其它因子(age,gender等等)的影响。</strong></span></div>
</blockquote>
<div></div>
<p><span id="more-1371"></span></p>
<div>我们还是拿TCGA的数据来做例子，卵巢癌的那篇文章里面根据甲基化数据和mRNA表达数据都可以把癌症样本分成四组，我们前面看了甲基化分组方法的确是有差异，但是还没有达到0.05的统计学意义的显著性。我们接下来把mRNA分组也检验一下，然后把两个分组方法当初一个影响生存率的因子，然后用cox方法看看这两个因子的权重！</div>
<div></div>
<div><b>Cox比例风险回归模型（Cox’s proportional hazards regression model），简称Cox回归模型。该模型由英国统计学家D.R.Cox于1972年提出，主要用于肿瘤和其它慢性病的预后分析，也可用于队列研究的病因探索。</b></div>
<div><span style="font-family: Times New Roman;">首先，我们从TCGA里面下载得到的做生存分析的数据如下（代码见末尾）： </span></div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/14.png"><img class="alignnone size-full wp-image-1372" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/14.png" alt="1" width="494" height="406" /></a></div>
<div>很明显看到，<b>两种分组方式不一致的地方非常多</b>，所以说癌症的分组仍然是一个没有解决的问题，我们可以把这两种分组方式当做因子来探究它们对生存率的影响！</div>
<div><span style="font-family: Times New Roman;">my.surv=Surv(sur_dat$OS_MONTHS.y,sur_dat$OS_STATUS.y=='DECEASED')</span></div>
<div><span style="font-family: Times New Roman;">#plot(survfit(my.surv~1))</span></div>
<div><span style="font-family: Times New Roman;">survfit(my.surv~1)</span></div>
<div><span style="font-family: Times New Roman;">kmfit=survfit(my.surv~1)</span></div>
<div><span style="font-family: Times New Roman;">plot(kmfit)</span></div>
<div><span style="font-family: Times New Roman;">summary(kmfit)</span></div>
<div><span style="font-family: Times New Roman;">用survdiff检验分组的显著性，结果如下：</span></div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/22.png"><img class="alignnone size-full wp-image-1373" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/22.png" alt="2" width="586" height="497" /></a></div>
<div>可以看出，这里两种分类方式都挺好的，虽然没有达到0.05的统计学意义上的显著。</div>
<div></div>
<div>如果用cox模型回归分析如下：</div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/33.png"><img class="alignnone size-full wp-image-1374" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/33.png" alt="3" width="600" height="568" /></a></div>
<div>所以R里面做生存分析是非常简单的，就寥寥几个函数即可，当然，你得知道这些函数的输入数据是什么。函数的结果很容易看懂，就是各种分组因子的显著性，还有风险比(HR)-hazard ratio（输出里面，coef就是beta值，相应的exp(coef)就是HR了） 而已，这也是大多数人关心的。</div>
<div>我记得用cox模型还可以得到预测函数，根据一些因子的值来预测病人还有多少天生存期</div>
<div>大家可以去这里深度学习：<a href="https://www.bioconductor.org/help/course-materials/2016/BioC2016/ConcurrentWorkshops4/Buros/applied-survival-model.html" target="_blank"> https://www.bioconductor.org/help/course-materials/2016/BioC2016/ConcurrentWorkshops4/Buros/applied-survival-model.html</a></div>
<div></div>
<div></div>
<div>参考：<a href="http://www.biomart.cn/experiment/430/586/588/240451.htm?trace=0420labstp">http://www.biomart.cn/experiment/430/586/588/240451.htm?trace=0420labstp</a></div>
<div><a href="http://www.dxy.cn/bbs/thread/3327209#3327209">http://www.dxy.cn/bbs/thread/3327209#3327209</a></div>
<div><a href="http://blog.csdn.net/shmilyringpull/article/details/17529637">http://blog.csdn.net/shmilyringpull/article/details/17529637</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1371.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TCGA数据里面的生存分析例子</title>
		<link>http://www.bio-info-trainee.com/1314.html</link>
		<comments>http://www.bio-info-trainee.com/1314.html#comments</comments>
		<pubDate>Fri, 08 Jan 2016 14:30:22 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[cancer]]></category>
		<category><![CDATA[subtype]]></category>
		<category><![CDATA[TCGA]]></category>
		<category><![CDATA[生存分析]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1314</guid>
		<description><![CDATA[我们知道了生存分析，就是随着时间的流逝，死亡率是如何增加的，一般是用KM法来估计 &#8230; <a href="http://www.bio-info-trainee.com/1314.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div><span style="font-family: Times New Roman;">我们知道了生存分析，就是随着时间的流逝，死亡率是如何增加的，一般是用KM法来估计生存函数，然后画个图即可！而根据某些因子把样本分组，可以看到他们死亡率的变化趋势显著的不同，这就说明了我们的这个因子是非常有效的分类方式，这个因子可以是一个biomarker，也可以某些其它指标！</span></div>
<div><span style="font-family: Times New Roman;">甚至，我们还可以用cox模型来分析这个因子是如何影响生存函数的，那个稍后再讲</span></div>
<div><span style="font-family: Times New Roman;">这里，我们就简单讲一个例子，是TCGA里面卵巢癌的数据，根据甲基化数据分成了4个组，那么我们就下载这四个组样本的临床数据，</span></div>
<div><span style="font-family: Times New Roman;"><b><span style="color: #ff0000;">看看这样分组后，他们的死亡率变化趋势是不是有显著区别！</span></b></span></div>
<p><span id="more-1314"></span></p>
<div><span style="font-family: Times New Roman;">数据是用cgdsr下载的：</span></div>
<div><span style="font-family: Times New Roman;">这个包的说明见：</span><a href="http://www.bio-info-trainee.com/?p=1257">http://www.bio-info-trainee.com/?p=1257</a> <span style="font-family: Times New Roman;"><br />
</span></p>
<div><span style="font-family: Times New Roman;">library(cgdsr)</span></div>
<div><span style="font-family: Times New Roman;">mycgds &lt;- CGDS('<a href="http://www.cbioportal.org/public-portal/">http://www.cbioportal.org/public-portal/</a>')</span></div>
<div><span style="font-family: Times New Roman;">test(mycgds)</span></div>
<div><span style="font-family: Times New Roman;">all_TCGA_studies &lt;- getCancerStudies(mycgds)</span></div>
<div><span style="font-family: Times New Roman;">all_tables &lt;- getCaseLists(mycgds, 'ov_tcga_pub')</span></div>
<div><span style="font-family: Times New Roman;">all_dataset&lt;- getGeneticProfiles(mycgds, 'ov_tcga_pub')</span></div>
<div><span style="font-family: Times New Roman;">#BRCA1 &lt;- getProfileData(mycgds, my_gene, my_dataset, my_table)</span></div>
<div><span style="font-family: Times New Roman;">ov_tcga_pub_meth1&lt;- getClinicalData(mycgds, all_tables[8,1])</span></div>
<div><span style="font-family: Times New Roman;">ov_tcga_pub_meth2&lt;- getClinicalData(mycgds, all_tables[9,1])</span></div>
<div><span style="font-family: Times New Roman;">ov_tcga_pub_meth3&lt;- getClinicalData(mycgds, all_tables[10,1])</span></div>
<div><span style="font-family: Times New Roman;">ov_tcga_pub_meth4&lt;- getClinicalData(mycgds, all_tables[11,1])</span></div>
<div><span style="font-family: Times New Roman;">下载之后的数据如下：</span></div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/1.png"><img class="alignnone size-full wp-image-1317" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/1.png" alt="1" width="422" height="96" /></a></div>
<div>根据甲基化数据，把癌症病人分成了4组，我们的临床数据记录了13项，但是我们只需要用到OS_MONTHS和OS_STATUS就可以来估计KM生存函数，画出生存曲线啦！</div>
<div></div>
<div><span style="color: #ff0000;"><strong>无病生存期（Disease-free  survival,DFS）</strong></span>的定义是指从随机化开始至疾病复发或由于疾病进展导致患者死亡的时间。该指标也常作 为抗肿瘤药物III期临床试验的主要终点。某些情况下，DFS与OS相比，作为终点比较难以记录，因为它要求认真随访，及时发现疾病复发，而且肿瘤患者的 死亡原因也很难确定。肿瘤患者常有合并症（如，心血管病），这些合并症可能会干扰对DFS的判断。并且，肿瘤患者常死于医院外，不能常规进行尸检。</div>
<div><span style="color: #ff0000;"><strong>总生存期（Overall survival,OS）</strong></span>的定义是指从随机化开始至因任何原因引起死亡的时间。该指标常常被认为是肿瘤临床试验中最佳的疗效终点。如果在生存期上有小幅度的提高，可以认为是有意义的临床受益证据。作为一个终点，生存期应每天进行评价，可通过在住院就诊时，通过与患者直接接触或者通过电话与患者交谈，这些相对比较容易 记录。确认死亡的日期通常几乎没有困难，并且死亡的时间有其独立的因果关系。当记录至死亡之前的失访患者，通常截止到最后一次有记录的、与患者接触的时间。</div>
<div></div>
<div><span style="font-family: Times New Roman;">library(survival)</span></div>
<div><span style="font-family: Times New Roman;">attach(ov_tcga_pub_meth1)</span></div>
<div><span style="color: #ff0000;"><strong><span style="font-family: Times New Roman;">## 估计KM生存曲线</span></strong></span></div>
<div><span style="color: #ff0000;"><strong><span style="font-family: Times New Roman;">my.surv &lt;- Surv(OS_MONTHS,OS_STATUS=='DECEASED')</span></strong></span></div>
<div><span style="color: #ff0000;"><strong><span style="font-family: Times New Roman;">kmfit1 &lt;- survfit(my.surv~1)</span></strong></span></div>
<div><span style="font-family: Times New Roman;">summary(kmfit1)</span></div>
<div><span style="font-family: Times New Roman;">plot(kmfit1)</span></div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/2.png"><img class="alignnone size-full wp-image-1318" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/2.png" alt="2" width="788" height="477" /></a></div>
<div><span style="font-family: Times New Roman;">##我们很容易看到，随着感染癌症的时间延长，病人的死亡率到了一定程度就不增加了，有些病人熬过了这个癌症，或者说，到我们拿到数据为止，他们还没有死亡！</span></div>
<div></div>
<div><span style="font-family: Times New Roman;">## 随便取一根因子来分组TUMOR_STAGE_2009估计KM生存曲线</span></div>
<div><span style="font-family: Times New Roman;">kmfit2 &lt;- survfit(my.surv~TUMOR_STAGE_2009)</span></div>
<div><span style="font-family: Times New Roman;">summary(kmfit2)</span></div>
<div><span style="font-family: Times New Roman;">plot(kmfit2,col = rainbow(length(unique(ov_tcga_pub_meth1[,13]))))</span></div>
<div><span style="font-family: Times New Roman;">detach(ov_tcga_pub_meth1)</span></div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/31.png"><img class="alignnone size-full wp-image-1319" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/31.png" alt="3" width="719" height="437" /></a></div>
<div><span style="font-family: Times New Roman;">##可以看到，我们根据病人的TUMOR_STAGE_2009把他们分成了这些组，不同组的生存曲线不一样，但是我们肉眼无法看出它们这些组直接的生存率是否有显著差异！我们需要做统计检验！</span></div>
<div></div>
<div>我们就不对这个进行检验了，我们还是用下面的代码来对甲基化数据的分组来做检验，看看我们的分组是否有效！</div>
<div><span style="font-family: Times New Roman;">ov_tcga_pub_meth1$sample&lt;- rownames(ov_tcga_pub_meth1)</span></div>
<div><span style="font-family: Times New Roman;">ov_tcga_pub_meth2$sample&lt;- rownames(ov_tcga_pub_meth2)</span></div>
<div><span style="font-family: Times New Roman;">ov_tcga_pub_meth3$sample&lt;- rownames(ov_tcga_pub_meth3)</span></div>
<div><span style="font-family: Times New Roman;">ov_tcga_pub_meth4$sample&lt;- rownames(ov_tcga_pub_meth4)</span></div>
<div><span style="font-family: Times New Roman;">ov_tcga_pub_meth1$type&lt;- 'meth1'</span></div>
<div><span style="font-family: Times New Roman;">ov_tcga_pub_meth2$type&lt;- 'meth2'</span></div>
<div><span style="font-family: Times New Roman;">ov_tcga_pub_meth3$type&lt;- 'meth3'</span></div>
<div><span style="font-family: Times New Roman;">ov_tcga_pub_meth4$type&lt;- 'meth4'</span></div>
<div><span style="font-family: Times New Roman;">dat=rbind(ov_tcga_pub_meth1,ov_tcga_pub_meth2,ov_tcga_pub_meth3,ov_tcga_pub_meth4)</span></div>
<div><span style="font-family: Times New Roman;">attach(dat)</span></div>
<div><span style="font-family: Times New Roman;">## 根据分组type估计KM生存曲线</span></div>
<div><span style="font-family: Times New Roman;">my.surv &lt;- Surv(OS_MONTHS,OS_STATUS=='DECEASED')</span></div>
<div><span style="font-family: Times New Roman;">kmfit3 &lt;- survfit(my.surv~type)</span></div>
<div><span style="font-family: Times New Roman;">summary(kmfit3)</span></div>
<div><span style="font-family: Times New Roman;">plot(kmfit3,col = rainbow(4))</span></div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/41.png"><img class="alignnone size-full wp-image-1320" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/41.png" alt="4" width="719" height="431" /></a></div>
<div>##由图中可以看到甲基化数据分成的4个组，生存率差异还是蛮大的</div>
<div><span style="font-family: Times New Roman;">##用图形方法检验PH假设</span></div>
<div><span style="font-family: Times New Roman;">plot(kmfit3,fun='cloglog',col = rainbow(4))</span></div>
<div><span style="font-family: Times New Roman;"># 检验显著性</span></div>
<div><span style="font-family: Times New Roman;">survdiff(my.surv~type, data=dat)</span></div>
<div><span style="font-family: Times New Roman;"># 用strata来控制协变量的影响</span></div>
<div><span style="font-family: Times New Roman;">survdiff(my.surv~type+strata(TUMOR_STAGE_2009),data=dat)</span></div>
<div><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/51.png"><img class="alignnone size-full wp-image-1321" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/51.png" alt="5" width="563" height="271" /></a></div>
<div><span style="font-family: Times New Roman;">##然后我们用这个代码来检验，是否显著，结果发现，p值并没有小于0.05，只能说是可以这样分组，但是分组的效果没有我们想象中的那么好！</span></div>
<div><span style="font-family: Times New Roman;">names(dat)</span></div>
<div><span style="font-family: Times New Roman;">detach(dat)</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1314.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>生存分析简介</title>
		<link>http://www.bio-info-trainee.com/1313.html</link>
		<comments>http://www.bio-info-trainee.com/1313.html#comments</comments>
		<pubDate>Fri, 08 Jan 2016 14:27:42 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[cancer]]></category>
		<category><![CDATA[survival]]></category>
		<category><![CDATA[生存分析]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1313</guid>
		<description><![CDATA[一般我们谈生存分析，就是说的KM方法估计生存函数，并且画出生存曲线，然后还可以根 &#8230; <a href="http://www.bio-info-trainee.com/1313.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div>一般我们谈生存分析，就是说的KM方法估计生存函数，并且画出生存曲线，然后还可以根据分组检验一下它们的生存曲线是否有显著的差异！</div>
<div></div>
<div>在R里面，非常的方便，有个包survival很容易就可以做生存分析了！</div>
<div>只需要记住三个函数即可：</div>
<div>Surv<span lang="ZH-CN">：用于创建生存数据对象</span><br />
survfit<span lang="ZH-CN">：创建</span>KM<span lang="ZH-CN">生存曲线或是</span>Cox<span lang="ZH-CN">调整生存曲线</span><br />
survdiff<span lang="ZH-CN">：用于不同组的统计检验</span></div>
<div></div>
<p><span id="more-1313"></span></p>
<div><span style="font-family: SimSun;">我们用下面的数据做例子<br />
</span><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/clipboard3.png"><img class="alignnone size-full wp-image-1315" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/01/clipboard3.png" alt="clipboard" width="633" height="406" /></a></div>
<div>对于上面的数据，我们用下面的代码做生存分析！</div>
<div>library(survival)</div>
<div>
<div><span style="font-family: Times New Roman;">my.surv &lt;- Surv(OS_MONTHS,OS_STATUS=='DECEASED')  </span></div>
<div><span style="font-family: Times New Roman;">##这个生存对象是看看病人的<b>总生存期</b>与<b>死亡状态</b>的关系</span></div>
<div><span style="font-family: Times New Roman;">###这个Surv函数第一个参数必须是数值型的时间，第二个参数是逻辑向量，1,0表示死亡与否</span></div>
<div><span style="font-family: Times New Roman;">kmfit1 &lt;- survfit(my.surv~1) ### 直接对生存对象拟合生存函数</span></div>
<div><span style="font-family: Times New Roman;">summary(kmfit1) ## 这个函数会详细打印出所有的结果，值得仔细理解</span></div>
<div><span style="font-family: Times New Roman;">plot(kmfit1)   ###画出生存曲线</span></div>
<p>survdiff(my.surv~type, data=dat)     ### 根据生存对象再加上一个分组因子来拟合生存函数，并且比较不同因子分组的生存效果</p>
</div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1313.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
