R/segment_relevant_functions.R
sub_seg_from_cytoband_anno.RdConverts clustered cytoband annotations into genomic segments by identifying the spanning regions for each cluster. Creates segments for both maternal and paternal haplotypes with additional metadata for downstream analysis.
sub_seg_from_cytoband_anno(cluster_anno)A list with two elements (maternal and paternal), each containing a data frame of genomic segments with the following columns:
chrom: Chromosome name
start: Starting position of the segment
end: Ending position of the segment
region_name: Unique identifier (format: "sub_haplotype_chrom_clusterIndex")
haplotype: Maternal or paternal
ref_start: Reference start position
ref_end: Reference end position
ori_start: Original start position
ori_end: Original end position
copy_index: Copy number index (initialized to 0)
seg_id: Segment identifier (initialized to 0)
CN_change: Copy number change (initialized to 0)
seg_source_edge: Source edge info (initialized to "root")
seg_source_event: Source event info (initialized to "base")
For each cluster in the input annotations, the function:
Identifies the minimum start and maximum end positions of all cytobands
Creates a unique region name using haplotype, chromosome, and cluster index
Initializes metadata fields for downstream analysis
Combines all segments into haplotype-specific data frames
The resulting segments serve as a baseline for further genomic analyses, with fields prepared for tracking copy number changes and segment evolution.
Related functions for genomic segment analysis and manipulation
if (FALSE) { # \dontrun{
# Assuming cluster_anno is already defined:
segments <- sub_seg_from_cytoband_anno(cluster_anno)
# Access maternal segments:
maternal_segs <- segments[["maternal"]]
} # }