Import genomic data from a file into a tidy data frame
Source:R/helpers_conversions.R
import_genomic_data.RdThis function imports genomic data from various file formats (BED, bigWig, GFF, etc.) using rtracklayer and converts it to a tidy data frame suitable for ggplot2.
Arguments
- file
Path to the genomic data file
- which
GRanges object specifying the genomic region to import (default: NULL, import all)
- n_bins
Number of bins used for megadepth BigWig queries. Only used for BigWig inputs when
whichis provided. Default: 2000.- verbose
Logical. If
TRUE, print megadepth progress output for BigWig imports. IfFALSE(default), suppress routine messages.- format
File format (default: NULL, auto-detected from file extension)
Examples
if (FALSE) { # \dontrun{
# Import a BED file
peaks_df <- import_genomic_data("peaks.bed")
# Import a specific region from a bigWig file
library(GenomicRanges)
region <- GRanges("chr1", IRanges(1000000, 2000000))
signal_df <- import_genomic_data("signal.bw", which = region)
} # }