Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create_patients() now samples patient age and gender in addition to m…
…utation status
- Loading branch information
Showing
35 changed files
with
488 additions
and
154 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
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
Binary file not shown.
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 @@ | ||
age_bot,age_top,percentage0,19,020,34,0.0235,44,145,54,7.455,64,21.765,74,33.475,84,26.885,Inf,9.4 | ||
|
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,51 @@ | ||
rm(list = ls()) | ||
library("data.table") | ||
library("ggplot2") | ||
theme_set(theme_bw()) | ||
|
||
# Age distribution table | ||
# Source: https://seer.cancer.gov/archive/csr/1975_2010/results_merged/topic_med_age.pdf | ||
age_dist <- fread("age-distribution.csv") | ||
age_dist[, age_top := ifelse(is.infinite(age_top), 100, age_top)] | ||
age_dist[, age_cat := paste0(age_bot, " - ", age_top)] | ||
age_dist[, age_cat := ifelse(age_bot == 85, "85+", age_cat)] | ||
age_dist[, age_cat := factor(age_cat)] | ||
age_dist[, prop := percentage/100] | ||
age_dist[, age_mid := (age_top - age_bot)/2 + age_bot] | ||
age_mean <- weighted.mean(x = age_dist$age_mid, w = age_dist$prop) | ||
print(paste0("Mean age: ", age_mean)) | ||
age_var <- sum(age_dist$prop * (age_dist$age_mid - age_mean)^2) | ||
age_sd <- sqrt(age_var) | ||
attr(age_dist, "mean") <- age_mean | ||
attr(age_dist, "sd") <- age_sd | ||
|
||
# A barplot to examine the distribution | ||
p <- ggplot(age_dist, aes(x = age_cat, y = prop)) + | ||
geom_bar(stat = "identity", fill = "lightblue", color = "blue") + xlab("Age category") + | ||
ylab("Proportion") | ||
ggsave("figs/age-barplot.pdf", p, width = 5, height = 7) | ||
|
||
# Can we replicate the distribution using a normal distribution? | ||
sim_data <- vector(mode = "list", length = nrow(age_dist)) | ||
for (i in 1:length(sim_data)){ | ||
sim_data[[i]] <- runif(1000 * age_dist[i]$prop, | ||
age_dist[i]$age_bot, | ||
age_dist[i]$age_top) | ||
} | ||
sim_data <- unlist(sim_data) | ||
sim_data <- data.table(age = c(sim_data)) | ||
|
||
p <- ggplot(sim_data, aes(x = age)) + | ||
geom_histogram(aes(y = ..density..), fill = "lightblue", color = "blue") + | ||
stat_function(data = age_dist, | ||
mapping = aes(x = age_mid), | ||
fun = dnorm, | ||
args = list(mean = age_mean, sd = age_sd), | ||
col = "red") | ||
ggsave("figs/age-density.pdf", p, width = 5, height = 7) | ||
|
||
|
||
# Save | ||
setcolorder(age_dist, c("age_cat", "age_bot", "age_top", "age_mid", "percentage", "prop")) | ||
age_dist[, percentage := NULL] | ||
save(age_dist, file = "../data/age_dist.rda", compress = "bzip2") |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file modified
BIN
-463 Bytes
(100%)
docs/articles/tutorial_files/figure-html/ae_probs_plot-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.51 KB
(97%)
docs/articles/tutorial_files/figure-html/mcda-prob-rank-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.39 KB
(100%)
docs/articles/tutorial_files/figure-html/mcda-total-value-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.28 KB
(95%)
docs/articles/tutorial_files/figure-html/mcda-total-value-decompose-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+221 Bytes
(100%)
docs/articles/tutorial_files/figure-html/pfs_os_curves-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+129 Bytes
(100%)
docs/articles/tutorial_files/figure-html/pfs_os_quantiles-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.