pcoa_freqs: Perform a PCoA (principal coordinates analysis) on population...

View source: R/pcoa_freqs.R

pcoa_freqsR Documentation

Perform a PCoA (principal coordinates analysis) on population allele frequencies

Description

Takes a long-format data table of allele frequencies, calculates pairwise FST, and conducts a PCoA of these pairwise FST values using R's ape::pcoa() function (be sure to cite Paradis & Schliep 2019).

Usage

pcoa_freqs(
  dat,
  popCol = "POP",
  locusCol = "LOCUS",
  freqCol = "FREQ",
  indsCol = "INDS"
)

Arguments

dat

Data table: A long-format data table containing allele frequency estimates for biallelic SNP loci. Requires the following columns:

  1. The population ID (see param popCol).

  2. The locus ID (see param locusCol).

  3. The allele frequency column column (see param genoCol).

  4. The number of pooled diploids used to generate the allele frequency estimates (see param indsCol)

popCol

Character: The column name with the population information. Default is 'POP'.

locusCol

Character: The column name with the locus information. Default is 'LOCUS'.

freqCol

Character: The column name with the allele freuqency information. Default is 'FREQ'.

indsCol

Character: The column name with the number of individuals contributing to the allele freuqency estimate. Default is indsCol.

Value

Returns a list-like object of class eigen, as per ape::pcoa, with an additional long-format data table of genome-wide pairiwse FST estimates in an index $fst.

References

Paradis & Schliep (2019) Bioinformatics. DOI: 10.1093/bioinformatics/bty633

Examples

library(genomalicious)
data(data_PoolFreqs)
data(data_PoolInfo)

# Note columns in data_PoolFreqs
colnames(data_PoolFreqs)

# We need to add in the number of diploid individuals, $INDS
newFreqData <- left_join(data_PoolFreqs, data_PoolInfo)
head(newFreqData)

# Fit the PCoA
PCOA <-pcoa_freqs(newFreqData)

# Object class
class(PCOA)

# Axes
PCOA$vectors

# Eigenvalues
PCOA$values

# Pairwise FST in long-format data table
PCOA$fst


j-a-thia/genomalicious documentation built on Oct. 19, 2024, 7:51 p.m.