Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
karissawhiting committed Jan 15, 2021
1 parent d816896 commit 7c6fc6c
Show file tree
Hide file tree
Showing 26 changed files with 502 additions and 97 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
^README\.Rmd$
4 changes: 2 additions & 2 deletions .Rproj.user/A70D84A5/sources/prop/193C080D
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"cursorPosition": "31,0",
"scrollLine": "10"
"cursorPosition": "41,13",
"scrollLine": "20"
}
5 changes: 5 additions & 0 deletions .Rproj.user/A70D84A5/sources/prop/1ECE0E8B
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tempName": "Untitled1",
"cursorPosition": "7,15",
"scrollLine": "0"
}
4 changes: 2 additions & 2 deletions .Rproj.user/A70D84A5/sources/prop/61673941
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"
}
5 changes: 5 additions & 0 deletions .Rproj.user/A70D84A5/sources/prop/6B2DD538
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tempName": "Untitled1",
"cursorPosition": "7,15",
"scrollLine": "0"
}
5 changes: 5 additions & 0 deletions .Rproj.user/A70D84A5/sources/prop/DF2C1924
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cursorPosition": "20,114",
"scrollLine": "17",
"source_window_id": ""
}
3 changes: 3 additions & 0 deletions .Rproj.user/A70D84A5/sources/prop/INDEX
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
~%2FRepositories%2Fcure-pipeline%2F.gitignore.R="1ECE0E8B"
~%2FRepositories%2Fcure-pipeline%2F.gitignore.txt="6B2DD538"
~%2FRepositories%2Fcure-pipeline%2FR%2Fcalibration-curve.R="DDEF45DE"
~%2FRepositories%2Fcure-pipeline%2FR%2Fclean-model-results.R="369CE3C2"
~%2FRepositories%2Fcure-pipeline%2FR%2Fcure-nomo-multi-var.R="0D44D543"
Expand All @@ -7,4 +9,5 @@
~%2FRepositories%2Fcure-pipeline%2FR%2Fmodel-fitting.R="61673941"
~%2FRepositories%2Fcure-pipeline%2FR%2Fnomogram.R="3A458D42"
~%2FRepositories%2Fcure-pipeline%2FR%2Fstability-tests.R="B4356C36"
~%2FRepositories%2Fcure-pipeline%2FREADME.Rmd="DF2C1924"
~%2FRepositories%2Fcure-pipeline%2Fexample.R="5F8A5441"
8 changes: 4 additions & 4 deletions .Rproj.user/A70D84A5/sources/s-D23FE8C5/1E1A0339
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"relative_order": 9,
"properties": {
"tempName": "Untitled1",
"cursorPosition": "95,29",
"scrollLine": "84"
"cursorPosition": "91,0",
"scrollLine": "85"
},
"folds": "",
"lastKnownWriteTime": 1610686360,
"lastKnownWriteTime": 1610688000,
"encoding": "UTF-8",
"collab_server": "",
"source_window": "",
"last_content_update": 1610686360971,
"last_content_update": 1610688000193,
"read_only": false,
"read_only_alternatives": []
}
27 changes: 2 additions & 25 deletions .Rproj.user/A70D84A5/sources/s-D23FE8C5/1E1A0339-contents
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Functions to Run Cure Models (Once or Multiple Times) ------------------------
# ------------------------------------------------------------------------------

source(here::here("R", "clean-model-results.R"))

# Single Model Run -------------------------------------------------------------
# Wrapper function for smcure to accept multi-level variables and save necessary
Expand Down Expand Up @@ -96,6 +95,8 @@ multiple_mod_runs <- function(formula,
num_repeats = 10,
data = mel) {

source(here::here("R", "clean-model-results.R"))

# pull original variables from formula
mf <- formula
mf <- eval(mf, parent.frame())
Expand Down Expand Up @@ -235,28 +236,4 @@ multiple_mod_runs <- function(formula,
}


# Examples

# data <- ISwR::melanom %>%
# mutate(status = case_when(status %in% c(1, 3) ~ 1,
# TRUE ~ 0)) %>%
# mutate(sex = case_when(sex == 2 ~ "male",
# sex == 1 ~ "female"),
# ulc = case_when(ulc == 1 ~ "present",
# ulc == 2 ~ "absent"))
#
# formula <- Surv(days, status) ~ ulc + sex
#
# x <- multiple_mod_runs(formula,
# nboot = 200,
# eps = 0.0001,
# num_repeats = 3,
# data = data)
# x$model_results
#
# x$var_surv_stab
# x$p_surv_stab
#
# x$var_cure_stab
# x$p_cure_stab

25 changes: 0 additions & 25 deletions .Rproj.user/A70D84A5/sources/s-D23FE8C5/7C2EB88F

This file was deleted.

25 changes: 25 additions & 0 deletions .Rproj.user/A70D84A5/sources/s-D23FE8C5/868C082D
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": []
}
18 changes: 18 additions & 0 deletions .Rproj.user/A70D84A5/sources/s-D23FE8C5/868C082D-contents
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))
}
25 changes: 25 additions & 0 deletions .Rproj.user/A70D84A5/sources/s-D23FE8C5/91B9DCD1
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": []
}
80 changes: 80 additions & 0 deletions .Rproj.user/A70D84A5/sources/s-D23FE8C5/91B9DCD1-contents
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

```


43 changes: 43 additions & 0 deletions .Rproj.user/A70D84A5/sources/s-D23FE8C5/CD6407BC-contents
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
10 changes: 5 additions & 5 deletions .Rproj.user/A70D84A5/sources/s-D23FE8C5/E5780712
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
"type": "r_source",
"hash": "0",
"contents": "",
"dirty": true,
"dirty": false,
"created": 1610686895894.0,
"source_on_save": false,
"relative_order": 5,
"properties": {
"cursorPosition": "31,0",
"scrollLine": "10"
"cursorPosition": "41,13",
"scrollLine": "20"
},
"folds": "",
"lastKnownWriteTime": 1610687370,
"lastKnownWriteTime": 1610688082,
"encoding": "UTF-8",
"collab_server": "",
"source_window": "",
"last_content_update": 1610687388996,
"last_content_update": 1610688082743,
"read_only": false,
"read_only_alternatives": []
}
Loading

0 comments on commit 7c6fc6c

Please sign in to comment.