Skip to contents

Orders a vector of indices according to their corresponding genomic locations (chromosome and position). This function is useful for sorting site sites or other genomic features by their physical positions.

Usage

orderByLoc(x, array = NULL, genome = NULL, genomic_locs = NULL)

Arguments

x

Character or integer vector. Indices or identifiers to be ordered

array

Character. Array platform type, either "450K" or "EPIC". Required when genomic_locs is NULL.

genome

Character. Genome version, either "hg38", "hg19", or "hs1". Required when genomic_locs is NULL.

genomic_locs

Data frame. Optional pre-computed genomic locations. If NULL, locations will be retrieved using getSortedGenomicLocs (default: NULL)

Value

Integer vector of ordered indices

Examples

locs <- data.frame(chr = c("chr1", "chr1", "chr2"), start = c(100L, 200L, 50L))
rownames(locs) <- c("cg1", "cg2", "cg3")
site_ids <- c("cg2", "cg3", "cg1")

ordered_indices <- orderByLoc(site_ids, genomic_locs = locs)
site_ids[ordered_indices]