| Type: | Package |
| Title: | Fine-Level Structure Simulator |
| Version: | 1.2.6 |
| Description: | A population genetic simulator that generates synthetic genotype datasets of single-nucleotide variants (SNPs) for multiple populations. The genetic distances among populations can be set according to the Fixation Index (Fst) as explained in Balding and Nichols (1995) <doi:10.1007/BF01441146>. It can also simulate outlying individuals and missing genotypes. For genome-wide association studies (GWAS), disease status can be set at the desired level according to a risk ratio. |
| Depends: | R (≥ 3.2.4) |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.2 |
| Imports: | KRIS (≥ 1.1.1), grDevices, stats, tools, utils |
| Suggests: | testthat |
| BugReports: | https://github.com/kridsadakorn/filest/issues |
| URL: | https://github.com/kridsadakorn/filest |
| NeedsCompilation: | no |
| Packaged: | 2026-12-02 15:53:19 UTC; kris |
| Author: | Kridsadakorn Chaichoompu [aut, cre], Kristel Van Steen [aut], Fentaw Abegaz [aut] |
| Maintainer: | Kridsadakorn Chaichoompu <kridsadakorn@biostatgen.org> |
| Repository: | CRAN |
| Date/Publication: | 2026-12-02 16:50:02 UTC |
Fine-Level Structure Simulator
Description
FILEST 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 add outlying individuals, missing genotypes, and cases with disease-associated SNPs for genome-wide association studies (GWAS).
Details
To get started, run demo.filest. The main functions are:
filestRun a simulation from a setting file.
create.template.settingCreate a setting file to edit.
demo.filestRun a demo simulation.
The helpers rbind_bigmatrix and cbind_bigmatrix
combine large matrices.
Author(s)
Maintainer: Kridsadakorn Chaichoompu kridsadakorn@biostatgen.org
Authors:
Kristel Van Steen
Fentaw Abegaz
See Also
Useful links:
Combine two matrices by column
Description
Joins two matrices by column by filling a preallocated matrix. Used
internally by filest.
Usage
cbind_bigmatrix(a, b)
Arguments
a |
The first matrix. |
b |
The second matrix. |
Value
The combined matrix. If one matrix is NULL, the other is
returned. Returns NULL if both are NULL or if the numbers of
rows differ.
See Also
Examples
X <- matrix(c(1,2,0,1,2,2,1,2,0,0,1,2,1,2,2,2),ncol=4)
Y <- matrix(c(2,1,1,0,1,0,0,1,1,2,2,0,0,1,1,0),ncol=4)
Z <- cbind_bigmatrix(X,Y)
print(Z)
Create a template setting file
Description
Writes a setting file for filest with default values for
three populations. Edit the file to set up your own simulation. The format
is described in filest.
Usage
create.template.setting(out.file, no.setting = 1)
Arguments
out.file |
Path to the new setting file. If the file already exists, it is not overwritten; a number is added to the file name instead. |
no.setting |
Number of settings to write (default 1). |
Value
The path of the file that was written.
See Also
Examples
# Create a setting file with two settings
output <- file.path(tempdir(), "example_setting.txt")
res <- create.template.setting(out.file = output, no.setting = 2)
cat(readLines(res), sep = "\n")
Run a demo simulation
Description
Writes the setting file example1.txt to a temporary directory and
runs filest on it. The setting simulates two populations of
100 individuals each with 1000 SNPs. Use the setting file as a starting
point for your own simulations.
Usage
demo.filest()
Value
The temporary directory that holds example1.txt and the
output folder example1.
See Also
filest, create.template.setting
Examples
output_dir <- demo.filest()
dir(file.path(output_dir, "example1"))
Simulate SNP data for multiple populations
Description
Reads a setting file, simulates SNP data for each setting in it and writes
the results to a folder named after the setting inside out.
Usage
filest(setting, out, thread = 1)
Arguments
setting |
Path to the setting file. See |
out |
Path to the output directory. It is created if it does not exist. |
thread |
Kept for backward compatibility. It is not used; the simulation runs on a single thread. |
Value
NULL, invisibly, on success. NA if the setting file
does not exist or the output directory cannot be created.
Setting file
A setting file is a plain text file with one parameter per line, written as
--name=value. Lines starting with # are comments and empty
lines are ignored. 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.
--settingName of the setting. The results are saved in a folder with this name.
--populationNumber of individuals in each population, for example
100,100. Values below 2 are set to 2.--fstFst between each population and the first population, for example
0.01,0.01. The first two values should be equal; otherwise their mean is used.--caseProportion of cases in each population, for example
0.5,0. Use 0 for no cases.--outlier1if the population is an outlier group,0if not.--markerNumber of SNPs.
--replicateNumber of data sets to simulate with this setting.
--riskratioRisk ratio used to generate the case SNPs. Optional, default 1.
--no.case.snpNumber of disease-associated SNPs added after the other SNPs. Optional, default 0.
--missingAmount of missing data. The number of missing genotypes is this value times the total number of individuals. Optional, default 0 (no missing data).
--pcTRUEto calculate principal components (PCs). Optional, defaultFALSE.--fulloutputTRUEto write the extra output files. Optional, defaultFALSE.
TRUE and FALSE are not case-sensitive. A setting that leaves
out --population, --fst, --case, --outlier,
--marker or --replicate stops with an error.
Output files
Each replicate n gets these files in the setting's folder:
simSNP_repn.bed,.bim,.famGenotypes in PLINK binary format.
simSNP_repn_data_numMark_rowVar_colInd.txtGenotypes coded 0, 1, 2 (missing is -1), one SNP per row.
simSNP_repn_individuals.txtIndividual ID, population label and disease status (1 = control, 2 = case).
simSNP_repn_estimated_Fst.txtFst estimated between each pair of populations.
simSNP_repn.RDataThe simulated data as R objects.
simSNP_repn_PC10.txt,_eigenvector10.txt,_PC.pdfThe first 10 PCs and a plot, when
--pc=TRUE.simSNP_repn_cases.*,_controls.*Cases and controls in separate PLINK files, when
--no.case.snpis above 0.simSNP_repn_PC.projected.txt,.pdfProjected PCs and a plot, when there are cases and
--pc=TRUE.simSNP_repn_data_numMark_rowInd_colVar.txt,_individuals_with_header.txtExtra files, when
--fulloutput=TRUE.
See Also
demo.filest, create.template.setting
Examples
# Write a setting file for two populations of 100 individuals each
setting_file <- file.path(tempdir(), "example1.txt")
writeLines(c(
"--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"
), setting_file)
# Run the simulation and list the output files
filest(setting = setting_file, out = tempdir())
dir(file.path(tempdir(), "example1"))
Combine two matrices by row
Description
Joins two matrices by row by filling a preallocated matrix. Used
internally by filest.
Usage
rbind_bigmatrix(a, b)
Arguments
a |
The first matrix. |
b |
The second matrix. |
Value
The combined matrix. If one matrix is NULL, the other is
returned. Returns NULL if both are NULL or if the numbers of
columns differ.
See Also
Examples
X <- matrix(c(1,2,0,1,2,2,1,2,0,0,1,2,1,2,2,2),ncol=4)
Y <- matrix(c(2,1,1,0,1,0,0,1,1,2,2,0,0,1,1,0),ncol=4)
Z <- rbind_bigmatrix(X,Y)
print(Z)