R/format_vctrs_bigSNP.R

Defines functions format.vctrs_bigSNP

#' @export
format.vctrs_bigSNP <- function(x, ..., width = 2) {
  # prevent width from being greater than the number of loci
  if (width > nrow(show_loci(x))) {
    width <- nrow(show_loci(x))
  }
  geno <- show_genotypes(x, loci_indices = 1:width)
  geno[is.na(geno)] <- "."
  geno <- paste0(
    "[",
    apply(geno, 1, function(row) {
      paste(row, collapse = ",")
    }), ",...]"
  )
  return(geno)
}

Try the tidypopgen package in your browser

Any scripts or data that you put into this service are public.

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