Learn R Programming

genio (version 1.0.9)

sex_to_int: Convert character sex codes to integer codes

Description

This function accepts the character sex codes accepted by eigenstrat and turns them into the integer codes accepted by plink. Matching is case insensitive. The correspondence is:

U:

0 (unknown)

M:

1 (male)

F:

2 (female)

Any other characters will also be mapped to 0 (unknown) but with a warning (U does not generate warnings).

Usage

sex_to_int(sex)

Arguments

sex

Character vector of sex codes

Value

The converged numeric vector of sex codes

See Also

sex_to_char

Eigenstrat IND format reference: https://github.com/DReichLab/EIG/tree/master/CONVERTF

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

Examples

Run this code
# NOT RUN {
# verify the mapping above
sex_char <- c('U', 'm', 'f') # mixed case works!
sex_int <- 0:2 # expected values
stopifnot(
  all(
    sex_to_int( sex_char ) == sex_int
  )
)

# }

Run the code above in your browser using DataLab