ukbtools (version 0.11.1)

ukb_gen_write_bgenie: Writes a BGENIE format phenotype or covariate file.

Description

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.

Usage

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

Run this code
# NOT RUN {
# Automatically sorts observations to match UKB sample file and writes missing values as -999

my_ukb_sample <- ukb_gen_read_sample("ukb.sample")

ukb_gen_write_bgenie(
   my_ukb_data,
   ukb.sample = my_ukb_sample,
   ukb.variables = c("height", "weight", "iq")
   path = "my_ukb_bgenie.pheno",
)

ukb_gen_write_bgenie(
   my_ukb_data,
   ukb.sample = my_ukb_sample,
   ukb.variables = c("age", "socioeconomic_status", "genetic_pcs")
   path = "my_ukb_bgenie.cov",
)
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace