gt_order_loci: Order the loci table of a gen_tibble

View source: R/gt_order_loci.R

gt_order_lociR Documentation

Order the loci table of a gen_tibble

Description

This function reorders the loci table so that positions within a chromosome are sequential. It also re-saves the genotypes into a new file backed matrix with the new order, so that it can be used by functions such as loci_ld_clump() and gt_pca_autoSVD(). If the loci table is already ordered, the original gen_tibble is returned.

Usage

gt_order_loci(
  .x,
  use_current_table = FALSE,
  ignore_genetic_dist = TRUE,
  quiet = FALSE,
  ...
)

Arguments

.x

a gen_tibble

use_current_table

boolean, if FALSE (the default), the table will be reordered; if TRUE, then the current loci table, which might have been reordered manually, will be used, but only if the positions within each chromosome are sequential

ignore_genetic_dist

boolean to ignore the genetic distance when checking. Note that, if genetic_dist are being ignored and they are not sorted, the function will set them to zero to avoid problems with other software.

quiet

boolean to suppress information about the files

...

other arguments

Value

A gen_tibble

Examples

example_gt <- load_example_gt("gen_tbl") %>% select_loci(c(1, 5, 2, 6, 4, 3))

# Loci are in the wrong order
show_loci(example_gt)

# Reorder the loci, ignoring genetic distance
example_gt_ordered <- gt_order_loci(example_gt, ignore_genetic_dist = TRUE)

# Loci are now in the correct order
show_loci(example_gt_ordered)

tidypopgen documentation built on Aug. 28, 2025, 1:08 a.m.