View source: R/write_control_file.R
write_control_file | R Documentation |
Write the control file (in YAML or JSON) needed
by read_cross2()
for a set of QTL data.
write_control_file(
output_file,
crosstype = NULL,
geno_file = NULL,
founder_geno_file = NULL,
gmap_file = NULL,
pmap_file = NULL,
pheno_file = NULL,
covar_file = NULL,
phenocovar_file = NULL,
sex_file = NULL,
sex_covar = NULL,
sex_codes = NULL,
crossinfo_file = NULL,
crossinfo_covar = NULL,
crossinfo_codes = NULL,
geno_codes = NULL,
alleles = NULL,
xchr = NULL,
sep = ",",
na.strings = c("-", "NA"),
comment.char = "#",
geno_transposed = FALSE,
founder_geno_transposed = FALSE,
pheno_transposed = FALSE,
covar_transposed = FALSE,
phenocovar_transposed = FALSE,
description = NULL,
comments = NULL,
overwrite = FALSE
)
output_file |
File name (with path) of the
YAML or JSON file to be created, as a character
string. If extension is |
crosstype |
Character string with the cross type. |
geno_file |
File name for genotype data. |
founder_geno_file |
File name for the founder genotype data. |
gmap_file |
File name for genetic map. |
pmap_file |
File name for the physical map. |
pheno_file |
File name for the phenotype data. |
covar_file |
File name for the covariate data. |
phenocovar_file |
File name for the phenotype covariate data (i.e., metadata about the phenotypes). |
sex_file |
File name for the individuals' sex. (Specify just
one of |
sex_covar |
Column name in the covariate data that corresponds
to sex. (Specify just one of |
sex_codes |
Named vector of character strings specifying the
encoding of sex. The names attribute should be the codes used in
the data files; the values within the vector should be
|
crossinfo_file |
File name for the |
crossinfo_covar |
Column name in the covariate data that
corresponds to the |
crossinfo_codes |
In the case that there is a single cross
info column (whether in a file or as a covariate), you can
provide a named vector of character strings specifying the
encoding of |
geno_codes |
Named vector specifying the encoding of genotypes. The names attribute has the codes used within the genotype and founder genotype data files; the values within the vector should be the integers to which the genotypes will be converted. |
alleles |
Vector of single-character codes for the founder alleles. |
xchr |
Character string with the ID for the X chromosome. |
sep |
Character string that separates columns in the data files. |
na.strings |
Vector of character strings with codes to be treated as missing values. |
comment.char |
Character string that is used as initial character in a set of leading comment lines in the data files. |
geno_transposed |
If TRUE, genotype file is transposed (with markers as rows). |
founder_geno_transposed |
If TRUE, founder genotype file is transposed (with markers as rows). |
pheno_transposed |
If TRUE, phenotype file is transposed (with phenotypes as rows). |
covar_transposed |
If TRUE, covariate file is transposed (with covariates as rows). |
phenocovar_transposed |
If TRUE, phenotype covariate file is transposed (with phenotype covariates as rows). |
description |
Optional character string describing the data. |
comments |
Vector of character strings to be inserted as comments at the top of the file (in the case of YAML), with each string as a line. For JSON, the comments are instead included within the control object. |
overwrite |
If TRUE, overwrite file if it exists. If FALSE (the default) and the file exists, stop with an error. |
This function takes a set of parameters and creates the control file (in YAML or JSON format) needed for the new input data file format for R/qtl2. See the sample data files and the vignette describing the input file format.
(Invisibly) The data structure that was written.
read_cross2()
, sample data files at
https://kbroman.org/qtl2/pages/sampledata.html
# Control file for the sample dataset, grav2
grav2_control_file <- file.path(tempdir(), "grav2.yaml")
write_control_file(grav2_control_file,
crosstype="riself",
geno_file="grav2_geno.csv",
gmap_file="grav2_gmap.csv",
pheno_file="grav2_pheno.csv",
phenocovar_file="grav2_phenocovar.csv",
geno_codes=c(L=1L, C=2L),
alleles=c("L", "C"),
na.strings=c("-", "NA"))
# Control file for the sample dataset, iron
iron_control_file <- file.path(tempdir(), "iron.yaml")
write_control_file(iron_control_file,
crosstype="f2",
geno_file="iron_geno.csv",
gmap_file="iron_gmap.csv",
pheno_file="iron_pheno.csv",
covar_file="iron_covar.csv",
phenocovar_file="iron_phenocovar.csv",
geno_codes=c(SS=1L, SB=2L, BB=3L),
sex_covar="sex",
sex_codes=c(f="female", m="male"),
crossinfo_covar="cross_direction",
crossinfo_codes=c("(SxB)x(SxB)"=0L, "(BxS)x(BxS)"=1L),
xchr="X",
alleles=c("S", "B"),
na.strings=c("-", "NA"))
# Remove these files, to clean up temporary directory
unlink(c(grav2_control_file, iron_control_file))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.