Advertisement

python生物信息分析_Python从零开始第五章生物信息学⑤生存分析(log-rank)

阅读量:

目录

Python从零开始第五章生物信息学⑤生存分析(log-rank)

==================================================

==================================================

正文

生存分析(Survival analysis)旨在基于试验或调查获得的数据系统地探讨影响生物或人类生存时间及其结果的各种因素,并评估这些因素之间的相互作用关系及其实质强度的方法。该方法也可称为生存率分析或存活率分析。

生存分析适用于分析时间-事件数据,其中生存时间(survival time)指的是从某一特定起始事件开始到对应个体达到终点事件所经历的时间长度,例如在癌症研究中,通常将患者的"诊断"作为起始事件并以"死亡"作为终点事件进行跟踪观察。

生存时间分为两种类型:完全数据指的是被跟踪对象从开始观察到发生终点事件所需经历的时间;截尾数据或称删失数据,则是指在终点事件发生前因研究过程中断而无法获得完整观测的数据。由于研究对象提供的信息存在不完整性,在这种情况下只知道他们的生存时间超过了截止观察时间点。导致截尾的主要原因包括研究对象失访、退出或研究过程自然终止等因素。

生存分析方法大致可分为三类:非参数法、半参数方法以及参数法;以Kaplan-Meier曲线(亦即乘积极限法)与寿命表法来估测生存率及中位生存时长属于非参数的方法;而将半参数方法定义为Cox比例风险模型,则将参数方法界定为指数模型、Weibull模型、Gompertz模型等分析手段。

非参数法(log-rank)

用于比较两个或多个群体的生存曲线Log-rank检验法通常基于生存率及其标准误来分析这些差异。

导入必须的python包

%reset -f

%clear

In[*]

from matplotlib import pyplot as plt

import numpy as np

import pandas as pd

import lifelines as ll

from IPython.display import HTML

%matplotlib inline

import matplotlib.pyplot as plt

import seaborn as sns

import plotly.plotly as py

import plotly.tools as tls

from plotly.graph_objs import *

import os

from lifelines.estimation import KaplanMeierFitter

kmf = KaplanMeierFitter()

from lifelines.statistics import logrank_test

os.chdir("D:\ Rwork\ third\ Fig2")

读取数据

sur = pd.read_csv('entropy_surival.csv',header=0,index_col=0)

sur = sur[['sample','entr','PFI_status', 'PFI_time']]

sur['entr'] = np.where(sur['entr'] > sur['entr'].median(), 'high','low')

sur = sur.dropna(axis=0,how='any')

#sur_high = sur.loc[sur["PPP2R2B"] >sur["PPP2R2B"].median()]

#sur_high = sur_high.loc[:,['futime','fustat','PPP2R2B']]

#sur_high.head(5)

sur['entr']

绘制两组的生存曲线,且比较其P值

In[*]

f_low = sur['entr'] == 'low'

T_low = sur[f_low]['PFI_time']

C_low = sur[f_low]['PFI_status']

kmf.fit(T_low,event_observed=C_low)

kmf.plot(title='low entr')

In[*]

f_high = sur['entr'] == 'high'

T_high = sur[f_high]['PFI_time']

C_high = sur[f_high]['PFI_status']

kmf.fit(T_high,event_observed=C_high)

kmf.plot(title='high entr')

得到的结果如下所示:两组的生存存在不同(p< 0.05)

t_0=-1, alpha=0.95, null_distribution=chi squared, df=1

test_statistic p

7.5138 0.0061 **

---

Signif. codes: 0 '' 0.001 '' 0.01 '' 0.05 '.' 0.1 ' ' 1

两组的各自生存曲线

全部评论 (0)

还没有任何评论哟~