This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Isolate The P-Value When Doing Survival Analysis Using The Coxph Package In Bioconductor.

Hi,

I have done survival analysis on a gene, using the coxph call and saved it in a variable a. I know i can do summary(a) and get a return with the coef, exp(coef), se(coef) and power- p-value. I want to take JUST the p-value out of a to put into a a matrix.

So essentially is there a way of accessing just the p-value form a coxph object , e.g. coefVal <- a$coef gives me the coef value.. ?

Thanks, R

r bioconductor

1 answer

Assign coef summary to a variable

coeffs <- coef(summary(a))

coeffs should be something like this:

Estimate  Std.    Error    z    value    Pr(>|z|)
(Intercept)    -3.86370076    0.71438758    -5.40840977    6.358681e-08
A    20.62019096    264.13705493    0.07806626    9.377753e-01
B    4.00226650    0.71574200    5.59177257    2.247631e-08
C    4.50171396    0.71849626    6.26546610    3.717119e-10
...

Subset 4th column as P is 4th column in this example:

as.matrix(coeffs[,4])
    [,1]
(Intercept)    6.358681e-08
A    9.377753e-01
B    2.247631e-08
C    3.717119e-10
...

Thank you, It was so frustrating as it should be very simple, I am not experienced in R and sometimes the simplest things can leave me baffled. Thank you this really helps me learn.

A very useful function to help sort out complex data structures is the str() function applied to the object in question.

Thanks very much , Ill read about this.

I was banging my head for half an hour and this saved my day :)

Thanks :)

Log in to answer this question.