| Title: | Allele-Specific Methylation Analysis for Imprinted DMR Diagnostics |
|---|---|
| Description: | Provides functions for SNP-phased allele-specific methylation (ASM) analysis across the 41 canonical human imprinted differentially methylated regions (DMRs). Reads are assigned to REF or ALT alleles based on bisulfite-aware SNP detection, enabling diagnosis of imprinting disorders from whole-genome bisulfite sequencing data. <https://github.com/19-saha/ImprintCapASM>. |
| Authors: | Subham Saha [aut, cre, cph], Francesco Cecere [aut], Frederic Brioude [aut, fnd] |
| Maintainer: | Subham Saha <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-06-30 21:31:22 UTC |
| Source: | https://github.com/cran/ImprintCapASM |
Performs SNP-phased allele-specific methylation (ASM) analysis across the canonical human imprinted differentially methylated regions (DMRs). Reads are assigned to REF or ALT alleles based on bisulfite-aware SNP detection, and per-allele CpG methylation fractions are computed.
ASM( cpg_snp_file, sam_file, filter_cpgs_file, output_file = NULL, sample_type = c("control", "patient"), verbose = TRUE )ASM( cpg_snp_file, sam_file, filter_cpgs_file, output_file = NULL, sample_type = c("control", "patient"), verbose = TRUE )
cpg_snp_file |
Character. Path to the Excel output from
|
sam_file |
Character. Path to the extracted wide BAM file
produced by |
filter_cpgs_file |
Character. Path to the CpG filter/variability
reference Excel file ( |
output_file |
Character or |
sample_type |
Character. Either |
verbose |
Logical. If |
A named list with three elements:
Full read-level ASM results as a data.table.
Per SNP x CpG summary table.
Per CpG allele methylation summary table.
## Not run: extdata <- system.file("extdata", package = "ImprintCapASM") cpg_snp_tmp <- tempfile(fileext = ".xlsx") prepare_cpg_snp_input( snp_file = file.path(extdata, "example_snp.out"), meth_file = file.path(extdata, "example_cgmeth.txt"), cpg_ref_file = file.path(extdata, "example_filter_cpgs.xlsx"), output_file = cpg_snp_tmp, sample_type = "control" ) result <- ASM( cpg_snp_file = cpg_snp_tmp, sam_file = file.path(extdata, "example_markdup.bam"), filter_cpgs_file = file.path(extdata, "example_filter_cpgs.xlsx"), output_file = tempfile(fileext = ".xlsx"), sample_type = "control" ) head(result$snp_cpg) ## End(Not run)## Not run: extdata <- system.file("extdata", package = "ImprintCapASM") cpg_snp_tmp <- tempfile(fileext = ".xlsx") prepare_cpg_snp_input( snp_file = file.path(extdata, "example_snp.out"), meth_file = file.path(extdata, "example_cgmeth.txt"), cpg_ref_file = file.path(extdata, "example_filter_cpgs.xlsx"), output_file = cpg_snp_tmp, sample_type = "control" ) result <- ASM( cpg_snp_file = cpg_snp_tmp, sam_file = file.path(extdata, "example_markdup.bam"), filter_cpgs_file = file.path(extdata, "example_filter_cpgs.xlsx"), output_file = tempfile(fileext = ".xlsx"), sample_type = "control" ) head(result$snp_cpg) ## End(Not run)
Calls samtools view and samtools sort to subset a
whole-genome bisulfite BAM file to the genomic windows defined in a BED
file, producing a smaller indexed BAM suitable for input to
ASM.
extract_bam_regions( bam_file, bed_file, output_dir = dirname(bam_file), overwrite = FALSE, sample_type = c("control", "patient"), verbose = TRUE )extract_bam_regions( bam_file, bed_file, output_dir = dirname(bam_file), overwrite = FALSE, sample_type = c("control", "patient"), verbose = TRUE )
bam_file |
Character. Path to the input |
bed_file |
Character. Path to the BED file produced by
|
output_dir |
Character. Directory for output files. Defaults to
|
overwrite |
Logical. If |
sample_type |
Character. Either |
verbose |
Logical. If |
Requires samtools to be available on the system PATH.
The function calls samtools view -b, samtools sort, and
samtools index in sequence. If no .bai index is found
alongside bam_file, indexBam is called
automatically.
The path to the output BAM file (returned invisibly).
if (nchar(Sys.which("samtools")) > 0L) { extdata <- system.file("extdata", package = "ImprintCapASM") out_bam <- extract_bam_regions( bam_file = file.path(extdata, "example_markdup.bam"), bed_file = file.path(extdata, "example_cpg_snp.bed"), output_dir = tempdir(), sample_type = "control" ) file.exists(out_bam) }if (nchar(Sys.which("samtools")) > 0L) { extdata <- system.file("extdata", package = "ImprintCapASM") out_bam <- extract_bam_regions( bam_file = file.path(extdata, "example_markdup.bam"), bed_file = file.path(extdata, "example_cpg_snp.bed"), output_dir = tempdir(), sample_type = "control" ) file.exists(out_bam) }
Loads a bisulfite SNP .out file and a CpG methylation file,
intersects heterozygous SNPs with the 41-DMR CpG panel, and returns
a per-sample CpG-SNP pair table ready for input to ASM.
prepare_cpg_snp_input( snp_file, meth_file, cpg_ref_file, output_file = NULL, min_depth = 20L, window_bp = 60L, sample_type = c("control", "patient"), verbose = TRUE )prepare_cpg_snp_input( snp_file, meth_file, cpg_ref_file, output_file = NULL, min_depth = 20L, window_bp = 60L, sample_type = c("control", "patient"), verbose = TRUE )
snp_file |
Character. Path to a VCF-like file ending in
|
meth_file |
Character. Path to the gemBS/Bismark CpG methylation
table ( |
cpg_ref_file |
Character. Path to the CpG panel reference Excel file
( |
output_file |
Character or |
min_depth |
Integer. Minimum total SNP read depth. Default
|
window_bp |
Integer. Window in base pairs around each SNP used
to search for CpG positions. Default |
sample_type |
Character. Either |
verbose |
Logical. If |
A data.table of CpG-SNP pairs (returned invisibly). The
.xlsx and .bed files are written as side effects.
extdata <- system.file("extdata", package = "ImprintCapASM") cpg_snp_tmp <- tempfile(fileext = ".xlsx") result <- prepare_cpg_snp_input( snp_file = file.path(extdata, "example_snp.out"), meth_file = file.path(extdata, "example_cgmeth.txt"), cpg_ref_file = file.path(extdata, "example_filter_cpgs.xlsx"), output_file = cpg_snp_tmp, sample_type = "control" ) head(result)extdata <- system.file("extdata", package = "ImprintCapASM") cpg_snp_tmp <- tempfile(fileext = ".xlsx") result <- prepare_cpg_snp_input( snp_file = file.path(extdata, "example_snp.out"), meth_file = file.path(extdata, "example_cgmeth.txt"), cpg_ref_file = file.path(extdata, "example_filter_cpgs.xlsx"), output_file = cpg_snp_tmp, sample_type = "control" ) head(result)
Convenience wrapper that executes the complete three-step pipeline:
(1) prepare_cpg_snp_input, (2) extract_bam_regions,
and (3) ASM for every sample in a directory.
Controls and patients are always processed independently using their
respective filter_cpgs reference files.
run_pipeline( bam_dir, snp_dir, meth_dir, cpg_ref_file, output_dir, sample_type = c("control", "patient"), bed_file, min_depth = 20L, window_bp = 60L, overwrite = FALSE, verbose = TRUE )run_pipeline( bam_dir, snp_dir, meth_dir, cpg_ref_file, output_dir, sample_type = c("control", "patient"), bed_file, min_depth = 20L, window_bp = 60L, overwrite = FALSE, verbose = TRUE )
bam_dir |
Character. Path to the directory containing |
snp_dir |
Character. Path to the directory containing SNP
|
meth_dir |
Character. Path to the directory containing CpG
methylation files (Bismark |
cpg_ref_file |
Character. Path to the cohort-matched
|
output_dir |
Character. Directory where all output files are written. Created automatically if it does not exist. |
sample_type |
Character. Either |
bed_file |
Character. Path to the BED file defining the 41 DMR
regions used by |
min_depth |
Integer. Minimum read depth filter passed to
|
window_bp |
Integer. Window in base pairs around each CpG passed to
|
overwrite |
Logical. If |
verbose |
Logical. If |
Invisibly returns a named list of ASM result objects, one per
sample. Each element is the list returned by ASM,
containing $asm, $snp_cpg, and $meth_summary.
## Not run: extdata <- system.file("extdata", package = "ImprintCapASM") cpg_ref <- file.path(extdata, "example_filter_cpgs.xlsx") bed <- file.path(extdata, "example_cpg_snp.bed") output_dir <- tempdir() results <- run_pipeline( bam_dir = extdata, snp_dir = extdata, meth_dir = extdata, cpg_ref_file = cpg_ref, output_dir = output_dir, sample_type = "control", bed_file = bed ) head(results[[1]]$asm) ## End(Not run)## Not run: extdata <- system.file("extdata", package = "ImprintCapASM") cpg_ref <- file.path(extdata, "example_filter_cpgs.xlsx") bed <- file.path(extdata, "example_cpg_snp.bed") output_dir <- tempdir() results <- run_pipeline( bam_dir = extdata, snp_dir = extdata, meth_dir = extdata, cpg_ref_file = cpg_ref, output_dir = output_dir, sample_type = "control", bed_file = bed ) head(results[[1]]$asm) ## End(Not run)