[cph] Error in `[.default`(y, , 3) : subscript out of bounds
0
0
Entering edit mode
4.8 years ago

Hi there, I'm trying to construct nomogram with my cancer data.

this is a summary of my data:

str(train)

'data.frame': 1323 obs. of 25 variables:

$ LYMPH_NODES_EXAMINED_POSITIVE: Factor w/ 3 levels "<=3","<=9",">10": 3 NA 1 2 NA 1 NA 1 3 1 ...

$ CELLULARITY : Factor w/ 3 levels "High","Low","Moderate": NA 1 3 1 3 3 1 3 NA 1 ...

$ MENOPAUSAL_STATE : Factor w/ 2 levels "Post","Pre": 1 2 2 1 1 1 1 1 NA 2 ...

$ ER_STATUS : Factor w/ 2 levels "Negative","Positive": 2 2 2 2 2 2 1 2 2 1 ...

$ OS_MONTHS : num 718 425 822 186 16 816 77 514 NA 821 ...

$ OS_STATUS : Factor w/ 2 levels "DECEASED","LIVING": 2 2 2 1 1 2 1 1 NA 2 ...

$ LATERALITY : Factor w/ 2 levels "Left","Right": 2 2 2 2 1 2 1 1 NA 2 ...

and this is my code:

attach(train);d <- datadist(CELLULARITY, MENOPAUSAL_STATE, ER_STATUS,
 LATERALITY, LYMPH_NODES_EXAMINED_POSITIVE)                   

 options(datadist = 'd')

 train$CELLULARITY <- train$CELLULARITY %>% factor()

 train$MENOPAUSAL_STATE <- train$MENOPAUSAL_STATE %>% factor()

 train$ER_STATUS <- train$ER_STATUS %>% factor()

 train$LATERALITY <- train$LATERALITY %>% factor() 

 train$LYMPH_NODES_EXAMINED_POSITIVE <- train$LYMPH_NODES_EXAMINED_POSITIVE %>% factor() 

 train$OS_MONTHS <- train$OS_MONTHS %>% as.numeric()

 mod.cox <- cph(formula(Surv(OS_MONTHS, OS_STATUS) ~ CELLULARITY + MENOPAUSAL_STATE + ER_STATUS + LATERALITY +LYMPH_NODES_EXAMINED_POSITIVE),
                    data=train, x= TRUE, y= TRUE, surv = TRUE)

Right now, I got the error:

Error in [.default(y, , 3) : subscript out of bounds

I did some researches and found this previous issue and this related, which solved by Prof.Harrelfe. But, It seems not working to me.

Any helps would be appreciated

cph nomogram R • 4.4k views
ADD COMMENT
1
Entering edit mode

At which step you are getting the error? Provide the example data that produces the same error.

General note, your code could be simplified/prettified as:

train <- train %>% 
  mutate(CELLULARITY = factor(CELLULARITY),
         ER_STATUS = factor(ER_STATUS),
         etc...
         )

Also, read about mutate_at and mutate_if.

ADD REPLY
1
Entering edit mode

or indeed, train %>% mutate_at(c("CELLULARITY", "MENOPAUSAL_STATUS", ...), factor) %>% mutate(as.numeric(OS_MONTHS))

ADD REPLY
0
Entering edit mode
 mod.cox <- cph(formula(Surv(OS_MONTHS, OS_STATUS) ~ CELLULARITY + MENOPAUSAL_STATE + ER_STATUS + LATERALITY +LYMPH_NODES_EXAMINED_POSITIVE),
                    data=train, x= TRUE, y= TRUE, surv = TRUE)

this step i'm getting one. and this is the example data: https://drive.google.com/open?id=1Bi9nfg34eByc5H1Bmmq43dz6O8lEaj5O

Many thanks for helping me!

ADD REPLY
1
Entering edit mode

find out what is throwing the error: use debug(cph) , then make your cph call as above, and step through the interactive debugger (as described here https://adv-r.hadley.nz/debugging.html#browser), then if it actually is a bug, and not just some inappropriate data that you've passed in (the most likely case), send an issue to the relevant bug tracker for cph or whichever dependency is bugged out. (But make a small reproducible example that captures the bug if you do post an issue to bioconductor or github)

ADD REPLY
0
Entering edit mode

This is my fault. the error is solved well

ADD REPLY
0
Entering edit mode

Could you summarise what solved the error, in case it happens to anyone else.

ADD REPLY

Login before adding your answer.

Traffic: 1962 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