tidy_fstat: fstat file to tidy dataframe

View source: R/fstat.R

tidy_fstatR Documentation

fstat file to tidy dataframe

Description

Used internally in radiator and might be of interest for users. The function tidy_fstat reads a file in the fstat file (Goudet, 1995) into a wide or long/tidy data frame

To manipulate and prune the dataset prior to tidying, use the functions tidy_genomic_data and genomic_converter, that uses blacklist and whitelist along several other filtering options.

Usage

tidy_fstat(data, strata = NULL, tidy = TRUE, filename = NULL)

Arguments

data

A fstat filename with extension .dat.

strata

(optional) A tab delimited file with 2 columns. Header: INDIVIDUALS and STRATA. The STRATA column can be any hierarchical grouping. To create a strata file see individuals2strata. Default: strata = NULL.

tidy

(optional, logical) With tidy = FALSE, the markers are the variables and the genotypes the observations (wide format). With the default: tidy = TRUE, markers and genotypes are variables with their own columns (long format).

filename

(optional) The file name for the tidy data frame written to the working directory. Default: filename = NULL, the tidy data is in the global environment only (i.e. not written in the working directory).

Value

The output in your global environment is a wide or long/tidy data frame. If filename is provided, the wide or long/tidy data frame is also written to the working directory.

Author(s)

Thierry Gosselin thierrygosselin@icloud.com

References

Goudet J. (1995). FSTAT (Version 1.2): A computer program to calculate F-statistics. Journal of Heredity 86:485-486

See Also

hierfstat

Examples

## Not run: 
# We will use the fstat dataset provided with adegenet package
require("hierfstat")

# The simplest form of the function:
fstat.file <- radiator::tidy_fstat(
    data = system.file(
    "extdata/diploid.dat",
    package = "hierfstat"
    )
 )

# To output a data frame in wide format, with markers in separate columns:
nancycats.wide <- radiator::tidy_fstat(
    data = system.file(
        "extdata/diploid.dat",
        package = "hierfstat"
    ),
tidy = FALSE
)

## End(Not run)

thierrygosselin/radiator documentation built on May 5, 2024, 5:12 a.m.