全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
4264 0
2022-03-10
各位老师,刚刚开始学习R 不久,遇到这么一个问题,代码运行老是报错,不知道错误出在哪里,以下是程序:

uni_cox_in_bulk <- function(gene_list, survival_info_df){
  uni_cox <- function(single_gene){
    formula <- as.formula(paste('Surv(PFS, PFS_status)~', single_gene))
    surv_uni_cox <- summary(coxph(formula, data = df))
    ph_hypothesis_p <- cox.zph(coxph(formula, data = df))$table[1,3]
    if (surv_uni_cox$coefficients[,5]<0.05 & ph_hypothesis_p>0.05){ #get the pvalue
      single_cox_report <- data.frame('uni_cox_sig_genes'=single_gene,
      'beta'=surv_uni_cox$coefficients[,1],
      'Hazard_Ratio'=exp(surv_uni_cox$coefficients[,1]),
      'z_pvalue'=surv_uni_cox$coefficients[,5],
      'Wald_pvalue'=as.numeric(surv_uni_cox$waldtest[3]),
      'Likelihood_pvalue'=as.numeric(surv_uni_cox$logtest[3]))
      single_cox_report
   }
  }
  uni_cox_list <- lapply(gene_list, uni_cox)
  do.call(rbind, uni_cox_list)
}

uni_cox_df <- uni_cox_in_bulk(gene_list = gene_list, survival_info_df = df)

运行后报错为:Error in asgn[[ii]] : subscript out of bounds


请问哪位前辈知道这是错在哪里吗?非常感谢!

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群