Learn R Programming

tidypopgen (version 0.4.3)

pop_tajimas_d: Estimate Tajima's D for the whole genome

Description

Note that Tajima's D estimates from data that have been filtered or ascertained can be difficult to interpret. This function should ideally be used on sequence data prior to filtering.

Usage

pop_tajimas_d(.x, n_cores, block_size, ...)

# S3 method for tbl_df pop_tajimas_d( .x, n_cores = bigstatsr::nb_cores(), block_size = bigstatsr::block_size(nrow(.x), 1), ... )

# S3 method for vctrs_bigSNP pop_tajimas_d( .x, n_cores = bigstatsr::nb_cores(), block_size = bigstatsr::block_size(length(.x), 1), ... )

# S3 method for grouped_df pop_tajimas_d( .x, n_cores = bigstatsr::nb_cores(), block_size = bigstatsr::block_size(nrow(.x), 1), ... )

Value

A single numeric value (Tajima's D D) for the whole data set, NA

when the statistic is not defined. For grouped data a list of Tajima's D D values (one per group) is returned.

Arguments

.x

a vector of class vctrs_bigSNP (usually the genotypes column of a gen_tibble object), or a gen_tibble.

n_cores

number of cores to be used, it defaults to bigstatsr::nb_cores()

block_size

maximum number of loci read at once.

...

other arguments passed to specific methods, currently unused.

Examples

Run this code
if (FALSE) { # all(rlang::is_installed(c("RhpcBLASctl", "data.table")))
# \dontshow{
data.table::setDTthreads(2)
RhpcBLASctl::blas_set_num_threads(2)
RhpcBLASctl::omp_set_num_threads(2)
# }
example_gt <- load_example_gt("grouped_gen_tbl")

# Compute Tajima's D
example_gt %>% pop_tajimas_d()
}

Run the code above in your browser using DataLab