sib-swiss / dsSwissKnifeClient

3 stars 1 forks source link

can't plot result of dssCoxph #2

Closed ciropom closed 2 years ago

ciropom commented 2 years ago

Hello, I'm trying to reproduce your test

https://github.com/sib-swiss/dsSwissKnifeClient/blob/master/tests/testthat/test-dssCoxph.R

on a different dataset. As a dataset I used

library(survival)
head(pbc)

that I saved to CSV and loaded into OPAL.

Then if I execute the following minimal script

logindata <- data.frame(url='..........', server='..........', user='..........',password='..........', 
                        table='testproject.pbc');
                        #table='mixOmics.nutrimouse_gene');
opals <- datashield.login(logins=logindata, assign=TRUE, symbol = 'D')

dsBaseClient::ds.asNumeric(x.name='D$time', newobj='time_num', datasources=opals)
dsBaseClient::ds.asNumeric(x.name='D$status', newobj='status_num', datasources=opals)

time_var <- 'time_num'
output <- 'status_num'
input <- '1'

output <- paste0("survival::Surv(",time_var,", ",output,")")
formula <- paste0(output," ~ ", input)
cox.res <- dsSwissKnifeClient::dssCoxph(formula=formula,
                                        data='D',
                                        datasources=opals)
graphics::plot(cox.res[["............"]]$fit, conf.int = TRUE, col = c('blue', 'red'))

the plot command returns

Error in xy.coords(x, y, xlabel, ylabel, log) : 
  'x' is a list, but does not have components 'x' and 'y'

Can you help me in plotting this cox-plot? thank you

IulianD commented 2 years ago

Hello, at first sight I think you need to use the specific plot implementation for the survival object (which is probably in the survival package). Try the same without the package qualifier - that is, no graphics::plot(cox.res...) but simply plot(cox.res....) and it should dispatch to the proper method. Let me know. Cheers, Iulian

ciropom commented 2 years ago

I'm sorry for the silly question, you are right.