Last updated: 2023-02-23

Checks: 6 1

Knit directory: multistate/

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(20230211) 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 28318c8. 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:  .Rhistory
    Untracked:  analysis/figure/

Unstaged changes:
    Modified:   .DS_Store
    Modified:   analysis/modeglm.Rmd
    Modified:   analysis/plots.Rmd
    Modified:   code/fulla.R
    Modified:   data/a3.rds

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/plots.Rmd) and HTML (docs/plots.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 e04d656 Your Name 2023-02-17 update
Rmd b960902 Your Name 2023-02-16 Update
Rmd dbae012 Your Name 2023-02-15 Update
html dbae012 Your Name 2023-02-15 Update

R Markdown

Here we examine the curves by PRS level for CAD by PRS strata:

library(survival)
library(survminer)
Loading required package: ggplot2
Loading required package: ggpubr

Attaching package: 'survminer'
The following object is masked from 'package:survival':

    myeloma
library(ggplot2)
library(data.table)

df_final = data.table(readRDS("~/Dropbox/pheno_dir/output/merged_pheno_censor_final.rds"))

fit <- survfit(Surv(Cad_0_censor_age, ifelse(df_final$Cad_0_Any==2,1,0)) ~cad.prs.lev, data=df_final, id=identifier)

#Survival
ggsurvplot(fit,
           conf.int = TRUE,
           ggtheme = theme_classic(base_size =20)) 

Version Author Date
dbae012 Your Name 2023-02-15
gs=ggsurvplot(fit,
           conf.int = TRUE,
           ggtheme = theme_classic(base_size =20),fun = "cumhaz") 

Plot mean PRS by age:

library("dplyr")

Attaching package: 'dplyr'
The following objects are masked from 'package:data.table':

    between, first, last
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
df_final$age.cat[df_final$Cad_0_Any==2]=round(df_final$Cad_0_censor_age[df_final$Cad_0_Any==2]/5,0)
d=df_final[df_final$Cad_0_Any==2]%>%group_by(age=round(Cad_0_censor_age/5,0))%>%summarise(cad.mean=mean(cad.prs),sd.cad=sd(na.omit(cad.prs))/sqrt(length(cad.prs)),htn.mean=mean(htn.prs),sd.htn=sd(na.omit(htn.prs))/sqrt(length(cad.prs)),ldl.mean=mean(ldl.prs),sd.ldl=sd(na.omit(ldl.prs))/sqrt(length(cad.prs)),dm2.mean=mean(dm2.prs),sd.dm=sd(na.omit(dm2.prs))/sqrt(length(cad.prs)))
df=data.frame(d[5:18,])

names(df)=c("age","mean","sem","mean","sem","mean","sem","mean","sem")

m=rbind(rbind(rbind(df[,c(1,2,3)],df[,c(1,4,5)]),df[,c(1,6,7)]),df[,c(1,8,9)])

#m$variable=c(rep("CAD",61),rep("HTN",61),rep("LDL",61),rep("DM",61))

m$variable=c(rep("CAD",14),rep("HTN",14),rep("LDL",14),rep("DM",14))
m$age=rep(c(22,27,32,37,42,47,52,57,62,67,72,77,82,85),4)
ggplot(m, aes(color=variable, y=mean, x=age))+xlab("Age of Event") +
  ylab("Mean PRS")+
  geom_errorbar(aes(ymin=mean-sem, ymax=mean+sem), width=.2,size=0.5, position=position_dodge(1)) +
  geom_point(position = position_dodge(1)) +
  expand_limits(y=0) +
  scale_y_continuous(expand=expand_scale(mult=c(0,0.02))) +
  theme_classic()
Warning: `expand_scale()` is deprecated; use `expansion()` instead.

c=df_final[df_final$Cad_0_Any==2]%>%group_by(age=round(Cad_0_censor_age,0))%>%summarise(events=length(Cad_0_censor_age))

ggplot(c[20:80,], aes(x=age, y=events))+geom_bar(position='dodge', stat='identity')+xlab("Age of Event")+ylab("Number of Events")+theme_classic(base_size =20)


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] dplyr_1.0.10      data.table_1.14.2 survminer_0.4.9   ggpubr_0.4.0     
[5] ggplot2_3.3.6     survival_3.4-0   

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9       lattice_0.20-45  tidyr_1.2.1      zoo_1.8-11      
 [5] assertthat_0.2.1 rprojroot_2.0.3  digest_0.6.29    utf8_1.2.2      
 [9] R6_2.5.1         backports_1.4.1  evaluate_0.17    highr_0.9       
[13] pillar_1.8.1     rlang_1.0.6      rstudioapi_0.14  whisker_0.4     
[17] car_3.1-0        jquerylib_0.1.4  Matrix_1.5-1     rmarkdown_2.17  
[21] labeling_0.4.2   splines_4.2.1    stringr_1.4.1    munsell_0.5.0   
[25] broom_1.0.1      compiler_4.2.1   httpuv_1.6.6     xfun_0.33       
[29] pkgconfig_2.0.3  htmltools_0.5.3  tidyselect_1.2.0 tibble_3.1.8    
[33] gridExtra_2.3    km.ci_0.5-6      workflowr_1.7.0  fansi_1.0.3     
[37] withr_2.5.0      later_1.3.0      grid_4.2.1       jsonlite_1.8.2  
[41] xtable_1.8-4     gtable_0.3.1     lifecycle_1.0.3  DBI_1.1.3       
[45] git2r_0.30.1     magrittr_2.0.3   KMsurv_0.1-5     scales_1.2.1    
[49] cli_3.4.1        stringi_1.7.8    cachem_1.0.6     carData_3.0-5   
[53] farver_2.1.1     ggsignif_0.6.4   fs_1.5.2         promises_1.2.0.1
[57] bslib_0.4.0      survMisc_0.5.6   generics_0.1.3   vctrs_0.4.2     
[61] tools_4.2.1      glue_1.6.2       purrr_0.3.5      abind_1.4-5     
[65] fastmap_1.1.0    yaml_2.3.5       colorspace_2.0-3 rstatix_0.7.0   
[69] knitr_1.40       sass_0.4.2