Package 'hmagmaR'

Title: Incorporation of chromatin interaction and epigenetic profiles to predict risk genes
Description: Combines chromatin interaction (e.g. PLAC-seq/Hi-C) data with regulatory region annotations (e.g. promoters, enhancers, H3K27ac) to link non-coding GWAS SNPs to their putative target genes, producing MAGMA-compatible gene annotation files for downstream gene-level association testing.
Authors: Aydan Asgarova [aut, cre]
Maintainer: Aydan Asgarova <[email protected]>
License: MIT + file LICENSE
Version: 0.99.3
Built: 2026-10-12 13:45:07 UTC
Source: https://github.com/BiocStaging/hmagmaR

Help Index


Gene level analysis carried out by magma (https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1004219)

Description

Generates an annotation file for magma input

Usage

AnnotationFileHmagma(
  hic,
  regulatoryRegions = NULL,
  promoterRegions = NULL,
  enhancerRegions = NULL,
  snps,
  annotated_genes,
  snpgeneexon,
  AnnotationFile
)

Arguments

hic

Dataframe of chromatin interaction data with 6 columns in the format: "chrom1", "start1", "end1", "chrom2", "start2", "end2". Chromosome columns should have "chr" before the number

regulatoryRegions

Dataframe of regulatory regions (H3K27ac) in the .bed format (chr, start, end). Chromosome columns should have "chr" before the number

promoterRegions

Dataframe of promoters in the .bed format (chr, start, end). Chromosome columns should have "chr" before the number

enhancerRegions

Dataframe of enhancers in the .bed format (chr, start, end). Chromosome columns should have "chr" before the number

snps

Dataframe of reference snps. This could be the ".bim" file from g1000 reference genome in the format: "chr", "position", "rsid"

annotated_genes

Dataframe of reference genes. This should contain columns with names "chr", "start", "end", "ensg". Chromosome columns should have "chr" before the number

snpgeneexon

Dataframe of genes and snps within it. This should contain columns with names "rsid", "ensg"

AnnotationFile

Path prefix for the output file; ".transcript.annot" is appended

Value

Function generates gene level analysis files (.genes.raw, .genes.out, .log.suppl, .log)

Examples

data("test_dataset.microglia.hg19")
out <- tempfile()
AnnotationFileHmagma(
  hic = hic, promoterRegions = promoterRegions, enhancerRegions = enhancerRegions,
  snps = snps, annotated_genes = annotated_genes, snpgeneexon = snpgeneexon,
  AnnotationFile = out
)

Gene level analysis carried out by magma (https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1004219)

Description

Generates an annotation file for magma input

Usage

GeneLevelAnalysis_hmagma(magma, g1000, gwas, AnnotationFile, output)

Arguments

magma

Path to magma binary file, should be in a '.../magma' format

g1000

Path to 1,000 Genomes reference data files (.bin, .bed, .fam, .synonyms). Include the name of the of the files in the path (e.g. /path_to_g1000/g1000_eur). Obtain from https://cncr.nl/research/magma/ under Auxiliary files.

gwas

Path to the GWAS summary statistics to be used where rsid column name is "SNP", p-value column name is "P", and sample size column name is "N"

AnnotationFile

Annotation file generated using AnnotationFileHmagma() or SampledDownAnnotation()

output

Name of the output file

Value

Function generates gene level analysis files (.genes.raw, .genes.out, .log.suppl, .log)

Examples

# Requires a local MAGMA installation and 1000 Genomes reference files;
# skipped automatically when magma is not found on the PATH.
magma_path <- Sys.which("magma")
if (nzchar(magma_path)) {
  GeneLevelAnalysis_hmagma(
    magma = magma_path,
    g1000 = "/path/to/g1000_eur",
    gwas = "/path/to/gwas_summary_stats.txt",
    AnnotationFile = "/path/to/annotation.transcript.annot",
    output = tempfile()
  )
} else {
  message("magma not found on PATH; skipping example.")
}

Gene level analysis carried out by magma (https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1004219)

Description

Generates an annotation file for magma input

Usage

SampledDownAnnotation(
  hic,
  regulatoryRegions,
  snps,
  annotated_genes,
  snpgeneexon,
  loopNumber,
  sampleDownNumber,
  AnnotationFile
)

Arguments

hic

Dataframe of chromatin interaction data with 6 columns in the format: "chrom1", "start1", "end1", "chrom2", "start2", "end2". Chromosome columns should have "chr" before the number

regulatoryRegions

Dataframe of regulatory regions (H3K27ac) in the .bed format (chr, start, end). Chromosome columns should have "chr" before the number

snps

Dataframe of reference snps. This could be the ".bim" file from g1000 reference genome in the format: "chr", "position", "rsid"

annotated_genes

Dataframe of reference genes. This should contain columns with names "chr", "start", "end", "ensg". Chromosome columns should have "chr" before the number

snpgeneexon

Dataframe of genes and snps within it. This should contain columns with names "rsid", "ensg"

loopNumber

Number to sample down the loop number to. This is useful when comparing more than one sample to ensure that the difference is not down to the difference in loop number

sampleDownNumber

Number of times sample down the loop number randomly

AnnotationFile

Path where to save the sampled down annotation files

Value

Function generates sampled down gene level analysis files (.genes.raw, .genes.out, .log.suppl, .log)

Examples

data("test_dataset.microglia.hg19")
out <- tempfile()
SampledDownAnnotation(
  hic = hic, regulatoryRegions = regulatoryRegions, snps = snps,
  annotated_genes = annotated_genes, snpgeneexon = snpgeneexon,
  loopNumber = 5000, sampleDownNumber = 1, AnnotationFile = out
)

Example microglia PLAC-seq dataset

Description

A small, randomly subsampled set of objects used to demonstrate the hmagmaR workflow in the package vignette and examples. Load with data("test_dataset.microglia.hg19"). Because the rows are drawn independently at random from each source table (rather than hand-picked around loci known to overlap), results produced from this dataset are illustrative only and not biologically meaningful.

Usage

hic

promoterRegions

enhancerRegions

regulatoryRegions

snps

annotated_genes

snpgeneexon

gwas

Format

Eight objects are provided:

hic

A data frame/tibble of 20,000 microglia PLAC-seq chromatin interactions (Nott et al., 2019), with columns chr1, start1, end1, chr2, start2, end2, plus interaction-calling metadata (count, expected, fdr, ClusterLabel, ClusterSize, ClusterType, ClusterNegLog10P, ClusterSummit).

promoterRegions

A data frame of 12,709 microglia promoter regions (Nott et al., 2019) in BED-like format: chr, start, end.

enhancerRegions

A data frame of 44,090 microglia enhancer regions (Nott et al., 2019) in BED-like format: chr, start, end.

regulatoryRegions

A data frame identical to promoterRegions, provided for functions such as SampledDownAnnotation() that take a single combined regulatory-region table instead of separate promoter and enhancer tables.

snps

A data table of 20,000 reference SNPs subsampled from 1000 Genomes (European ancestry), with columns chr, Position, SNP.

annotated_genes

A data table of 20,000 reference gene coordinates, with columns chr, start, end, ensg.

snpgeneexon

A data table of 20,000 SNPs falling within exons/promoters of a gene, with columns rsid, ensg.

gwas

A data table of 20,000 example GWAS summary statistics rows, with columns SNP, CHR, BP, A1, A2, FRQ, BETA, SE, P, N.

An object of class tbl_df (inherits from tbl, data.frame) with 20000 rows and 14 columns.

An object of class data.frame with 12709 rows and 3 columns.

An object of class data.frame with 44090 rows and 3 columns.

An object of class data.frame with 12709 rows and 3 columns.

An object of class data.table (inherits from data.frame) with 20000 rows and 3 columns.

An object of class data.table (inherits from data.frame) with 20000 rows and 4 columns.

An object of class data.table (inherits from data.frame) with 20000 rows and 2 columns.

An object of class data.table (inherits from data.frame) with 20000 rows and 10 columns.

Source

Subsampled from microglia PLAC-seq interactions and regulatory regions (Nott et al., 2019, https://doi.org/10.1126/science.aay0793), 1000 Genomes reference SNPs, and example GWAS summary statistics.