make_fam: Create a Plink FAM tibble

View source: R/make_fam.R

make_famR Documentation

Create a Plink FAM tibble

Description

This function simplifies the creation of Plink FAM-formatted tibbles, which autocompletes missing information if a partial tibble is provided, or generates a completely made up tibble if the number of individuals is provided. The default values are most useful for simulated genotypes, where IDs can be made up but must be unique, and there are no parents, families, gender, or phenotype.

Usage

make_fam(tib, n = NA)

Arguments

tib

The input tibble (optional). Missing columns will be autocompleted with reasonable values that are accepted by Plink and other external software. If missing, all will be autocompleted, but n is required.

n

The desired number of individuals (rows). Required if tib is missing; otherwise it is ignored.

Details

Autocompleted column values:

  • fam: 1:n

  • id: 1:n

  • pat: 0 (missing)

  • mat: 0 (missing)

  • sex: 0 (missing)

  • pheno: 0 (missing)

Note that n is either given directly or obtained from the input tibble.

Value

The input tibble with autocompleted columns and columns in default order, or the made up tibble if only the number of individuals was provided. The output begins with the standard columns in standard order: fam, id, pat, mat, sex, pheno. Additional columns in the input tibble are preserved but placed after the standard columns.

See Also

Plink FAM format reference: https://www.cog-genomics.org/plink/1.9/formats#fam

Examples

# create a synthetic tibble for 10 individuals
# (most common use case)
fam <- make_fam(n = 10)

# manually create a partial tibble with only phenotypes defined
library(tibble)
fam <- tibble(pheno = 0:2)
# autocomplete the rest of the columns
fam <- make_fam(fam)


genio documentation built on Jan. 7, 2023, 1:12 a.m.