Writes a space-delimited file with a header, missing character set to "-999", and observations (i.e. UKB subject ids) in sample file order. Use this function to write phenotype and covariate files for downstream genetic analysis in BGENIE - the format is the same.

ukb_gen_write_bgenie(
  x,
  ukb.sample,
  ukb.variables,
  path,
  ukb.id = "eid",
  na.strings = "-999"
)

Arguments

x

A UKB dataset.

ukb.sample

A UKB sample file.

ukb.variables

A character vector of either the phenotypes for a BGENIE phenotype file, or covariates for a BGENIE covariate file.

path

A path to a file.

ukb.id

The eid variable name (default = "eid").

na.strings

Character string to be used for missing value in output file. Default = "-999"

Details

Uses a dplyr::left_join to the sample file to match sample file order. Any IDs in the sample file not included in the phenotype or covariate data will be missing for all variables selected. See BGENIE usage for descriptions of the --pheno and --covar flags to read phenotype and covariate data into BGENIE.

See also

ukb_gen_read_sample to read a sample file, ukb_gen_excl_to_na to update a phenotype with NAs for samples to-be-excluded based on genetic metadata, and ukb_gen_write_plink to write phenotype and covariate files to PLINK format.

Examples