FILEST

R-CMD-check CRAN status License: MIT Lifecycle: maturing DOI FOSSA Status

FILEST (Fine-Level Structure Simulator) simulates single-nucleotide polymorphism (SNP) data for several populations at once. You control how far apart the populations are by setting the fixation index (Fst) between them.

You can also:

Installation

Install the released version from CRAN:

install.packages("FILEST")

Or install the development version from GitHub:

install.packages("remotes")
remotes::install_github("kridsadakorn/filest", dependencies = TRUE)

Quick start

The easiest way to start is to run the demo. It writes a setting file, simulates two populations of 100 individuals each and saves the results in a temporary directory.

library(FILEST)

output_dir <- demo.filest()

The setting file is example1.txt:

cat(readLines(file.path(output_dir, "example1.txt")), sep = "\n")
#> --setting=example1
#> --population=100,100
#> --fst=0.01,0.01
#> --case=0,0
#> --outlier=0,0
#> --marker=1000
#> --replicate=1
#> --riskratio=1
#> --no.case.snp=0
#> --pc=TRUE
#> --missing=0
#> --fulloutput=TRUE

The simulated files are in the folder example1:

dir(file.path(output_dir, "example1"))
#>  [1] "simSNP_rep1_data_numMark_rowInd_colVar.txt"
#>  [2] "simSNP_rep1_data_numMark_rowVar_colInd.txt"
#>  [3] "simSNP_rep1_eigenvector10.txt"             
#>  [4] "simSNP_rep1_estimated_Fst.txt"             
#>  [5] "simSNP_rep1_individuals_with_header.txt"   
#>  [6] "simSNP_rep1_individuals.txt"               
#>  [7] "simSNP_rep1_PC.pdf"                        
#>  [8] "simSNP_rep1_PC10.txt"                      
#>  [9] "simSNP_rep1.bed"                           
#> [10] "simSNP_rep1.bim"                           
#> [11] "simSNP_rep1.fam"                           
#> [12] "simSNP_rep1.RData"

To run your own simulation, create a template, edit it, and pass it to filest():

setting_file <- create.template.setting(out.file = "my_setting.txt", no.setting = 1)
# Edit my_setting.txt, then:
filest(setting = setting_file, out = "my_output")

The setting file

A setting file is a plain text file with one parameter per line, written as --name=value. Lines starting with # are comments. One file can hold several settings; each one starts with --setting.

Lists have one value per population, separated by commas, so --population, --fst, --case and --outlier must all have the same length. --marker and --replicate are also required; the other parameters are optional.

Parameter Example Meaning
--setting example1 Name of the setting. The results are saved in a folder with this name.
--population 100,100 Number of individuals in each population.
--fst 0.01,0.01 Fst between each population and the first population. The first two values should be equal.
--case 0,0 Proportion of cases in each population (0 means no cases).
--outlier 0,0 1 if the population is an outlier group, 0 if not.
--marker 1000 Number of SNPs.
--replicate 1 Number of data sets to simulate with this setting.
--riskratio 1 Risk ratio used to generate the case SNPs. Optional, default 1.
--no.case.snp 0 Number of disease-associated SNPs added after the other SNPs. Optional, default 0.
--missing 0 Amount of missing data. The number of missing genotypes is this value times the total number of individuals. Optional, default 0.
--pc TRUE Whether to calculate principal components (PCs). Optional, default FALSE.
--fulloutput TRUE Whether to write the extra output files. Optional, default FALSE.

Output files

Each replicate n gets its own set of files in the setting’s folder:

File Contents
simSNP_repn.bed, .bim, .fam Genotypes in PLINK binary format.
simSNP_repn_data_numMark_rowVar_colInd.txt Genotypes coded 0, 1, 2 (missing is -1), one SNP per row.
simSNP_repn_individuals.txt Individual ID, population label and disease status (1 = control, 2 = case).
simSNP_repn_estimated_Fst.txt Fst estimated between each pair of populations.
simSNP_repn.RData The simulated data as R objects.
simSNP_repn_PC10.txt, _eigenvector10.txt, _PC.pdf The first 10 PCs and a plot (when --pc=TRUE).
simSNP_repn_cases.*, _controls.* Cases and controls in separate PLINK files (when --no.case.snp is above 0).
simSNP_repn_PC.projected.txt, .pdf Projected PCs and a plot (when there are cases and --pc=TRUE).
simSNP_repn_data_numMark_rowInd_colVar.txt, _individuals_with_header.txt Extra files (when --fulloutput=TRUE).

Documentation

The full reference manual is at https://www.biostatgen.org/filest/. In R, see ?filest.

Citation

Run citation("FILEST") in R.

License

MIT. See LICENSE.

FOSSA Status

About