manhattanr: Creates a manhattanr object

Description Usage Arguments Value Source See Also Examples

View source: R/manhattanr.R

Description

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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
manhattanr(
  x,
  chr = "CHR",
  bp = "BP",
  p = "P",
  snp,
  gene,
  annotation1,
  annotation2,
  logp = TRUE
)

Arguments

x

A data.frame which must contain at least the following three columns:

  • the chromosome number

  • genomic base-pair position

  • a numeric quantity to plot such as a p-value or zscore

chr

A string denoting the column name for the chromosome. Default is chr = "CHR". This column must be numeric or integer. Minimum number of chromosomes required is 1. If you have X, Y, or MT chromosomes, be sure to renumber these 23, 24, 25, etc.

bp

A string denoting the column name for the chromosomal position. Default is bp = "BP". This column must be numeric or integer.

p

A string denoting the column name for the numeric quantity to be plotted on the y-axis. Default is p = "P". This column must be numeric or integer. This does not have to be a p-value. It can be any numeric quantity such as peak heights, bayes factors, test statistics. If it is not a p-value, make sure to set logp = FALSE.

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 character. This argument is optional, however it is necessary to specify if you want to highlight points on the plot using the highlight argument in the manhattanly function

gene

A string denoting the column name for the GENE names. This column could be a character or numeric. More generally this could be any annotation information that you want to include in the plot. This argument is optional.

annotation1

A string denoting the column name for an annotation. This column could be a character or numeric. This could be any annotation information that you want to include in the plot (e.g. zscore, effect size, minor allele frequency). This argument is optional.

annotation2

A string denoting the column name for an annotation. This column could be a character or numeric. This could be any annotation information that you want to include in the plot (e.g. zscore, effect size, minor allele frequency). This argument is optional.

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.

Value

A list object of class manhattanr with the following elements

data

processed data to be used for plotting

xlabel

The label of the x-axis which is determined by the number of chromosomes present in the data

ticks

the coordinates on the x-axis of where the tick marks should be placed

labs

the labels for each tick. This defaults to the chromosome number but can be changed in the manhattanly function

nchr

the number of unique chromosomes present in the data

pName, snpName, geneName, annotation1Name, annotation2Name

The names of the columns corresponding to the data provided. This information is used for annotating the plot in the manhattanly function

Source

The pre-processing is mostly the same as the manhattan function from the qqman package

See Also

manhattanly

Examples

1
2
3
4
5
6
7
8
9
# 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"]])

Example output

See example usage at http://sahirbhatnagar.com/manhattanly/
[1] "manhattanr"
  CHR      BP         P       logp     pos index
1   1  937641 0.3353438 0.47450973  937641     1
2   1 1136887 0.2458571 0.60931719 1136887     1
3   1 2116240 0.8232859 0.08444933 2116240     1
4   1 2310562 0.4932038 0.30697357 2310562     1
5   1 2681715 0.6053916 0.21796358 2681715     1
6   1 2917484 0.1944431 0.71120743 2917484     1
  CHR      BP         P        SNP    GENE       logp     pos index
1   1  937641 0.3353438  rs9697358   ISG15 0.47450973  937641     1
2   1 1136887 0.2458571 rs34945898 TNFRSF4 0.60931719 1136887     1
3   1 2116240 0.8232859 rs12034613  FP7162 0.08444933 2116240     1
4   1 2310562 0.4932038  rs4648633   MORN1 0.30697357 2310562     1
5   1 2681715 0.6053916  rs4430271   MMEL1 0.21796358 2681715     1
6   1 2917484 0.1944431  rs6685625  ACTRT2 0.71120743 2917484     1

manhattanly documentation built on April 26, 2021, 9:05 a.m.