Skip to contents

Generates a genome-wide coverage plot, displaying the positions of markers across chromosomes. It is a customized version of plot_coverage from MapRtools and allows additional aesthetic modifications.

Usage

plot_coverage(map, limits = NULL, customize = TRUE)

Arguments

map

A data frame with two columns:

  • "chrom": Chromosome identifier (e.g., "CHR1", "CHR2", ...").

  • "position": The genomic position of markers (in base pairs).

limits

(Optional) A data frame specifying the maximum position for each chromosome. If NULL (default), the function computes chromosome limits from map.

customize

Logical. If TRUE, applies additional visual customizations. Default is TRUE.

Value

A ggplot2 object representing genome-wide coverage.

Details

  • Converts genomic positions from base pairs to megabases (Mb).

  • If limits are not provided, the function calculates the maximum position for each chromosome from map.

  • Orders chromosomes and positions correctly for visualization.

  • Uses geom_segment() to generate a chromosome-wide coverage plot.

  • When customize = TRUE, applies a minimalistic theme for enhanced visualization.

Note

Inspired by functions of Professor Jeffrey Endelman's MapRtools

Examples

# Example dataset
map_data <- data.frame(
  chrom = c("CHR1", "CHR1", "CHR2", "CHR2", "CHR3"),
  position = c(500000, 1200000, 800000, 1600000, 2000000)
)

# Basic coverage plot
plot_coverage(map_data)


# Coverage plot with custom aesthetics
plot_coverage(map_data, customize = TRUE)