ggmiami: Create a Miami plot ggplot2 object.

View source: R/ggmiami.R

ggmiamiR Documentation

Create a Miami plot ggplot2 object.

Description

Create a Miami plot ggplot2 object.

Usage

ggmiami(
  data,
  split_by,
  split_at,
  chr = "chr",
  pos = "pos",
  p = "p",
  chr_colors = c("black", "grey"),
  upper_chr_colors = NULL,
  lower_chr_colors = NULL,
  upper_ylab = "-log10(p)",
  lower_ylab = "-log10(p)",
  genome_line = 5e-08,
  genome_line_color = "red",
  suggestive_line = 1e-05,
  suggestive_line_color = "blue",
  hits_label_col = NULL,
  hits_label = NULL,
  top_n_hits = 5,
  upper_labels_df = NULL,
  lower_labels_df = NULL,
  upper_highlight = NULL,
  upper_highlight_col = NULL,
  upper_highlight_color = "green",
  lower_highlight = NULL,
  lower_highlight_col = NULL,
  lower_highlight_color = "green"
)

Arguments

data

A data.frame object. Required.

split_by

A character vector. The name of the column to use for splitting into upper and lower sections of the Miami plot. Required.

split_at

A character or numeric vector. If numeric, the upper plot will contain your results where the values in the split_by column are >= split_at. If character, the upper plot will contain your results where the values in the split_by column are equal to split_at. Required.

chr

The name of the column containing your chromosome information. Defaults to "chr"

pos

The name of the column containing your position information. Defaults to "pos"

p

The name of the column containing your p-value information. Defaults to "p"

chr_colors

Applies the same colors to both upper and lower plots. Either a vector of two colors to alternate across chromosomes or a vector of colors to use for coloring chromosomes, with length equal to the number of chromosomes being plotted. Defaults to alternating black and grey. Set NULL if you want to specify different colors for the upper and lower plots.

upper_chr_colors

Either a vector of two colors to alternate across the chromosomes plotted in the *upper* plot or a vector of colors to use for coloring the chromosomes of the *upper* plot, with length equal to the number of chromosomes being plotted. Defaults to NULL so that precedence can be given to chr_colors argument.

lower_chr_colors

Either a vector of two colors to alternate across the chromosomes plotted in the *lower* plot or a vector of colors to use for coloring the chromosomes of the *lower* plot, with length equal to the number of chromosomes being plotted. Defaults to NULL so that precedence can be given to chr_colors argument.

upper_ylab

What would you like the y-axis title for the upper plot to be? Defaults to "-log10(p)". Text added here will result in a two-line axis with your text on top and "-log10(p)" below.

lower_ylab

Same as upper_ylab, but for the lower plot.

genome_line

Should we draw a genome-wide significance line? Set to NULL if you do not want this line. Defaults to 5e-8, or supply your own number.

genome_line_color

What color should your genome-wide significance line be? Defaults to red.

suggestive_line

Should we draw a suggestive significance line? Set to NULL if you do not want this line. Defaults to 1e-5, or supply your own number.

suggestive_line_color

What color should your suggestive significance line be? Defaults to blue.

hits_label_col

Either the name of the column(s), max = 2, to use for automatically labeling n hits, defined by top_n_hits, or the column where the values you provide in hits_label can be found. Defaults to NULL: labels aren't displayed.

hits_label

A user-specified character vector of probes/genes/SNPs to label. Defaults to NULL. If you specify this, you must also specify hits_labels_col so that we know where to look for the items.

top_n_hits

How many of the top hits do you want to label? Defaults to 5. Set to NULL to turn off this filtering.

upper_labels_df

A dataframe containing the relative position, logged p-value, and label to use for labelling the upper plot. Column names should be c("rel_pos", "logged_p", "label"). Defaults to NULL.

lower_labels_df

Same as upper_labels_df but for the lower plot.

upper_highlight

A vector of SNPs or gene names you would like to highlight in the upper plot. Defaults to NULL. If you specify this, you must also specify upper_highlight_col so that we know where to find the items.

upper_highlight_col

The column where the values you provide in upper_highlight can be found. Defaults to NULL.

upper_highlight_color

The color that you would like the highlighted points in the upper plot to be. Defaults to "green."

lower_highlight

Same as upper_highlight but for the lower plot.

lower_highlight_col

Same as upper_highlight_col but for the lower plot.

lower_highlight_color

Same as lower_highlight_color but for the lower plot.

Value

a ggplot2 object

Author(s)

Julie White

References

https://github.com/juliedwhite/miamiplot

Examples

  # If you want to put SNPs with positive beta values in the upper plot and
  # negative beta values in the lower plot:
  ggmiami(data = gwas_results, split_by = "beta", split_at = 0, p = "pval")

  # If you want to put results from study A in the upper plot and study B
  # in the lower plot:
  ggmiami(data = gwas_results, split_by = "study", split_at = "A",
          p = "pval")

  # More examples in the vignette:
  vignette("miamiplot")


juliedwhite/miamiplot documentation built on Aug. 16, 2022, 12:05 a.m.