manhattan_plot | R Documentation |
A generic function for manhattan plot.
manhattan_plot(x, ...)
manhattan_plot.default(x, ...)
## S3 method for class 'data.frame'
manhattan_plot(
x,
chromosome = NULL,
outfn = NULL,
signif = c(5e-08, 1e-05),
pval.colname = "pval",
chr.colname = "chr",
pos.colname = "pos",
label.colname = NULL,
highlight.colname = NULL,
chr.order = NULL,
signif.col = NULL,
chr.col = NULL,
highlight.col = NULL,
rescale = TRUE,
rescale.ratio.threshold = 5,
signif.rel.pos = 0.2,
chr.gap.scaling = 1,
color.by.highlight = FALSE,
preserve.position = FALSE,
thin = NULL,
thin.n = 1000,
thin.bins = 200,
pval.log.transform = TRUE,
plot.title = ggplot2::waiver(),
plot.subtitle = ggplot2::waiver(),
plot.width = 10,
plot.height = 5,
point.size = 0.75,
label.font.size = 2,
max.overlaps = 20,
x.label = "Chromosome",
y.label = expression(-log[10](p)),
...
)
## S3 method for class 'MPdata'
manhattan_plot(
x,
chromosome = NULL,
outfn = NULL,
signif = NULL,
signif.col = NULL,
rescale = TRUE,
rescale.ratio.threshold = 5,
signif.rel.pos = 0.2,
chr.gap.scaling = NULL,
color.by.highlight = FALSE,
label.colname = NULL,
x.label = "Chromosome",
y.label = expression(-log[10](p)),
point.size = 0.75,
label.font.size = 2,
max.overlaps = 20,
plot.title = ggplot2::waiver(),
plot.subtitle = ggplot2::waiver(),
plot.width = 10,
plot.height = 5,
...
)
## S4 method for signature 'GRanges'
manhattan_plot(
x,
chromosome = NULL,
outfn = NULL,
signif = c(5e-08, 1e-05),
pval.colname = "pval",
label.colname = NULL,
highlight.colname = NULL,
chr.order = NULL,
signif.col = NULL,
chr.col = NULL,
highlight.col = NULL,
rescale = TRUE,
rescale.ratio.threshold = 5,
signif.rel.pos = 0.2,
chr.gap.scaling = 1,
color.by.highlight = FALSE,
preserve.position = FALSE,
thin = NULL,
thin.n = 1000,
thin.bins = 200,
pval.log.transform = TRUE,
plot.title = ggplot2::waiver(),
plot.subtitle = ggplot2::waiver(),
plot.width = 10,
plot.height = 5,
point.size = 0.75,
label.font.size = 2,
max.overlaps = 20,
x.label = "Chromosome",
y.label = expression(-log[10](p)),
...
)
x |
a |
... |
additional arguments to be passed onto |
chromosome |
a character. This is supplied if a manhattan plot of a single chromosome is
desired. If |
outfn |
a character. File name to save the Manhattan Plot. If |
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 |
pval.colname |
a character. Column name of |
chr.colname |
a character. Column name of |
pos.colname |
a character. Column name of |
label.colname |
a character. Name of the column in |
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 |
chr.order |
a character vector. Order of chromosomes presented in manhattan plot. |
signif.col |
a character vector of equal length as |
chr.col |
a character vector of equal length as chr.order. It contains colors
for the chromosomes. Name of the vector should match |
highlight.col |
a character vector. It contains color mapping for the values from
|
rescale |
a logical. If |
rescale.ratio.threshold |
a numeric. Threshold of that triggers the rescale. |
signif.rel.pos |
a numeric between 0.1 and 0.9. If the plot is rescaled, where should the significance threshold be positioned? |
chr.gap.scaling |
a numeric. scaling factor for gap between chromosome if you desire to change it
if x is an |
color.by.highlight |
a logical. Should the points be colored based on a highlight column? |
preserve.position |
a logical. If |
thin |
a logical. If |
thin.n |
an integer. Number of max points per horizontal partitions of the plot. Defaults to 1000. |
thin.bins |
an integer. Number of bins to partition the data. Defaults to 200. |
pval.log.transform |
a logical. If |
plot.title |
a character. Plot title |
plot.subtitle |
a character. Plot subtitle |
plot.width |
a numeric. Plot width in inches. |
plot.height |
a numeric. Plot height in inches. |
point.size |
a numeric. Size of the points. |
label.font.size |
a numeric. Size of the labels. |
max.overlaps |
an integer. Exclude text labels that overlaps too many things. |
x.label |
a character. x-axis label |
y.label |
a character. y-axis label |
This generic function accepts a result of a GWAS in the form of data.frame
or a MPdata
object produced by manhattan_data_preprocess
. The
function will throw an error if another type of object is passed.
Having rescale = TRUE
is useful when there are points with very
high -log10(p.value). In this case, the function attempts to split
the plot into two different scales, with the split happening near the strictest
significance threshold. More precisely, the plot is rescaled when
-log10(pvalue) / (strictest significance threshold) \ge rescale.ratio.threshold
If you wish to add annotation to the points, provide the name of the column to
label.colname
. The labels are added with ggrepel
.
Be careful though: if the annotation column contains
a large number of variants, then the plotting could take a long time, and the
labels will clutter up the plot. For those points with no annotation, you have the
choice to set them as NA
or ""
.
gg
object if is.null(outfn)
, NULL
if !is.null(outf)
gwasdat <- data.frame(
"chromosome" = rep(1:5, each = 30),
"position" = c(replicate(5, sample(1:300, 30))),
"pvalue" = rbeta(150, 1, 1)^5
)
manhattan_plot(
gwasdat, pval.colname = "pvalue", chr.colname = "chromosome", pos.colname = "position",
chr.order = as.character(1:5)
)
mpdata <- manhattan_data_preprocess(
gwasdat, pval.colname = "pvalue", chr.colname = "chromosome", pos.colname = "position",
chr.order = as.character(1:5)
)
manhattan_plot(mpdata)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.