Last updated: 2025-05-13

Checks: 7 0

Knit directory: prs/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

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(20250417) 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 c5d5446. 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:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/.DS_Store
    Ignored:    data/.DS_Store

Untracked files:
    Untracked:  analysis/continuous/
    Untracked:  analysis/metadata.txt
    Untracked:  analysis/metadata_quantile.txt
    Untracked:  analysis/normalized_counts.rda
    Untracked:  analysis/quantile/
    Untracked:  analysis/validation.Rmd
    Untracked:  analysis/vst norm counts.rda
    Untracked:  data/Artery_Aorta.v8.covariates.txt
    Untracked:  data/GTEx_v8.bk
    Untracked:  data/GTEx_v8.rds
    Untracked:  data/Whole_Blood.v8.covariates.txt
    Untracked:  data/blood_cell/
    Untracked:  data/gene_reads_2017-06-05_v8_artery_aorta.gct.gz
    Untracked:  data/gene_reads_2017-06-05_v8_whole_blood.gct
    Untracked:  data/gene_tpm_2017-06-05_v8_whole_blood.gct.gz
    Untracked:  data/immune/
    Untracked:  data/protein-coding_gene.txt

Unstaged changes:
    Deleted:    analysis/QC.Rmd
    Deleted:    analysis/normalized_counts.txt
    Modified:   analysis/prs_blood_cell.txt
    Modified:   prs.Rproj

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/metadata.Rmd) and HTML (docs/metadata.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
html d129b3e ElisaChen 2025-05-07 Build site.
Rmd 7a5b0e4 ElisaChen 2025-05-07 wflow_publish(c("analysis/index.Rmd", "analysis/metadata.Rmd",
html c4ece77 ElisaChen 2025-04-30 Build site.
Rmd 5b80e27 ElisaChen 2025-04-30 workflowr::wflow_publish(c("analysis/differential_expression.Rmd",
html eba00c6 ElisaChen 2025-04-24 Build site.
Rmd 077b30f ElisaChen 2025-04-24 wflow_publish(c("analysis/index.Rmd", "analysis/about.Rmd", "analysis/license.Rmd",

Obtain whole blood gene expression samples

# Load the gene expression data
gene_expr_file <- "data/gene_reads_2017-06-05_v8_whole_blood.gct"
raw_count_df <- fread(gene_expr_file, header = TRUE)
raw_count_df <- raw_count_df[, -c(1:3)]

# modify GTEx sample names matching names used in PRS data
colnames(raw_count_df) <- sub("^(GTEX-[^-.]+).*", "\\1", colnames(raw_count_df))

Match samples between PRS and count matrix

# load PRS data for blood trait
prs_file <- "analysis/prs_blood_cell.txt"
prs_blood <- fread(prs_file, header = T, stringsAsFactors = FALSE)

# obtain GTEx sample id
id <- prs_blood$sample_id

# Load the PRS data for immune trait
prs_file <- "analysis/prs_immune.txt"
prs_immune <- fread(prs_file, header = T, stringsAsFactors = FALSE)

# subset samples
matching_samples <- intersect(id, colnames(raw_count_df))
prs_blood <- prs_blood[prs_blood$sample_id %in% matching_samples, ]
prs_immune <- prs_immune[prs_immune$sample_id %in% matching_samples, ]

Whole blood covariates

cov_file <- "data/Whole_Blood.v8.covariates.txt"
cov <- fread(cov_file, header = T, stringsAsFactors = FALSE)
cov <- cov %>% filter(ID %in% c(paste0("PC", 1:5), "sex"))
col <- cov$ID
cov <- as.matrix(t(cov[, -1])) 
colnames(cov) <- col

Create metadata for continuous traits

# continuous traits
metadata <- cbind(cov, prs_blood[, 2:30], prs_immune[,2:9])
rownames(metadata) <- matching_samples
metadata$sex <- as.factor(metadata$sex)
head(metadata)
       PC1     PC2     PC3     PC4     PC5    sex Basophil count
     <num>   <num>   <num>   <num>   <num> <fctr>          <num>
1:  0.0154 -0.0093  0.0107 -0.0038 -0.0083      1      0.5410653
2:  0.0139 -0.0097  0.0067 -0.0144  0.0296      2      0.2568363
3:  0.0145 -0.0093  0.0327  0.0056  0.0510      2      0.4498869
4: -0.0728 -0.0077 -0.0044 -0.0146  0.0063      1      0.2381773
5:  0.0106  0.0037 -0.0116 -0.0239 -0.0036      2      0.0698766
6:  0.0139 -0.0056 -0.0096 -0.0022  0.0177      1      0.2181521
   Basophil percentage of white cells Eosinophil count
                                <num>            <num>
1:                          1.0156237        -3.584264
2:                          0.9157099        -4.195580
3:                          0.9594237        -4.354380
4:                          0.8845315        -3.847279
5:                          0.6832743        -3.697957
6:                          0.8695345        -3.709683
   Eosinophil percentage of white cells Hematocrit Hemoglobin concentration
                                  <num>      <num>                    <num>
1:                            -3.380372  0.0788395                 1.386430
2:                            -3.219698  0.4280533                 2.024007
3:                            -3.727362 -0.3491181                 1.248190
4:                            -3.262860  0.2038707                 1.859773
5:                            -3.324072  0.3378556                 2.139808
6:                            -3.616119 -0.0546889                 1.734757
   High light scatter reticulocyte count
                                   <num>
1:                              4.759111
2:                              4.202698
3:                              4.561965
4:                              4.206057
5:                              4.207088
6:                              4.300133
   High light scatter reticulocyte percentage of red cells
                                                     <num>
1:                                                4.850884
2:                                                4.515898
3:                                                4.653108
4:                                                4.560175
5:                                                4.453233
6:                                                4.315553
   Immature fraction of reticulocytes Lymphocyte count
                                <num>            <num>
1:                           3.073905       -0.0895070
2:                           3.180095        0.1487145
3:                           3.066648        0.0183342
4:                           2.724009       -0.0072076
5:                           2.500608       -0.4254034
6:                           2.662584       -0.1073850
   Lymphocyte percentage of white cells Mean corpuscular hemoglobin
                                  <num>                       <num>
1:                            0.2374592                    2.636155
2:                            0.2513990                    2.790015
3:                           -0.0272472                    2.227260
4:                           -0.0555840                    2.433216
5:                            0.0748983                    3.202261
6:                            0.3191792                    3.315746
   Mean corpuscular hemoglobin concentration Mean corpuscular volume
                                       <num>                   <num>
1:                                  1.632886                2.411277
2:                                  1.781026                2.681980
3:                                  1.870210                1.707190
4:                                  1.923650                1.997743
5:                                  2.100451                2.924678
6:                                  1.901161                3.245288
   Monocyte count Monocyte percentage of white cells Mean platelet volume
            <num>                              <num>                <num>
1:      2.0512947                          0.9079310            0.7683186
2:      1.2232565                          0.0900392            1.0050662
3:      1.2055734                          0.5576229            0.5335173
4:      0.9881165                         -0.4985315            0.9883115
5:      1.1199602                          0.2586746            0.3808877
6:      1.0788232                          0.1757293            0.9693893
   Mean reticulocyte volume Mean sphered corpuscular volume Neutrophil count
                      <num>                           <num>            <num>
1:               -0.6711704                      -0.1915244       -0.7245853
2:               -0.7286477                      -0.0609871       -1.0541924
3:               -0.9191123                       0.0123445       -0.5928827
4:               -1.0593541                      -0.1854266       -0.7716597
5:               -0.7623533                      -0.1125280       -1.1219023
6:                0.1781564                       0.7304979       -1.2248109
   Neutrophil percentage of white cells Platelet crit
                                  <num>         <num>
1:                           -0.3556682      3.317813
2:                           -0.5039774      2.423712
3:                            0.0069968      2.904152
4:                           -0.1767276      3.195600
5:                           -0.0572866      3.074190
6:                           -0.1422708      2.890912
   Platelet distribution width Platelet count Red blood cell count
                         <num>          <num>                <num>
1:                    1.995272      1.2545477            0.5340879
2:                    2.592336      0.6764149            0.9435796
3:                    1.301701      1.5763316            0.6182782
4:                    2.720634      1.2843909            0.3390140
5:                    2.202220      1.0326955            0.8687638
6:                    1.622803      1.4565123           -0.1164535
   Red cell distribution width Reticulocyte count
                         <num>              <num>
1:                   0.9369695           4.549213
2:                   1.2345469           4.160999
3:                   1.6481568           4.525393
4:                   1.0718717           4.426697
5:                   0.2488524           4.553244
6:                   0.9978962           4.165813
   Reticulocyte fraction of red cells White blood cell count
                                <num>                  <num>
1:                           4.758601             -0.5033859
2:                           4.367083             -0.8890277
3:                           4.599732             -0.6487270
4:                           4.391039             -0.4018935
5:                           4.626704             -0.9232945
6:                           4.265575             -0.9320550
   Celiac_GCST90014442 Celiac_GCST90468120 IBD_GCST90013901 IBD_GCST90013951
                 <num>               <num>            <num>            <num>
1:         -0.26979202           -1.664964       -0.9357205        -1.031167
2:         -0.29874466           -2.266667       -0.9111857        -1.023133
3:         -0.30873975           -2.037649       -0.9511192        -1.084680
4:         -0.08861998           -2.234620       -0.9120145        -1.027695
5:         -0.19971851           -2.091880       -0.8808438        -1.034828
6:         -0.02010055           -2.856789       -0.9944172        -1.112842
   T1D_GCST90000529 T1D_GCST90014023 LUPUS_GCST003156 LUPUS_GCST011096
              <num>            <num>            <num>            <num>
1:         -3.54534        -60.34438        5.0958297       5.11865538
2:        -20.04924        -66.73086       -1.0720317      -1.10548637
3:        -19.21859        -54.94239       -2.6333984      -2.91795672
4:        -24.05473        -58.12421        0.1342057       0.04848093
5:        -18.64035        -61.99394        6.5632418       7.13558573
6:        -16.68449        -59.92546        1.0688929       1.10597115
write.table(metadata, "analysis/metadata.txt", sep="\t", row.names = T,
            col.names = T, quote = F)

Stratify by PRS level (High vs Median vs Low)

Blood trait

for (i in 2:ncol(prs_blood)) {
  # Extract the PRS values for the current trait
  prs_trait <- prs_blood[[i]]

  # Calculate the 75th percentile for the trait (top 25% threshold)
  p75 <- quantile(prs_trait, 0.75, na.rm = TRUE)

  # Create a new column for the group classification based on the 75th percentile
  group <- ifelse(prs_trait > p75, "Top 25%", "Remaining")

  # Assign the group to the new column for this trait
  prs_blood[[colnames(prs_blood)[i]]] <- factor(group, 
                                      levels = c("Remaining", "Top 25%"))
}

Immune trait

for (i in 2:ncol(prs_immune)) {
  # Extract the PRS values for the current trait
  prs_trait <- prs_immune[[i]]

  # Calculate the 75th percentile for the trait (top 25% threshold)
  p75 <- quantile(prs_trait, 0.75, na.rm = TRUE)

  # Create a new column for the group classification based on the 75th percentile
  group <- ifelse(prs_trait > p75, "Top 25%", "Remaining")

  # Assign the group to the new column for this trait
  prs_immune[[colnames(prs_immune)[i]]] <- factor(group, 
                                      levels = c("Remaining", "Top 25%"))
}

Create metadata for quantile traits into top 25% & remaining

metadata <- cbind(cov, prs_blood[, 2:30], prs_immune[,2:9])
rownames(metadata) <- matching_samples
metadata$sex <- as.factor(metadata$sex)
head(metadata)
       PC1     PC2     PC3     PC4     PC5    sex Basophil count
     <num>   <num>   <num>   <num>   <num> <fctr>         <fctr>
1:  0.0154 -0.0093  0.0107 -0.0038 -0.0083      1        Top 25%
2:  0.0139 -0.0097  0.0067 -0.0144  0.0296      2      Remaining
3:  0.0145 -0.0093  0.0327  0.0056  0.0510      2        Top 25%
4: -0.0728 -0.0077 -0.0044 -0.0146  0.0063      1      Remaining
5:  0.0106  0.0037 -0.0116 -0.0239 -0.0036      2      Remaining
6:  0.0139 -0.0056 -0.0096 -0.0022  0.0177      1      Remaining
   Basophil percentage of white cells Eosinophil count
                               <fctr>           <fctr>
1:                            Top 25%          Top 25%
2:                          Remaining        Remaining
3:                          Remaining        Remaining
4:                          Remaining        Remaining
5:                          Remaining          Top 25%
6:                          Remaining          Top 25%
   Eosinophil percentage of white cells Hematocrit Hemoglobin concentration
                                 <fctr>     <fctr>                   <fctr>
1:                            Remaining  Remaining                Remaining
2:                            Remaining    Top 25%                  Top 25%
3:                            Remaining  Remaining                Remaining
4:                            Remaining    Top 25%                  Top 25%
5:                            Remaining    Top 25%                  Top 25%
6:                            Remaining  Remaining                Remaining
   High light scatter reticulocyte count
                                  <fctr>
1:                               Top 25%
2:                             Remaining
3:                               Top 25%
4:                             Remaining
5:                             Remaining
6:                             Remaining
   High light scatter reticulocyte percentage of red cells
                                                    <fctr>
1:                                                 Top 25%
2:                                               Remaining
3:                                                 Top 25%
4:                                               Remaining
5:                                               Remaining
6:                                               Remaining
   Immature fraction of reticulocytes Lymphocyte count
                               <fctr>           <fctr>
1:                            Top 25%        Remaining
2:                            Top 25%          Top 25%
3:                            Top 25%        Remaining
4:                          Remaining        Remaining
5:                          Remaining        Remaining
6:                          Remaining        Remaining
   Lymphocyte percentage of white cells Mean corpuscular hemoglobin
                                 <fctr>                      <fctr>
1:                              Top 25%                   Remaining
2:                              Top 25%                   Remaining
3:                            Remaining                   Remaining
4:                            Remaining                   Remaining
5:                            Remaining                     Top 25%
6:                              Top 25%                     Top 25%
   Mean corpuscular hemoglobin concentration Mean corpuscular volume
                                      <fctr>                  <fctr>
1:                                 Remaining               Remaining
2:                                 Remaining               Remaining
3:                                 Remaining               Remaining
4:                                 Remaining               Remaining
5:                                   Top 25%                 Top 25%
6:                                 Remaining                 Top 25%
   Monocyte count Monocyte percentage of white cells Mean platelet volume
           <fctr>                             <fctr>               <fctr>
1:        Top 25%                            Top 25%            Remaining
2:      Remaining                          Remaining            Remaining
3:      Remaining                            Top 25%            Remaining
4:      Remaining                          Remaining            Remaining
5:      Remaining                          Remaining            Remaining
6:      Remaining                          Remaining            Remaining
   Mean reticulocyte volume Mean sphered corpuscular volume Neutrophil count
                     <fctr>                          <fctr>           <fctr>
1:                Remaining                       Remaining        Remaining
2:                Remaining                       Remaining        Remaining
3:                Remaining                       Remaining          Top 25%
4:                Remaining                       Remaining        Remaining
5:                Remaining                       Remaining        Remaining
6:                  Top 25%                         Top 25%        Remaining
   Neutrophil percentage of white cells Platelet crit
                                 <fctr>        <fctr>
1:                            Remaining       Top 25%
2:                            Remaining     Remaining
3:                            Remaining     Remaining
4:                            Remaining       Top 25%
5:                            Remaining       Top 25%
6:                            Remaining     Remaining
   Platelet distribution width Platelet count Red blood cell count
                        <fctr>         <fctr>               <fctr>
1:                   Remaining        Top 25%            Remaining
2:                     Top 25%      Remaining              Top 25%
3:                   Remaining        Top 25%            Remaining
4:                     Top 25%        Top 25%            Remaining
5:                   Remaining      Remaining              Top 25%
6:                   Remaining        Top 25%            Remaining
   Red cell distribution width Reticulocyte count
                        <fctr>             <fctr>
1:                   Remaining            Top 25%
2:                     Top 25%          Remaining
3:                     Top 25%            Top 25%
4:                   Remaining          Remaining
5:                   Remaining            Top 25%
6:                   Remaining          Remaining
   Reticulocyte fraction of red cells White blood cell count
                               <fctr>                 <fctr>
1:                            Top 25%              Remaining
2:                          Remaining              Remaining
3:                          Remaining              Remaining
4:                          Remaining                Top 25%
5:                          Remaining              Remaining
6:                          Remaining              Remaining
   Celiac_GCST90014442 Celiac_GCST90468120 IBD_GCST90013901 IBD_GCST90013951
                <fctr>              <fctr>           <fctr>           <fctr>
1:           Remaining             Top 25%        Remaining          Top 25%
2:           Remaining           Remaining          Top 25%          Top 25%
3:           Remaining           Remaining        Remaining        Remaining
4:             Top 25%           Remaining          Top 25%          Top 25%
5:           Remaining           Remaining          Top 25%          Top 25%
6:             Top 25%           Remaining        Remaining        Remaining
   T1D_GCST90000529 T1D_GCST90014023 LUPUS_GCST003156 LUPUS_GCST011096
             <fctr>           <fctr>           <fctr>           <fctr>
1:          Top 25%        Remaining          Top 25%          Top 25%
2:        Remaining        Remaining        Remaining        Remaining
3:        Remaining          Top 25%        Remaining        Remaining
4:        Remaining        Remaining        Remaining        Remaining
5:        Remaining        Remaining          Top 25%          Top 25%
6:        Remaining        Remaining        Remaining        Remaining
write.table(metadata, "analysis/metadata_quantile.txt", sep="\t", row.names = T,
            col.names = T, quote = F)

sessionInfo()
R version 4.2.2 (2022-10-31)
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.1.4       data.table_1.16.4 workflowr_1.7.1  

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.14       compiler_4.2.2    pillar_1.10.1     bslib_0.9.0      
 [5] later_1.4.1       git2r_0.33.0      jquerylib_0.1.4   tools_4.2.2      
 [9] getPass_0.2-4     digest_0.6.37     jsonlite_1.8.9    evaluate_1.0.3   
[13] lifecycle_1.0.4   tibble_3.2.1      pkgconfig_2.0.3   rlang_1.1.5      
[17] cli_3.6.3         rstudioapi_0.17.1 yaml_2.3.10       xfun_0.50        
[21] fastmap_1.2.0     httr_1.4.7        stringr_1.5.1     knitr_1.49       
[25] generics_0.1.3    fs_1.6.5          vctrs_0.6.5       sass_0.4.9       
[29] tidyselect_1.2.1  rprojroot_2.0.4   glue_1.8.0        R6_2.5.1         
[33] processx_3.8.5    rmarkdown_2.29    callr_3.7.6       magrittr_2.0.3   
[37] whisker_0.4.1     ps_1.8.1          promises_1.3.2    htmltools_0.5.8.1
[41] httpuv_1.6.15     stringi_1.8.4     cachem_1.1.0