How To Isolate The P-Value When Doing Survival Analysis Using The Coxph Package In Bioconductor.
1
2
Entering edit mode
11.7 years ago
moranr ▴ 290

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 • 14k views
ADD COMMENT
7
Entering edit mode
11.7 years ago
zx8754 12k

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
...
ADD COMMENT
2
Entering edit mode

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

Thanks :)

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
3
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Thanks very much , Ill read about this.

ADD REPLY

Login before adding your answer.

Traffic: 2572 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6