我有一个函数tryCatch
,它为ind_gene
中定义的不同输入输出p值。
有没有办法搜索ind_gene
中的所有输入并从tryCatch
获取所有输出,其中p < 0.05
ind_gene <- which(rownames(matrix_cpm_spike_liver) == "hsa-miR-320c")
s1 <- tryCatch(survdiff(
Surv(as.numeric(as.character(ClinicalDataHep$new_death))[ind_clin],
ClinicalDataHep$death_event[ind_clin])~
event_rna[ind_gene,ind_tum]), error = function(e) return(NA))
> s1
Call:
survdiff(formula = Surv(as.numeric(as.character(ClinicalDataHep$new_death))[ind_clin],
ClinicalDataHep$death_event[ind_clin]) ~ event_rna[ind_gene,
ind_tum])
N Observed Expected (O-E)^2/E (O-E)^2/V
event_rna[ind_gene, ind_tum]=0 8 6 5.52 0.0420 0.0652
event_rna[ind_gene, ind_tum]=1 51 25 25.48 0.0091 0.0652
Chisq= 0.1 on 1 degrees of freedom, p= 0.798
p值可以这样计算:
p.val <- 1 - pchisq(s1$chisq, length(s1$n) - 1)