map_snp_to_gene: Map SNPs to genes

View source: R/map_snp_to_gene.R

map_snp_to_geneR Documentation

Map SNPs to genes

Description

Annotate SNPs onto their neighboring genes (or arbitrary genomic regions) to perform set-based association tests.

Usage

map_snp_to_gene(
  info_snp,
  info_gene,
  extend_start = 20L,
  extend_end = 20L,
  only_sets = FALSE
)

Arguments

info_snp

A data frame with columns: "id", "chr", and "pos".

  • id = SNP ID (e.g., rs numbers)

  • chr = chromosome

  • pos = base-pair position

info_gene

A data frame with columns: "gene.id", "chr", "start", and "end".

  • gene.id = gene ID (or identifier for genomic regions)

  • chr = chromosome (must be the same chromosome coding scheme in info_snp)

  • start = genomic start position

  • end = genomic end position

If a gene has multiple intervals, SNPs mapped to any of them will be merged into a single set. Please assign unique IDs if you don't want this behavior.

extend_start

A single non-negative integer, allowing for a certain kb window before the gene to be included. Default is 20 (= 20kb).

extend_end

A single non-negative integer, allowing for a certain kb window after the gene to be included. Default is 20 (= 20kb).

only_sets

If TRUE, only sets of SNPs for individual genes are returned. Otherwise, both sets and mapping information are returned. Default is FALSE.

Value

A nested list containing following components:

  • sets: a named list where each index represents a separate set of SNPs

  • map: a data frame containing SNP mapping information

Examples


## GWAS summary statistics
head(exGWAS)

## Gene information data
head(gene.curated.GRCh37)

## Map SNPs to genes
snp_sets <- map_snp_to_gene(exGWAS, gene.curated.GRCh37)

## Better to use harmonized GWAS data for gene mapping
bfile <- system.file("extdata", "example.bed", package = "snpsettest")
x <- read_reference_bed(path = bfile)
hsumstats <- harmonize_sumstats(exGWAS, x)
snp_sets <- map_snp_to_gene(hsumstats, gene.curated.GRCh37)


snpsettest documentation built on Sept. 10, 2023, 1:08 a.m.