read_phen: Read *.phen files

Description Usage Arguments Value See Also Examples

View source: R/read_phen.R

Description

This function reads a standard *.phen file into a tibble. It uses readr::read_table2() to do it efficiently. GCTA and EMMAX use this format.

Usage

1
read_phen(file, verbose = TRUE)

Arguments

file

Input file (whatever is accepted by readr::read_table2()). If file as given does not exist and is missing the expected *.phen extension, the function adds the .phen extension and uses that path if that file exists. Additionally, the .gz extension is added automatically if the file (after *.phen extension is added as needed) is still not found and did not already contain the .gz extension and adding it points to an existing file.

verbose

If TRUE (default), function reports the path of the file being loaded (after autocompleting the extensions).

Value

A tibble with columns: fam, id, pheno.

See Also

GCTA PHEN format reference: https://cnsgenomics.com/software/gcta/#GREMLanalysis

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# to read "data.phen", run like this:
# phen <- read_phen("data")
# this also works
# phen <- read_phen("data.phen")

# The following example is more awkward
# because package sample data has to be specified in this weird way:

# read an existing plink *.phen file
file <- system.file("extdata", 'sample.phen', package = "genio", mustWork = TRUE)
phen <- read_phen(file)
phen

# can specify without extension
file <- sub('\\.phen$', '', file) # remove extension from this path on purpose
file # verify .phen is missing
phen <- read_phen(file) # load it anyway!
phen

genio documentation built on June 11, 2021, 5:12 p.m.