Question: How To Isolate The P-Value When Doing Survival Analysis Using The Coxph Package In Bioconductor.
2
moranr270 wrote:

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 • 12k views
modified 7.7 years ago by Istvan Albert ♦♦ 85k • written 7.7 years ago by moranr270
7
zx87549.7k wrote:

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
...
``````
2

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

Thanks :)

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.

3

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