-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d816896
commit 7c6fc6c
Showing
26 changed files
with
502 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
^README\.Rmd$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"cursorPosition": "31,0", | ||
"scrollLine": "10" | ||
"cursorPosition": "41,13", | ||
"scrollLine": "20" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"tempName": "Untitled1", | ||
"cursorPosition": "7,15", | ||
"scrollLine": "0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"tempName": "Untitled1", | ||
"cursorPosition": "95,29", | ||
"scrollLine": "84" | ||
"cursorPosition": "91,0", | ||
"scrollLine": "85" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"tempName": "Untitled1", | ||
"cursorPosition": "7,15", | ||
"scrollLine": "0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cursorPosition": "20,114", | ||
"scrollLine": "17", | ||
"source_window_id": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"id": "868C082D", | ||
"path": "~/Repositories/cure-pipeline/R/clean-model-results.R", | ||
"project_path": "R/clean-model-results.R", | ||
"type": "r_source", | ||
"hash": "0", | ||
"contents": "", | ||
"dirty": false, | ||
"created": 1610687727650.0, | ||
"source_on_save": false, | ||
"relative_order": 6, | ||
"properties": { | ||
"tempName": "Untitled1", | ||
"cursorPosition": "18,0", | ||
"scrollLine": "0" | ||
}, | ||
"folds": "", | ||
"lastKnownWriteTime": 1610677076, | ||
"encoding": "UTF-8", | ||
"collab_server": "", | ||
"source_window": "", | ||
"last_content_update": 1610677076, | ||
"read_only": false, | ||
"read_only_alternatives": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
# Clean Model Results ---------------------------------------------------------- | ||
mmcure <- function(fit_k2_cat) { | ||
enframe(fit_k2_cat$b) %>% | ||
left_join(enframe(fit_k2_cat$b_pvalue), | ||
by = "name") %>% | ||
transmute(name, | ||
value = round(exp(value.x), 2), | ||
pvalue = round(value.y, 2)) | ||
} | ||
|
||
mmsurv <- function(fit_k2_cat) { | ||
enframe(fit_k2_cat$beta) %>% | ||
left_join(enframe(fit_k2_cat$beta_pvalue), by = "name") %>% | ||
transmute(name, | ||
value = round(exp(value.x), 2), | ||
pvalue = round(value.y, 2)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"id": "91B9DCD1", | ||
"path": "~/Repositories/cure-pipeline/README.Rmd", | ||
"project_path": "README.Rmd", | ||
"type": "r_markdown", | ||
"hash": "2669428527", | ||
"contents": "", | ||
"dirty": false, | ||
"created": 1610688405206.0, | ||
"source_on_save": false, | ||
"relative_order": 7, | ||
"properties": { | ||
"cursorPosition": "20,114", | ||
"scrollLine": "17", | ||
"source_window_id": "" | ||
}, | ||
"folds": "", | ||
"lastKnownWriteTime": 1610690234, | ||
"encoding": "UTF-8", | ||
"collab_server": "", | ||
"source_window": "", | ||
"last_content_update": 1610690234968, | ||
"read_only": false, | ||
"read_only_alternatives": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
output: github_document | ||
--- | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
```{r, include = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>", | ||
fig.path = "man/figures/README-", | ||
out.width = "100%" | ||
) | ||
``` | ||
|
||
# Cure Model Pipeline | ||
|
||
<!-- badges: start --> | ||
<!-- badges: end --> | ||
|
||
The goal of this package is to provide an easy way to build, evaluate and visualize mixture cure models ([link to paper draft](https://docs.google.com/document/d/1Lhom9H7Hxb8_C6d55Trs9JHSfJCn1i6yuu_xsDyYqZQ/edit?usp=sharing)) | ||
|
||
|
||
## Available Functions | ||
|
||
- `fit_cure()` - wrapper for `smcure::smcure()` function that allows you to pass multilevel variables as factors directly (instead of first creating dummy codes). It also saves outputs necessary to create nomogram. | ||
- `nomogram()-` - accepts an object created by `fit_cure()` and creates graphical nomogram based on model fit | ||
- `cure_calibration()` - accepts an object created by `fit_cure()` and creates a calibration curve for uncured patients | ||
- `multiple_mod_runs()`- allows you to check stability of models but running them multiple times and viewing distributions of variables and p-values. | ||
- Coming soon: | ||
- k-index and C-index wrapper functions | ||
- tidyr function to better clean/view coefficients from cure model | ||
|
||
## Example | ||
|
||
```{r, eval = FALSE} | ||
library(smcure) | ||
library(ISwR) | ||
library(gtsummary) | ||
library(tidyverse) | ||
|
||
# Prepare Data -------------------------- | ||
mel <- ISwR::melanom %>% | ||
mutate(status = case_when(status %in% c(1, 3) ~ 1, | ||
TRUE ~ 0)) %>% | ||
mutate(thick_cat = | ||
case_when(thick <= 129 ~ "≤ 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")) | ||
|
||
# Run Pipeline -------------------------- | ||
fit <- fit_cure(formula = Surv(days, status) ~ ulc + sex + thick_cat + thick , | ||
data = mel) | ||
cure_nomogram(fit, prediction_time = 300) | ||
cure_calibration(fit, prediction_time = 300) | ||
|
||
|
||
# Check Stability ---- | ||
formula <- Surv(days, status) ~ ulc + sex | ||
x <- multiple_mod_runs(formula, | ||
nboot = 200, | ||
eps = 0.0001, | ||
num_repeats = 3, | ||
data = mel) | ||
x$model_results | ||
|
||
x$var_surv_stab | ||
x$p_surv_stab | ||
|
||
x$var_cure_stab | ||
x$p_cure_stab | ||
|
||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# ignore R data files | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
.rds | ||
.Ruserdata | ||
.Rapp.history | ||
.Rhistory.RData | ||
|
||
# Temporary files created by R markdown | ||
*.utf8.md | ||
*.knit.md | ||
|
||
# ignore other types of data files | ||
*.xlsx | ||
*.xls | ||
*.csv | ||
*.dta | ||
*.sas7bdat | ||
*.sav | ||
*.txt | ||
|
||
# ignore data folder/symbolic link/sensitive file | ||
data | ||
admin | ||
raw-data | ||
secure_data | ||
ext_data | ||
tmp | ||
env.json | ||
archives | ||
outputs/archive | ||
|
||
# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 | ||
.httr-oauth | ||
|
||
# ignore misc files | ||
~$*.docx | ||
~$*.xlsx | ||
~$*.pptx | ||
~$*.tmp | ||
Thumbs.db | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.