binned_manhattan_plot: Plot Binned Manhattan Plot

View source: R/binned_manhattan.R

binned_manhattan_plotR Documentation

Plot Binned Manhattan Plot

Description

Contrary to the traditional manhattan plot, which plots all the points, the binned manhattan plot vertically and horizontally bins the variants into blocks. This speeds up plotting and reduces clutter in the case of high number of variants. The colors of the blocks can also be used to summarise the variants within each block and highlight certain features.

Usage

binned_manhattan_plot(x, ...)

## Default S3 method:
binned_manhattan_plot(x, ...)

## S3 method for class 'MPdataBinned'
binned_manhattan_plot(
  x,
  outfn = NULL,
  signif.lwd = 1,
  bin.outline = FALSE,
  bin.outline.alpha = 0.2,
  highlight.colname = NULL,
  highlight.counts = TRUE,
  bin.palette = "viridis::plasma",
  bin.alpha = 0.9,
  palette.direction = 1,
  nonsignif.default = NULL,
  show.legend = TRUE,
  legend.title = NULL,
  background.col = c("grey90", "white"),
  background.alpha = 0.7,
  plot.title = ggplot2::waiver(),
  plot.subtitle = ggplot2::waiver(),
  plot.width = 10,
  plot.height = 5,
  plot.scale = 1,
  ...
)

## S3 method for class 'data.frame'
binned_manhattan_plot(
  x,
  bins.x = 10,
  bins.y = 100,
  chr.gap.scaling = 0.4,
  signif = c(5e-08, 1e-05),
  pval.colname = "pval",
  chr.colname = "chr",
  pos.colname = "pos",
  chr.order = NULL,
  signif.col = NULL,
  preserve.position = TRUE,
  pval.log.transform = TRUE,
  summarise.expression.list = NULL,
  outfn = NULL,
  signif.lwd = 1,
  bin.outline = FALSE,
  bin.outline.alpha = 0.2,
  highlight.colname = NULL,
  highlight.counts = TRUE,
  bin.palette = "viridis::plasma",
  bin.alpha = 0.9,
  palette.direction = 1,
  nonsignif.default = NULL,
  show.legend = TRUE,
  legend.title = NULL,
  background.col = c("grey90", "white"),
  background.alpha = 0.7,
  plot.title = ggplot2::waiver(),
  plot.subtitle = ggplot2::waiver(),
  plot.width = 10,
  plot.height = 5,
  plot.scale = 1,
  ...
)

## S4 method for signature 'GRanges'
binned_manhattan_plot(
  x,
  bins.x = 10,
  bins.y = 100,
  chr.gap.scaling = 0.4,
  signif = c(5e-08, 1e-05),
  pval.colname = "pval",
  chr.order = NULL,
  signif.col = NULL,
  preserve.position = TRUE,
  pval.log.transform = TRUE,
  summarise.expression.list = NULL,
  outfn = NULL,
  signif.lwd = 1,
  bin.outline = FALSE,
  bin.outline.alpha = 0.2,
  highlight.colname = NULL,
  highlight.counts = TRUE,
  bin.palette = "viridis::plasma",
  bin.alpha = 0.9,
  palette.direction = 1,
  nonsignif.default = NULL,
  show.legend = TRUE,
  legend.title = NULL,
  background.col = c("grey90", "white"),
  background.alpha = 0.7,
  plot.title = ggplot2::waiver(),
  plot.subtitle = ggplot2::waiver(),
  plot.width = 10,
  plot.height = 5,
  plot.scale = 1,
  ...
)

Arguments

x

a data.frame or any other extension of a data frame. It can also be a MPdata object.

...

Ignored

outfn

a character. File name to save the Manhattan Plot. If outfn is supplied (i.e. !is.null(outfn)), then the plot is not drawn in the graphics window.

signif.lwd

a number. Line width of the significance threshold line.

bin.outline

a logical. Outline each bin. The bins are colored black.

bin.outline.alpha

a number. Alpha value of the bin outline.

highlight.colname

a character. If you desire to color certain points (e.g. significant variants) rather than color by chromosome, you can specify the category in this column, and provide the color mapping in highlight.col. Ignored if NULL.

highlight.counts

a logical. If logical, the bins are colored based on the number of points in each block.

bin.palette

a character. Palette to color the bins. Only palettes supported by the package paletteer are supported. More in details.

bin.alpha

a number. Alpha value of the bins.

palette.direction

a number. Direction of the palette. 1 for increasing and -1 for decreasing.

nonsignif.default

a character. Default color for bins that are not significant.

show.legend

a logical. Show legend if bins are colored based on a variable.

legend.title

a character. Title of the legend.

background.col

a character. Color of the background panels. Set to NULL for no color.

background.alpha

a number. Alpha value of the background panels.

plot.title

a character. Plot title

plot.subtitle

a character. Plot subtitle

plot.width

a numeric. Plot width in inches. Corresponds to width argument in ggsave function.

plot.height

a numeric. Plot height in inches. Corresponds to height argument in ggsave function.

plot.scale

a numeric. Plot scale. Corresponds to scale argument in ggsave function.

bins.x

an integer. number of blocks to horizontally span the longest chromosome

bins.y

an integer. number of blocks to vertically span the plot

chr.gap.scaling

a numeric. scaling factor for gap between chromosome if you desire to change it if x is an MPdata object, then the gap will scale relative to the gap in the object.

signif

a numeric vector. Significant p-value thresholds to be drawn for manhattan plot. At least one value should be provided. Default value is c(5e-08, 1e-5). If signif is not NULL and x is an MPdata object, signif argument overrides the value inside MPdata.

pval.colname

a character. Column name of x containing p.value.

chr.colname

a character. Column name of x containing chromosome.

pos.colname

a character. Column name of x containing position.

chr.order

a character vector. Order of chromosomes presented in manhattan plot.

signif.col

a character vector of equal length as signif. It contains colors for the lines drawn at signif. If NULL, the smallest value is colored black while others are grey. If x is an MPdata object, behaves similarly to signif.

preserve.position

a logical. If TRUE, the width of each chromosome reflect the number of variants and the position of each variant is correctly scaled? If FALSE, the width of each chromosome is equal and the variants are equally spaced.

pval.log.transform

a logical. If TRUE, the p-value will be transformed to -log10(p-value).

summarise.expression.list

a list of formulas to summarise data for each bin. Check details for more information.

Details

Similar to manhattan_plot, this function accepts summary statistics from GWAS and plots manhattan plot. The difference is that the variants are binned. The number of blocks can be controlled by bins.x and bins.y. The blocks can be colored based on a column in the data frame.

Palette for coloring the bins can be chosen from the package paletteer. Only palettes available in paletteer are supported. Furthermore, what palette you can use depends on what kind of variable you are using to fill the bins. Use discrete palette for categorical variable and continuous palette for continuous variable.


leejs-abv/ggmanh documentation built on Sept. 19, 2024, 10:13 p.m.