Learn R Programming

comorbidPGS

comorbidPGS is a tool for analysing an already computed Polygenic Score (PGS, also named PRS/GRS for binary outcomes) distribution to investigate shared genetic aetiology in multiple conditions.

comorbidPGS is under GPL-3 license, and is freely available for download.

Prerequisite

  • R version 3.5 or higher with the following packages:
    • stats
    • utils
    • ggplot2

Installation

comorbidPGS is available on CRAN, you can download it using the following command:

install.packages("comorbidPGS")

If you prefer the latest stable development version, you can download it from GitHub with:

if (!require("devtools", quietly = TRUE)) install.packages("devtools")
devtools::install_github("VP-biostat/comorbidPGS")

Example

Building an Association Table of PGS

This is a basic example which shows you how to do basic association with the example dataset:

library(comorbidPGS)
#> 
#> Attaching package: 'comorbidPGS'
#> The following object is masked from 'package:graphics':
#> 
#>     assocplot

# use the demo dataset
dataset <- comorbidData
# NOTE: The dataset must have at least 3 different columns:
# - an ID column (the first one)
# - a PGS column (must be numeric, by default it is the column named "SCORESUM" or the second column if "SCORESUM" is not present)
# - a Phenotype column, can be factors, numbers or characters

# do an association of one PGS with one Phenotype
result_1 <- assoc(dataset, prs_col = "t2d_PGS", phenotype_col = "t2d")
PGSPhenotypePhenotype_typeStatistical_methodCovarN_casesN_controlsNEffectSElower_CIupper_CIP_value
t2d_PGSt2dCases/ControlsBinary logistic regressionNA7309270100001.688258NA1.5618211.8249310
# do multiple associations
assoc <- expand.grid(c("t2d_PGS", "ldl_PGS"), c("ethnicity","brc","t2d","log_ldl","sbp_cat"))
result_2 <- multiassoc(df = dataset, assoc_table = assoc, covar = c("age", "sex", "gen_array"))
#> Warning in phenotype_type(df = df, phenotype_col = phenotype_col): Phenotype
#> column log_ldl is continuous and not normal, please normalise prior association

#> Warning in phenotype_type(df = df, phenotype_col = phenotype_col): Phenotype
#> column log_ldl is continuous and not normal, please normalise prior association
PGSPhenotypePhenotype_typeStatistical_methodCovarN_casesN_controlsNEffectSElower_CIupper_CIP_value
2t2d_PGSethnicity 1 ~ 2CategoricalMultinomial logistic regressionage+sex+gen_array2142638185230.9814174NA0.93451501.03067390.4528020
3t2d_PGSethnicity 1 ~ 3CategoricalMultinomial logistic regressionage+sex+gen_array1205638175861.0178971NA0.95709311.08256400.5724292
4t2d_PGSethnicity 1 ~ 4CategoricalMultinomial logistic regressionage+sex+gen_array272638166530.9434640NA0.83559801.06525420.3474694
21ldl_PGSethnicity 1 ~ 2CategoricalMultinomial logistic regressionage+sex+gen_array2142638185230.9925623NA0.94516781.04233340.7648927
31ldl_PGSethnicity 1 ~ 3CategoricalMultinomial logistic regressionage+sex+gen_array1205638175861.0083869NA0.94812151.07248300.7905175
41ldl_PGSethnicity 1 ~ 4CategoricalMultinomial logistic regressionage+sex+gen_array272638166530.9760204NA0.86472261.10164330.6943783
1t2d_PGSbrcCases/ControlsBinary logistic regressionage+sex+gen_array402504154431.0061678NA0.90875431.11402350.9057882
11ldl_PGSbrcCases/ControlsBinary logistic regressionage+sex+gen_array402504154431.1037106NA0.99563701.22351530.0605407
12t2d_PGSt2dCases/ControlsBinary logistic regressionage+sex+gen_array7309270100001.7359738NA1.60298671.87999380.0000000
13ldl_PGSt2dCases/ControlsBinary logistic regressionage+sex+gen_array7309270100000.9823272NA0.91024111.06012230.6465580
14t2d_PGSlog_ldlContinuousLinear regressionage+sex+gen_arrayNANA100000.00599610.00227470.00153780.01045440.0084010
15ldl_PGSlog_ldlContinuousLinear regressionage+sex+gen_arrayNANA100000.08285450.00211830.07870270.08700640.0000000
16t2d_PGSsbp_catOrdered CategoricalOrdinal logistic regressionage+sex+gen_arrayNANA100001.0628744NA1.02360441.10365090.0015002
17ldl_PGSsbp_catOrdered CategoricalOrdinal logistic regressionage+sex+gen_arrayNANA100001.0078855NA0.97073301.04645980.6818849

Extension of association analysis: one-sample MR using the Wald Ratio and 2SLS methods

# MR using Wald ratio method
mr1 <- mr_ratio(df = dataset, prs_col = "ldl_PGS", exposure_col = "log_ldl", outcome_col = "sbp") 
#> Warning in phenotype_type(df = df, phenotype_col = exposure_col): Phenotype
#> column log_ldl is continuous and not normal, please normalise prior association
#> Warning in phenotype_type(df = df, phenotype_col = outcome_col): Phenotype
#> column sbp is continuous and not normal, please normalise prior association
PGSExposureOutcomeMethodN_casesN_controlsNMR_estimateSEF_stat
ldl_PGSldl_PGSlog_ldlsbpRatioNANA100000.03210992.3876911449.37
# MR using 2-stage least square method (2SLS)
mr2 <- mr_2sls(df = dataset, prs_col = "ldl_PGS", exposure_col = "log_ldl", outcome_col = "sbp") 
#> Warning in phenotype_type(df = df, phenotype_col = exposure_col): Phenotype
#> column log_ldl is continuous and not normal, please normalise prior association
#> Warning in phenotype_type(df = df, phenotype_col = outcome_col): Phenotype
#> column sbp is continuous and not normal, please normalise prior association
PGSExposureOutcomeMethodN_casesN_controlsNMR_estimateSEF_stat
valueldl_PGSlog_ldlsbp2SLSNANA100000.03210992.3875321449.37

Examples of data visualisation using comorbidPGS

densityplot(dataset, prs_col = "ldl_PGS", phenotype_col = "sbp_cat")
# show multiple associations in a plot
assoplot <- assocplot(score_table = result_2)
assoplot$continuous_phenotype
assoplot$discrete_phenotype

NOTE: The score_table should have the assoc() output format

centileplot(dataset, prs_col = "brc_PGS", phenotype_col = "brc")
#> Warning in centileplot(dataset, prs_col = "brc_PGS", phenotype_col = "brc"):
#> The dataset has less than 10,000 individuals, centiles plot may not look good!
#> Use the argument decile = TRUE to adapt to small datasets

As those graphical functions use ggplot2, you can fully customize your plot:

library(ggplot2)
centileplot(dataset, prs_col = "t2d_PGS", phenotype_col = "t2d") + 
  scale_color_gradient(low = "green", high = "red")
decileboxplot(dataset, prs_col = "ldl_PGS", phenotype_col = "ldl")

Citation

To cite comorbidPGS in publications, please use:

Copy Link

Version

Install

install.packages('comorbidPGS')

Monthly Downloads

180

Version

1.0.0

License

GPL (>= 3)

Maintainer

Vincent Pascat

Last Published

July 15th, 2025

Functions in comorbidPGS (1.0.0)

comorbidData

Mock dataset for comorbidPGS package
mr_2sls

Mendelian Randomization Two-Stage Least Square (2SLS) method with external PGS
multiassoc

Multiple PGS Associations from a Data Frame
mr_ratio

Mendelian Randomization ratio method with external PGS
multiphenassoc

Multiple PGS Associations from different Phenotypes
assocplot

Multiple PGS Associations Plot
decileboxplot

Deciles BoxPlot from a PGS Association with a Continuous Phenotype
densityplot

Density Plot from a PGS Association
assoc

Association of a PGS distribution with a Phenotype
centileplot

Centiles Plot from a PGS Association