Title: | Interactive Q-Q and Manhattan Plots Using 'plotly.js' |
---|---|
Description: | Create interactive manhattan, Q-Q and volcano plots that are usable from the R console, in 'Dash' apps, in the 'RStudio' viewer pane, in 'R Markdown' documents, and in 'Shiny' apps. Hover the mouse pointer over a point to show details or drag a rectangle to zoom. A manhattan plot is a popular graphical method for visualizing results from high-dimensional data analysis such as a (epi)genome wide association study (GWAS or EWAS), in which p-values, Z-scores, test statistics are plotted on a scatter plot against their genomic position. Manhattan plots are used for visualizing potential regions of interest in the genome that are associated with a phenotype. Interactive manhattan plots allow the inspection of specific value (e.g. rs number or gene name) by hovering the mouse over a cell, as well as zooming into a region of the genome (e.g. a chromosome) by dragging a rectangle around the relevant area. This work is based on the 'qqman' package and the 'plotly.js' engine. It produces similar manhattan and Q-Q plots as the 'manhattan' and 'qq' functions in the 'qqman' package, with the advantage of including extra annotation information and interactive web-based visualizations directly from R. Once uploaded to a 'plotly' account, 'plotly' graphs (and the data behind them) can be viewed and modified in a web browser. |
Authors: | Sahir Bhatnagar [aut, cre] (http://sahirbhatnagar.com/) |
Maintainer: | Sahir Bhatnagar <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0 |
Built: | 2025-03-04 03:17:27 UTC |
Source: | https://github.com/sahirbhatnagar/manhattanly |
A dataset containing a subset of the draft release 2 for genome-wide SNP genotyping in DNA samples from 11 human populations (sometimes referred to as the "HapMap 3" samples). Only the PLINK .map file was used. Approximately 2.5% of the SNPs in each chromosome were retained. The p-values, zscores, and effectsizes were simulated using random distributions in R. Annotation information (nearest gene and distance to nearest gene) was obtained from the UCSC genome annotation database for the Mar. 2006 GenBank freeze assembled by NCBI (hg18, Build 36.1)
HapMap
HapMap
A data frame with 14412 rows and 8 variables:
chromosome number. Autosomes coded 1 through 22, and 23 is the X
chromosome (integer
)
genomic base-pair position
(integer
)
p-value (numeric
)
rs# or snp
identifier (character
)
z-score (numeric
)
effect size (numeric
)
nearest gene to
the SNP (character
)
distance between the SNP and
GENE. if DISTANCE=0
then the SNP is located in the GENE
(integer
)
ftp://ftp.ncbi.nlm.nih.gov/hapmap/genotypes/2009-01_phaseIII/plink_format/
http://hgdownload.cse.ucsc.edu/goldenPath/hg18/database/
Creates an interactive manhattan plot with multiple annotation options
manhattanly( x, ..., col = c("#969696", "#252525"), point_size = 5, labelChr = NULL, suggestiveline = -log10(1e-05), suggestiveline_color = "blue", suggestiveline_width = 1, genomewideline = -log10(5e-08), genomewideline_color = "red", genomewideline_width = 1, highlight = NULL, highlight_color = "#00FF00", showlegend = FALSE, showgrid = FALSE, xlab = NULL, ylab = "-log10(p)", title = "Manhattan Plot" )
manhattanly( x, ..., col = c("#969696", "#252525"), point_size = 5, labelChr = NULL, suggestiveline = -log10(1e-05), suggestiveline_color = "blue", suggestiveline_width = 1, genomewideline = -log10(5e-08), genomewideline_color = "red", genomewideline_width = 1, highlight = NULL, highlight_color = "#00FF00", showlegend = FALSE, showgrid = FALSE, xlab = NULL, ylab = "-log10(p)", title = "Manhattan Plot" )
x |
Can be an object of class
|
... |
other parameters passed to |
col |
A character vector indicating the colors of each chromosome. If the number of colors specified is less than the number of unique chromosomes, then the elements will be recycled. Can be Hex Codes as well. |
point_size |
A |
labelChr |
A character vector equal to the number of chromosomes
specifying the chromosome labels (e.g., |
suggestiveline |
Where to draw a "suggestive" line. Default is
|
suggestiveline_color |
color of "suggestive" line. Only used if
|
suggestiveline_width |
Width of |
genomewideline |
Where to draw a "genome-wide sigificant" line. Default
|
genomewideline_color |
color of "genome-wide sigificant" line. Only used
if |
genomewideline_width |
Width of |
highlight |
A character vector of SNPs in your dataset to highlight.
These SNPs should all be in your dataset. Default is |
highlight_color |
Color used to highlight points. Only used if
|
showlegend |
Should a legend be shown. Default is |
showgrid |
Should gridlines be shown. Default is |
xlab |
X-axis label. Default is |
ylab |
Y-axis label. Default is |
title |
Title of the plot. Default is |
An interactive manhattan plot.
This package is inspired by the
qqman
package. This
package provides additional annotation options and builds on the
plotly
d3.js
engine. These plots can be included in
Dash apps, Shiny apps, Rmarkdown documents or embedded in websites using
simple HTML code.
manhattanr
, HapMap
,
significantSNP
## Not run: library(manhattanly) manhattanly(HapMap) # highlight SNPs of interest # 'signigicantSNP' is a character vector of SNPs included in this package manhattanly(HapMap, snp = "SNP", highlight = significantSNP) ## End(Not run)
## Not run: library(manhattanly) manhattanly(HapMap) # highlight SNPs of interest # 'signigicantSNP' is a character vector of SNPs included in this package manhattanly(HapMap, snp = "SNP", highlight = significantSNP) ## End(Not run)
An object of class manhattanr includes all the needed information for
producing a manhattan plot. The goal is to seperate the pre-processing of the
manhattan plot elements from the graphical rendaring of the object, which
could be done using any graphical device including
plot_ly
and plot
in base
R
.
manhattanr( x, chr = "CHR", bp = "BP", p = "P", snp, gene, annotation1, annotation2, logp = TRUE )
manhattanr( x, chr = "CHR", bp = "BP", p = "P", snp, gene, annotation1, annotation2, logp = TRUE )
x |
A
|
chr |
A string denoting the column name for the chromosome. Default is
|
bp |
A string denoting the column name for the chromosomal position.
Default is |
p |
A string denoting the column name for the numeric quantity to be
plotted on the y-axis. Default is |
snp |
A string denoting the column name for the SNP names (e.g. rs
number). More generally, this column could be anything that identifies each
point being plotted. For example, in an Epigenomewide association study
(EWAS) this could be the probe name or cg number. This column should be a
|
gene |
A string denoting the column name for the GENE names. This column
could be a |
annotation1 |
A string denoting the column name for an annotation. This
column could be a |
annotation2 |
A string denoting the column name for an annotation. This
column could be a |
logp |
If TRUE, the -log10 of the p-value is plotted. It isn't very useful to plot raw p-values, but plotting the raw value could be useful for other genome-wide plots, for example, peak heights, bayes factors, test statistics, other "scores" etc. |
A list
object of class manhattanr
with the following
elements
processed data to be used for plotting
The label of the x-axis which is determined by the number of chromosomes present in the data
the coordinates on the x-axis of where the tick marks should be placed
the labels for each
tick. This defaults to the chromosome number but can be changed in the
manhattanly
function
the number of unique chromosomes present in the data
The names of the columns corresponding to
the data provided. This information is used for annotating the plot in the
manhattanly
function
The pre-processing is mostly the same as the
manhattan function from the
qqman
package
# HapMap dataset included in this package already has columns named P, CHR and BP library(manhattanly) DT <- manhattanr(HapMap) class(DT) head(DT[["data"]]) # include snp and gene information DT2 <- manhattanr(HapMap, snp = "SNP", gene = "GENE") head(DT2[["data"]])
# HapMap dataset included in this package already has columns named P, CHR and BP library(manhattanly) DT <- manhattanr(HapMap) class(DT) head(DT[["data"]]) # include snp and gene information DT2 <- manhattanr(HapMap, snp = "SNP", gene = "GENE") head(DT2[["data"]])
Creates an interactive Q-Q plot with multiple annotation options
qqly( x, ..., col = "#252525", size = 5, type = 20, abline_col = "red", abline_size = 1, abline_type = "solid", highlight = NULL, highlight_color = "#00FF00", xlab = "Expected -log10(p)", ylab = "Observed -log10(p)", title = "Q-Q Plot" )
qqly( x, ..., col = "#252525", size = 5, type = 20, abline_col = "red", abline_size = 1, abline_type = "solid", highlight = NULL, highlight_color = "#00FF00", xlab = "Expected -log10(p)", ylab = "Observed -log10(p)", title = "Q-Q Plot" )
x |
Can be an object of class
|
... |
other parameters passed to |
col |
A |
size |
A |
type |
An integer between 0 and 25 specifying the point shape. Default is 20 (filled circle). Deprecated. |
abline_col |
A |
abline_size |
A |
abline_type |
Sets the line type of the 45 degree line. Set to a dash type character among "solid", "dot", "dash", "longdash", "dashdot", or "longdashdot", or a dash length list in px (eg "5px","10px","2px"). Can also be a positive numeric value (e.g 5, 10, 2). Default is "dash". See plotly help page on layouts for complete list and more details |
highlight |
A character vector of SNPs in your dataset to highlight.
These SNPs should all be in your dataset. Default is |
highlight_color |
Color used to highlight points. Only used if
|
xlab |
X-axis label. Default is |
ylab |
Y-axis label. Default is |
title |
Title of the plot. Default is |
An interactive Q-Q plot.
## Not run: library(manhattanly) qqly(HapMap) # highlight SNPs of interest # 'signigicantSNP' is a character vector of SNPs included in this package qqly(HapMap, snp = "SNP", highlight = significantSNP) ## End(Not run)
## Not run: library(manhattanly) qqly(HapMap) # highlight SNPs of interest # 'signigicantSNP' is a character vector of SNPs included in this package qqly(HapMap, snp = "SNP", highlight = significantSNP) ## End(Not run)
An object of class qq includes all the needed information for producing a
quantile-quantile plot of p-values. The goal is to seperate the
pre-processing of the quantile-quantile plot elements from the graphical
rendaring of the object, which could be done using any graphical device
including plot_ly
and plot
in
base R
.
qqr(x, p = "P", snp, gene, annotation1, annotation2, ...)
qqr(x, p = "P", snp, gene, annotation1, annotation2, ...)
x |
A
|
p |
A string denoting the column name for the p-values. Default is
|
snp |
A string denoting the column name for the SNP names (e.g. rs
number). More generally, this column could be anything that identifies each
point being plotted. For example, in an Epigenomewide association study
(EWAS) this could be the probe name or cg number. This column should be a
|
gene |
A string denoting the column name for the GENE names. This column
could be a |
annotation1 |
A string denoting the column name for an annotation. This
column could be a |
annotation2 |
A string denoting the column name for an annotation. This
column could be a |
... |
currently ignored |
An list object of class qqr
with the following elements
processed data to be used for plotting the Q-Q plot including the observed and expected p-values on the -log10 scale
The names
of the columns corresponding to the data provided. This information is used
for annotating the plot in the qqly
function
This function will return an error if any of the p-values are NA, less than 0 or greater than 1
The calculation of the expected p-value is taken from the
qq function from the
qqman
package
library(manhattanly) qqrObj <- qqr(HapMap, snp = "SNP", highlight = significantSNP) class(qqrObj) head(qqrObj[["data"]])
library(manhattanly) qqrObj <- qqr(HapMap, snp = "SNP", highlight = significantSNP) class(qqrObj) head(qqrObj[["data"]])
SNP rs identifiers from HapMap
dataset that are significant at p-value
< 1e-6
significantSNP
significantSNP
A character vector with 20 elements
Creates an interactive volcano plot with multiple annotation options
volcanoly( x, ..., col = c("#252525"), point_size = 5, effect_size_line = c(-1, 1), effect_size_line_color = "grey", effect_size_line_width = 0.5, effect_size_line_type = "dash", genomewideline = -log10(1e-05), genomewideline_color = "grey", genomewideline_width = 0.5, genomewideline_type = "dash", highlight = NULL, highlight_color = "red", xlab = NULL, ylab = "-log10(p)", title = "Volcano Plot" )
volcanoly( x, ..., col = c("#252525"), point_size = 5, effect_size_line = c(-1, 1), effect_size_line_color = "grey", effect_size_line_width = 0.5, effect_size_line_type = "dash", genomewideline = -log10(1e-05), genomewideline_color = "grey", genomewideline_width = 0.5, genomewideline_type = "dash", highlight = NULL, highlight_color = "red", xlab = NULL, ylab = "-log10(p)", title = "Volcano Plot" )
x |
Can be an object of class
|
... |
other parameters passed to |
col |
A character of length 1 indicating the color of the points. Only the first argument will be used if more than one color is supplied. Can be Hex Codes as well. |
point_size |
A |
effect_size_line |
Where to draw a "suggestive" line on the x-axis.
Default is |
effect_size_line_color |
color of "suggestive" line. Only used if
|
effect_size_line_width |
Width of |
effect_size_line_type |
Sets the line type of the
|
genomewideline |
Where to draw a "genome-wide sigificant" line. Default
|
genomewideline_color |
color of "genome-wide sigificant" line. Only used
if |
genomewideline_width |
Width of |
genomewideline_type |
Sets the line type of the |
highlight |
A character vector of SNPs in your dataset to highlight.
These SNPs should all be in your dataset. Default is |
highlight_color |
Color used to highlight points. Only used if
|
xlab |
X-axis label. Default is |
ylab |
Y-axis label. Default is |
title |
Title of the plot. Default is |
An interactive volcano plot.
This package provides additional annotation options and builds on the
plotly
d3.js
engine. These plots can be included in
Shiny apps, Dash apps, Rmarkdown documents or embeded in websites using
simple HTML code.
volcanor
, HapMap
,
significantSNP
volcanorObj <- volcanor(HapMap, p = "P", effect_size = "EFFECTSIZE", snp = "SNP", gene = "GENE" ) class(volcanorObj) head(volcanorObj$data)
volcanorObj <- volcanor(HapMap, p = "P", effect_size = "EFFECTSIZE", snp = "SNP", gene = "GENE" ) class(volcanorObj) head(volcanorObj$data)
An object of class volcano includes all the needed information for producing
a volcano plot of p-values against effect sizes or fold-changes. The goal is
to seperate the pre-processing of the volcano plot elements from the
graphical rendaring of the object, which could be done using any graphical
device including plot_ly
and
plot
in base R
.
volcanor( x, p = "P", effect_size = "EFFECTSIZE", snp, gene, annotation1, annotation2, ... )
volcanor( x, p = "P", effect_size = "EFFECTSIZE", snp, gene, annotation1, annotation2, ... )
x |
A
|
p |
A chracter string denoting the column name for the p-values. Default
is |
effect_size |
A string denoting the column name for the effect size.
Default is |
snp |
A string denoting the column name for the SNP names (e.g. rs
number). This argument is optional but required if you want to highlight
any points. More generally, this column could be anything that identifies
each point being plotted. For example, in an Epigenomewide association
study (EWAS) this could be the probe name or cg number. This column should
contain |
gene |
A string denoting the column name for the GENE names. This column
could be a |
annotation1 |
A string denoting the column name for an annotation. This
column could be a |
annotation2 |
A string denoting the column name for an annotation. This
column could be a |
... |
currently ignored |
An list object of class volcanor
with the following elements
processed data to be used for plotting the volcano plot including the observed and expected p-values on the -log10 scale
The names
of the columns corresponding to the data provided. This information is used
for annotating the plot in the volcanoly
function
This function will return an error if any of the p-values are NA, less than 0 or greater than 1
library(manhattanly) volcanorObj <- volcanor(HapMap) class(volcanorObj) head(volcanorObj)
library(manhattanly) volcanorObj <- volcanor(HapMap) class(volcanorObj) head(volcanorObj)