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 is untracked by Git. 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 b7ec3d3. 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:  .DS_Store
    Untracked:  Figs/
    Untracked:  analysis/.DS_Store
    Untracked:  analysis/Fig1.Rmd
    Untracked:  analysis/Fig2.Rmd
    Untracked:  analysis/Fig3.Rmd
    Untracked:  analysis/Fig4.Rmd
    Untracked:  analysis/Fig5.Rmd
    Untracked:  analysis/generation_rawfiles/
    Untracked:  analysis/table1.Rmd
    Untracked:  code/TextXX.R
    Untracked:  code/utils.R
    Untracked:  output/.DS_Store
    Untracked:  output/AUC.csv
    Untracked:  output/PVE_fhs.csv
    Untracked:  output/PVE_ukb.csv
    Untracked:  output/amit_df.rds
    Untracked:  output/fh_full.rds
    Untracked:  output/fh_prs.rds
    Untracked:  output/hazards_fhs.rds
    Untracked:  output/hazards_fhs_EQ.rds
    Untracked:  output/hazards_rate_UKB_amit.rds
    Untracked:  output/hazards_rate_UKB_amit_EQ.rds
    Untracked:  output/hazards_rate_lowerbound_amit.rds
    Untracked:  output/hazards_rate_lowerbound_amit_EQ.rds
    Untracked:  output/hazards_rate_lowerbound_fh.rds
    Untracked:  output/hazards_rate_lowerbound_fh_EQ.rds
    Untracked:  output/hazards_rate_upperbound_amit.rds
    Untracked:  output/hazards_rate_upperbound_amit_EQ.rds
    Untracked:  output/hazards_rate_upperbound_fh.rds
    Untracked:  output/hazards_rate_upperbound_fh_EQ.rds
    Untracked:  output/hr_all.xls
    Untracked:  output/hrindex.csv
    Untracked:  output/hrindex_FHs.csv
    Untracked:  output/hrindex_UKB.csv
    Untracked:  output/output/
    Untracked:  output/proportions_table.csv

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.


There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.


Here we plot table 1

library(table1)

Attaching package: 'table1'
The following objects are masked from 'package:base':

    units, units<-
df=readRDS("output/amit_df.rds")
dat=df

dat$age=df$phenos.enrollment
dat$dm    <- factor(dat$prev_disease_dm, levels=0:1, labels=c("None", "Diabetes Mellitus"))
dat$sex     <- factor(dat$sex, levels=c("male", "female"), labels=c("Male", "Female"))
dat$prscat  <- factor(dat$prscat,  labels=c("Low","Intermediate", "High"))
dat$ascvdcat   <- factor(dat$ascvdcat_all,
                      labels=c("<7.5",
                               "7.5-20",
                               "20+"))
dat$smoke=factor(dat$old_smoke,levels=c(-3,0,1,2),
                      labels=c("Never","Never","Former",
                               "Current"))
dat$bp_med=factor(dat$bp_med,levels=c(0,1),labels=c("No","Yes"))

                               

label(dat$age)      <- "Age (y)"
label(dat$sex)      <- "Sex"
label(dat$prscat)    <- "Polygenic score category"
label(dat$dm)    <- "Diabetes status"
label(dat$sbp)  <- "Systolic blood pressure (mm Hg) "
label(dat$choladj)   <- "Total cholesterol (ng/ml)"
label(dat$hdladj)  <- "High-density lipoprotein (ng/ml)"
label(dat$smoke) <- "Smoking Status"
label(dat$ldladj)  <- "Low-density lipoprotein (ng/ml)"
label(dat$bp_med)  <- "Anti-hypertensive"
label(dat$ascvdcat)  <- "Pooled cohort equation category (10 year risk)"

table1(~ age + sex + prscat + sbp + choladj + hdladj + smoke + ascvdcat+
         ldladj + bp_med , data=dat)
Overall
(N=327837)
Age (y)
Mean (SD) 56.1 (8.08)
Median [Min, Max] 56.9 [38.9, 73.7]
Sex
Male 141330 (43.1%)
Female 186507 (56.9%)
Polygenic score category
Low 65696 (20.0%)
Intermediate 196750 (60.0%)
High 65391 (19.9%)
Systolic blood pressure (mm Hg)
Mean (SD) 140 (20.4)
Median [Min, Max] 138 [62.0, 279]
Total cholesterol (ng/ml)
Mean (SD) 229 (41.4)
Median [Min, Max] 226 [69.6, 598]
High-density lipoprotein (ng/ml)
Mean (SD) 57.2 (14.8)
Median [Min, Max] 55.3 [8.74, 170]
Smoking Status
Never 186591 (56.9%)
Former 107377 (32.8%)
Current 33869 (10.3%)
Pooled cohort equation category (10 year risk)
<7.5 207150 (63.2%)
7.5-20 96775 (29.5%)
20+ 23912 (7.3%)
Low-density lipoprotein (ng/ml)
Mean (SD) 144 (31.9)
Median [Min, Max] 142 [31.1, 476]
Anti-hypertensive
No 309420 (94.4%)
Yes 18417 (5.6%)
###
table1(~ age + sex + prscat + sbp + choladj + hdladj + smoke + ascvdcat+
         ldladj + bp_med |ascvdcat, data=dat)
<7.5
(N=207150)
7.5-20
(N=96775)
20+
(N=23912)
Overall
(N=327837)
Age (y)
Mean (SD) 52.5 (7.08) 61.4 (5.83) 65.4 (3.79) 56.1 (8.08)
Median [Min, Max] 52.2 [38.9, 70.3] 62.2 [40.2, 71.1] 66.1 [40.4, 73.7] 56.9 [38.9, 73.7]
Sex
Male 55003 (26.6%) 63116 (65.2%) 23211 (97.1%) 141330 (43.1%)
Female 152147 (73.4%) 33659 (34.8%) 701 (2.9%) 186507 (56.9%)
Polygenic score category
Low 42166 (20.4%) 18892 (19.5%) 4638 (19.4%) 65696 (20.0%)
Intermediate 123405 (59.6%) 58686 (60.6%) 14659 (61.3%) 196750 (60.0%)
High 41579 (20.1%) 19197 (19.8%) 4615 (19.3%) 65391 (19.9%)
Systolic blood pressure (mm Hg)
Mean (SD) 133 (17.1) 148 (18.4) 166 (19.1) 140 (20.4)
Median [Min, Max] 131 [62.0, 247] 147 [83.0, 268] 164 [97.0, 279] 138 [62.0, 279]
Total cholesterol (ng/ml)
Mean (SD) 224 (40.3) 237 (41.9) 235 (42.4) 229 (41.4)
Median [Min, Max] 222 [69.6, 511] 234 [79.2, 598] 232 [80.6, 586] 226 [69.6, 598]
High-density lipoprotein (ng/ml)
Mean (SD) 59.7 (14.8) 54.0 (13.7) 48.0 (11.6) 57.2 (14.8)
Median [Min, Max] 58.1 [8.82, 170] 52.0 [8.74, 156] 46.4 [10.7, 158] 55.3 [8.74, 170]
Smoking Status
Never 129984 (62.7%) 47864 (49.5%) 8743 (36.6%) 186591 (56.9%)
Former 63295 (30.6%) 34113 (35.2%) 9969 (41.7%) 107377 (32.8%)
Current 13871 (6.7%) 14798 (15.3%) 5200 (21.7%) 33869 (10.3%)
Pooled cohort equation category (10 year risk)
<7.5 207150 (100%) 0 (0%) 0 (0%) 207150 (63.2%)
7.5-20 0 (0%) 96775 (100%) 0 (0%) 96775 (29.5%)
20+ 0 (0%) 0 (0%) 23912 (100%) 23912 (7.3%)
Low-density lipoprotein (ng/ml)
Mean (SD) 139 (30.8) 152 (31.8) 154 (33.1) 144 (31.9)
Median [Min, Max] 137 [31.1, 369] 150 [37.0, 377] 151 [44.4, 476] 142 [31.1, 476]
Anti-hypertensive
No 205365 (99.1%) 89074 (92.0%) 14981 (62.7%) 309420 (94.4%)
Yes 1785 (0.9%) 7701 (8.0%) 8931 (37.3%) 18417 (5.6%)
table1(~ age + sex + prscat + sbp + choladj + hdladj + smoke + ascvdcat+
         ldladj + bp_med |prscat, data=dat)
Low
(N=65696)
Intermediate
(N=196750)
High
(N=65391)
Overall
(N=327837)
Age (y)
Mean (SD) 56.1 (8.14) 56.2 (8.07) 55.7 (8.05) 56.1 (8.08)
Median [Min, Max] 56.8 [39.2, 71.1] 57.0 [38.9, 73.7] 56.3 [40.0, 71.2] 56.9 [38.9, 73.7]
Sex
Male 28757 (43.8%) 85194 (43.3%) 27379 (41.9%) 141330 (43.1%)
Female 36939 (56.2%) 111556 (56.7%) 38012 (58.1%) 186507 (56.9%)
Polygenic score category
Low 65696 (100%) 0 (0%) 0 (0%) 65696 (20.0%)
Intermediate 0 (0%) 196750 (100%) 0 (0%) 196750 (60.0%)
High 0 (0%) 0 (0%) 65391 (100%) 65391 (19.9%)
Systolic blood pressure (mm Hg)
Mean (SD) 139 (20.3) 140 (20.4) 141 (20.4) 140 (20.4)
Median [Min, Max] 137 [62.0, 279] 138 [69.0, 261] 139 [78.0, 245] 138 [62.0, 279]
Total cholesterol (ng/ml)
Mean (SD) 222 (40.7) 229 (41.1) 234 (42.1) 229 (41.4)
Median [Min, Max] 220 [69.6, 506] 226 [70.7, 586] 232 [79.2, 598] 226 [69.6, 598]
High-density lipoprotein (ng/ml)
Mean (SD) 57.6 (14.9) 57.1 (14.7) 56.8 (14.7) 57.2 (14.8)
Median [Min, Max] 55.7 [8.74, 158] 55.3 [8.82, 170] 54.9 [14.5, 153] 55.3 [8.74, 170]
Smoking Status
Never 37823 (57.6%) 111650 (56.7%) 37118 (56.8%) 186591 (56.9%)
Former 21143 (32.2%) 64919 (33.0%) 21315 (32.6%) 107377 (32.8%)
Current 6730 (10.2%) 20181 (10.3%) 6958 (10.6%) 33869 (10.3%)
Pooled cohort equation category (10 year risk)
<7.5 42166 (64.2%) 123405 (62.7%) 41579 (63.6%) 207150 (63.2%)
7.5-20 18892 (28.8%) 58686 (29.8%) 19197 (29.4%) 96775 (29.5%)
20+ 4638 (7.1%) 14659 (7.5%) 4615 (7.1%) 23912 (7.3%)
Low-density lipoprotein (ng/ml)
Mean (SD) 139 (31.4) 144 (31.7) 149 (32.4) 144 (31.9)
Median [Min, Max] 137 [31.1, 349] 142 [32.6, 476] 147 [37.5, 379] 142 [31.1, 476]
Anti-hypertensive
No 62038 (94.4%) 185760 (94.4%) 61622 (94.2%) 309420 (94.4%)
Yes 3658 (5.6%) 10990 (5.6%) 3769 (5.8%) 18417 (5.6%)
rm(dat)

fh=readRDS("output/fh_full.rds")
dat=fh

dat=na.omit(dat)

dat$age=dat$enroll_age
dat$dm    <- factor(dat$DMRX1, levels=c("NA","0","1"), labels=c("None","None","Diabetes Mellitus"))
dat$sex     <- factor(dat$SEX, levels=c(1, 2), labels=c("Male", "Female"))
# dat$prscat  <- factor(dat$prscat,  labels=c("Low","Intermediate", "High"))
# dat$ascvdcat   <- factor(dat$ascvdcat_all,
#                       labels=c("<7.5",
#                                "7.5-20",
#                                "20+"))
dat$smoke=factor(dat$CURRSMK1,levels=c(0,1),
                      labels=c("Never",
                               "Current"))
dat$bp_med=factor(dat$HRX1,levels=c(0,"NA",1),labels=c("No","No","Yes"))

                               

label(dat$AGE1)      <- "Age (y)"
label(dat$sex)      <- "Sex"
label(dat$dm)    <- "Diabetes status"
label(dat$SBP1)  <- "Systolic blood pressure (mm Hg) "
label(dat$TC1)   <- "Total cholesterol (ng/ml)"
label(dat$HDL1)  <- "High-density lipoprotein (ng/ml)"
label(dat$smoke) <- "Smoking Status"
label(dat$CALC_LDL1)  <- "Low-density lipoprotein (ng/ml)"
label(dat$bp_med)  <- "Anti-hypertensive"

table1(~ AGE1 + sex + SBP1 + TC1 + HDL1 + smoke +
         CALC_LDL1 + bp_med , data=dat)
Overall
(N=3660)
Age (y)
Mean (SD) 35.9 (10.3)
Median [Min, Max] 35.0 [9.00, 70.0]
Sex
Male 1817 (49.6%)
Female 1843 (50.4%)
Systolic blood pressure (mm Hg)
Mean (SD) 122 (16.5)
Median [Min, Max] 120 [78.0, 240]
Total cholesterol (ng/ml)
Mean (SD) 198 (39.2)
Median [Min, Max] 193 [100, 457]
High-density lipoprotein (ng/ml)
Mean (SD) 51.9 (16.0)
Median [Min, Max] 50.0 [14.0, 132]
Smoking Status
Never 2048 (56.0%)
Current 1612 (44.0%)
Low-density lipoprotein (ng/ml)
Mean (SD) 127 (37.2)
Median [Min, Max] 124 [33.0, 394]
Anti-hypertensive
No 3538 (96.7%)
Yes 122 (3.3%)
fhp=readRDS("output/fh_prs.rds")
fhp$prs=scale(fhp$V2)
fhp$prs.r=rank(fhp$prs)/length(fhp$prs)
fhp$prscat <- cut(fhp$prs.r, breaks=c(0, 0.20,0.80,1), labels=c("low", "intermediate","high"))

dat=fhp
dat=na.omit(dat)

dat$age=dat$enroll_age
dat$dm    <- factor(dat$DMRX1, levels=c("NA","0","1"), labels=c("None","None","Diabetes Mellitus"))
dat$sex     <- factor(dat$SEX, levels=c(1, 2), labels=c("Male", "Female"))
dat$prscat  <- factor(dat$prscat,  labels=c("Low","Intermediate", "High"))
# dat$ascvdcat   <- factor(dat$ascvdcat_all,
#                       labels=c("<7.5",
#                                "7.5-20",
#                                "20+"))
dat$smoke=factor(dat$CURRSMK1,levels=c(0,1),
                      labels=c("Never",
                               "Current"))
dat$bp_med=factor(dat$HRX1,levels=c(0,"NA",1),labels=c("No","No","Yes"))

                               

label(dat$AGE1)      <- "Age (y)"
label(dat$sex)      <- "Sex"
label(dat$dm)    <- "Diabetes status"
label(dat$SBP1)  <- "Systolic blood pressure (mm Hg) "
label(dat$TC1)   <- "Total cholesterol (ng/ml)"
label(dat$HDL1)  <- "High-density lipoprotein (ng/ml)"
label(dat$smoke) <- "Smoking Status"
label(dat$CALC_LDL1)  <- "Low-density lipoprotein (ng/ml)"
label(dat$bp_med)  <- "Anti-hypertensive"
label(dat$prscat)    <- "Polygenic score category"
table1(~ AGE1 + sex + SBP1 + TC1 + HDL1 + smoke +prscat+
         CALC_LDL1 + bp_med , data=dat)
Overall
(N=2656)
Age (y)
Mean (SD) 34.2 (9.57)
Median [Min, Max] 33.0 [9.00, 65.0]
Sex
Male 1253 (47.2%)
Female 1403 (52.8%)
Systolic blood pressure (mm Hg)
Mean (SD) 120 (14.5)
Median [Min, Max] 118 [78.0, 209]
Total cholesterol (ng/ml)
Mean (SD) 194 (37.0)
Median [Min, Max] 190 [103, 394]
High-density lipoprotein (ng/ml)
Mean (SD) 52.6 (15.9)
Median [Min, Max] 51.0 [14.0, 126]
Smoking Status
Never 1589 (59.8%)
Current 1067 (40.2%)
Polygenic score category
Low 535 (20.1%)
Intermediate 1590 (59.9%)
High 531 (20.0%)
Low-density lipoprotein (ng/ml)
Mean (SD) 124 (35.2)
Median [Min, Max] 120 [33.0, 326]
Anti-hypertensive
No 2595 (97.7%)
Yes 61 (2.3%)

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] table1_1.4.3

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9       Formula_1.2-4    rstudioapi_0.14  knitr_1.40      
 [5] magrittr_2.0.3   workflowr_1.7.0  R6_2.5.1         rlang_1.0.6     
 [9] fastmap_1.1.0    fansi_1.0.3      stringr_1.4.1    tools_4.2.1     
[13] xfun_0.33        utf8_1.2.2       cli_3.4.1        git2r_0.30.1    
[17] jquerylib_0.1.4  htmltools_0.5.3  rprojroot_2.0.3  yaml_2.3.5      
[21] digest_0.6.29    tibble_3.1.8     lifecycle_1.0.3  later_1.3.0     
[25] sass_0.4.2       vctrs_0.5.2      promises_1.2.0.1 fs_1.5.2        
[29] cachem_1.0.6     glue_1.6.2       evaluate_0.17    rmarkdown_2.17  
[33] stringi_1.7.8    bslib_0.4.0      compiler_4.2.1   pillar_1.8.1    
[37] jsonlite_1.8.2   httpuv_1.6.6     pkgconfig_2.0.3