analyze.pgs.binary.predictiveness: Analyze PGS Predictiveness for Binary Phenotypes

analyze.pgs.binary.predictivenessR Documentation

Analyze PGS Predictiveness for Binary Phenotypes

Description

This function performs logistic regression to evaluate the predictiveness of polygenic scores for binary or continuous phenotypes. For continuous phenotypes, it converts them to binary based on a specified cutoff threshold. It calculates and returns AUC, Odds Ratios (OR), and p-values for each PGS. Corresponding ROC curves are plotted automatically.

Usage

analyze.pgs.binary.predictiveness(
  pgs.data,
  pgs.columns,
  phenotype.columns,
  covariate.columns = NULL,
  phenotype.type = "binary",
  cutoff.threshold = NULL,
  output.dir = NULL,
  filename.prefix = NULL,
  file.extension = "png",
  width = 8,
  height = 8,
  xaxes.cex = 1.5,
  yaxes.cex = 1.5,
  titles.cex = 1.5
)

Arguments

pgs.data

A data frame containing the PGS, phenotype, and covariate columns.

pgs.columns

A character vector specifying the names of the PGS columns in pgs.data to be analyzed. All specified columns must be numeric.

phenotype.columns

A character vector specifying the names of the phenotype columns in data to be analyzed. If binary phenotypes are specified, they must be factors with two levels (0 and 1).

covariate.columns

A character vector specifying the names of covariate columns in data to be included in the regression model. Default is NULL.

phenotype.type

A character string specifying the type of phenotype. Must be either 'continuous' or 'binary'. All provided phenotype columns must match this type.

cutoff.threshold

A numeric value or a named list specifying the cutoff threshold for converting continuous phenotypes to binary. If a named list, it must contain entries for each continuous phenotype.

output.dir

A character string specifying the directory where the ROC plots will be saved. If NULL, no plots are saved.

filename.prefix

A character string specifying the prefix for the output filenames. If NULL, defaults to 'ApplyPolygenicScore-Plot'.

file.extension

A character string specifying the file extension for the output plots. Default is 'png'.

width

Numeric value specifying the width of the output plot in inches.

height

Numeric value specifying the height of the output plot in inches.

xaxes.cex

Numeric size for all x-axis labels.

yaxes.cex

Numeric size for all y-axis labels.

titles.cex

Numeric size for all plot titles.

Value

A list containing a data frame of logistic regression results and a plot object of corresponding ROC curves.

Output Formatting

results.df

A data frame with columns:

  • phenotype: Name of the phenotype column.

  • PGS: Name of the PGS column.

  • AUC: Area Under the Reciever Operator Curve.

  • OR: Odds Ratio for the PGS from logistic regression.

  • OR.Lower.CI: Lower 95

  • OR.Upper.CI: Upper 95

  • p.value: P-value for the PGS coefficient.

Values for AUC, OR, OR.Lower.CI, OR.Upper.CI, and p.value may be NA if model fitting or ROC calculation fails (e.g., due to no complete cases, no variance in PGS, or ROC calculation errors).

roc.plot

A multipanelplot object (from BoutrosLab.plotting.general) if output.dir is NULL, otherwise NULL if plots are saved to file.

Each phenotype is plotted in a separate panel, with ROC curves for each PGS specified in pgs.columns.

Examples

set.seed(100);

pgs.data <- data.frame(
    PGS = rnorm(100, 0, 1),
    continuous.phenotype = rnorm(100, 2, 1),
    binary.phenotype = sample(c(0, 1), 100, replace = TRUE),
    covariate1 = rnorm(100, 0, 1)
    );
 temp.dir <- tempdir();

# Basic analysis with binary phenotype
analyze.pgs.binary.predictiveness(
    pgs.data,
    output.dir = temp.dir,
    filename.prefix = 'basic-plot',
    pgs.columns = 'PGS',
    phenotype.columns = 'binary.phenotype',
    phenotype.type = 'binary',
    covariate.columns = 'covariate1',
    width = 6,
    height = 6
    );

# Analysis with continuous phenotype and cutoff threshold
analyze.pgs.binary.predictiveness(
   pgs.data,
   output.dir = temp.dir,
   filename.prefix = 'continuous-plot',
   pgs.columns = 'PGS',
   phenotype.columns = 'continuous.phenotype',
   phenotype.type = 'continuous',
   cutoff.threshold = 1.5, # Convert to binary using this threshold
   covariate.columns = NULL,
   width = 6,
   height = 6
   );


ApplyPolygenicScore documentation built on Aug. 21, 2025, 5:43 p.m.