Last updated: 2023-03-11
Checks: 6 1
Knit directory: paperscripts/
This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
The R Markdown file has unstaged changes. To know which version of
the R Markdown file created these results, you’ll want to first commit
it to the Git repo. If you’re still working on the analysis, you can
ignore this warning. When you’re finished, you can run
wflow_publish
to commit the R Markdown file and build the
HTML.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20230311)
was run prior to running
the code in the R Markdown file. Setting a seed ensures that any results
that rely on randomness, e.g. subsampling or permutations, are
reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version e19764b. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for
the analysis have been committed to Git prior to generating the results
(you can use wflow_publish
or
wflow_git_commit
). workflowr only checks the R Markdown
file, but you know if there are other scripts or data files that it
depends on. Below is the status of the Git repository when the results
were generated:
Untracked files:
Untracked: Figs/Fig2/gprs_abs_withleg.tiff
Unstaged changes:
Modified: .DS_Store
Modified: Figs/.DS_Store
Modified: Figs/Fig1/hr_pce.tiff
Modified: Figs/Fig2/gpce_abs.tiff
Modified: Figs/Fig2/gprs_abs.tiff
Deleted: Figs/aucplot.tiff
Modified: analysis/Fig1.Rmd
Modified: analysis/Fig2.Rmd
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were
made to the R Markdown (analysis/Fig2.Rmd
) and HTML
(docs/Fig2.html
) files. If you’ve configured a remote Git
repository (see ?wflow_git_remote
), click on the hyperlinks
in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 7ddb13f | Your Name | 2023-03-11 | Update |
html | 7ddb13f | Your Name | 2023-03-11 | Update |
source("code/utils.R")
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.1 ✔ purrr 0.3.5
✔ tibble 3.1.8 ✔ stringr 1.4.1
✔ tidyr 1.2.1 ✔ forcats 0.5.2
✔ readr 2.1.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
Loading required package: ggpubr
Attaching package: 'survminer'
The following object is masked from 'package:survival':
myeloma
Attaching package: 'reshape'
The following objects are masked from 'package:tidyr':
expand, smiths
The following object is masked from 'package:dplyr':
rename
Attaching package: 'gridExtra'
The following object is masked from 'package:dplyr':
combine
Attaching package: 'survMisc'
The following object is masked from 'package:ggplot2':
autoplot
Attaching package: 'rsq'
The following object is masked from 'package:survMisc':
rsq
Type 'citation("pROC")' for a citation.
Attaching package: 'pROC'
The following object is masked from 'package:survMisc':
ci
The following objects are masked from 'package:stats':
cov, smooth, var
Attaching package: 'data.table'
The following object is masked from 'package:reshape':
melt
The following object is masked from 'package:purrr':
transpose
The following objects are masked from 'package:dplyr':
between, first, last
Attaching package: 'plotly'
The following object is masked from 'package:reshape':
rename
The following object is masked from 'package:ggplot2':
last_plot
The following object is masked from 'package:stats':
filter
The following object is masked from 'package:graphics':
layout
fig_path="./Figs/Fig2/"
df=readRDS("output/amit_df.rds")
dt=df[,c("prs.r","phenos.has_CAD","phenos.enrollment")]
names(dt)=c("x","y","phenos.enrollment")
my <- glm(formula = y~x,data = dt[which(dt$phenos.enrollment<55),],family="binomial")
newdf=data.frame(x=seq(0,1,by=0.01),y=rep(1,101),phenos.enrollment=rep(1,101))
preds <- predict(my, newdata = newdf, type = "response", se.fit = TRUE)
critval <- 1.96 ## approx 95% CI
upr <- preds$fit + (critval * preds$se.fit)
lwr <- preds$fit - (critval * preds$se.fit)
fit <- preds$fit
predy=data.frame(fit,upr,lwr)
rm(preds)
rm(my)
####################
mm <- glm(formula = y~ x #+ phenos.enrollment,
,data = dt[which(dt$phenos.enrollment<65&dt$phenos.enrollment>55),],family="binomial")
preds <- predict(mm, newdata = newdf, type = "response", se.fit = TRUE)
critval <- 1.96 ## approx 95% CI
upr <- preds$fit + (critval * preds$se.fit)
lwr <- preds$fit - (critval * preds$se.fit)
fit <- preds$fit
predm=data.frame(fit,upr,lwr)
rm(preds)
rm(mm)
#########
mo<- glm(formula = y~ x #+ phenos.enrollment,
,data = dt[which(dt$phenos.enrollment>65),],family="binomial")
preds <- predict(mo, newdata = newdf, type = "response", se.fit = TRUE)
critval <- 1.96 ## approx 95% CI
upr <- preds$fit + (critval * preds$se.fit)
lwr <- preds$fit - (critval * preds$se.fit)
fit <- preds$fit
predo=data.frame(fit,upr,lwr)
rm(preds)
rm(mo)
predf=rbind(predy,predm,predo)
## link scale
#predr=exp(predf)/(1+exp(predf))
predr=predf
predr$variable=c(rep("<55",101),rep("55-65",101),rep(">65",101))
predr$x=rep(newdf$x,3)
predr$variable= factor(
predr$variable,
levels = c("<55","55-65",">65"),labels = c(
"<55 years","55-65 years",">65 years"
)
)
gp=ggplot(data=predr, aes(x=x*100, y=fit, ymin=lwr, ymax=upr, color=variable,fill=variable)) +
geom_line(linewidth=2) +
geom_ribbon(alpha=0.3) +
xlab("Polygenic score percentile") +
ylab("Absolute risk of coronary artery disease")+
scale_fill_manual(name="Age Group",values=c("<55"="deepskyblue","55-65"="deepskyblue3",">65"="deepskyblue4"))+
scale_color_manual(name="Age Group",values=c("<55 years"="deepskyblue","55-65 years"="deepskyblue3",">65 years"="deepskyblue4"))+theme_classic(base_size =20)#+theme(legend.position = "null")
ggsave(gp,filename = paste0(fig_path,"gprs_abs_withleg.tiff"),dpi=300,height=6,width = 6)
gp=ggplot(data=predr, aes(x=x*100, y=fit, ymin=lwr, ymax=upr, color=variable,fill=variable)) +
geom_line(linewidth=2) +
geom_ribbon(alpha=0.3) +
xlab("Polygenic score percentile") +
ylab("Absolute risk of coronary artery disease")+
scale_fill_manual(name="Age Group",values=c("<55"="deepskyblue","55-65"="deepskyblue3",">65"="deepskyblue4"))+
scale_color_manual(name="Age Group",values=c("<55 years"="deepskyblue","55-65 years"="deepskyblue3",">65 years"="deepskyblue4"))+theme_classic(base_size =20)+theme(legend.position = "null")
ggsave(gp,filename = paste0(fig_path,"gprs_abs.tiff"),dpi=300,height=6,width = 6)
predy$fit=predy$fit/min(predy$fit)
predy$lwr=predy$lwr/min(predy$lwr)
predy$upr=predy$upr/min(predy$upr)
predm$fit=predm$fit/min(predm$fit)
predm$lwr=predm$lwr/min(predm$lwr)
predm$upr=predm$upr/min(predm$upr)
predo$fit=predo$fit/min(predo$fit)
predo$lwr=predo$lwr/min(predo$lwr)
predo$upr=predo$upr/min(predo$upr)
predr=rbind(predy,predm,predo)
predr$variable=c(rep("<55",101),rep("55-65",101),rep(">65",101))
predr$x=rep(newdf$x,3)
gp=ggplot(data=predr, aes(x=x*100, y=fit, ymin=lwr, ymax=upr, fill=variable,color=variable)) +
geom_line(linewidth=2) +
geom_ribbon(alpha=0.3) +
xlab("Polygenic score percentile") +
ylab("Relative Risk")+
scale_fill_manual(name="Age Group",values=c("<55"="deepskyblue","55-65"="deepskyblue3",">65"="deepskyblue4"))+scale_color_manual(name="Age Group",values=c("<55"="deepskyblue","55-65"="deepskyblue3",">65"="deepskyblue4"))+theme_classic(base_size =20)+theme(legend.position = "null")
ggsave(gp,filename = paste0(fig_path,"gprs_rel.tiff"),dpi=300,height=6,width = 6)
rm(list=ls())
source("code/utils.R")
fig_path="./Figs/Fig2/"
df=readRDS("output/amit_df.rds")
df$ascvd.r=rank(df$ascvd_10y_accaha_all)/length(df$ascvd_10y_accaha_all)
dt=df[,c("ascvd.r","phenos.has_CAD","phenos.enrollment")]
names(dt)=c("x","y","phenos.enrollment")
my <- glm(formula = y~x,data = dt[which(dt$phenos.enrollment<55),],family="binomial")
newdf=data.frame(x=seq(0,1,by=0.01),y=rep(1,101),phenos.enrollment=rep(1,101))
preds <- predict(my, newdata = newdf[c(5:101),], type = "response", se.fit = TRUE)
critval <- 1.96 ## approx 95% CI
upr <- preds$fit + (critval * preds$se.fit)
lwr <- preds$fit - (critval * preds$se.fit)
fit <- preds$fit
predy=data.frame(fit,upr,lwr)
rm(preds)
rm(my)
####################
mm <- glm(formula = y~ x,data = dt[which(dt$phenos.enrollment<65&dt$phenos.enrollment>55),],family="binomial")
preds <- predict(mm, newdata = newdf[c(5:101),], type = "response", se.fit = TRUE)
critval <- 1.96 ## approx 95% CI
upr <- preds$fit + (critval * preds$se.fit)
lwr <- preds$fit - (critval * preds$se.fit)
fit <- preds$fit
predm=data.frame(fit,upr,lwr)
rm(preds)
rm(mm)
#########
mo<- glm(formula = y~ x #+ phenos.enrollment,
,data = dt[which(dt$phenos.enrollment>65),],family="binomial")
## for old, the PCE doesn't start until 0.33
preds <- predict(mo, newdata = newdf[c(34:101),], type = "response", se.fit = TRUE)
critval <- 1.96 ## approx 95% CI
upr <- preds$fit + (critval * preds$se.fit)
lwr <- preds$fit - (critval * preds$se.fit)
fit <- preds$fit
predo=data.frame(fit,upr,lwr)
rm(preds)
rm(mo)
predf=rbind(predy,predm,predo)
## link scale
#predr=exp(predf)/(1+exp(predf))
predr=predf
predr$variable=c(rep("<55",97),rep("55-65",97),rep(">65",68))
predr$x=c(rep(newdf$x[5:101],2),newdf$x[34:101])
predr$variable= factor(
predr$variable,
levels = c(
"<55","55-65",">65"
)
)
gp=ggplot(data=predr, aes(x=x*100, y=fit, ymin=lwr, ymax=upr, fill=variable,color=variable)) +
geom_line(linewidth=3) +
geom_ribbon(alpha=0.3) +
xlab("PCE Percentile") +
ylab("Absolute risk of coronary artery disease")+
scale_fill_manual(name="Age Group",values=c("<55"="deepskyblue","55-65"="deepskyblue3",">65"="deepskyblue4"))+scale_color_manual(name="Age Group",values=c("<55"="deepskyblue","55-65"="deepskyblue3",">65"="deepskyblue4"))+theme_classic(base_size =20)+theme(legend.position = "null")
ggsave(gp,filename = paste0(fig_path,"gpce_abs.tiff"),dpi=300,height=6,width = 6)
predy$fit=predy$fit/min(predy$fit)
predy$lwr=predy$lwr/min(predy$lwr)
predy$upr=predy$upr/min(predy$upr)
predm$fit=predm$fit/min(predm$fit)
predm$lwr=predm$lwr/min(predm$lwr)
predm$upr=predm$upr/min(predm$upr)
predo$fit=predo$fit/min(predo$fit)
predo$lwr=predo$lwr/min(predo$lwr)
predo$upr=predo$upr/min(predo$upr)
predr=rbind(predy,predm,predo)
predr$variable=c(rep("<55",97),rep("55-65",97),rep(">65",68))
predr$variable= factor(
predr$variable,
levels = c(
"<55","55-65",">65"
)
)
predr$x=c(rep(newdf$x[5:101],2),newdf$x[34:101])
gp=ggplot(data=predr, aes(x=x*100, y=fit, ymin=lwr, ymax=upr, fill=variable,color=variable)) +
geom_line(linewidth=3) +
geom_ribbon(alpha=0.3) +
xlab("PCE Percentile") +
ylab("Relative Risk")+
scale_fill_manual(name="Age Group",values=c("<55"="deepskyblue","55-65"="deepskyblue3",">65"="deepskyblue4"))+scale_color_manual(name="Age Group",values=c("<55"="deepskyblue","55-65"="deepskyblue3",">65"="deepskyblue4"))+theme_classic(base_size =20)+theme(legend.position = "null")
ggsave(gp,filename = paste0(fig_path,"gpce_rel.tiff"),dpi=300,height=6,width = 6)
sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur ... 10.16
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] babynames_1.0.1 gapminder_0.3.0 carData_3.0-5 plotly_4.10.0
[5] DT_0.24 gt_0.8.0 RColorBrewer_1.1-3 data.table_1.14.2
[9] pROC_1.18.0 rsq_2.5 survMisc_0.5.6 gridExtra_2.3
[13] ggfortify_0.4.14 reshape_0.8.9 eulerr_6.1.1 survminer_0.4.9
[17] ggpubr_0.4.0 survival_3.4-0 forcats_0.5.2 stringr_1.4.1
[21] purrr_0.3.5 readr_2.1.2 tidyr_1.2.1 tibble_3.1.8
[25] ggplot2_3.4.1 tidyverse_1.3.2 dplyr_1.0.10
loaded via a namespace (and not attached):
[1] googledrive_2.0.0 minqa_1.2.4 colorspace_2.0-3
[4] ggsignif_0.6.4 ellipsis_0.3.2 rprojroot_2.0.3
[7] fs_1.5.2 rstudioapi_0.14 farver_2.1.1
[10] Deriv_4.1.3 fansi_1.0.3 lubridate_1.8.0
[13] xml2_1.3.3 splines_4.2.1 cachem_1.0.6
[16] knitr_1.40 jsonlite_1.8.2 workflowr_1.7.0
[19] nloptr_2.0.3 broom_1.0.1 km.ci_0.5-6
[22] dbplyr_2.2.1 compiler_4.2.1 httr_1.4.4
[25] backports_1.4.1 assertthat_0.2.1 Matrix_1.5-1
[28] fastmap_1.1.0 lazyeval_0.2.2 gargle_1.2.0
[31] cli_3.4.1 later_1.3.0 htmltools_0.5.3
[34] tools_4.2.1 gtable_0.3.1 glue_1.6.2
[37] Rcpp_1.0.9 cellranger_1.1.0 jquerylib_0.1.4
[40] vctrs_0.5.2 nlme_3.1-159 xfun_0.33
[43] lme4_1.1-30 rvest_1.0.3 lifecycle_1.0.3
[46] rstatix_0.7.0 googlesheets4_1.0.1 MASS_7.3-58.1
[49] zoo_1.8-11 scales_1.2.1 ragg_1.2.3
[52] hms_1.1.2 promises_1.2.0.1 yaml_2.3.5
[55] KMsurv_0.1-5 sass_0.4.2 stringi_1.7.8
[58] boot_1.3-28 systemfonts_1.0.4 rlang_1.0.6
[61] pkgconfig_2.0.3 evaluate_0.17 lattice_0.20-45
[64] labeling_0.4.2 htmlwidgets_1.5.4 tidyselect_1.2.0
[67] plyr_1.8.7 magrittr_2.0.3 R6_2.5.1
[70] generics_0.1.3 DBI_1.1.3 pillar_1.8.1
[73] haven_2.5.1 whisker_0.4 withr_2.5.0
[76] abind_1.4-5 modelr_0.1.9 crayon_1.5.2
[79] car_3.1-0 utf8_1.2.2 tzdb_0.3.0
[82] rmarkdown_2.17 grid_4.2.1 readxl_1.4.1
[85] git2r_0.30.1 reprex_2.0.2 digest_0.6.29
[88] xtable_1.8-4 httpuv_1.6.6 textshaping_0.3.6
[91] munsell_0.5.0 viridisLite_0.4.1 bslib_0.4.0