ukb_gen_write_plink {ukbtools} | R Documentation |
Writes a PLINK format phenotype or covariate file
Description
This function writes a space-delimited file with header, with the obligatory first two columns FID and IID. Use this function to write phenotype and covariate files for downstream genetic analysis in plink - the format is the same.
Usage
ukb_gen_write_plink(x, path, ukb.variables, ukb.id = "eid",
na.strings = "NA")
Arguments
x |
A UKB dataset. |
path |
A path to a file. |
ukb.variables |
A character vector of either the phenotypes for a PLINK phenotype file, or covariates for a PLINK covariate file. |
ukb.id |
The id variable name (default = "eid"). |
na.strings |
String used for missing values. Defaults to NA. |
Details
The function writes the id variable in your dataset to the first two columns of the output file with the names FID and IID - you do not need to have two id columns in the data.frame passed to the argument x
. Use the --pheno-name
and --covar-name
PLINK flags to select columns by name. See the PLINK documentation for the --pheno
, --mpheno
, --pheno-name
, and --covar
, --covar-name
, --covar-number
flags.
See Also
ukb_gen_read_sample
to read a sample file, and ukb_gen_write_bgenie
to write phenotype and covariate files to BGENIE format.
Examples
## Not run:
# Automatically inserts FID IID columns required by PLINK
ukb_gen_write_plink(
my_ukb_data,
path = "my_ukb_plink.pheno",
ukb.variables = c("height", "weight", "iq")
)
ukb_gen_write_plink(
my_ukb_data,
path = "my_ukb_plink.cov",
ukb.variables = c("age", "socioeconomic_status", "genetic_pcs")
)
## End(Not run)