PheWAS_Plotting: Plotting methods for PheWAS results, phenotype association...

PheWAS_PlottingR Documentation

Plotting methods for PheWAS results, phenotype association studies, or generic phenotype values

Description

These functions permit the plotting of a variety of data types found when working with phenotypes. The functions are sequentially nested calls as outlined below. Supplying lower level parameters will permit tweaks to the higher level functions as well.

Usage

phewasManhattan(d, annotate.phenotype.description=T, ...)

phenotypeManhattan(d, suggestive.line = 0.05, significant.line,
  OR.size = F, OR.direction = F, sizes, annotate.level, 
  y.axis.interval = 5, y.axis.label = expression(-log[10](italic(p))), max.y,
  ...)
  
phenotypePlot(d, max.y,max.x, suggestive.line, significant.line, 
           size.x.labels=9, size.y.labels=9, switch.axis=F, 
           sort.by.value=F, sort.by.category.value=F,
           base.labels=F, annotate.phenotype.description,
           annotate.angle=0, annotate.size=5, annotate.level,
           annotate.phenotype=F, annotate.snp.w.phenotype=F,
           annotate.snp=F, annotate.snp.angle=0,
           annotate.list, annotate.only.largest=T,
           lc.labels=F, x.group.labels=T, x.phenotype.labels=F,
           sizes=F, direction=F, point.size=3,
           use.color=T, color.palette,
           title= paste0("Phenotype Plot ", date()),
           x.axis.label="Phenotypes",
           y.axis.label="Values",
           y.axis.interval=5)

Arguments

d

Data frame containing phenotype and p, or in the case of phenotypePlot, phenotype and value.

...

Further parameters to be passed down to phenotypeManhattan and phenotypePlot.

suggestive.line

For phenotypeManhattan, Draw a blue line at this p-value to show a suggestive significance threshold. Defaults to 0.05. A missing or NA value as applicable will result in no line. For phenotypePlot, Blue line drawn at value to emphasize interesting data points. Missing or an NA value will result in no line.

significant.line

For phenotypeManhattan, draw a red line at this p-value to show an adjusted significance threshold. Defaults to suggestive.line divided by the number of non-NA p-values. An NA value will result in no line. For phenotypePlot, the red line is drawn at the specified value to emphasize interesting data points. Missing or an NA value will result in no line.

OR.size

Adjust point size based on odds ratios? Requires d to contain the OR column. Default is FALSE. Mutually exclusive with sizes.

OR.direction

Adjust point shape based on odds ratio direction? Requires d to contain the OR column. Default is FALSE.

annotate.level

For phenotypeManhattan or phenotypeManhattan, annotate points at or below this p with a default of significant.line. Set to NA to disable adding these annotations. For phenotypePlot, minimum value to annotate points. Default of no annotation with a missing arugment, or set to NA to disable.

y.axis.interval

The interval for y axis labeling. Defaults to 5. Scale is in -log10 units for the Manhattan plots and is the same as value for phenotypePlot.

x.axis.label

The label for the x axis. Defaults to "Phenotypes".

y.axis.label

The label for the y axis. Defaults to a stylized "-log10(p)" for the Manhattan plots and "Values" for phenotypePlot.

max.y

For the Manhattan plots, the maximum -log10(p) on the axis. Defaults to the larger of 4.4 or the maximum -log10(p) in the supplied data. For phenotypePlot, the maximum value for the plot. If missing, defaults to the maximum value in the supplied data.

max.x

Maximum number of phenotypes for the plot. If missing, defaults to the total number.

size.x.labels

The size of the x axis labels.

size.y.labels

The size of the y axis labels.

switch.axis

Switch the X and Y axis? Currently non-functioning. Defaults to false.

sort.by.value

Sort the plot by highest to lowest -log10(p) or value? Defaults to false.

sort.by.category.value

Sort the plot by -log10(p) or value within each phenotype group? Requires group attributes in d. Defaults to false.

base.labels

Use base ggplot2 labels? Defaults to FALSE, which uses ggrepel.

annotate.phenotype.description

Contains either TRUE or a data frame that contains description annotations for each phenotype. Should contain columns "phenotype" and "description". Missing or FALSE yields no description annotation.

annotate.angle

Angle for annotation text.

annotate.size

Size of annotation text

annotate.phenotype

Include the phenotype name in the annotation? Default is FALSE.

annotate.snp.w.phenotype

Include the snp in the phenotype annotation? Default is FALSE.

annotate.snp

Annotate the SNP? This is a second annotation, default is FALSE.

annotate.snp.angle

Angle of annotation for the SNP only annotation.

annotate.list

A vector of phenotypes to force annotation, regardless of significance.

annotate.only.largest

Should only the largest point for each phenotype be annotated? Default is TRUE, which only shows text for each phenotype once, even if multiple points pass the annotation threshold or are listed.

lc.labels

Force the labels to lower case? Default is FALSE.

x.group.labels

Label the phenotype groups? Requires group attributes in d. Default is TRUE.

x.phenotype.labels

Label every phenotype? Default is no, cannot be used in conjunction with x.group.labels.

sizes

Adjust point size based on size in d? Default is FALSE. Mutually exclusive with OR.size available in the Manhattan plots.

direction

Adjust point shape based on direction in d? Default is FALSE.

point.size

Size of the points. Default is 2.

use.color

Color the points? Requires color.palette or color in d. Default is TRUE.

color.palette

An alternate color palette. Requires at least the number of groups that exist.

title

Title for the plot. Defaults to "Phenotype Plot" with the date and time.

Details

These functions are nested: phewasManhattan calls phenotypeManhattan which calls phenotypePlot.

phewasManhattan generates a PheWAS Manhattan plot and can be used with a result data frame from phewas using phecodes. This function only adds PheWAS code groupings and descriptions as applicable before calling phenotypeManhattan.

phenotypeManhattan performs the transformations to the data and paramters for a -log10 scale. It is useful in cases of phewas results using other phenotypes besides phecodes.

phenotypePlot does the actual plotting and can be used to visualize non-p-value data.

All of these functions return ggplot2 objects. Aspects of the plots can be modified post hoc, for instance to adjust the point size scale one can use plot + scale_size(<parameters>)

Value

A ggplot2 plot. It contains PheWAS codes against their -log10 transformed p-values for phewasManhattan, generic phenotypes versus -log10 transformed p-values for phenotypeManhattan, and generic phenotypes versus generic values for phenotypePlot.

See Also

The PheWAS package for a complete example.


PheWAS/PheWAS documentation built on July 3, 2023, 3:40 p.m.