Skip to contents

This function extracts genomic signal data for a specified region from either a data frame or a file. It filters the data to only include features within the specified region and optionally adds a track name.

Usage

get_single_coverage(
  input,
  region,
  name = NULL,
  n_bins = 2000L,
  verbose = FALSE
)

Arguments

input

Either a data frame with genomic coordinates or a character string specifying the path to a genomic data file (BED, bigWig, GFF, etc.)

region

A genomic region string in the format "chr:start-end" or a GRanges object

name

Optional name to assign to the track (default: NULL)

n_bins

Maximum number of bins used for BigWig queries through megadepth (default: 2000).

verbose

Logical. If TRUE, print megadepth progress output for BigWig imports. If FALSE (default), suppress routine messages.

Value

A data frame containing the filtered genomic data with an optional name column

Examples

if (FALSE) { # \dontrun{
# Extract data from a data frame
df <- data.frame(
  seqnames = c("chr1", "chr1", "chr2"),
  start = c(1, 100, 200),
  end = c(50, 150, 250),
  score = c(0.1, 0.5, 0.9)
)
region_data <- get_single_coverage(df, "chr1:50-150", name = "track1")

# Extract data from a file
file_data <- get_single_coverage("peaks.bed", "chr1:1000000-2000000", name = "peaks")
} # }