sort_alias.Rd
This function sorts annotation data by chromosome and strand. It organizes data based on user-defined chromosome ordering and sorts each strand (`+` or `-`) by start and end positions. The function is designed to work with data frames that follow the format of GTF or GFF files. Data must be pre-loaded using load_annotation() or after calling create_GTF_df(), followed by add_UTR(), create_full_GTF(), or create_reduced_GTF().
sort_alias(input, chromosomes_queue = NaN)
Data frame. The input annotation data. The first column should represent chromosomes, the fourth column should represent start positions, the fifth column end positions, and the seventh column strands (`+` or `-`).
Character vector (optional). A predefined order of chromosomes for sorting. If `NaN` (default), chromosomes will be ordered based on their unique appearance in the input data.
A data frame containing the sorted annotation data, where:
Data is grouped and ordered by chromosome as defined in `chromosomes_queue`.
Each chromosome group is further sorted by strand (`+` and `-`).
Within each strand, data is sorted by start and end positions in ascending order.
This function is particularly useful for processing annotation data (e.g., GTF, GFF files) where sorting by genomic position and strand is required. The default chromosome order is determined by the unique appearance of chromosomes in the input data, but users can provide a specific order using `chromosomes_queue`.
The function processes each chromosome and strand separately, ensuring data is correctly grouped and sorted.
# Example with default chromosome order:
sorted_data <- sort_alias(input_data, chromosomes_queue = NaN)
#> Error: object 'input_data' not found
# Example with a specific chromosome order:
sorted_data <- sort_alias(input_data, chromosomes_queue = c("chr1", "chr2", "chrX", "chrY"))
#> Error: object 'input_data' not found