poolfstat_DT2Fst: Calculate FST with 'poolfstat' from a data table of read...

View source: R/poolfstat_DT2Fst.R

poolfstat_DT2FstR Documentation

Calculate FST with poolfstat from a data table of read counts

Description

Takes a data table of read counts and creates an object of class poolfstat. The FST for the pools in the data table is calculated using the function poolfstat::computeFST. Also requires pool size information.

Usage

poolfstat_DT2Fst(dat, pool.info, method = "Anova")

Arguments

dat

Data table: Contains read counts, e.g. like that been produced by the function vcf2DT. Must contain all the following columns:

  1. $CHROM The chromosome (contig) ID.

  2. $POS The variant position on the chromosome.

  3. $REF The reference allele.

  4. $ALT The alternate allele.

  5. $POOL The pool ID.

  6. $AO The number of reads supporting the alternate allele.

  7. $RO The number of reads supporting the reference allele.

pool.info

Data table: Contains the sample sample sizes (number of diploids) for for each unique pool listed in dat$POOL. Requires two columns:

  1. $POOL The pools listed in dat$POOL.

  2. $INDS The number of diploid individuals for the pools.

method

Character: Either 'Anova' (default) or 'Identity'. Passed to method argument in poolfstat::computeFST.

Value

Returns a list with two indices: $Fst is the calculated FST among the pools using a function call of poolfstat::computeFST, whereas $pooldat is the poolfstat object used to generate said FST values.

Examples

library(genomalicious)

# Load in the pool metadata and reads
data(data_PoolInfo)
data(data_PoolFreqs)

# Pool info
data_PoolInfo

# Pool reads in $DP, $AO, and $RO
data_PoolFreqs[, c('POOL','DP','AO','RO')]

# Calculate FST using poolfstat
Y <- poolfstat_DT2Fst(data_PoolFreqs, data_PoolInfo)

# Output is a list
class(Y)

# Outout from poolfstat::computeFST
Y$Fst

# The pooldata class object, generated from data table of pooled reads
class(Y$pooldat)
Y$pooldat


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