nwise_pop_pbs: Compute the Population Branch Statistics for each combination...

View source: R/nwise_pop_pbs.R

nwise_pop_pbsR Documentation

Compute the Population Branch Statistics for each combination of populations

Description

The function computes the population branch statistics (PBS) for each combination of populations at each locus. The PBS is a measure of the genetic differentiation between one focal population and two reference populations, and is used to identify outlier loci that may be under selection.

Usage

nwise_pop_pbs(
  .x,
  type = c("tidy", "matrix"),
  fst_method = c("Hudson", "Nei87", "WC84"),
  return_fst = FALSE
)

Arguments

.x

A grouped gen_tibble

type

type of object to return. One of "tidy" or "matrix". Default is "tidy".

fst_method

the method to use for calculating Fst, one of 'Hudson', 'Nei87', and 'WC84'. See pairwise_pop_fst() for details.

return_fst

A logical value indicating whether to return the Fst values along with the PBS values. Default is FALSE.

Value

Either a matrix with locus ID as rownames and the following columns:

  • pbs_a.b.c: the PBS value for population a given b & c (there will be multiple such columns covering all 3 way combinations of populations in the grouped gen_tibble object)

  • pbsn1_a.b.c: the normalized PBS value for population a given b & c.

  • fst_a.b: the Fst value for population a and b, if return_fst is TRUE or a tidy tibble with the following columns:

  • loci: the locus ID

  • stat_name: the name of populations used in the pbs calculation (e.g. "pbs_pop1.pop2.pop3"). If return_fst is TRUE, stat_name will also include "fst" calculations in the same column (e.g. "fst_pop1.pop2").

  • value: the pbs value for the populations

References

Yi X, et al. (2010) Sequencing of 50 human exomes reveals adaptation to high altitude. Science 329: 75-78.

Examples

example_gt <- load_example_gt()

# We can compute the PBS for all populations using "Hudson" method
example_gt %>%
  group_by(population) %>%
  nwise_pop_pbs(fst_method = "Hudson")

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