# Run association analysis.

## Usage

solarAssoc(formula, data, dir, kinship, traits, covlist = "1", snpformat, snpdata, snpcovdata, snpmap, snplist, snpind, genocov.files, snplists.files, snpmap.files, mga.files, plink.ped, plink.map, plink.raw, assoc.outformat = c("df", "outfile", "outfile.gz"), assoc.outdir, assoc.options = "", cores = getOption("cores"), batch.size = 1000, ..., verbose = 0)

## Arguments

formula
an object of class formula or one that can be coerced to that class. It is a symbolic description of fixed effects (covariates) to be fitted.
data
A data frame containing the variables in the model, including ID fields needed to construct random effects: genetic and house-hold (both optional). Other classes such as list, environment or object coercible by as.data.frame to a data frame are not supported.
dir
an optional character string, the name of directory, where SOLAR performs the analysis. In this case, the analysis within related input/output files is conducted in the given folder instead of a temporary one (the default work flow).
kinship
A matrix of the kinship coefficients (custom kinship matrix). The IDs are required to be in row and column names.
traits
a vector of characters to specify trait(s) in the model. It is alternative to the formula interface.
covlist
a vector of characters to specify fixed effects (covariates) in the model. It is alternative to the formula interface. The default value is "1".
snpformat
a character, the format of SNP data passsed by snpdata argument. Currently, this argument is not used.
snpdata
A matrix of SNP data. SNPs are given in the columns, and individuals correspond to the rows. The IDs of individuals are required to be in row and column names.
snpcovdata
A matrix of SNP data, which are converted to covariates (numeric format). SNPs are given in the columns, and individuals correspond to the rows. The IDs of individuals are required to be in row and column names.
snpmap
A data.frame of annotation for SNPs.
snplist
a vector of characters, the names of SNPs to be used in the analysis. This argument may be used when a subset of SNPs is of the interest.
snpind
a vector of positive integers, the indices of SNPs to be used in the analysis. This argument may be used when a subset of SNPs is of the interest.
genocov.files
A vector of characters, the file paths to genocov SOLAR files.
snplists.files
A vector of characters, the file paths to snplists SOLAR files.
snpmap.files
A vector of characters (optional), the file paths to snpmap SOLAR files.
mga.files
A list with 2-3 elements, where each element is a vector of characters. This argument is an alternative to the other three genocov.files, snplists.files and snpmap.files. The element 3 of the list is optional.
A character, the file path to genotype data in plink .ped format. Two columns are used per genotype.
A character, the file path to genotype annotation data in plink .map format.
A character, the file path to genotype data in allele-dosage plink format (an example plink command: plink --noweb --file dat50 --recodeA). One column is used per genotype.
assoc.outformat
A character, the output format. Possible values are "df", "outfile" and "outfile.gz". Currently, the only supported output format is "df". That means the table of results is stored in snpf slot of a returned object.
assoc.outdir
a character, the path to the output directory. Currently, this argument is not used.
assoc.options
A character, specific options to be passed to mga SOLAR command.
cores
A positive integer, the number of cores for parallel computing. The default value is taken from getOption("cores"). If the default value is NULL then the number of cores is 1.
batch.size
An integer, the number of SNPs per batch for parallel computation. The default value is 1000.
...
Arguments to be passed to solarPolygenic function. For example, one of such arguments may be polygenic.settings = "option EnableDiscrete 0". Arguments of solarMultipoint, which are also passed to solarPolygenic, include formula, data, dir, kinship, traits and covlist.
verbose
An non-negative integer of the verbose level. The default value is 0.

## Description

The association analysis is conducted in the following sequence: parse input files of SNP markers, export data to a directory by df2solar function, run the polygenic analysis in a directory, run the association analysis on the top of the polygenic analysis, parse output files and store results in an object of solarAssoc class (see solarAssocClass).

## Note

solarAssoc function accepts input genetic data in three formats: SOLAR (genocov.files, snplists.files, snpmap.files and param mga.files arguments), R data frame or matrix (snpdata, snpcovdata and snpmap arguments), and plink (plink.ped, plink.map and plink.raw arguments).

For large-size problems, the user is recommended to prepare the genetic data in SOLAR format and to split them into batches of size, for example, 1,000 markers. The use of the other two R and plink formats is not optimized for large-scale scenarios.

## Examples

### load data
data(dat50)
dim(phenodata)

[1] 66  4

dim(kin)

[1] 66 66

dim(genodata)

[1] 66 50

## Not run:
# ### basic (univariate) association model with a custom kinship
# mod <- solarAssoc(trait~age+sex, phenodata,
#   kinship = kin, snpdata = genodata)
# mod\$snpf # table of results for 50 SNPs
# ## End(Not run)