Chop Genomic Segments into Fixed-Size Genomic Bins
Source:R/converting_segments_and_reads.R
segs_to_reads.RdSplits variable-length copy number segments into fixed-size genomic bins (windows) of a specified width (e.g., 500 Kb).
Arguments
- segs_df
A data.frame or tibble containing genomic segments with start, end, and chromosome name columns.
- bin_size
Numeric. The width of the genomic windows in base pairs. Defaults to
5e5(500 Kb).- genome_version
Character. The assembly build to use for creating genomic windows. Must be one of
"hg19"or"hg38".- return_type
Character. The format of the returned object. Must be one of
"granges"or"tibble". Defaults to"tibble".- seg_start_col
Character. The name of the column in
segs_dfrepresenting segment start coordinates. Defaults to"start".- seg_end_col
Character. The name of the column in
segs_dfrepresenting segment end coordinates. Defaults to"end".- sample_id_col
Character. The name of the column in
segs_dfidentifying the sample or cell. Defaults to"cell_id".- state_col
Character. The name of the column in
segs_dfrepresenting the copy number state. Defaults to"state".- other_meta_cols
Character vector. Optional additional metadata column names in
segs_dfto carry over to the output. Defaults to an empty vector.- chrom_col
Character. The name of the column in
segs_dfrepresenting chromosomes. Defaults to"chr".
Value
Depending on return_type:
"granges": AGRangesobject containing the chopped bins with associated metadata columns."tibble": Atibbleversion of the GRanges object, with the chromosome column renamed back tochrom_col.
In both formats, the output retains the original segment start and end
positions in the seg_start and seg_end metadata columns.