R/event_relevant_functions.R
process_cnv_events.RdProcesses 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)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
For each row in the input table:
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
Otherwise keeps the original row unchanged
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
} # }