Processes a table of genomic events, expanding chromosome-level CNV events into separate events for p and q arms while preserving other events.

process_cnv_events(event_table)

Arguments

event_table

A data frame of genomic events containing:

  • event_type: Type of event (e.g., "CNV", "WGD")

  • region_name: Region identifier or chromosome name in format "chrN" where N is the chromosome number

  • Other event-specific columns that will be preserved

Value

A data frame with the same structure as input but with chromosome-level CNV events expanded into p and q arm events. For example:

  • A CNV event for "chr1" becomes two events for "chr1p" and "chr1q"

  • Non-CNV events or non-chromosome-level CNVs remain unchanged

Details

For each row in the input table:

  1. If it's a CNV event with region_name matching "chr" followed by numbers:

    • Creates two new rows with "p" and "q" suffixes

    • Copies all other column values to both new rows

  2. Otherwise keeps the original row unchanged

Examples

if (FALSE) { # \dontrun{
events <- data.frame(
  event_type = c("CNV", "WGD", "CNV"),
  region_name = c("chr1", "genome", "chr1p"),
  CN_change = c(1, 0, -1),
  stringsAsFactors = FALSE
)

processed <- process_cnv_events(events)
# Returns:
#   event_type region_name CN_change
# 1      CNV       chr1p        1
# 2      CNV       chr1q        1
# 3      WGD      genome        0
# 4      CNV       chr1p       -1
} # }