Creates a chromosome bar annotation track for ComplexHeatmap visualization, which includes alternating black and grey bars to distinguish chromosomes and chromosome number labels. The function handles both standard (22 autosomes + X, Y) and custom chromosome sets.

draw_chr_bar(window_data)

Arguments

window_data

A data frame containing genomic window information with at least one column named 'chr' (case-insensitive) containing chromosome identifiers (e.g., "chr1", "chr2", etc.).

Value

A HeatmapAnnotation object from the ComplexHeatmap package containing:

  • A text annotation track with chromosome numbers

  • A binary pattern track with alternating black and grey bars

Details

The function performs the following steps:

  • Standardizes chromosome column names to lowercase

  • Computes chromosome lengths and boundaries

  • Creates alternating binary pattern for visual separation

  • Calculates mean positions for chromosome labels

  • Generates chromosome text annotations

Examples

if (FALSE) { # \dontrun{
# Create sample window data
window_data <- data.frame(
  chr = rep(paste0("chr", c(1:22, "X")), each = 100),
  start = 1:2300,
  end = 101:2400
)

# Generate chromosome bar annotation
chr_annotation <- draw_chr_bar(window_data)

# Use in ComplexHeatmap
library(ComplexHeatmap)
Heatmap(matrix_data,
        top_annotation = chr_annotation)
} # }