Git Product home page Git Product logo

cureit's People

Contributors

karissawhiting avatar tengfei-emory avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

cureit's Issues

Allow `cureit()` function to accept multiple timepoints to be displayed in nomogram

library(ISwR)
library(tidyverse)
library(cureit)

mel <- ISwR::melanom %>%
  mutate(status = case_when(status %in% c(1, 3) ~ 1, 
                            TRUE ~ 0)) %>%
  mutate(thick_cat = 
           case_when(thick <= 129 ~ "less equal 129", 
                     thick <= 322 ~ "less equal 322", 
                     thick > 322 ~ "greater 322")) %>%
  mutate(thick_cat = fct_relevel(thick_cat, "≤ 129", "≤ 322")) %>%
  mutate(sex = case_when(sex == 2 ~ "male", 
                         sex == 1 ~ "female"),
         ulc = case_when(ulc == 1 ~ "present", 
                         ulc == 2 ~ "absent"))

x <- cureit(surv_formula = Surv(days, status) ~ ulc + sex + thick_cat + thick,
            cure_formula = ~ ulc + sex, data = mel)
nomogram.cureit(x,time=300)
predict(x,times=c(100,300)

One thing we can further add is to allow the nomogram.cureit function to take more than one time point, so that survival probabilities at multiple times can be generated on the nomogram.

Error in if (type == "factor") { : argument is of length zero

Greetings, I encountered a quandary whilst executing the program. Upon meticulous examination of my data, all appears to be in order, devoid of discrepancies. Might I inquire as to the location of the error within my code?

mydata=read.table('huizong11.txt',sep = '\t',header = T)
mydata$CEA=as.numeric(mydata$CEA)
mydata$CEA2=as.factor(mydata$CEA2)
mydata$CA125=as.numeric(mydata$CA125)
mydata$CA1252=as.factor(mydata$CA1252)
mydata$cyfra211=as.numeric(mydata$cyfra211)
mydata$cyfra2112=as.factor(mydata$cyfra2112)
mydata$diameter=as.numeric(mydata$diameter)
mydata$diameter2=as.factor(mydata$diameter2)
mydata$LVI=as.factor(mydata$LVI)
mydata$disease=as.factor(mydata$disease)
mydata$symptom=as.factor(mydata$symptom)
mydata$smoke=as.factor(mydata$smoke)
mydata$surgery1=as.factor(mydata$surgery1)
mydata$age=as.numeric(mydata$age)
mydata$age1=as.factor(mydata$age1)
mydata$sex=as.factor(mydata$sex)
mydata$subtype4=as.factor(mydata$subtype4)
mydata$wei1<-as.factor(mydata$wei1)
mydata$wei2<-as.factor(mydata$wei2)
mydata$wei2.1<-as.factor(mydata$wei2.1)
mydata$local<-as.factor(mydata$local)
mydata$nian<-as.factor(mydata$nian)
mydata$NLR<-as.numeric(mydata$NLR)
mydata$PLR<-as.numeric(mydata$PLR)
mydata$recrudescence1<-as.numeric(mydata$recrudescence1)
mydata$PFS<-as.numeric(mydata$PFS)
library(cureit)
library(ROCR)
library(evacure)
library(MASS)
str(mydata)
'data.frame': 1064 obs. of 27 variables:
$ num : int 670 673 678 682 683 686 692 729 730 732 ...
$ CEA : num 2.15 0.27 0.2 2.2 0.9 3.3 1.4 2.7 1.7 0.91 ...
$ CEA2 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
$ CA125 : num 7.84 1.95 4.32 5.78 5.9 ...
$ CA1252 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 2 1 1 1 ...
$ cyfra211 : num 0.47 0.1 0.51 3.45 6.02 5.12 0.59 3.2 4.49 0.15 ...
$ cyfra2112 : Factor w/ 2 levels "0","1": 1 1 1 2 2 2 1 1 2 1 ...
$ nian : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
$ diameter : num 0.6 1.1 0.9 0.9 2.6 1.8 0.8 1 1.4 1.6 ...
$ diameter2 : Factor w/ 3 levels "0","1","2": 1 2 1 1 3 2 1 1 2 2 ...
$ LVI : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
$ disease : Factor w/ 2 levels "0","1": 1 2 1 1 2 1 1 2 2 1 ...
$ symptom : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 2 1 1 ...
$ smoke : Factor w/ 2 levels "0","1": 1 2 1 1 1 1 1 1 1 1 ...
$ surgery1 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 2 2 2 2 ...
$ age : num 74 70 60 55 81 68 41 70 81 76 ...
$ age1 : Factor w/ 2 levels "0","1": 2 2 2 1 2 2 1 2 2 2 ...
$ sex : Factor w/ 2 levels "0","1": 2 2 1 2 2 1 1 1 2 1 ...
$ subtype4 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
$ wei1 : Factor w/ 2 levels "0","1": 1 1 1 1 2 1 1 1 1 1 ...
$ wei2 : Factor w/ 2 levels "0","1": 1 1 1 1 2 1 1 1 1 1 ...
$ wei2.1 : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
$ local : Factor w/ 5 levels "1","2","3","4",..: 4 4 1 3 3 4 4 4 3 5 ...
$ NLR : num 1.7 1.7 0.9 1.8 2.9 1.1 2.6 1.9 1.8 0.8 ...
$ PLR : num 126.8 122.2 71.2 205.9 118.1 ...
$ recrudescence1: num 0 0 0 0 0 0 0 0 0 0 ...
$ PFS : num 66 79 69 66 80 78 107 80 105 122 ...
mydata$PFS=as.numeric(mydata$PFS)
p<-cureit(

  • surv_formula=Surv(PFS,recrudescence1==1)~CEA+diameter+cyfra211+CA125+age,
  • cure_formula=~CEA+diameter+cyfra211+CA125+age,
  • offset = NULL,
  • data=mydata
  • na.action = na.omit,

  • model = c("ph"),

  • link = "logit"

  • Var = TRUE,

  • emmax = 50,

  • eps = 1e-07,

  • nboot = 100,

  • n_post = 100,

  • init = NULL,

  • em = "smcure",

  • cutpoint = c(0.1,0.25, 0.5, 0.75, 0.9),

  • eva_model = NULL,

  • est_type = "EM",

  • posterior = TRUE

  • )
    Warning message:
    0 of 100 did not converge.

.calc_k_index(p)
[1] 0.5450771
nomogram(x = p,time=30)
Error in if (type == "factor") { : argument is of length zero

Update smcure() function

  • Update the smcure::smcure() function to save the bootstrap iterations. This will allow us to use these bootstraps to calculate Brier score. (Evacure package has done this already but we may want to keep changes to a minimum: https://github.com/elong0527/evacure/blob/master/R/smcure1.R) - @tengfei-emory
  • Look into improving error/warning message on em() function. Right now you get errors or warnings with bootstraps (example coming soon)- @karissawhiting

A certain way of resampling data often causes warning or even an error of the Cox submodel in the cure model. This essentially means the more bootstrap runs we generate, the higher chance of observing a warning or getting an error.

  • Once function has been updated, submit issue/PR with suggestion to smcure package authors

Is it possible to incorporate calibration curves and add evaluation metrics for the test set?

Greetings, as a medical student, I am greatly intrigued by the mix cure model. The Cureit package, which enriches the smcure function with evaluation metrics and visualization capabilities, is an invaluable R package. However, these evaluations pertain solely to the training set, with no apparent consideration for the test set. I am curious about how to apply the predict function to the mix cure model.

To-dos

  • - finish generalizing/cleaning nomogram code
  • - allow different variables in cure portion and survival portion
  • - allow use of averaged coefficients in graphical nomogram (right now it just renders based on a single model run)
  • - add functions to calc/clean/display K and C indexes

Nomogram issues

  1. Continuous variable is not scaled by sc on the nomogram
  2. No total points scale on the nomogram
  3. Need to double check how lp is scaled: what's the theoretical maximum and minimum of lp? Is it necessary to get the range of lp from real data?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.