├── src ├── Makevars ├── read_lines.cpp └── RcppExports.cpp ├── docs ├── _config.yml ├── extra.css ├── favicon.ico ├── articles │ ├── cor_pheno.png │ ├── cor_pheno-min.png │ ├── cor_simulated.png │ ├── wallthickness.png │ ├── cor_simulated-min.png │ ├── wallthickness-min.png │ ├── gwas_results_gemma_qqplot.png │ ├── PhenotypeSimulator_files │ │ ├── figure-html │ │ │ ├── unnamed-chunk-7-1.png │ │ │ ├── unnamed-chunk-7-2.png │ │ │ ├── unnamed-chunk-14-1.png │ │ │ ├── unnamed-chunk-14-2.png │ │ │ ├── unnamed-chunk-16-1.png │ │ │ ├── unnamed-chunk-16-2.png │ │ │ ├── unnamed-chunk-18-1.png │ │ │ ├── unnamed-chunk-18-2.png │ │ │ ├── unnamed-chunk-18-3.png │ │ │ ├── unnamed-chunk-18-4.png │ │ │ ├── unnamed-chunk-19-1.png │ │ │ ├── unnamed-chunk-19-2.png │ │ │ ├── unnamed-chunk-21-1.png │ │ │ └── unnamed-chunk-21-2.png │ │ └── accessible-code-block-0.0.1 │ │ │ └── empty-anchor.js │ ├── Simulation-and-LinearModel_files │ │ ├── figure-html │ │ │ ├── qqplot-1.png │ │ │ ├── freq-beta-1.png │ │ │ └── heatmaps-1.png │ │ └── accessible-code-block-0.0.1 │ │ │ └── empty-anchor.js │ ├── SimulationBasedOnExampleData_files │ │ ├── figure-html │ │ │ ├── pheno-1.png │ │ │ ├── wall-1.png │ │ │ ├── background-1.png │ │ │ ├── simulation-1.png │ │ │ └── distribution-1.png │ │ └── accessible-code-block-0.0.1 │ │ │ └── empty-anchor.js │ ├── UsagePhenotypeSimulator_files │ │ └── figure-html │ │ │ ├── unnamed-chunk-7-1.png │ │ │ ├── unnamed-chunk-7-2.png │ │ │ ├── unnamed-chunk-14-1.png │ │ │ ├── unnamed-chunk-14-2.png │ │ │ ├── unnamed-chunk-16-1.png │ │ │ ├── unnamed-chunk-16-2.png │ │ │ ├── unnamed-chunk-18-1.png │ │ │ ├── unnamed-chunk-18-2.png │ │ │ ├── unnamed-chunk-18-3.png │ │ │ ├── unnamed-chunk-18-4.png │ │ │ ├── unnamed-chunk-19-1.png │ │ │ ├── unnamed-chunk-19-2.png │ │ │ ├── unnamed-chunk-21-1.png │ │ │ └── unnamed-chunk-21-2.png │ ├── sample-scripts-external-genotype-simulation_files │ │ └── accessible-code-block-0.0.1 │ │ │ └── empty-anchor.js │ └── index.html ├── reference │ ├── Rplot001.png │ ├── PhenotypeSimulator.html │ ├── addNonNulls.html │ └── read_lines.html ├── simulatedPhenotypes.png ├── docs │ └── articles │ │ ├── Simulation-and-LinearModel_files │ │ └── figure-html │ │ │ └── qqplot-1.png │ │ └── SimulationBasedOnExampleData_files │ │ └── figure-html │ │ ├── pheno-1.png │ │ ├── wall-1.png │ │ └── background-1.png ├── pkgdown.yml ├── link.svg ├── bootstrap-toc.css ├── docsearch.js ├── pkgdown.js ├── bootstrap-toc.js ├── LICENSE-text.html ├── 404.html └── authors.html ├── LICENSE ├── inst ├── extdata │ ├── genotypes │ │ ├── plink │ │ │ ├── plink_sim_par.txt │ │ │ ├── genotypes_plink.bed │ │ │ ├── simulate_genotypes_plink.sh │ │ │ ├── genotypes_plink.log │ │ │ └── genotypes_plink.fam │ │ ├── hapgen │ │ │ ├── genotypes_hapgen.cases.sample │ │ │ ├── simulate_genotypes_hapgen2.sh │ │ │ ├── genotypes_hapgen.controls.sample │ │ │ ├── genotypes_hapgen_chr22.sample │ │ │ └── genotypes_hapgen.summary │ │ └── genome │ │ │ └── simulate_genotypes_genome.sh │ ├── vignettes │ │ ├── covs.rds │ │ ├── cor_pheno.png │ │ ├── pheno_small.rds │ │ ├── cor_pheno-min.png │ │ ├── cor_simulated.png │ │ ├── wallthickness.png │ │ ├── cor_simulated-min.png │ │ ├── wallthickness-min.png │ │ └── gwas_results_gemma_qqplot.png │ └── resultsSimulationAndLinearModel │ │ ├── correlation_phenotype.pdf │ │ ├── gwas_results_gemma_qqplot.png │ │ ├── simulation_phenoComponentsFinal.rds │ │ ├── sigSNPs.csv │ │ ├── SNP_effects_NrSNP10.csv │ │ └── simulated_withEffect.csv └── CITATION ├── pkgdown └── extra.css ├── .travis.yml ├── vignettes ├── cor_pheno-min.png ├── cor_simulated-min.png ├── wallthickness-min.png ├── gwas_results_gemma_qqplot.png ├── plos-genetics.csl ├── Vignette-example-data.bib ├── SimulationAndLinearModel.bib └── sample-scripts-external-genotype-simulation.Rmd ├── tests ├── testthat.R └── testthat │ ├── test-utility.r │ └── test-createphenotypeFunctions.r ├── R ├── pkg.R ├── RcppExports.R └── PhenotypeSimulator.R ├── .Rbuildignore ├── man ├── PhenotypeSimulator.Rd ├── read_lines.Rd ├── addNonNulls.Rd ├── commaList2vector.Rd ├── getAlleleFrequencies.Rd ├── vmessage.Rd ├── expGen2probGen.Rd ├── testNumerics.Rd ├── rescaleVariance.Rd ├── probGen2expGen.Rd ├── standardiseGenotypes.Rd ├── simulatePhenotypes.Rd ├── simulateGenotypes.Rd ├── getKinship.Rd ├── simulateDist.Rd ├── noiseBgEffects.Rd ├── transformNonlinear.Rd ├── correlatedBgEffects.Rd ├── geneticBgEffects.Rd ├── savePheno.Rd ├── geneticFixedEffects.Rd ├── setModel.Rd ├── getCausalSNPs.Rd └── noiseFixedEffects.Rd ├── cran-comments.md ├── .github └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── NAMESPACE ├── DESCRIPTION ├── README.md ├── INDEX.md ├── README.Rmd ├── INDEX.Rmd └── NEWS.md /src/Makevars: -------------------------------------------------------------------------------- 1 | CXX_STD = CXX11 2 | 3 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2017 2 | COPYRIGHT HOLDER: Hannah Verena Meyer -------------------------------------------------------------------------------- /inst/extdata/genotypes/plink/plink_sim_par.txt: -------------------------------------------------------------------------------- 1 | 1000 SNP 0.00 1.00 1.00 1.00 2 | -------------------------------------------------------------------------------- /docs/extra.css: -------------------------------------------------------------------------------- 1 | .headroom { 2 | background-color: rgba(255, 255, 255, 1); 3 | } 4 | -------------------------------------------------------------------------------- /pkgdown/extra.css: -------------------------------------------------------------------------------- 1 | .headroom { 2 | background-color: rgba(255, 255, 255, 1); 3 | } 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: r 2 | warnings_are_errors: true 3 | sudo: required 4 | cache: packages 5 | -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/favicon.ico -------------------------------------------------------------------------------- /inst/extdata/genotypes/hapgen/genotypes_hapgen.cases.sample: -------------------------------------------------------------------------------- 1 | ID_1 ID_2 missing pheno 2 | 0 0 0 B 3 | -------------------------------------------------------------------------------- /docs/articles/cor_pheno.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/cor_pheno.png -------------------------------------------------------------------------------- /docs/reference/Rplot001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/reference/Rplot001.png -------------------------------------------------------------------------------- /vignettes/cor_pheno-min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/vignettes/cor_pheno-min.png -------------------------------------------------------------------------------- /docs/simulatedPhenotypes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/simulatedPhenotypes.png -------------------------------------------------------------------------------- /docs/articles/cor_pheno-min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/cor_pheno-min.png -------------------------------------------------------------------------------- /docs/articles/cor_simulated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/cor_simulated.png -------------------------------------------------------------------------------- /docs/articles/wallthickness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/wallthickness.png -------------------------------------------------------------------------------- /inst/extdata/vignettes/covs.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/inst/extdata/vignettes/covs.rds -------------------------------------------------------------------------------- /vignettes/cor_simulated-min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/vignettes/cor_simulated-min.png -------------------------------------------------------------------------------- /vignettes/wallthickness-min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/vignettes/wallthickness-min.png -------------------------------------------------------------------------------- /docs/articles/cor_simulated-min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/cor_simulated-min.png -------------------------------------------------------------------------------- /docs/articles/wallthickness-min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/wallthickness-min.png -------------------------------------------------------------------------------- /inst/extdata/vignettes/cor_pheno.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/inst/extdata/vignettes/cor_pheno.png -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | Sys.setenv(R_TESTS="") 2 | library(testthat) 3 | library(PhenotypeSimulator) 4 | 5 | test_check("PhenotypeSimulator") 6 | -------------------------------------------------------------------------------- /inst/extdata/vignettes/pheno_small.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/inst/extdata/vignettes/pheno_small.rds -------------------------------------------------------------------------------- /vignettes/gwas_results_gemma_qqplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/vignettes/gwas_results_gemma_qqplot.png -------------------------------------------------------------------------------- /inst/extdata/vignettes/cor_pheno-min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/inst/extdata/vignettes/cor_pheno-min.png -------------------------------------------------------------------------------- /inst/extdata/vignettes/cor_simulated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/inst/extdata/vignettes/cor_simulated.png -------------------------------------------------------------------------------- /inst/extdata/vignettes/wallthickness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/inst/extdata/vignettes/wallthickness.png -------------------------------------------------------------------------------- /docs/articles/gwas_results_gemma_qqplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/gwas_results_gemma_qqplot.png -------------------------------------------------------------------------------- /inst/extdata/vignettes/cor_simulated-min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/inst/extdata/vignettes/cor_simulated-min.png -------------------------------------------------------------------------------- /inst/extdata/vignettes/wallthickness-min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/inst/extdata/vignettes/wallthickness-min.png -------------------------------------------------------------------------------- /inst/extdata/genotypes/plink/genotypes_plink.bed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/inst/extdata/genotypes/plink/genotypes_plink.bed -------------------------------------------------------------------------------- /inst/extdata/vignettes/gwas_results_gemma_qqplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/inst/extdata/vignettes/gwas_results_gemma_qqplot.png -------------------------------------------------------------------------------- /docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-7-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-7-2.png -------------------------------------------------------------------------------- /docs/articles/Simulation-and-LinearModel_files/figure-html/qqplot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/Simulation-and-LinearModel_files/figure-html/qqplot-1.png -------------------------------------------------------------------------------- /docs/articles/SimulationBasedOnExampleData_files/figure-html/pheno-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/SimulationBasedOnExampleData_files/figure-html/pheno-1.png -------------------------------------------------------------------------------- /docs/articles/SimulationBasedOnExampleData_files/figure-html/wall-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/SimulationBasedOnExampleData_files/figure-html/wall-1.png -------------------------------------------------------------------------------- /inst/extdata/resultsSimulationAndLinearModel/correlation_phenotype.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/inst/extdata/resultsSimulationAndLinearModel/correlation_phenotype.pdf -------------------------------------------------------------------------------- /R/pkg.R: -------------------------------------------------------------------------------- 1 | #' @useDynLib PhenotypeSimulator, .registration = TRUE 2 | #' @importFrom Rcpp sourceCpp 3 | NULL 4 | 5 | .onUnload <- function (libpath) { 6 | library.dynam.unload(getPackageName(), libpath) 7 | } 8 | -------------------------------------------------------------------------------- /docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-14-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-14-1.png -------------------------------------------------------------------------------- /docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-14-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-14-2.png -------------------------------------------------------------------------------- /docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-16-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-16-1.png -------------------------------------------------------------------------------- /docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-16-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-16-2.png -------------------------------------------------------------------------------- /docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-18-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-18-1.png -------------------------------------------------------------------------------- /docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-18-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-18-2.png -------------------------------------------------------------------------------- /docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-18-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-18-3.png -------------------------------------------------------------------------------- /docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-18-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-18-4.png -------------------------------------------------------------------------------- /docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-19-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-19-1.png -------------------------------------------------------------------------------- /docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-19-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-19-2.png -------------------------------------------------------------------------------- /docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-21-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-21-1.png -------------------------------------------------------------------------------- /docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-21-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/PhenotypeSimulator_files/figure-html/unnamed-chunk-21-2.png -------------------------------------------------------------------------------- /docs/articles/Simulation-and-LinearModel_files/figure-html/freq-beta-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/Simulation-and-LinearModel_files/figure-html/freq-beta-1.png -------------------------------------------------------------------------------- /docs/articles/Simulation-and-LinearModel_files/figure-html/heatmaps-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/Simulation-and-LinearModel_files/figure-html/heatmaps-1.png -------------------------------------------------------------------------------- /inst/extdata/resultsSimulationAndLinearModel/gwas_results_gemma_qqplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/inst/extdata/resultsSimulationAndLinearModel/gwas_results_gemma_qqplot.png -------------------------------------------------------------------------------- /docs/articles/SimulationBasedOnExampleData_files/figure-html/background-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/SimulationBasedOnExampleData_files/figure-html/background-1.png -------------------------------------------------------------------------------- /docs/articles/SimulationBasedOnExampleData_files/figure-html/simulation-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/SimulationBasedOnExampleData_files/figure-html/simulation-1.png -------------------------------------------------------------------------------- /docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-7-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-7-2.png -------------------------------------------------------------------------------- /docs/docs/articles/Simulation-and-LinearModel_files/figure-html/qqplot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/docs/articles/Simulation-and-LinearModel_files/figure-html/qqplot-1.png -------------------------------------------------------------------------------- /docs/docs/articles/SimulationBasedOnExampleData_files/figure-html/pheno-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/docs/articles/SimulationBasedOnExampleData_files/figure-html/pheno-1.png -------------------------------------------------------------------------------- /docs/docs/articles/SimulationBasedOnExampleData_files/figure-html/wall-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/docs/articles/SimulationBasedOnExampleData_files/figure-html/wall-1.png -------------------------------------------------------------------------------- /docs/articles/SimulationBasedOnExampleData_files/figure-html/distribution-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/SimulationBasedOnExampleData_files/figure-html/distribution-1.png -------------------------------------------------------------------------------- /docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-14-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-14-1.png -------------------------------------------------------------------------------- /docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-14-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-14-2.png -------------------------------------------------------------------------------- /docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-16-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-16-1.png -------------------------------------------------------------------------------- /docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-16-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-16-2.png -------------------------------------------------------------------------------- /docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-18-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-18-1.png -------------------------------------------------------------------------------- /docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-18-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-18-2.png -------------------------------------------------------------------------------- /docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-18-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-18-3.png -------------------------------------------------------------------------------- /docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-18-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-18-4.png -------------------------------------------------------------------------------- /docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-19-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-19-1.png -------------------------------------------------------------------------------- /docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-19-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-19-2.png -------------------------------------------------------------------------------- /docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-21-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-21-1.png -------------------------------------------------------------------------------- /docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-21-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/articles/UsagePhenotypeSimulator_files/figure-html/unnamed-chunk-21-2.png -------------------------------------------------------------------------------- /docs/docs/articles/SimulationBasedOnExampleData_files/figure-html/background-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/docs/docs/articles/SimulationBasedOnExampleData_files/figure-html/background-1.png -------------------------------------------------------------------------------- /inst/extdata/genotypes/genome/simulate_genotypes_genome.sh: -------------------------------------------------------------------------------- 1 | cd ~/PhenotypeSimulator/inst/extdata/genotypes/genome 2 | 3 | # 3 subpopulation with 30, 30 and 40 individuals each 4 | genome -pop 3 30 30 40 > genotypes_genome.txt 5 | -------------------------------------------------------------------------------- /inst/extdata/resultsSimulationAndLinearModel/simulation_phenoComponentsFinal.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meyer-lab-cshl/PhenotypeSimulator/HEAD/inst/extdata/resultsSimulationAndLinearModel/simulation_phenoComponentsFinal.rds -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^docs$ 2 | ^.*\.Rproj$ 3 | ^\.Rproj\.user$ 4 | ^cran-comments\.md$ 5 | ^README\.Rmd$ 6 | ^README\.html$ 7 | ^README-.*\.png$ 8 | ^INDEX\.Rmd$ 9 | ^INDEX\.md$ 10 | ^INDEX\.html$ 11 | ^doc$ 12 | ^Meta$ 13 | ^CRAN-RELEASE$ 14 | pkgdown 15 | .travis.yml 16 | .github 17 | -------------------------------------------------------------------------------- /inst/extdata/genotypes/plink/simulate_genotypes_plink.sh: -------------------------------------------------------------------------------- 1 | cd ~/PhenotypeSimulator/inst/extdata/genotypes/plink 2 | 3 | echo -e "1000\tSNP\t0.00\t1.00\t1.00\t1.00" > plink_sim_par.txt 4 | 5 | plink --simulate plink_sim_par.txt \ 6 | --simulate-ncases 0 \ 7 | --simulate-ncontrols 100 \ 8 | --out genotypes_plink 9 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: 2.7.3 2 | pkgdown: 1.6.1 3 | pkgdown_sha: ~ 4 | articles: 5 | PhenotypeSimulator: PhenotypeSimulator.html 6 | Simulation-and-LinearModel: Simulation-and-LinearModel.html 7 | SimulationBasedOnExampleData: SimulationBasedOnExampleData.html 8 | sample-scripts-external-genotype-simulation: sample-scripts-external-genotype-simulation.html 9 | last_built: 2021-07-14T17:12Z 10 | 11 | -------------------------------------------------------------------------------- /man/PhenotypeSimulator.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/PhenotypeSimulator.R 3 | \docType{package} 4 | \name{PhenotypeSimulator} 5 | \alias{PhenotypeSimulator} 6 | \title{PhenotypeSimulator: A package for simulating phenotypes from different 7 | genetic and noise components} 8 | \description{ 9 | Type, Name and Dependencies 10 | } 11 | \keyword{internal} 12 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Test environments 2 | * local R installation, R 4.0.3 3 | * ubuntu 16.04 (on travis-ci), R 4.0.3 4 | * win-builder (devel) 5 | 6 | ## R CMD check results 7 | 8 | 0 errors | 0 warnings | 1 note 9 | 10 | * This is a new release. 11 | * Minor bug fixes and additions to vignettes, all documented in NEWS.md 12 | * Resubmission changes: removed reference/URL to package no longer available 13 | on CRAN -------------------------------------------------------------------------------- /R/RcppExports.R: -------------------------------------------------------------------------------- 1 | # Generated by using Rcpp::compileAttributes() -> do not edit by hand 2 | # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 3 | 4 | #' Scan file for specific line numbers 5 | #' 6 | #' @param filename /path/to/chromosomefile [string] 7 | #' @param lines vector of line numbers [integer] to be read 8 | #' @param sep [string] end-of-line delimiter 9 | read_lines <- function(filename, lines, sep = '\n') { 10 | .Call(`_PhenotypeSimulator_read_lines`, filename, lines, sep) 11 | } 12 | 13 | -------------------------------------------------------------------------------- /man/read_lines.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/RcppExports.R 3 | \name{read_lines} 4 | \alias{read_lines} 5 | \title{Scan file for specific line numbers} 6 | \usage{ 7 | read_lines(filename, lines, sep = "\\n") 8 | } 9 | \arguments{ 10 | \item{filename}{/path/to/chromosomefile [string]} 11 | 12 | \item{lines}{vector of line numbers [integer] to be read} 13 | 14 | \item{sep}{[string] end-of-line delimiter} 15 | } 16 | \description{ 17 | Scan file for specific line numbers 18 | } 19 | -------------------------------------------------------------------------------- /man/addNonNulls.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utilityFunctions.R 3 | \name{addNonNulls} 4 | \alias{addNonNulls} 5 | \title{Add all non-NULL elements of list.} 6 | \usage{ 7 | addNonNulls(compList) 8 | } 9 | \arguments{ 10 | \item{compList}{List of numeric matrices or data.frames of the equal 11 | dimensions.} 12 | } 13 | \value{ 14 | Matrix or data.frame containing sum of all list elements where 15 | \code{is.null} is FALSE. 16 | } 17 | \description{ 18 | Add all non-NULL elements of list. 19 | } 20 | -------------------------------------------------------------------------------- /inst/extdata/genotypes/hapgen/simulate_genotypes_hapgen2.sh: -------------------------------------------------------------------------------- 1 | cd ~/PhenotypeSimulator/inst/extdata/genotypes/hapgen 2 | 3 | # directory with data downloaded from https://mathgen.stats.ox.ac.uk/impute/impute_v1.html#Using_IMPUTE_with_the_HapMap_Data 4 | hapdir=~/data/hmeyer/Supplementary/CEU.0908.impute.files 5 | 6 | hapgen2 -m $hapdir/genetic_map_chr22_combined_b36.txt \ 7 | -l legend_file \ 8 | -h $hapdir/CEU.0908.chr22.hap \ 9 | -o genotypes_hapgen \ 10 | -n 100 0 \ 11 | -dl 45162 0 0 0 \ 12 | -no_haps_output 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context about the feature request here. 21 | -------------------------------------------------------------------------------- /inst/extdata/genotypes/plink/genotypes_plink.log: -------------------------------------------------------------------------------- 1 | PLINK v1.90b2i 64-bit (8 Sep 2014) 2 | 8 arguments: --out genotypes_plink --simulate plink_sim_par.txt --simulate-ncases 0 --simulate-ncontrols 100 3 | Hostname: ebi-cli-002.ebi.ac.uk 4 | Working directory: /homes/hannah/PhenotypeSimulator/inst/extdata/genotypes/plink 5 | Start time: Fri Nov 24 12:47:07 2017 6 | 7 | Random number seed: 1511527627 8 | 128733 MB RAM detected; reserving 64366 MB for main workspace. 9 | Writing --simulate dataset to genotypes_plink.bed + genotypes_plink.bim + 10 | genotypes_plink.fam ... done. 11 | Realized simulation parameters saved to genotypes_plink.simfreq. 12 | 13 | End time: Fri Nov 24 12:47:07 2017 14 | -------------------------------------------------------------------------------- /inst/extdata/resultsSimulationAndLinearModel/sigSNPs.csv: -------------------------------------------------------------------------------- 1 | rsID,observed,expected,model,trait,causal,observed_adjusted 2 | rs6948782,3.202576e-30,6.19316685605371e-08,mvLMM,all,with effect,3.202576e-30 3 | rs28788872,8.465234e-24,1.85795005681611e-07,mvLMM,all,with effect,8.465234e-24 4 | 5-7362997,3.824327e-17,1.30056503977128e-06,mvLMM,all,with effect,3.824327e-17 5 | rs10953472,7.711818e-10,2.79311825208022e-05,mvLMM,all,with effect,7.711818e-10 6 | rs6948782,1.392764e-18,6.19316685605371e-08,uvLMM,trait2,with effect,4.178292e-18 7 | rs28788872,9.070022e-15,1.85795005681611e-07,uvLMM,trait2,with effect,2.7210066e-14 8 | 5-7362997,2.321156e-10,8.05111691286982e-07,uvLMM,trait2,with effect,6.963468e-10 9 | -------------------------------------------------------------------------------- /man/commaList2vector.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utilityFunctions.R 3 | \name{commaList2vector} 4 | \alias{commaList2vector} 5 | \title{Comma-separated string to numeric vector.} 6 | \usage{ 7 | commaList2vector(commastring = NULL, type = "numeric") 8 | } 9 | \arguments{ 10 | \item{commastring}{Input [character] vector containing numbers separated by 11 | commas.} 12 | 13 | \item{type}{Name [string] of the type of input variables; one of numeric, 14 | logical or character} 15 | } 16 | \value{ 17 | Numeric vector of values extracted from commastring. 18 | } 19 | \description{ 20 | Split input of comma-separated string into vector of numeric, logical or 21 | character values. 22 | } 23 | -------------------------------------------------------------------------------- /R/PhenotypeSimulator.R: -------------------------------------------------------------------------------- 1 | #' PhenotypeSimulator: A package for simulating phenotypes from different 2 | #' genetic and noise components 3 | #' 4 | #' Type, Name and Dependencies 5 | #' @docType package 6 | #' @name PhenotypeSimulator 7 | #' @import snpStats 8 | #' @import ggplot2 9 | #' @importFrom cowplot plot_grid 10 | #' @importFrom methods getPackageName as 11 | #' @importFrom stats median pnorm rbinom rnorm runif sd var na.omit rexp 12 | #' @importFrom utils read.table write.table 13 | #' @importFrom optparse make_option parse_args OptionParser 14 | #' @importFrom dplyr filter 15 | #' @importFrom reshape2 melt 16 | #' @importFrom snpStats write.plink 17 | #' @importClassesFrom snpStats SnpMatrix 18 | #' @importFrom R.utils countLines 19 | #' @keywords internal 20 | NULL 21 | -------------------------------------------------------------------------------- /man/getAlleleFrequencies.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/genotypeFunctions.R 3 | \name{getAlleleFrequencies} 4 | \alias{getAlleleFrequencies} 5 | \title{Compute allele frequencies from genotype data.} 6 | \usage{ 7 | getAlleleFrequencies(snp) 8 | } 9 | \arguments{ 10 | \item{snp}{[N x 1] Vector of length [N] samples with genotypes of a single 11 | bi-allelic genetic variant/SNP encoded as 0,1 and 2.} 12 | } 13 | \value{ 14 | Vector with ref (0-encoded) and alt (1-encoded) allele frequencies. 15 | } 16 | \description{ 17 | Compute allele frequencies from genotype data. 18 | } 19 | \examples{ 20 | # create snp vector with minor allele frequency 0.3 21 | snp <- rbinom(200, 2, 0.3) 22 | allelefreq <- getAlleleFrequencies(snp) 23 | } 24 | -------------------------------------------------------------------------------- /docs/articles/PhenotypeSimulator_files/accessible-code-block-0.0.1/empty-anchor.js: -------------------------------------------------------------------------------- 1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> 2 | // v0.0.1 3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | const codeList = document.getElementsByClassName("sourceCode"); 7 | for (var i = 0; i < codeList.length; i++) { 8 | var linkList = codeList[i].getElementsByTagName('a'); 9 | for (var j = 0; j < linkList.length; j++) { 10 | if (linkList[j].innerHTML === "") { 11 | linkList[j].setAttribute('aria-hidden', 'true'); 12 | } 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /docs/articles/Simulation-and-LinearModel_files/accessible-code-block-0.0.1/empty-anchor.js: -------------------------------------------------------------------------------- 1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> 2 | // v0.0.1 3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | const codeList = document.getElementsByClassName("sourceCode"); 7 | for (var i = 0; i < codeList.length; i++) { 8 | var linkList = codeList[i].getElementsByTagName('a'); 9 | for (var j = 0; j < linkList.length; j++) { 10 | if (linkList[j].innerHTML === "") { 11 | linkList[j].setAttribute('aria-hidden', 'true'); 12 | } 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /docs/articles/SimulationBasedOnExampleData_files/accessible-code-block-0.0.1/empty-anchor.js: -------------------------------------------------------------------------------- 1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> 2 | // v0.0.1 3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | const codeList = document.getElementsByClassName("sourceCode"); 7 | for (var i = 0; i < codeList.length; i++) { 8 | var linkList = codeList[i].getElementsByTagName('a'); 9 | for (var j = 0; j < linkList.length; j++) { 10 | if (linkList[j].innerHTML === "") { 11 | linkList[j].setAttribute('aria-hidden', 'true'); 12 | } 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /man/vmessage.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utilityFunctions.R 3 | \name{vmessage} 4 | \alias{vmessage} 5 | \title{Print userinfo.} 6 | \usage{ 7 | vmessage(userinfo, verbose = TRUE, sep = " ") 8 | } 9 | \arguments{ 10 | \item{userinfo}{Vector of [string] element(s) and variables} 11 | 12 | \item{verbose}{[boolean] If TRUE message is displayed on standard out, if 13 | FALSE, message is suppressed.} 14 | 15 | \item{sep}{Delimiter [string] to separate message elements when userinfo 16 | given as vector.} 17 | } 18 | \description{ 19 | Wrapper function around \code{\link{message}} that allows to turn the 20 | printing of messages to standard out. 21 | on or off 22 | } 23 | \seealso{ 24 | \code{\link{message}} which this function wraps 25 | } 26 | -------------------------------------------------------------------------------- /man/expGen2probGen.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utilityFunctions.R 3 | \name{expGen2probGen} 4 | \alias{expGen2probGen} 5 | \title{Rewrite expected genotypes into genotype probabilities.} 6 | \usage{ 7 | expGen2probGen(geno) 8 | } 9 | \arguments{ 10 | \item{geno}{Vector [numeric] with genotypes} 11 | } 12 | \value{ 13 | Numeric vector of length [length(geno)*3] with the genotype encoded 14 | as probabbilities (p(AA), p(Aa), p(aa)). 15 | } 16 | \description{ 17 | Convert genotype frequencies to genotypes encoded as triplets of probablities 18 | (p(AA), p(Aa), p(aa)). 19 | } 20 | \examples{ 21 | nrSamples <- 10 22 | # Simulate binomial SNP with 0.2 allele frequency 23 | geno <- rbinom(nrSamples, 2, p=0.2) 24 | geno_prob<- expGen2probGen(geno) 25 | } 26 | -------------------------------------------------------------------------------- /docs/articles/sample-scripts-external-genotype-simulation_files/accessible-code-block-0.0.1/empty-anchor.js: -------------------------------------------------------------------------------- 1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> 2 | // v0.0.1 3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | const codeList = document.getElementsByClassName("sourceCode"); 7 | for (var i = 0; i < codeList.length; i++) { 8 | var linkList = codeList[i].getElementsByTagName('a'); 9 | for (var j = 0; j < linkList.length; j++) { 10 | if (linkList[j].innerHTML === "") { 11 | linkList[j].setAttribute('aria-hidden', 'true'); 12 | } 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Provide a minimal example of what you re trying to do. If you rely on some external data, please provide a link to a small, sample dataset. 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Error messages** 20 | Show the error messages received when executing the steps outlined above. 21 | 22 | **Please complete the following information):** 23 | - OS: [e.g. iOS] 24 | - sessionInfo() 25 | 26 | **Additional context** 27 | Add any other context about the problem here. 28 | -------------------------------------------------------------------------------- /man/testNumerics.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utilityFunctions.R 3 | \name{testNumerics} 4 | \alias{testNumerics} 5 | \title{Test lists for different properties of numerics.} 6 | \usage{ 7 | testNumerics(numbers, positives = NULL, integers = NULL, proportions = NULL) 8 | } 9 | \arguments{ 10 | \item{numbers}{List whose elements are tested for being numeric} 11 | 12 | \item{positives}{List whose elements are tested for being positive numbers} 13 | 14 | \item{integers}{List whose elements are tested for being integers} 15 | 16 | \item{proportions}{List whose elements are tested for being proportions 17 | between 0 and 1} 18 | } 19 | \description{ 20 | Test all elements of a list if they are numeric, positive numbers, integers 21 | or proportions (range 0-1) 22 | } 23 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | citHeader("To cite PhenotypeSimulator in publications use:") 2 | 3 | citEntry(entry = "Article", 4 | title = "PhenotypeSimulator: A comprehensive framework for simulating multi-trait, multi-locus genotype to phenotype relationships", 5 | author = personList(as.person("Hannah V Meyer"), 6 | as.person("Ewan Birney")), 7 | journal = "Bioinformatics", 8 | year = "2018", 9 | volume = "34", 10 | number = "17", 11 | pages = "2951--2956", 12 | 13 | textVersion = 14 | paste("Hannah V Meyer, Ewan Birney (2018).", 15 | "PhenotypeSimulator: A comprehensive framework for simulating multi-trait, multi-locus genotype to phenotype relationships.", 16 | "Bioinformatics, 34(17), 2951-2956.", 17 | "URL https://doi.org/10.1093/bioinformatics/bty197.") 18 | ) 19 | 20 | -------------------------------------------------------------------------------- /inst/extdata/resultsSimulationAndLinearModel/SNP_effects_NrSNP10.csv: -------------------------------------------------------------------------------- 1 | ,sharedEffect1_5-7362997,sharedEffect2_rs6891963,sharedEffect3_rs347421,sharedEffect4_rs62461360,sharedEffect5_rs28788872,sharedEffect6_rs6948782,sharedEffect7_rs10953472,sharedEffect8_11-21798013,sharedEffect9_rs12576450,sharedEffect10_rs11216590 2 | Trait_1,-0.200486070072339,-0.127111150461199,0.0877151912419139,-0.161370916282726,-0.241712110516961,0.230233628641577,-0.466319000531486,-0.202325890888045,0.0361480287122858,-0.0448698105723619 3 | Trait_2,-0.359401716689492,-0.227866034132185,0.157242796473172,-0.28928186539265,-0.43330565277224,0.412728731445417,-0.835947601025209,-0.362699874807545,0.0648008291521147,-0.0804359472028181 4 | Trait_3,-0.0880965324835118,-0.0558545119448005,0.0385433471350529,-0.0709087577160134,-0.106211861941991,0.101168047920242,-0.204907438023888,-0.0889049768517224,0.0158839763007862,-0.0197164557277761 5 | -------------------------------------------------------------------------------- /man/rescaleVariance.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/createphenotypeFunctions.R 3 | \name{rescaleVariance} 4 | \alias{rescaleVariance} 5 | \title{Scale phenotype component.} 6 | \usage{ 7 | rescaleVariance(component, propvar) 8 | } 9 | \arguments{ 10 | \item{component}{[N x P] Phenotype matrix [double] where [N] are the number 11 | of samples and P the number of phenotypes} 12 | 13 | \item{propvar}{Number [double] specifying the proportion of variance that 14 | should be explained by this phenotype component} 15 | } 16 | \value{ 17 | If propvar != 0, a named list with the [N x P] matrix of the scaled 18 | component (component) and its scale factor [double] (scale_factor) else 19 | returns NULL 20 | } 21 | \description{ 22 | The function scales the specified component such that the average column 23 | variance is equal to the user-specified proportion of variance. 24 | } 25 | \examples{ 26 | x <- matrix(rnorm(100), nc=10) 27 | x_scaled <- rescaleVariance(x, propvar=0.4) 28 | } 29 | -------------------------------------------------------------------------------- /vignettes/plos-genetics.csl: -------------------------------------------------------------------------------- 1 | 2 | 18 | -------------------------------------------------------------------------------- /man/probGen2expGen.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utilityFunctions.R 3 | \name{probGen2expGen} 4 | \alias{probGen2expGen} 5 | \title{Compute expected genotypes from genotype probabilities.} 6 | \usage{ 7 | probGen2expGen(probGeno) 8 | } 9 | \arguments{ 10 | \item{probGeno}{Vector [numeric] with genotype probabilites; has to be a 11 | multiple of 3.} 12 | } 13 | \value{ 14 | Numeric vector of length [length(probGeno)/3] with the expected 15 | genotype value per individual. 16 | } 17 | \description{ 18 | Convert genotypes encoded as triplets of probablities (p(AA), p(Aa), p(aa)) 19 | into their expected genotype frequencies by 0*p(AA) + p(Aa) + 2p(aa). 20 | } 21 | \examples{ 22 | nrSamples <- 10 23 | # Construct genotype probability vector (usually from external input) 24 | # First, assign zero probabilty of AA, Aa and aa for all samples 25 | genotype_prob <- rep(0, 3*nrSamples) 26 | # Second, for each sample draw one of 0,1,2 (corresponding to AA, Aa and aa) 27 | genotype_prob[seq(1, nrSamples*3, 3) + sample(0:2, 10, replace=TRUE)] <- 1 28 | genotype_exp <- probGen2expGen(genotype_prob) 29 | } 30 | -------------------------------------------------------------------------------- /src/read_lines.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | //' Scan file for specific line numbers 9 | //' 10 | //' @param filename /path/to/chromosomefile [string] 11 | //' @param lines vector of line numbers [integer] to be read 12 | //' @param sep [string] end-of-line delimiter 13 | // [[Rcpp::export]] 14 | Rcpp::CharacterVector read_lines(std::string const& filename, Rcpp::NumericVector const& lines, char sep = '\n') { 15 | std::ifstream file{filename.c_str()}; 16 | Rcpp::CharacterVector ret{lines.size(), NA_STRING}; 17 | std::string line; 18 | int lineno = 1; 19 | unsigned int next_index = 0; 20 | unsigned int ret_index = 0; 21 | while (std::getline(file, line, sep)) { 22 | if (lineno % 10000 == 0) Rcpp::checkUserInterrupt(); 23 | if (next_index == lines.size()) break; 24 | if (lineno++ == lines[next_index]) { 25 | ret[ret_index++] = line; 26 | ++next_index; 27 | } 28 | } 29 | 30 | if (next_index < lines.size()) { 31 | Rcpp::Function warning{"warning"}; 32 | warning("File contained fewer lines than indicated by arguments."); 33 | } 34 | 35 | return ret; 36 | } 37 | -------------------------------------------------------------------------------- /src/RcppExports.cpp: -------------------------------------------------------------------------------- 1 | // Generated by using Rcpp::compileAttributes() -> do not edit by hand 2 | // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 3 | 4 | #include 5 | 6 | using namespace Rcpp; 7 | 8 | // read_lines 9 | Rcpp::CharacterVector read_lines(std::string const& filename, Rcpp::NumericVector const& lines, char sep); 10 | RcppExport SEXP _PhenotypeSimulator_read_lines(SEXP filenameSEXP, SEXP linesSEXP, SEXP sepSEXP) { 11 | BEGIN_RCPP 12 | Rcpp::RObject rcpp_result_gen; 13 | Rcpp::RNGScope rcpp_rngScope_gen; 14 | Rcpp::traits::input_parameter< std::string const& >::type filename(filenameSEXP); 15 | Rcpp::traits::input_parameter< Rcpp::NumericVector const& >::type lines(linesSEXP); 16 | Rcpp::traits::input_parameter< char >::type sep(sepSEXP); 17 | rcpp_result_gen = Rcpp::wrap(read_lines(filename, lines, sep)); 18 | return rcpp_result_gen; 19 | END_RCPP 20 | } 21 | 22 | static const R_CallMethodDef CallEntries[] = { 23 | {"_PhenotypeSimulator_read_lines", (DL_FUNC) &_PhenotypeSimulator_read_lines, 3}, 24 | {NULL, NULL, 0} 25 | }; 26 | 27 | RcppExport void R_init_PhenotypeSimulator(DllInfo *dll) { 28 | R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); 29 | R_useDynamicSymbols(dll, FALSE); 30 | } 31 | -------------------------------------------------------------------------------- /man/standardiseGenotypes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/genotypeFunctions.R 3 | \name{standardiseGenotypes} 4 | \alias{standardiseGenotypes} 5 | \title{Standardise genotypes.} 6 | \usage{ 7 | standardiseGenotypes(geno, impute = FALSE) 8 | } 9 | \arguments{ 10 | \item{geno}{[N x NrSNP] Matrix/dataframe of genotypes [integer]/[double].} 11 | 12 | \item{impute}{[logical] Indicating if missing genotypes should be imputed; if 13 | set FALSE and data contains missing values, \code{standardiseGenotypes} will 14 | return an error.} 15 | } 16 | \value{ 17 | [N x NrSNP] Matrix of standardised genotypes [double]. 18 | } 19 | \description{ 20 | Genotypes are standardised as described in Yang et al: 21 | snp_standardised = (snp - 2 * ref_allele_freq)/ 22 | sqrt(2 * ref_allele_freq * alt_allele_freq). 23 | } 24 | \details{ 25 | Missing genotypes can be mean-imputed and rounded to nearest integer 26 | before standardisation. If genotypes contain missing values and impute is set 27 | to FALSE, \code{standardiseGenotypes} will return an error. 28 | } 29 | \examples{ 30 | geno <- cbind(rbinom(2000, 2, 0.3), rbinom(2000, 2, 0.4),rbinom(2000, 2, 0.5)) 31 | geno_sd <- standardiseGenotypes(geno) 32 | } 33 | \references{ 34 | Yang, J., Lee, S.H., Goddard, M.E., Visscher, P.M. (2011) GCTA: 35 | a tool for genome-wide complex trait analysis, AJHG: 88 36 | } 37 | \seealso{ 38 | \code{\link{getAlleleFrequencies}} 39 | } 40 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(correlatedBgEffects) 4 | export(expGen2probGen) 5 | export(geneticBgEffects) 6 | export(geneticFixedEffects) 7 | export(getAlleleFrequencies) 8 | export(getCausalSNPs) 9 | export(getKinship) 10 | export(noiseBgEffects) 11 | export(noiseFixedEffects) 12 | export(probGen2expGen) 13 | export(readStandardGenotypes) 14 | export(rescaleVariance) 15 | export(runSimulation) 16 | export(savePheno) 17 | export(setModel) 18 | export(simulateDist) 19 | export(simulateGenotypes) 20 | export(simulatePhenotypes) 21 | export(standardiseGenotypes) 22 | export(transformNonlinear) 23 | export(writeStandardOutput) 24 | import(ggplot2) 25 | import(snpStats) 26 | importClassesFrom(snpStats,SnpMatrix) 27 | importFrom(R.utils,countLines) 28 | importFrom(Rcpp,sourceCpp) 29 | importFrom(cowplot,plot_grid) 30 | importFrom(dplyr,filter) 31 | importFrom(methods,as) 32 | importFrom(methods,getPackageName) 33 | importFrom(optparse,OptionParser) 34 | importFrom(optparse,make_option) 35 | importFrom(optparse,parse_args) 36 | importFrom(reshape2,melt) 37 | importFrom(snpStats,write.plink) 38 | importFrom(stats,median) 39 | importFrom(stats,na.omit) 40 | importFrom(stats,pnorm) 41 | importFrom(stats,rbinom) 42 | importFrom(stats,rexp) 43 | importFrom(stats,rnorm) 44 | importFrom(stats,runif) 45 | importFrom(stats,sd) 46 | importFrom(stats,var) 47 | importFrom(utils,read.table) 48 | importFrom(utils,write.table) 49 | useDynLib(PhenotypeSimulator, .registration = TRUE) 50 | -------------------------------------------------------------------------------- /man/simulatePhenotypes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/commandlineFunctions.R 3 | \name{simulatePhenotypes} 4 | \alias{simulatePhenotypes} 5 | \title{Command line execution for PhenotypeSimulator.} 6 | \usage{ 7 | simulatePhenotypes() 8 | } 9 | \description{ 10 | simulatePhenotypes runs without arguments. Upon call, it reads command-line 11 | parameters and supplies these to \code{\link{runSimulation}} and 12 | \code{\link{savePheno}}. For details on input to \code{\link{runSimulation}} 13 | and \code{\link{savePheno}}, please refer to their help pages. For help on 14 | the command line arguments that can be passed, see examples below. From the 15 | command line, the help function can be called via 16 | 'Rscript -e "PhenotypeSimulator::simulatePhenotypes()" --args --help 17 | } 18 | \examples{ 19 | # (not run) 20 | # Simulate simple phenotype of genetic and noise background effects only: 21 | # (not run) 22 | # Rscript -e "PhenotypeSimulator::simulatePhenotypes()" \ 23 | #--args \ 24 | #--NrSamples=100 --NrPhenotypes=15 \ 25 | #--tNrSNPs=10000 --cNrSNPs=30 \ 26 | #--SNPfrequencies=0.05,0.1,0.3,0.4 \ 27 | #--genVar=0.4 --h2s=0.025 --phi=0.6 --delta=0.3 --gamma=1 \ 28 | #--pcorr=0.8 \ 29 | #--NrFixedEffects=4 --NrConfounders=1,2,1,2 \ 30 | #--pIndependentConfounders=0,1,1,0.5 \ 31 | #--distConfounders=bin,cat_norm,cat_unif,norm \ 32 | #--probConfounders=0.2 \ 33 | #--catConfounders=0,3,4,0 \ 34 | #--directory=/tmp \ 35 | #--showProgress \ 36 | } 37 | -------------------------------------------------------------------------------- /man/simulateGenotypes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/genotypeFunctions.R 3 | \name{simulateGenotypes} 4 | \alias{simulateGenotypes} 5 | \title{Simulate bi-allelic genotypes.} 6 | \usage{ 7 | simulateGenotypes( 8 | N, 9 | NrSNP = 5000, 10 | frequencies = c(0.1, 0.2, 0.4), 11 | sampleID = "ID_", 12 | snpID = "SNP_", 13 | verbose = TRUE 14 | ) 15 | } 16 | \arguments{ 17 | \item{N}{Number of samples for which to simulate bi-allelic genotypes.} 18 | 19 | \item{NrSNP}{Number of SNPs to simulate.} 20 | 21 | \item{frequencies}{Vector of allele frequencies [double] from which to 22 | sample.} 23 | 24 | \item{sampleID}{Prefix [string] for naming samples (will be followed by 25 | sample number from 1 to N when constructing id_samples).} 26 | 27 | \item{snpID}{Prefix [string] for naming SNPs (will be followed by SNP number 28 | from 1 to NrSNP when constructing id_snps).} 29 | 30 | \item{verbose}{[boolean] If TRUE, progress info is printed to standard out.} 31 | } 32 | \value{ 33 | Named list with [N x NrSNP] matrix of simulated genotypes 34 | (genotypes), their SNP frequencies (freq), a vector of sample IDs 35 | (id_samples) and a vector of SNP IDs (id_snps). 36 | } 37 | \description{ 38 | Simulate bi-allelic genotypes. 39 | } 40 | \examples{ 41 | N10NrSNP10 <- simulateGenotypes(N=10, NrSNP=10) 42 | N10NrSNP10 <- simulateGenotypes(N=10, NrSNP=10, 43 | frequencies=c(0.2,0.3,0.4)) 44 | } 45 | \seealso{ 46 | \code{\link{standardiseGenotypes}} 47 | } 48 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | 6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ 7 | 8 | /* All levels of nav */ 9 | nav[data-toggle='toc'] .nav > li > a { 10 | display: block; 11 | padding: 4px 20px; 12 | font-size: 13px; 13 | font-weight: 500; 14 | color: #767676; 15 | } 16 | nav[data-toggle='toc'] .nav > li > a:hover, 17 | nav[data-toggle='toc'] .nav > li > a:focus { 18 | padding-left: 19px; 19 | color: #563d7c; 20 | text-decoration: none; 21 | background-color: transparent; 22 | border-left: 1px solid #563d7c; 23 | } 24 | nav[data-toggle='toc'] .nav > .active > a, 25 | nav[data-toggle='toc'] .nav > .active:hover > a, 26 | nav[data-toggle='toc'] .nav > .active:focus > a { 27 | padding-left: 18px; 28 | font-weight: bold; 29 | color: #563d7c; 30 | background-color: transparent; 31 | border-left: 2px solid #563d7c; 32 | } 33 | 34 | /* Nav: second level (shown on .active) */ 35 | nav[data-toggle='toc'] .nav .nav { 36 | display: none; /* Hide by default, but at >768px, show it */ 37 | padding-bottom: 10px; 38 | } 39 | nav[data-toggle='toc'] .nav .nav > li > a { 40 | padding-top: 1px; 41 | padding-bottom: 1px; 42 | padding-left: 30px; 43 | font-size: 12px; 44 | font-weight: normal; 45 | } 46 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 47 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 48 | padding-left: 29px; 49 | } 50 | nav[data-toggle='toc'] .nav .nav > .active > a, 51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 53 | padding-left: 28px; 54 | font-weight: 500; 55 | } 56 | 57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ 58 | nav[data-toggle='toc'] .nav > .active > ul { 59 | display: block; 60 | } 61 | -------------------------------------------------------------------------------- /man/getKinship.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/genotypeFunctions.R 3 | \name{getKinship} 4 | \alias{getKinship} 5 | \title{Get genetic kinship.} 6 | \usage{ 7 | getKinship( 8 | N, 9 | sampleID = "ID_", 10 | X = NULL, 11 | kinshipfile = NULL, 12 | id_samples = NULL, 13 | standardise = FALSE, 14 | sep = ",", 15 | header = TRUE, 16 | verbose = TRUE 17 | ) 18 | } 19 | \arguments{ 20 | \item{N}{Number [integer] of samples to simulate.} 21 | 22 | \item{sampleID}{Prefix [string] for naming samples (will be followed by 23 | sample number from 1 to N when constructing id_samples).} 24 | 25 | \item{X}{[NrSamples x totalNrSNPs] Matrix of (standardised) genotypes.} 26 | 27 | \item{kinshipfile}{path/to/kinshipfile [string] to be read; either X or 28 | kinshipfile must be provided.} 29 | 30 | \item{id_samples}{Vector of [NrSamples] sample IDs [string]; if not provided 31 | constructed by paste(sampleID, 1:N, sep="").} 32 | 33 | \item{standardise}{[boolean] If TRUE genotypes will be standardised before 34 | kinship estimation.} 35 | 36 | \item{sep}{Field separator [string] of kinship file.} 37 | 38 | \item{header}{[boolean], If TRUE kinship file has header information.} 39 | 40 | \item{verbose}{[boolean]; If TRUE, progress info is printed to standard out} 41 | } 42 | \value{ 43 | [NrSamples x NrSamples] Matrix of kinship estimate. 44 | } 45 | \description{ 46 | Estimate kinship from standardised genotypes or read pre-computed kinship 47 | file. Standardised genotypes can be obtained via 48 | \code{\link{standardiseGenotypes}}. 49 | } 50 | \details{ 51 | The kinship is estimated as \eqn{K = XX_T}, with X the standardised 52 | genotypes of the samples. When estimating the kinship from the provided 53 | genotypes, the kinship is normalised by the mean of its diagonal 54 | elements and 1e-4 added to the diagonal for numerical stability. 55 | } 56 | \examples{ 57 | geno <- simulateGenotypes(N=10, NrSNP=50) 58 | K_fromGenotypesNormalised <- getKinship(N=10, X=geno$genotypes, 59 | standardise=TRUE) 60 | 61 | kinshipfile <- system.file("extdata/kinship", 62 | "kinship.csv", 63 | package = "PhenotypeSimulator") 64 | K_fromFile <- getKinship(N=50, kinshipfile=kinshipfile) 65 | } 66 | -------------------------------------------------------------------------------- /man/simulateDist.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utilityFunctions.R 3 | \name{simulateDist} 4 | \alias{simulateDist} 5 | \title{Data simulation for different distributions.} 6 | \usage{ 7 | simulateDist( 8 | x, 9 | dist = c("unif", "norm", "bin", "cat_norm", "cat_unif"), 10 | m = NULL, 11 | std = 1, 12 | categories = NULL, 13 | prob = NULL 14 | ) 15 | } 16 | \arguments{ 17 | \item{x}{The number [integer] of observations to simulate.} 18 | 19 | \item{dist}{Name of distribution [string] from which the observations are 20 | drawn. 'norm' is the normal distribution, 'unif' the uniform distribution 21 | 'bin' the binomial distribution, "cat_norm" samples categorical variables 22 | according to a normal distribution and "cat_unif" 23 | according to a uniform distribution. For "cat_norm", length(category)/2 is 24 | used mean for the normal distribution unless 25 | specified otherwise.} 26 | 27 | \item{m}{Mean of the normal distribution [double]/the mean between min 28 | and max for the uniform distribution [double]/ 29 | the rank of the category to be used as mean for "cat_norm" [integer].} 30 | 31 | \item{std}{Standard deviation of the normal distribution or the distance 32 | of min/max from the mean for the uniform distribution [double].} 33 | 34 | \item{categories}{Number of categories [integer] for simulating categorical 35 | variables (for distr="cat_norm" or "cat_unif").} 36 | 37 | \item{prob}{Probability [double] of success for each trial 38 | (for distr="bin").} 39 | } 40 | \value{ 41 | Numeric vector of length [x] with the sampled values 42 | } 43 | \description{ 44 | Wrapper function to simulate data from different distribution with different 45 | parameter settings. 46 | } 47 | \examples{ 48 | normal <- simulateDist(x=10, dist="norm", m=2, std=4) 49 | cat_normal <- simulateDist(x=10, dist="cat_norm", categories=5) 50 | cat_uniform <- simulateDist(x=10, dist="cat_unif", categories=5) 51 | uniform <- simulateDist(x=10, dist="unif", m=4, std=1) 52 | binomial <- simulateDist(x=10, dist="bin", prob=0.4) 53 | } 54 | \seealso{ 55 | \code{\link{runif}}, \code{\link{rnorm}}, \code{\link{rbinom}} for 56 | documentation of the underlying distributions. 57 | } 58 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: PhenotypeSimulator 2 | Title: Flexible Phenotype Simulation from Different Genetic and Noise Models 3 | Version: 0.3.4 4 | Authors@R: c( 5 | person("Hannah", "Meyer", email = "hannah.v.meyer@gmail.com", role = c("aut", "cre"), 6 | comment = c(ORCID = "0000-0003-4564-0899")), 7 | person("Konrad", "Rudolph", email = "konrad.rudolph@gmail.com", role = "ctb", 8 | comment = c(ORCID = "0000-0002-9866-7051")) 9 | ) 10 | URL: https://github.com/HannahVMeyer/PhenotypeSimulator 11 | BugReports: https://github.com/HannahVMeyer/PhenotypeSimulator/issues 12 | Description: Simulation is a critical part of method development and assessment 13 | in quantitative genetics. 'PhenotypeSimulator' allows for the flexible 14 | simulation of phenotypes under different models, including genetic variant 15 | and infinitesimal genetic effects (reflecting population structure) as well 16 | as non-genetic covariate effects, observational noise and additional 17 | correlation effects. The different phenotype components are combined into a 18 | final phenotype while controlling for the proportion of variance explained 19 | by each of the components. For each effect component, the number of 20 | variables, their distribution and the design of their effect across traits 21 | can be customised. For the simulation of the genetic effects, external 22 | genotype data from a number of standard software ('plink', 'hapgen2'/ 23 | 'impute2', 'genome', 'bimbam', simple text files) can be imported. The final 24 | simulated phenotypes and its components can be automatically saved into .rds 25 | or .csv files. In addition, they can be saved in formats compatible with 26 | commonly used genetic association software ('gemma', 'bimbam', 'plink', 27 | 'snptest', 'LiMMBo'). 28 | Depends: 29 | R (>= 3.5.0) 30 | biocViews: 31 | LinkingTo: 32 | Rcpp 33 | Imports: 34 | methods, 35 | optparse, 36 | Hmisc, 37 | R.utils, 38 | mvtnorm, 39 | snpStats, 40 | zoo, 41 | data.table (>= 1.11.0), 42 | Rcpp (>= 0.12.11), 43 | cowplot, 44 | ggplot2, 45 | reshape2, 46 | dplyr 47 | Suggests: 48 | testthat, 49 | knitr, 50 | formatR, 51 | rmarkdown 52 | License: MIT + file LICENSE 53 | Encoding: UTF-8 54 | RoxygenNote: 7.1.1 55 | VignetteBuilder: knitr 56 | -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /inst/extdata/genotypes/hapgen/genotypes_hapgen.controls.sample: -------------------------------------------------------------------------------- 1 | ID_1 ID_2 missing pheno 2 | 0 0 0 B 3 | id1_0 id2_0 0 0 4 | id1_1 id2_1 0 0 5 | id1_2 id2_2 0 0 6 | id1_3 id2_3 0 0 7 | id1_4 id2_4 0 0 8 | id1_5 id2_5 0 0 9 | id1_6 id2_6 0 0 10 | id1_7 id2_7 0 0 11 | id1_8 id2_8 0 0 12 | id1_9 id2_9 0 0 13 | id1_10 id2_10 0 0 14 | id1_11 id2_11 0 0 15 | id1_12 id2_12 0 0 16 | id1_13 id2_13 0 0 17 | id1_14 id2_14 0 0 18 | id1_15 id2_15 0 0 19 | id1_16 id2_16 0 0 20 | id1_17 id2_17 0 0 21 | id1_18 id2_18 0 0 22 | id1_19 id2_19 0 0 23 | id1_20 id2_20 0 0 24 | id1_21 id2_21 0 0 25 | id1_22 id2_22 0 0 26 | id1_23 id2_23 0 0 27 | id1_24 id2_24 0 0 28 | id1_25 id2_25 0 0 29 | id1_26 id2_26 0 0 30 | id1_27 id2_27 0 0 31 | id1_28 id2_28 0 0 32 | id1_29 id2_29 0 0 33 | id1_30 id2_30 0 0 34 | id1_31 id2_31 0 0 35 | id1_32 id2_32 0 0 36 | id1_33 id2_33 0 0 37 | id1_34 id2_34 0 0 38 | id1_35 id2_35 0 0 39 | id1_36 id2_36 0 0 40 | id1_37 id2_37 0 0 41 | id1_38 id2_38 0 0 42 | id1_39 id2_39 0 0 43 | id1_40 id2_40 0 0 44 | id1_41 id2_41 0 0 45 | id1_42 id2_42 0 0 46 | id1_43 id2_43 0 0 47 | id1_44 id2_44 0 0 48 | id1_45 id2_45 0 0 49 | id1_46 id2_46 0 0 50 | id1_47 id2_47 0 0 51 | id1_48 id2_48 0 0 52 | id1_49 id2_49 0 0 53 | id1_50 id2_50 0 0 54 | id1_51 id2_51 0 0 55 | id1_52 id2_52 0 0 56 | id1_53 id2_53 0 0 57 | id1_54 id2_54 0 0 58 | id1_55 id2_55 0 0 59 | id1_56 id2_56 0 0 60 | id1_57 id2_57 0 0 61 | id1_58 id2_58 0 0 62 | id1_59 id2_59 0 0 63 | id1_60 id2_60 0 0 64 | id1_61 id2_61 0 0 65 | id1_62 id2_62 0 0 66 | id1_63 id2_63 0 0 67 | id1_64 id2_64 0 0 68 | id1_65 id2_65 0 0 69 | id1_66 id2_66 0 0 70 | id1_67 id2_67 0 0 71 | id1_68 id2_68 0 0 72 | id1_69 id2_69 0 0 73 | id1_70 id2_70 0 0 74 | id1_71 id2_71 0 0 75 | id1_72 id2_72 0 0 76 | id1_73 id2_73 0 0 77 | id1_74 id2_74 0 0 78 | id1_75 id2_75 0 0 79 | id1_76 id2_76 0 0 80 | id1_77 id2_77 0 0 81 | id1_78 id2_78 0 0 82 | id1_79 id2_79 0 0 83 | id1_80 id2_80 0 0 84 | id1_81 id2_81 0 0 85 | id1_82 id2_82 0 0 86 | id1_83 id2_83 0 0 87 | id1_84 id2_84 0 0 88 | id1_85 id2_85 0 0 89 | id1_86 id2_86 0 0 90 | id1_87 id2_87 0 0 91 | id1_88 id2_88 0 0 92 | id1_89 id2_89 0 0 93 | id1_90 id2_90 0 0 94 | id1_91 id2_91 0 0 95 | id1_92 id2_92 0 0 96 | id1_93 id2_93 0 0 97 | id1_94 id2_94 0 0 98 | id1_95 id2_95 0 0 99 | id1_96 id2_96 0 0 100 | id1_97 id2_97 0 0 101 | id1_98 id2_98 0 0 102 | id1_99 id2_99 0 0 103 | -------------------------------------------------------------------------------- /inst/extdata/genotypes/hapgen/genotypes_hapgen_chr22.sample: -------------------------------------------------------------------------------- 1 | ID_1 ID_2 missing pheno 2 | 0 0 0 B 3 | id1_0 id2_0 0 0 4 | id1_1 id2_1 0 0 5 | id1_2 id2_2 0 0 6 | id1_3 id2_3 0 0 7 | id1_4 id2_4 0 0 8 | id1_5 id2_5 0 0 9 | id1_6 id2_6 0 0 10 | id1_7 id2_7 0 0 11 | id1_8 id2_8 0 0 12 | id1_9 id2_9 0 0 13 | id1_10 id2_10 0 0 14 | id1_11 id2_11 0 0 15 | id1_12 id2_12 0 0 16 | id1_13 id2_13 0 0 17 | id1_14 id2_14 0 0 18 | id1_15 id2_15 0 0 19 | id1_16 id2_16 0 0 20 | id1_17 id2_17 0 0 21 | id1_18 id2_18 0 0 22 | id1_19 id2_19 0 0 23 | id1_20 id2_20 0 0 24 | id1_21 id2_21 0 0 25 | id1_22 id2_22 0 0 26 | id1_23 id2_23 0 0 27 | id1_24 id2_24 0 0 28 | id1_25 id2_25 0 0 29 | id1_26 id2_26 0 0 30 | id1_27 id2_27 0 0 31 | id1_28 id2_28 0 0 32 | id1_29 id2_29 0 0 33 | id1_30 id2_30 0 0 34 | id1_31 id2_31 0 0 35 | id1_32 id2_32 0 0 36 | id1_33 id2_33 0 0 37 | id1_34 id2_34 0 0 38 | id1_35 id2_35 0 0 39 | id1_36 id2_36 0 0 40 | id1_37 id2_37 0 0 41 | id1_38 id2_38 0 0 42 | id1_39 id2_39 0 0 43 | id1_40 id2_40 0 0 44 | id1_41 id2_41 0 0 45 | id1_42 id2_42 0 0 46 | id1_43 id2_43 0 0 47 | id1_44 id2_44 0 0 48 | id1_45 id2_45 0 0 49 | id1_46 id2_46 0 0 50 | id1_47 id2_47 0 0 51 | id1_48 id2_48 0 0 52 | id1_49 id2_49 0 0 53 | id1_50 id2_50 0 0 54 | id1_51 id2_51 0 0 55 | id1_52 id2_52 0 0 56 | id1_53 id2_53 0 0 57 | id1_54 id2_54 0 0 58 | id1_55 id2_55 0 0 59 | id1_56 id2_56 0 0 60 | id1_57 id2_57 0 0 61 | id1_58 id2_58 0 0 62 | id1_59 id2_59 0 0 63 | id1_60 id2_60 0 0 64 | id1_61 id2_61 0 0 65 | id1_62 id2_62 0 0 66 | id1_63 id2_63 0 0 67 | id1_64 id2_64 0 0 68 | id1_65 id2_65 0 0 69 | id1_66 id2_66 0 0 70 | id1_67 id2_67 0 0 71 | id1_68 id2_68 0 0 72 | id1_69 id2_69 0 0 73 | id1_70 id2_70 0 0 74 | id1_71 id2_71 0 0 75 | id1_72 id2_72 0 0 76 | id1_73 id2_73 0 0 77 | id1_74 id2_74 0 0 78 | id1_75 id2_75 0 0 79 | id1_76 id2_76 0 0 80 | id1_77 id2_77 0 0 81 | id1_78 id2_78 0 0 82 | id1_79 id2_79 0 0 83 | id1_80 id2_80 0 0 84 | id1_81 id2_81 0 0 85 | id1_82 id2_82 0 0 86 | id1_83 id2_83 0 0 87 | id1_84 id2_84 0 0 88 | id1_85 id2_85 0 0 89 | id1_86 id2_86 0 0 90 | id1_87 id2_87 0 0 91 | id1_88 id2_88 0 0 92 | id1_89 id2_89 0 0 93 | id1_90 id2_90 0 0 94 | id1_91 id2_91 0 0 95 | id1_92 id2_92 0 0 96 | id1_93 id2_93 0 0 97 | id1_94 id2_94 0 0 98 | id1_95 id2_95 0 0 99 | id1_96 id2_96 0 0 100 | id1_97 id2_97 0 0 101 | id1_98 id2_98 0 0 102 | id1_99 id2_99 0 0 103 | -------------------------------------------------------------------------------- /man/noiseBgEffects.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/variancecomponentFunctions.R 3 | \name{noiseBgEffects} 4 | \alias{noiseBgEffects} 5 | \title{Simulate observational noise effects.} 6 | \usage{ 7 | noiseBgEffects( 8 | N, 9 | P, 10 | mean = 0, 11 | sd = 1, 12 | sampleID = "ID_", 13 | phenoID = "Trait_", 14 | shared = TRUE, 15 | independent = TRUE, 16 | id_samples = NULL, 17 | id_phenos = NULL 18 | ) 19 | } 20 | \arguments{ 21 | \item{N}{Number [integer] of samples to simulate.} 22 | 23 | \item{P}{Number [integer] of phenotypes to simulate.} 24 | 25 | \item{mean}{Mean [double] of the normal distribution.} 26 | 27 | \item{sd}{Standard deviation [double] of the normal distribution.} 28 | 29 | \item{sampleID}{Prefix [string] for naming samples.} 30 | 31 | \item{phenoID}{Prefix [string] for naming traits.} 32 | 33 | \item{shared}{[bool] shared effect simulated if set to TRUE; at least one of 34 | shared or independent has to be set to TRUE.} 35 | 36 | \item{independent}{[bool] independent effect simulated if set to TRUE.} 37 | 38 | \item{id_samples}{Vector of [NrSamples] sample IDs [string]; if not provided 39 | constructed by paste(sampleID, 1:N, sep="").} 40 | 41 | \item{id_phenos}{Vector of [NrTraits] phenotype IDs [string]; if not provided 42 | constructed by paste(phenoID, 1:P, sep="").} 43 | } 44 | \value{ 45 | Named list of shared noise effects (shared: [N x P] matrix) and 46 | independent noise effects (independent: [N x P] matrix), the covariance term 47 | of the shared effect (cov_shared: [P x P] matrix) and the covariance term of 48 | the independent effect (cov_independent: [P x P] matrix). 49 | } 50 | \description{ 51 | noiseBgEffects simulates observational noise with a proportion of the effect 52 | shared across samples and a proportion independent across samples. 53 | } 54 | \details{ 55 | For the simulation of the observational noise effects, two 56 | components are used: i) matrix B [N x P] with vec(B) drawn from a normal 57 | distribution with mean=mean and sd=sd and ii) the trait design matrix A 58 | [P x P]. For the independent effect, A is a diagonal matrix with normally 59 | distributed values. A for the shared effect is a matrix of rowrank one, with 60 | normally distributed entries in row 1 and zeros elsewhere. To construct the 61 | final effects, the two matrices are multiplied as: E = BA^T. 62 | } 63 | \examples{ 64 | noiseBG <- noiseBgEffects(N=100, P=20, mean=2) 65 | } 66 | -------------------------------------------------------------------------------- /inst/extdata/genotypes/plink/genotypes_plink.fam: -------------------------------------------------------------------------------- 1 | per0 per0 0 0 2 1 2 | per1 per1 0 0 2 1 3 | per2 per2 0 0 2 1 4 | per3 per3 0 0 2 1 5 | per4 per4 0 0 2 1 6 | per5 per5 0 0 2 1 7 | per6 per6 0 0 2 1 8 | per7 per7 0 0 2 1 9 | per8 per8 0 0 2 1 10 | per9 per9 0 0 2 1 11 | per10 per10 0 0 2 1 12 | per11 per11 0 0 2 1 13 | per12 per12 0 0 2 1 14 | per13 per13 0 0 2 1 15 | per14 per14 0 0 2 1 16 | per15 per15 0 0 2 1 17 | per16 per16 0 0 2 1 18 | per17 per17 0 0 2 1 19 | per18 per18 0 0 2 1 20 | per19 per19 0 0 2 1 21 | per20 per20 0 0 2 1 22 | per21 per21 0 0 2 1 23 | per22 per22 0 0 2 1 24 | per23 per23 0 0 2 1 25 | per24 per24 0 0 2 1 26 | per25 per25 0 0 2 1 27 | per26 per26 0 0 2 1 28 | per27 per27 0 0 2 1 29 | per28 per28 0 0 2 1 30 | per29 per29 0 0 2 1 31 | per30 per30 0 0 2 1 32 | per31 per31 0 0 2 1 33 | per32 per32 0 0 2 1 34 | per33 per33 0 0 2 1 35 | per34 per34 0 0 2 1 36 | per35 per35 0 0 2 1 37 | per36 per36 0 0 2 1 38 | per37 per37 0 0 2 1 39 | per38 per38 0 0 2 1 40 | per39 per39 0 0 2 1 41 | per40 per40 0 0 2 1 42 | per41 per41 0 0 2 1 43 | per42 per42 0 0 2 1 44 | per43 per43 0 0 2 1 45 | per44 per44 0 0 2 1 46 | per45 per45 0 0 2 1 47 | per46 per46 0 0 2 1 48 | per47 per47 0 0 2 1 49 | per48 per48 0 0 2 1 50 | per49 per49 0 0 2 1 51 | per50 per50 0 0 2 1 52 | per51 per51 0 0 2 1 53 | per52 per52 0 0 2 1 54 | per53 per53 0 0 2 1 55 | per54 per54 0 0 2 1 56 | per55 per55 0 0 2 1 57 | per56 per56 0 0 2 1 58 | per57 per57 0 0 2 1 59 | per58 per58 0 0 2 1 60 | per59 per59 0 0 2 1 61 | per60 per60 0 0 2 1 62 | per61 per61 0 0 2 1 63 | per62 per62 0 0 2 1 64 | per63 per63 0 0 2 1 65 | per64 per64 0 0 2 1 66 | per65 per65 0 0 2 1 67 | per66 per66 0 0 2 1 68 | per67 per67 0 0 2 1 69 | per68 per68 0 0 2 1 70 | per69 per69 0 0 2 1 71 | per70 per70 0 0 2 1 72 | per71 per71 0 0 2 1 73 | per72 per72 0 0 2 1 74 | per73 per73 0 0 2 1 75 | per74 per74 0 0 2 1 76 | per75 per75 0 0 2 1 77 | per76 per76 0 0 2 1 78 | per77 per77 0 0 2 1 79 | per78 per78 0 0 2 1 80 | per79 per79 0 0 2 1 81 | per80 per80 0 0 2 1 82 | per81 per81 0 0 2 1 83 | per82 per82 0 0 2 1 84 | per83 per83 0 0 2 1 85 | per84 per84 0 0 2 1 86 | per85 per85 0 0 2 1 87 | per86 per86 0 0 2 1 88 | per87 per87 0 0 2 1 89 | per88 per88 0 0 2 1 90 | per89 per89 0 0 2 1 91 | per90 per90 0 0 2 1 92 | per91 per91 0 0 2 1 93 | per92 per92 0 0 2 1 94 | per93 per93 0 0 2 1 95 | per94 per94 0 0 2 1 96 | per95 per95 0 0 2 1 97 | per96 per96 0 0 2 1 98 | per97 per97 0 0 2 1 99 | per98 per98 0 0 2 1 100 | per99 per99 0 0 2 1 101 | -------------------------------------------------------------------------------- /man/transformNonlinear.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/createphenotypeFunctions.R 3 | \name{transformNonlinear} 4 | \alias{transformNonlinear} 5 | \title{Phenotype transformation.} 6 | \usage{ 7 | transformNonlinear( 8 | component, 9 | alpha, 10 | method, 11 | logbase = 10, 12 | power = 2, 13 | expbase = NULL, 14 | transformNeg = "abs", 15 | f = NULL, 16 | verbose = TRUE 17 | ) 18 | } 19 | \arguments{ 20 | \item{component}{[N x P] Phenotype matrix [double] where [N] are the number 21 | of samples and P the number of phenotypes} 22 | 23 | \item{alpha}{[double] weighting scalar for non-linearity: alpha==0 fully 24 | linear phenotype, alpha==1 fully non-linear phenotype. See @details.} 25 | 26 | \item{method}{[string] one of exp (exponential), log (logarithm), poly 27 | (polynomial), sqrt (squareroot) or custom (user-supplied function)} 28 | 29 | \item{logbase}{[int] when method==log, sets the log base for transformation} 30 | 31 | \item{power}{[double] when method==poly, sets the power to raise to.} 32 | 33 | \item{expbase}{[double] when method==exp, sets the exp base for 34 | transformation.} 35 | 36 | \item{transformNeg}{[string] one of abs (absolute value) or set0 (set all 37 | negative values to zero). If method==log and transformNeg==set0, negative 38 | values set to 1e-5} 39 | 40 | \item{f}{[function] function accepting component as a single argument.} 41 | 42 | \item{verbose}{[boolean]; If TRUE, progress info is printed to standard out.} 43 | } 44 | \value{ 45 | [N x P] transformed phenotype matrix [double] 46 | } 47 | \description{ 48 | Transformation of phenotype component by applying a user-specified 49 | non-linear transformation to the phenotype component. 50 | } 51 | \details{ 52 | transformNonlinear takes a phenotype component as input and 53 | transforms it according to the specified transformation method. The user can 54 | choose how strongly non-linear the resulting phenotype component should be, 55 | by specifying the weighting parameter alpha: 56 | component_transformed = (1 - alpha) \* component + 57 | alpha \* transformfunction(component) 58 | } 59 | \examples{ 60 | # Simulate non-genetic covariate effects 61 | cov_effects <- noiseFixedEffects(N=100, P=5) 62 | # Transform logarithmically 63 | covs_log <- transformNonlinear(cov_effects$shared, alpha=0.5, method="log", 64 | transformNeg="abs") 65 | # Transform custom 66 | f_custom <- function(x) {x^2 + 3*x} 67 | covs_custom <- transformNonlinear(cov_effects$shared, alpha=0.5, 68 | method="custom", f=f_custom) 69 | } 70 | -------------------------------------------------------------------------------- /man/correlatedBgEffects.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/variancecomponentFunctions.R 3 | \name{correlatedBgEffects} 4 | \alias{correlatedBgEffects} 5 | \title{Simulate correlated background effects.} 6 | \usage{ 7 | correlatedBgEffects( 8 | N, 9 | P, 10 | pcorr = NULL, 11 | corr_mat = NULL, 12 | sampleID = "ID_", 13 | phenoID = "Trait_", 14 | id_samples = NULL, 15 | id_phenos = NULL, 16 | verbose = FALSE 17 | ) 18 | } 19 | \arguments{ 20 | \item{N}{Number [integer] of samples to simulate.} 21 | 22 | \item{P}{Number [integer] of phenotypes to simulate.} 23 | 24 | \item{pcorr}{Initial strength of correlation [double] between neighbouring 25 | traits. Decreases by pcorr^(distance); distance from 0 to P-1. See details.} 26 | 27 | \item{corr_mat}{[P x P] correlation matrix [double] as covariance 28 | component for the multivariate normal distribution. If not provided, pcorr is 29 | used to construct the correlation matrix.} 30 | 31 | \item{sampleID}{Prefix [string] for naming samples.} 32 | 33 | \item{phenoID}{Prefix [string] for naming traits.} 34 | 35 | \item{id_samples}{Vector of [NrSamples] sample IDs [string]; if not provided 36 | constructed by paste(sampleID, 1:N, sep="").} 37 | 38 | \item{id_phenos}{Vector of [NrTraits] phenotype IDs [string]; if not provided 39 | constructed by paste(phenoID, 1:P, sep="").} 40 | 41 | \item{verbose}{[boolean] If TRUE, progress info is printed to standard out.} 42 | } 43 | \value{ 44 | Named list with [N x P] matrix of correlated background effects ( 45 | correlatedBg) and the correlation matrix (cov_correlated). If corr_mat 46 | provided corr_mat == cov_correlated. 47 | } 48 | \description{ 49 | correlatedBgEffects computes a background effect that simulates structured 50 | correlation between the phenotypes. 51 | } 52 | \details{ 53 | correlatedBgEffects can be used to simulate phenotypes with a 54 | defined level of correlation between traits. If the corr_mat is not provided, 55 | a simple correlation structure based on the distance of the traits will be 56 | constructed. Traits of distance d=1 (adjacent columns) will have correlation 57 | cor=\eqn{pcorr^1}{pcorr^1}, traits with d=2 have cor=\eqn{pcorr^2}{pcorr^2} 58 | up to traits with d=(P-1) cor=\eqn{pcorr^{(P-1)}}{pcorr^{(P-1)}} and 59 | 0 < pcorr < 1. The correlated background effect correlated is simulated based 60 | on this correlation structure C: 61 | \eqn{correlated ~ N_{NP}(0,C)}{correlated ~ N_{NP}(0,C)}. 62 | } 63 | \examples{ 64 | correlatedBg <- correlatedBgEffects(N=100, P=20, pcorr=0.4) 65 | } 66 | \seealso{ 67 | \code{\link[mvtnorm]{rmvnorm}} which is used to simulate the 68 | multivariate normal distribution 69 | } 70 | -------------------------------------------------------------------------------- /inst/extdata/genotypes/hapgen/genotypes_hapgen.summary: -------------------------------------------------------------------------------- 1 | 2 | =================================================================== 3 | Welcome to HAPGEN_v2.2.0 (01/04/2011) 4 | Zhan Su, Peter Donnelly, Jonathan Marchini 5 | =================================================================== 6 | 7 | Command line input is: 8 | hapgen2 -m /homes/hannah/data/hmeyer/Supplementary/CEU.0908.impute.files/genetic_map_chr22_combined_b36.txt -l legend_file -h /homes/hannah/data/hmeyer/Supplementary/CEU.0908.impute.files/CEU.0908.chr22.hap -o genotypes_hapgen -n 100 0 -dl 45162 0 0 0 -no_haps_output 9 | 10 | FILE INPUTS 11 | haplotype file: /homes/hannah/data/hmeyer/Supplementary/CEU.0908.impute.files/CEU.0908.chr22.hap 12 | legend file: legend_file 13 | genetic map file: /homes/hannah/data/hmeyer/Supplementary/CEU.0908.impute.files/genetic_map_chr22_combined_b36.txt 14 | tag snps file: 15 | FILE OUTPUTS 16 | output file: genotypes_hapgen 17 | summary file: genotypes_hapgen.summary 18 | PARAMETER INPUTS 19 | no. controls to simulate: 100 20 | no. cases to simulate: 0 21 | disease loci: (1) 45162 22 | disease alleles: (1) 0 23 | heterozygote/homozygote risks: (1) 0.00/0.00 24 | lower: 0 25 | upper: 500000000 26 | Ne: 11418 27 | theta: -1 28 | 29 | Reading genetic map file ... done 30 | number of rates read: 43414 31 | 32 | 33 | Reading haplotype and legend files: looking for SNPs in [0, 500000000] ... done 34 | number of haplotypes: 112 35 | number of SNPs in total: 1000 36 | number of SNPs in interval: 1000 37 | 38 | 39 | Random seed set to 0.889133 40 | theta not set, so setting to a default value of 0.188673 41 | 42 | Processing disease loci ... done 43 | 44 | 45 | Simulating haplotypes ... done 46 | 47 | Writing output to files 48 | writing output file genotypes_hapgen.controls.gen 49 | writing output file genotypes_hapgen.cases.gen 50 | writing output file genotypes_hapgen.controls.sample 51 | writing output file genotypes_hapgen.cases.sample 52 | 53 | HAPGEN took 0 seconds to complete. Have a nice day! 54 | -------------------------------------------------------------------------------- /inst/extdata/resultsSimulationAndLinearModel/simulated_withEffect.csv: -------------------------------------------------------------------------------- 1 | "rsID","observed","expected","model","trait","causal" 2 | "rs6948782",3.202576e-30,6.19316685605371e-08,"mvLMM","all","with effect" 3 | "rs28788872",8.465234e-24,1.85795005681611e-07,"mvLMM","all","with effect" 4 | "5-7362997",3.824327e-17,1.30056503977128e-06,"mvLMM","all","with effect" 5 | "rs10953472",7.711818e-10,2.79311825208022e-05,"mvLMM","all","with effect" 6 | "rs6891963",1.522443e-06,4.51481863806315e-05,"mvLMM","all","with effect" 7 | "rs347421",0.006818504,0.0101349317649262,"mvLMM","all","with effect" 8 | "rs11216590",0.01808669,0.0266667236438017,"mvLMM","all","with effect" 9 | "rs62461360",0.3500164,0.478280006450803,"mvLMM","all","with effect" 10 | "rs12576450",0.5189191,0.688859322710318,"mvLMM","all","with effect" 11 | "rs6948782",8.525384e-08,6.19316685605371e-08,"uvLMM","trait1","with effect" 12 | "rs28788872",8.977751e-06,8.98009194127788e-06,"uvLMM","trait1","with effect" 13 | "5-7362997",1.320489e-05,1.49255321230894e-05,"uvLMM","trait1","with effect" 14 | "rs10953472",0.0001711909,0.000146839986157033,"uvLMM","trait1","with effect" 15 | "rs11216590",0.003411716,0.00347157968116091,"uvLMM","trait1","with effect" 16 | "rs6891963",0.01250972,0.0125823474431015,"uvLMM","trait1","with effect" 17 | "rs347421",0.1213753,0.123102506572808,"uvLMM","trait1","with effect" 18 | "rs62461360",0.2461324,0.247830409786987,"uvLMM","trait1","with effect" 19 | "rs12576450",0.69212,0.69329375404259,"uvLMM","trait1","with effect" 20 | "rs6948782",1.392764e-18,6.19316685605371e-08,"uvLMM","trait2","with effect" 21 | "rs28788872",9.070022e-15,1.85795005681611e-07,"uvLMM","trait2","with effect" 22 | "5-7362997",2.321156e-10,8.05111691286982e-07,"uvLMM","trait2","with effect" 23 | "rs10953472",8.434739e-06,4.03175162329096e-05,"uvLMM","trait2","with effect" 24 | "rs6891963",5.578154e-05,0.000104230998187384,"uvLMM","trait2","with effect" 25 | "rs347421",0.0795464,0.0802179226780641,"uvLMM","trait2","with effect" 26 | "rs12576450",0.5234497,0.524741268068255,"uvLMM","trait2","with effect" 27 | "rs62461360",0.5461021,0.5474569370529,"uvLMM","trait2","with effect" 28 | "rs11216590",0.9000301,0.90074973239326,"uvLMM","trait2","with effect" 29 | "rs28788872",0.001397267,0.00145112092604194,"uvLMM","trait3","with effect" 30 | "rs347421",0.06847544,0.0699269850400339,"uvLMM","trait3","with effect" 31 | "5-7362997",0.09176134,0.0930759279779285,"uvLMM","trait3","with effect" 32 | "rs12576450",0.3908786,0.393671066540128,"uvLMM","trait3","with effect" 33 | "rs6891963",0.5545924,0.556955644786704,"uvLMM","trait3","with effect" 34 | "rs6948782",0.5819357,0.583958100005772,"uvLMM","trait3","with effect" 35 | "rs62461360",0.7192035,0.721118166366793,"uvLMM","trait3","with effect" 36 | "rs11216590",0.8482654,0.848914164441462,"uvLMM","trait3","with effect" 37 | "rs10953472",0.9546342,0.954936721936965,"uvLMM","trait3","with effect" 38 | -------------------------------------------------------------------------------- /man/geneticBgEffects.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/variancecomponentFunctions.R 3 | \name{geneticBgEffects} 4 | \alias{geneticBgEffects} 5 | \title{Simulate infinitesimal genetic effects (reflecting sample kinship).} 6 | \usage{ 7 | geneticBgEffects( 8 | P, 9 | N, 10 | kinship, 11 | phenoID = "Trait_", 12 | id_samples = colnames(kinship), 13 | shared = TRUE, 14 | independent = TRUE, 15 | id_phenos = NULL 16 | ) 17 | } 18 | \arguments{ 19 | \item{P}{Number [integer] of phenotypes to simulate .} 20 | 21 | \item{N}{Number [integer] of samples to simulate; has to be provided as a 22 | dimnesionality check for kinship and downstream analyses; nrow(kinship) has 23 | to be equal to N.} 24 | 25 | \item{kinship}{[N x N] Matrix of kinship estimates [double].} 26 | 27 | \item{phenoID}{Prefix [string] for naming traits.} 28 | 29 | \item{id_samples}{Vector of [NrSamples] sample IDs [string]; if not provided 30 | colnames(kinship) are used.} 31 | 32 | \item{shared}{[bool] shared effect simulated if set to TRUE; at least one of 33 | shared or independent has to be set to TRUE.} 34 | 35 | \item{independent}{[bool] independent effect simulated if set to TRUE.} 36 | 37 | \item{id_phenos}{Vector of [NrTraits] phenotype IDs [string]; if not provided 38 | constructed by paste(phenoID, 1:P, sep="").} 39 | } 40 | \value{ 41 | Named list of shared infinitesimal genetic effects (shared: [N x P] 42 | matrix) and independent infinitesimal genetic effects (independent: [N x P] 43 | matrix), the covariance term of the shared effect (cov_shared: [P x P] 44 | matrix), the covariance term of the independent effect (cov_independent: 45 | [P x P] matrix), the eigenvectors (eigenvec_kinship: [N x N]) and eigenvalues 46 | (eigenval_kinship: [N]) of the kinship matrix. 47 | } 48 | \description{ 49 | geneticBgEffects simulates an infinitesimal genetic effects with a proportion 50 | of the effect shared across samples and a proportion independent across 51 | samples; they are based on the kinship estimates of the (simulated) samples. 52 | } 53 | \details{ 54 | For the simulation of the infinitesimal genetic effects, three 55 | matrix components are used: i) the kinship matrix K [N x N] which is treated 56 | as the sample design matrix, ii) matrix B [N x P] with vec(B) drawn from a 57 | normal distribution and iii) the trait design matrix A [P x P]. For the 58 | independent effect, A is a diagonal matrix with normally distributed values. 59 | A for the shared effect is a matrix of rowrank one, with normally distributed 60 | entries in row 1 and zeros elsewhere. To construct the final effects, the 61 | three matrices are multiplied as: E = cholesky(K)BA^T. 62 | } 63 | \examples{ 64 | genotypes <- simulateGenotypes(N=100, NrSNP=400, verbose=FALSE) 65 | kinship <- getKinship(N=100, X=genotypes$genotypes, standardise=TRUE, 66 | verbose=FALSE) 67 | geneticBg <- geneticBgEffects(N=100, P=10, kinship=kinship) 68 | } 69 | -------------------------------------------------------------------------------- /man/savePheno.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/outputFunctions.R 3 | \name{savePheno} 4 | \alias{savePheno} 5 | \title{Save final phenotype and phenotype components.} 6 | \usage{ 7 | savePheno( 8 | simulatedData, 9 | directory, 10 | format = ".csv", 11 | outstring = "", 12 | saveIntermediate = TRUE, 13 | intercept_gemma = TRUE, 14 | verbose = TRUE 15 | ) 16 | } 17 | \arguments{ 18 | \item{simulatedData}{Named list of i) dataframe of proportion of variance 19 | explained for each component (varComponents), 20 | ii) a named list with the final simulated phenotype components 21 | (phenoComponentsFinal), iii) a named list with the intermediate simulated 22 | phenotype components (phenoComponentsIntermediate), iv) a named list of 23 | parameters describing the model setup (setup) and v) a named list of raw 24 | components (rawComponents) used for genetic effect simulation (genotypes 25 | and/or kinship); obtained from \link{runSimulation}} 26 | 27 | \item{directory}{Absolute path (no tilde expansion) to parent directory 28 | [string] where simulated data should be saved [needs user writing 29 | permission]} 30 | 31 | \item{format}{Vector of format name(s) [string] specifying the output format; 32 | multiple output formats can be requested. Options are: plink, bimbam, 33 | snptest, gemma, limmbo, csv or rds. For information on format see details. In 34 | orde to save intermediate phenotype components, at least one of csv or rds 35 | need to be specified. plink/bimbam/snptest will only save final 36 | phenotype/genotype, kinship and covariate data.} 37 | 38 | \item{outstring}{Optional name [string] of subdirectory (in relation to 39 | directory) to save set-up dependent simulation results; if 40 | set to NULL, subdirectory named by NrSamples, NrSNPs, genetic Model and 41 | noise Model and genVar is created.} 42 | 43 | \item{saveIntermediate}{[bool] If TRUE, intermediate phenotype components 44 | such as shared and independent effect components are saved.} 45 | 46 | \item{intercept_gemma}{[boolean] When modeling an intercept term in gemma, a 47 | column of 1's have to be appended to the covariate files. Set intercept_gemma 48 | to TRUE to include a column of 1's in the output; only used when 49 | "gemma" \%in\% format} 50 | 51 | \item{verbose}{[boolean]; If TRUE, progress info is printed to standard out} 52 | } 53 | \value{ 54 | Path [string] to final output directory. If outstring is 55 | NULL, this directory will be a subdirectory of the input directory. 56 | } 57 | \description{ 58 | savePheno saves simulated phenotypes and their components, model setup 59 | parameters and variance components to the specified directories. Requires a 60 | simulatedData list which is the output of \link{runSimulation}. 61 | } 62 | \examples{ 63 | simulatedPhenotype <- runSimulation(N=100, P=5, cNrSNP=10, 64 | genVar=0.2, h2s=0.2, phi=1) 65 | \dontrun{ 66 | outputdir <- savePheno(simulatedPhenotype, directory=tempdir(), 67 | outstring="Data_simulation", format=c("csv", "plink"))} 68 | } 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/PhenotypeSimulator)](https://cran.r-project.org/package=PhenotypeSimulator) 5 | [![License: 6 | MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 7 | [![Downloads](http://cranlogs.r-pkg.org/badges/grand-total/PhenotypeSimulator?color=blue)](https://CRAN.R-project.org/package=PhenotypeSimulator) 8 | 9 | ## PhenotypeSimulator 10 | 11 | **PhenotypeSimulator** allows for the flexible simulation of phenotypes 12 | from different genetic and non-genetic (noise) components. 13 | 14 | In quantitative genetics, genotype to phenotype mapping is commonly 15 | realised by fitting a linear model to the genotype as the explanatory 16 | variable and the phenotype as the response variable. Other explanatory 17 | variable such as additional sample measures (e.g. age, height, weight) 18 | or batch effects can also be included. For linear mixed models, in 19 | addition to the fixed effects of the genotype and the covariates, 20 | different random effect components can be included, accounting for 21 | population structure in the study cohort or environmental effects. The 22 | application of linear and linear mixed models in quantitative genetics 23 | ranges from genetic studies in model organism such as yeast and 24 | *Arabidopsis thaliana* to human molecular, morphological or imaging 25 | derived traits. Developing new methods for increasing numbers of sample 26 | cohorts, phenotypic measurements or complexity of phenotypes to analyse, 27 | often requires the simulation of datasets with a specific underlying 28 | phenotype structure. 29 | 30 | **PhenotypeSimulator** allows for the simulation of complex phenotypes 31 | under different models, including genetic variant effects and 32 | infinitesimal genetic effects (reflecting population structure) as well 33 | as correlated, non-genetic covariates and observational noise effects. 34 | Different phenotypic effects can be combined into a final phenotype 35 | while controlling for the proportion of variance explained by each of 36 | the components. For each component, the number of variables, their 37 | distribution and the design of their effect across traits can be 38 | customised. 39 | 40 | ## Installation 41 | 42 | Full documentation of **PhenotypeSimulator** is available at 43 | . 44 | 45 | The current github version of *PhenotypeSimulator* is 0.3.4 and can be 46 | installed via 47 | 48 | ``` r 49 | # install.packages("devtools") 50 | devtools::install_github("meyer-lab-cshl/PhenotypeSimulator") 51 | ``` 52 | 53 | The current CRAN version of *PhenotypeSimulator* is 0.3.4 and can be 54 | installed via: 55 | 56 | ``` r 57 | install.packages("PhenotypeSimulator") 58 | ``` 59 | 60 | A log of version changes can be found 61 | [here](https://github.com/meyer-lab-cshl/PhenotypeSimulator/blob/master/NEWS.md). 62 | 63 | ## Citation 64 | 65 | Meyer, HV & Birney E (2018) [PhenotypeSimulator: A comprehensive 66 | framework for simulating multi-trait, multi-locus genotype to phenotype 67 | relationships](https://doi.org/10.1093/bioinformatics/bty197), 68 | *Bioinformatics*, 34(17):2951–2956 69 | -------------------------------------------------------------------------------- /man/geneticFixedEffects.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/variancecomponentFunctions.R 3 | \name{geneticFixedEffects} 4 | \alias{geneticFixedEffects} 5 | \title{Simulate genetic variant effects.} 6 | \usage{ 7 | geneticFixedEffects( 8 | X_causal, 9 | P, 10 | N, 11 | phenoID = "Trait_", 12 | id_samples = rownames(X_causal), 13 | id_phenos = NULL, 14 | pTraitsAffected = 1, 15 | pIndependentGenetic = 0.4, 16 | pTraitIndependentGenetic = 0.2, 17 | keepSameIndependent = FALSE, 18 | distBeta = "norm", 19 | mBeta = 0, 20 | sdBeta = 1, 21 | verbose = FALSE 22 | ) 23 | } 24 | \arguments{ 25 | \item{X_causal}{[N x NrCausalSNPs] Matrix of [NrCausalSNPs] SNPs from [N] 26 | samples.} 27 | 28 | \item{P}{Number [integer] of phenotypes to simulate.} 29 | 30 | \item{N}{Number [integer] of samples to simulate; has to be provided as a 31 | dimnesionality check for X_causal and downstream analyses; nrow(X_causal) has 32 | to be equal to N.} 33 | 34 | \item{phenoID}{Prefix [string] for naming traits.} 35 | 36 | \item{id_samples}{Vector of [NrSamples] sample IDs [string]; if not provided 37 | colnames(X_causal) used.} 38 | 39 | \item{id_phenos}{Vector of [NrTraits] phenotype IDs [string]; if not provided 40 | constructed by paste(phenoID, 1:P, sep="").} 41 | 42 | \item{pTraitsAffected}{Proportion [double] of traits affected by the genetic 43 | effect. For non-integer results of pTraitsAffected*P, the ceiling of the 44 | result is used. Allows to simulate for instance different levels of 45 | pleiotropy.} 46 | 47 | \item{pIndependentGenetic}{Proportion [double] of genetic effects (SNPs) to 48 | have an independent fixed effect.} 49 | 50 | \item{pTraitIndependentGenetic}{Proportion [double] of traits influenced by 51 | independent fixed genetic effects.} 52 | 53 | \item{keepSameIndependent}{[boolean] If set to TRUE, the independent genetic 54 | effects always influence the same subset of traits.} 55 | 56 | \item{distBeta}{Vector of name(s) [string] of distribution to use to simulate 57 | effect sizes of SNPs; one of "unif" or "norm".} 58 | 59 | \item{mBeta}{Vector of mean/midpoint(s) [double] of normal/uniform 60 | distribution for effect sizes of SNPs.} 61 | 62 | \item{sdBeta}{Vector of standard deviation/distance from midpoint [double] 63 | of normal/uniform distribution for effect sizes of SNPs.} 64 | 65 | \item{verbose}{[boolean] If TRUE, progress info is printed to standard out} 66 | } 67 | \value{ 68 | Named list of shared fixed genetic effects (shared: [N x P] matrix), 69 | independent fixed genetic effects (independent: [N x P] matrix), 70 | the causal SNPs labeled as shared or independent effect 71 | (cov: [NrCausalSNPs x N] matrix) and the simulated effect sizes of the causal 72 | SNPs (cov_effect: [P x NrCausalSNPs] dataframe). 73 | } 74 | \description{ 75 | geneticFixedEffects takes genetic variants which should be added as genetic 76 | variant effects to the phenotype. These variants can have the same effects 77 | across all traits (shared) or can be independent across traits (independent); 78 | in addition, only a certain proportion of traits can be affected by the 79 | genetic variants. 80 | } 81 | \examples{ 82 | genotypes <- simulateGenotypes(N=100, NrSNP=20, verbose=FALSE) 83 | causalSNPs <- getCausalSNPs(N=100, genotypes=genotypes$genotypes) 84 | geneticFixed <- geneticFixedEffects(N=100, X_causal=causalSNPs, 85 | P=10) 86 | } 87 | -------------------------------------------------------------------------------- /INDEX.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/PhenotypeSimulator)](https://cran.r-project.org/package=PhenotypeSimulator) 5 | [![Build 6 | Status](https://travis-ci.org/HannahVMeyer/PhenotypeSimulator.svg?branch=master)](https://travis-ci.org/HannahVMeyer/PhenotypeSimulator) 7 | [![License: 8 | MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 9 | [![Downloads](http://cranlogs.r-pkg.org/badges/grand-total/PhenotypeSimulator?color=blue)](http://cran.rstudio.com/web/packages/PhenotypeSimulator/index.html) 10 | 11 | ## PhenotypeSimulator 12 | 13 | **PhenotypeSimulator** allows for the flexible simulation of phenotypes 14 | from different genetic and non-genetic (noise) components. 15 | 16 | In quantitative genetics, genotype to phenotype mapping is commonly 17 | realised by fitting a linear model to the genotype as the explanatory 18 | variable and the phenotype as the response variable. Other explanatory 19 | variable such as additional sample measures (e.g. age, height, weight) 20 | or batch effects can also be included. For linear mixed models, in 21 | addition to the fixed effects of the genotype and the covariates, 22 | different random effect components can be included, accounting for 23 | population structure in the study cohort or environmental effects. The 24 | application of linear and linear mixed models in quantitative genetics 25 | ranges from genetic studies in model organism such as yeast and 26 | *Arabidopsis thaliana* to human molecular, morphological or imaging 27 | derived traits. Developing new methods for increasing numbers of sample 28 | cohorts, phenotypic measurements or complexity of phenotypes to analyse, 29 | often requires the simulation of datasets with a specific underlying 30 | phenotype structure. 31 | 32 | **PhenotypeSimulator** allows for the simulation of complex phenotypes 33 | under different models, including genetic variant effects and 34 | infinitesimal genetic effects (reflecting population structure) as well 35 | as correlated, non-genetic covariates and observational noise effects. 36 | Different phenotypic effects can be combined into a final phenotype 37 | while controlling for the proportion of variance explained by each of 38 | the components. For each component, the number of variables, their 39 | distribution and the design of their effect across traits can be 40 | customised. 41 | 42 | 43 | 44 | ## Installation 45 | 46 | The current github version of *PhenotypeSimulator* is 0.3.4 and can be 47 | installed via: 48 | 49 | ``` r 50 | library(devtools) 51 | install_github("HannahVMeyer/PhenotypeSimulator") 52 | ``` 53 | 54 | The current CRAN version of *PhenotypeSimulator* is 0.3.4 and can be 55 | installed via: 56 | 57 | ``` r 58 | install.packages("PhenotypeSimulator") 59 | ``` 60 | 61 | A log of version changes can be found 62 | [here](https://github.com/HannahVMeyer/PhenotypeSimulator/blob/master/NEWS.md). 63 | 64 | ## Citation 65 | 66 | Meyer, HV & Birney E (2018) [PhenotypeSimulator: A comprehensive 67 | framework for simulating multi-trait, multi-locus genotype to phenotype 68 | relationships](https://doi.org/10.1093/bioinformatics/bty197), 69 | *Bioinformatics*, 34(17):2951–2956 70 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | 6 | 7 | ```{r, echo = FALSE} 8 | knitr::opts_chunk$set( 9 | collapse = TRUE, 10 | comment = "#>", 11 | fig.path = "README-" 12 | ) 13 | ``` 14 | 15 | [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/PhenotypeSimulator)](https://cran.r-project.org/package=PhenotypeSimulator) 16 | [![Build Status](https://travis-ci.org/HannahVMeyer/PhenotypeSimulator.svg?branch=master)](https://travis-ci.org/HannahVMeyer/PhenotypeSimulator) 17 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 18 | [![Downloads](http://cranlogs.r-pkg.org/badges/grand-total/PhenotypeSimulator?color=blue)](https://CRAN.R-project.org/package=PhenotypeSimulator) 19 | 20 | 21 | ## PhenotypeSimulator 22 | 23 | **PhenotypeSimulator** allows for the flexible simulation of phenotypes from 24 | different genetic and non-genetic (noise) components. 25 | 26 | In quantitative genetics, genotype to phenotype mapping is commonly realised by 27 | fitting a linear model to the genotype as the explanatory variable and the 28 | phenotype as the response variable. Other explanatory variable such as 29 | additional sample measures (e.g. age, height, weight) or batch effects can also 30 | be included. For linear mixed models, in addition to the fixed effects of the 31 | genotype and the covariates, different random effect components can be included, 32 | accounting for population structure in the study cohort or environmental 33 | effects. The application of linear and linear mixed models in quantitative 34 | genetics ranges from genetic studies in model organism such as yeast and 35 | *Arabidopsis thaliana* to human molecular, morphological or imaging derived 36 | traits. Developing new methods for increasing numbers of sample cohorts, 37 | phenotypic measurements or complexity of phenotypes to analyse, often requires 38 | the simulation of datasets with a specific underlying phenotype structure. 39 | 40 | **PhenotypeSimulator** allows for the simulation of complex phenotypes under 41 | different models, including genetic variant effects and infinitesimal genetic 42 | effects (reflecting population structure) as well as correlated, non-genetic 43 | covariates and observational noise effects. Different phenotypic effects can be 44 | combined into a final phenotype while controlling for the proportion of variance 45 | explained by each of the components. For each component, the number of 46 | variables, their distribution and the design of their effect across traits can 47 | be customised. 48 | 49 | ## Installation 50 | 51 | Full documentation of **PhenotypeSimulator** is available at 52 | https://HannahVMeyer.github.io/PhenotypeSimulator/. 53 | 54 | The current github version of *PhenotypeSimulator* is 0.3.4 and can be 55 | installed via 56 | 57 | ```{r gh-installation, eval = FALSE} 58 | # install.packages("devtools") 59 | devtools::install_github("HannahVMeyer/PhenotypeSimulator") 60 | ``` 61 | 62 | The current CRAN version of *PhenotypeSimulator* is 0.3.4 and can be installed 63 | via: 64 | ```{r, eval=FALSE} 65 | install.packages("PhenotypeSimulator") 66 | ``` 67 | 68 | A log of version changes can be found [here](https://github.com/HannahVMeyer/PhenotypeSimulator/blob/master/NEWS.md). 69 | 70 | ## Citation 71 | Meyer, HV & Birney E (2018) [PhenotypeSimulator: A comprehensive framework for simulating multi-trait, multi-locus genotype to phenotype relationships](https://doi.org/10.1093/bioinformatics/bty197), *Bioinformatics*, 34(17):2951–2956 72 | -------------------------------------------------------------------------------- /INDEX.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | 6 | 7 | ```{r, echo = FALSE} 8 | knitr::opts_chunk$set( 9 | collapse = TRUE, 10 | comment = "#>", 11 | fig.path = "README-" 12 | ) 13 | ``` 14 | [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/PhenotypeSimulator)](https://cran.r-project.org/package=PhenotypeSimulator) 15 | [![Build Status](https://travis-ci.org/HannahVMeyer/PhenotypeSimulator.svg?branch=master)](https://travis-ci.org/HannahVMeyer/PhenotypeSimulator) 16 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 17 | [![Downloads](http://cranlogs.r-pkg.org/badges/grand-total/PhenotypeSimulator?color=blue)](http://cran.rstudio.com/web/packages/PhenotypeSimulator/index.html) 18 | 19 | 20 | ## PhenotypeSimulator 21 | 22 | **PhenotypeSimulator** allows for the flexible simulation of phenotypes from 23 | different genetic and non-genetic (noise) components. 24 | 25 | In quantitative genetics, genotype to phenotype mapping is commonly realised by 26 | fitting a linear model to the genotype as the explanatory variable and the 27 | phenotype as the response variable. Other explanatory variable such as 28 | additional sample measures (e.g. age, height, weight) or batch effects can also 29 | be included. For linear mixed models, in addition to the fixed effects of the 30 | genotype and the covariates, different random effect components can be included, 31 | accounting for population structure in the study cohort or environmental 32 | effects. The application of linear and linear mixed models in quantitative 33 | genetics ranges from genetic studies in model organism such as yeast and 34 | *Arabidopsis thaliana* to human molecular, morphological or imaging derived 35 | traits. Developing new methods for increasing numbers of sample cohorts, 36 | phenotypic measurements or complexity of phenotypes to analyse, often requires 37 | the simulation of datasets with a specific underlying phenotype structure. 38 | 39 | **PhenotypeSimulator** allows for the simulation of complex phenotypes under 40 | different models, including genetic variant effects and infinitesimal genetic 41 | effects (reflecting population structure) as well as correlated, non-genetic 42 | covariates and observational noise effects. Different phenotypic effects can be 43 | combined into a final phenotype while controlling for the proportion of variance 44 | explained by each of the components. For each component, the number of 45 | variables, their distribution and the design of their effect across traits can 46 | be customised. 47 | 48 | 49 | ```{r, echo = FALSE, out.width='100%'} 50 | knitr::include_graphics("docs/simulatedPhenotypes.png") 51 | ``` 52 | 53 | 54 | ## Installation 55 | 56 | The current github version of *PhenotypeSimulator* is 0.3.4 and can be 57 | installed via: 58 | ```{r, eval=FALSE} 59 | library(devtools) 60 | install_github("HannahVMeyer/PhenotypeSimulator") 61 | ``` 62 | The current CRAN version of *PhenotypeSimulator* is 0.3.4 and can be installed 63 | via: 64 | ```{r, eval=FALSE} 65 | install.packages("PhenotypeSimulator") 66 | ``` 67 | 68 | A log of version changes can be found [here](https://github.com/HannahVMeyer/PhenotypeSimulator/blob/master/NEWS.md). 69 | 70 | ## Citation 71 | 72 | Meyer, HV & Birney E (2018) [PhenotypeSimulator: A comprehensive framework for simulating multi-trait, multi-locus genotype to phenotype relationships](https://doi.org/10.1093/bioinformatics/bty197), *Bioinformatics*, 34(17):2951–2956 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /docs/pkgdown.js: -------------------------------------------------------------------------------- 1 | /* http://gregfranko.com/blog/jquery-best-practices/ */ 2 | (function($) { 3 | $(function() { 4 | 5 | $('.navbar-fixed-top').headroom(); 6 | 7 | $('body').css('padding-top', $('.navbar').height() + 10); 8 | $(window).resize(function(){ 9 | $('body').css('padding-top', $('.navbar').height() + 10); 10 | }); 11 | 12 | $('[data-toggle="tooltip"]').tooltip(); 13 | 14 | var cur_path = paths(location.pathname); 15 | var links = $("#navbar ul li a"); 16 | var max_length = -1; 17 | var pos = -1; 18 | for (var i = 0; i < links.length; i++) { 19 | if (links[i].getAttribute("href") === "#") 20 | continue; 21 | // Ignore external links 22 | if (links[i].host !== location.host) 23 | continue; 24 | 25 | var nav_path = paths(links[i].pathname); 26 | 27 | var length = prefix_length(nav_path, cur_path); 28 | if (length > max_length) { 29 | max_length = length; 30 | pos = i; 31 | } 32 | } 33 | 34 | // Add class to parent
  • , and enclosing
  • if in dropdown 35 | if (pos >= 0) { 36 | var menu_anchor = $(links[pos]); 37 | menu_anchor.parent().addClass("active"); 38 | menu_anchor.closest("li.dropdown").addClass("active"); 39 | } 40 | }); 41 | 42 | function paths(pathname) { 43 | var pieces = pathname.split("/"); 44 | pieces.shift(); // always starts with / 45 | 46 | var end = pieces[pieces.length - 1]; 47 | if (end === "index.html" || end === "") 48 | pieces.pop(); 49 | return(pieces); 50 | } 51 | 52 | // Returns -1 if not found 53 | function prefix_length(needle, haystack) { 54 | if (needle.length > haystack.length) 55 | return(-1); 56 | 57 | // Special case for length-0 haystack, since for loop won't run 58 | if (haystack.length === 0) { 59 | return(needle.length === 0 ? 0 : -1); 60 | } 61 | 62 | for (var i = 0; i < haystack.length; i++) { 63 | if (needle[i] != haystack[i]) 64 | return(i); 65 | } 66 | 67 | return(haystack.length); 68 | } 69 | 70 | /* Clipboard --------------------------*/ 71 | 72 | function changeTooltipMessage(element, msg) { 73 | var tooltipOriginalTitle=element.getAttribute('data-original-title'); 74 | element.setAttribute('data-original-title', msg); 75 | $(element).tooltip('show'); 76 | element.setAttribute('data-original-title', tooltipOriginalTitle); 77 | } 78 | 79 | if(ClipboardJS.isSupported()) { 80 | $(document).ready(function() { 81 | var copyButton = ""; 82 | 83 | $(".examples, div.sourceCode").addClass("hasCopyButton"); 84 | 85 | // Insert copy buttons: 86 | $(copyButton).prependTo(".hasCopyButton"); 87 | 88 | // Initialize tooltips: 89 | $('.btn-copy-ex').tooltip({container: 'body'}); 90 | 91 | // Initialize clipboard: 92 | var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { 93 | text: function(trigger) { 94 | return trigger.parentNode.textContent; 95 | } 96 | }); 97 | 98 | clipboardBtnCopies.on('success', function(e) { 99 | changeTooltipMessage(e.trigger, 'Copied!'); 100 | e.clearSelection(); 101 | }); 102 | 103 | clipboardBtnCopies.on('error', function() { 104 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 105 | }); 106 | }); 107 | } 108 | })(window.jQuery || window.$) 109 | -------------------------------------------------------------------------------- /man/setModel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/createphenotypeFunctions.R 3 | \name{setModel} 4 | \alias{setModel} 5 | \title{Set simulation model.} 6 | \usage{ 7 | setModel( 8 | genVar = NULL, 9 | h2s = NULL, 10 | theta = 0.8, 11 | h2bg = NULL, 12 | eta = 0.8, 13 | noiseVar = NULL, 14 | delta = NULL, 15 | gamma = 0.8, 16 | rho = NULL, 17 | phi = NULL, 18 | alpha = 0.8, 19 | pcorr = 0.6, 20 | pIndependentConfounders = 0.4, 21 | pTraitIndependentConfounders = 0.2, 22 | pIndependentGenetic = 0.4, 23 | pTraitIndependentGenetic = 0.2, 24 | proportionNonlinear = 0, 25 | cNrSNP = NULL, 26 | NrConfounders = 10, 27 | verbose = TRUE 28 | ) 29 | } 30 | \arguments{ 31 | \item{genVar}{Total genetic variance [double].} 32 | 33 | \item{h2s}{Proportion [double] of variance of genetic variant effects.} 34 | 35 | \item{theta}{Proportion [double] of variance of shared genetic variant 36 | effects.} 37 | 38 | \item{h2bg}{Proportion [double] of variance of infinitesimal genetic effects 39 | i.e. correlation introduced by sample kinship).} 40 | 41 | \item{eta}{Proportion [double] of variance of shared infinitesimal genetic 42 | effects.} 43 | 44 | \item{noiseVar}{Total noise variance [double].} 45 | 46 | \item{delta}{Proportion [double] of variance of non-genetic covariate effect.} 47 | 48 | \item{gamma}{Proportion [double] of variance of shared non-genetic covariate 49 | effects.} 50 | 51 | \item{rho}{Proportion [double] of variance of correlated noise effects.} 52 | 53 | \item{phi}{Proportion [double] of variance of observational noise effects.} 54 | 55 | \item{alpha}{Proportion [double] of variance of shared observational noise 56 | effect.} 57 | 58 | \item{pcorr}{Correlation [double] between phenotypes.} 59 | 60 | \item{pIndependentConfounders}{Proportion [double] of non-genetic covariate 61 | to have a trait-independent effect.} 62 | 63 | \item{pTraitIndependentConfounders}{Proportion [double] of traits influenced 64 | by independent non-genetic covariate effects.} 65 | 66 | \item{pIndependentGenetic}{Proportion [double] of genetic variant effects to 67 | have a trait-independent fixed effect.} 68 | 69 | \item{pTraitIndependentGenetic}{Proportion [double] of traits influenced by 70 | independent genetic variant effects.} 71 | 72 | \item{proportionNonlinear}{[double] proportion of the phenotype to be non- 73 | linear} 74 | 75 | \item{cNrSNP}{Number [integer] of causal SNPs; used as genetic variant 76 | effects.} 77 | 78 | \item{NrConfounders}{Number [integer] of non-genetic covariates; used as 79 | non-genetic covariate effects.} 80 | 81 | \item{verbose}{[boolean]; If TRUE, progress info is printed to standard out.} 82 | } 83 | \value{ 84 | Named list containing the genetic model (modelGenetic), the noise 85 | model (modelNoise) and the input parameters (h2s, h2bg, noiseVar, rho, delta, 86 | phi, gamma, theta, eta, alpha, pcorr, proportionNonlinear). Model options 87 | are: modelNoise: "noNoise", "noiseFixedOnly", "noiseBgOnly", 88 | "noiseCorrelatedOnly", "noiseFixedAndBg","noiseCorrelatedAndBg", 89 | "noiseFixedAndCorrelated", "noiseFixedAndBgAndCorrelated" 90 | modelGenetic: "noGenetic","geneticBgOnly", "geneticFixedOnly", 91 | "geneticFixedAndBg" 92 | } 93 | \description{ 94 | Based on parameters provided, this function sets the name for the phenotype 95 | simulation. It carries out compatibiltiy checks of the specifie parameters 96 | and checks for any missing information. 97 | } 98 | \examples{ 99 | #genetic fixed effects only 100 | model <- setModel(genVar=1, h2s=1) 101 | 102 | #genetic fixed and bg effects 103 | model <- setModel(genVar=1, h2s=0.01) 104 | 105 | #genetic and noise fixed effects only 106 | model <- setModel(genVar=0.4, h2s=1, delta=1) 107 | } 108 | -------------------------------------------------------------------------------- /vignettes/Vignette-example-data.bib: -------------------------------------------------------------------------------- 1 | @article{Biffi2017, 2 | author = {Biffi, Carlo and de Marvao, Antonio and Attard, Mark I. and Dawes, Timothy J.W. and Whiffin, Nicola and Bai, Wenjia and Shi, Wenzhe and Francis, Catherine and Meyer, Hannah and Buchan, Rachel and Cook, Stuart A. and Rueckert, Daniel and O'Regan, Declan P.}, 3 | doi = {10.1093/bioinformatics/btx552}, 4 | file = {:Users/hannah/Documents/Mendeley Desktop/2017{\_}Bioinformatics{\_}Biffi et al.pdf:pdf}, 5 | issn = {1367-4803}, 6 | journal = {Bioinformatics}, 7 | month = {sep}, 8 | title = {{Three-dimensional Cardiovascular Imaging-Genetics: A Mass Univariate Framework}}, 9 | url = {http://academic.oup.com/bioinformatics/article/doi/10.1093/bioinformatics/btx552/4103396/Threedimensional-Cardiovascular-ImagingGenetics-A}, 10 | year = {2017} 11 | } 12 | @article{deMarvao2014, 13 | abstract = {BACKGROUND: Cardiac phenotypes, such as left ventricular (LV) mass, demonstrate high heritability although most genes associated with these complex traits remain unidentified. Genome-wide association studies (GWAS) have relied on conventional 2D cardiovascular magnetic resonance (CMR) as the gold-standard for phenotyping. However this technique is insensitive to the regional variations in wall thickness which are often associated with left ventricular hypertrophy and require large cohorts to reach significance. Here we test whether automated cardiac phenotyping using high spatial resolution CMR atlases can achieve improved precision for mapping wall thickness in healthy populations and whether smaller sample sizes are required compared to conventional methods. METHODS: LV short-axis cine images were acquired in 138 healthy volunteers using standard 2D imaging and 3D high spatial resolution CMR. A multi-atlas technique was used to segment and co-register each image. The agreement between methods for end-diastolic volume and mass was made using Bland-Altman analysis in 20 subjects. The 3D and 2D segmentations of the LV were compared to manual labeling by the proportion of concordant voxels (Dice coefficient) and the distances separating corresponding points. Parametric and nonparametric data were analysed with paired t-tests and Wilcoxon signed-rank test respectively. Voxelwise power calculations used the interstudy variances of wall thickness. RESULTS: The 3D volumetric measurements showed no bias compared to 2D imaging. The segmented 3D images were more accurate than 2D images for defining the epicardium (Dice: 0.95 vs 0.93, P {\textless} 0.001; mean error 1.3 mm vs 2.2 mm, P {\textless} 0.001) and endocardium (Dice 0.95 vs 0.93, P {\textless} 0.001; mean error 1.1 mm vs 2.0 mm, P {\textless} 0.001). The 3D technique resulted in significant differences in wall thickness assessment at the base, septum and apex of the LV compared to 2D (P {\textless} 0.001). Fewer subjects were required for 3D imaging to detect a 1 mm difference in wall thickness (72 vs 56, P {\textless} 0.001). CONCLUSIONS: High spatial resolution CMR with automated phenotyping provides greater power for mapping wall thickness than conventional 2D imaging and enables a reduction in the sample size required for studies of environmental and genetic determinants of LV wall thickness.}, 14 | author = {de Marvao, Antonio and Dawes, Timothy Jw and Shi, Wenzhe and Minas, Christopher and Keenan, Niall G and Diamond, Tamara and Durighel, Giuliana and Montana, Giovanni and Rueckert, Daniel and Cook, Stuart A and O'Regan, Declan P}, 15 | doi = {10.1186/1532-429X-16-16}, 16 | file = {:Users/hannah/Documents/Mendeley Desktop/2014{\_}Journal of Cardiovascular Magnetic Resonance{\_}de Marvao et al.pdf:pdf}, 17 | issn = {1532-429X}, 18 | journal = {Journal of Cardiovascular Magnetic Resonance}, 19 | month = {jan}, 20 | number = {1}, 21 | pages = {16}, 22 | pmid = {24490638}, 23 | title = {{Population-based studies of myocardial hypertrophy: high resolution cardiovascular magnetic resonance atlases improve statistical power.}}, 24 | url = {http://www.ncbi.nlm.nih.gov/pubmed/24490638}, 25 | volume = {16}, 26 | year = {2014} 27 | } 28 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | (function() { 6 | 'use strict'; 7 | 8 | window.Toc = { 9 | helpers: { 10 | // return all matching elements in the set, or their descendants 11 | findOrFilter: function($el, selector) { 12 | // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ 13 | // http://stackoverflow.com/a/12731439/358804 14 | var $descendants = $el.find(selector); 15 | return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); 16 | }, 17 | 18 | generateUniqueIdBase: function(el) { 19 | var text = $(el).text(); 20 | var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); 21 | return anchor || el.tagName.toLowerCase(); 22 | }, 23 | 24 | generateUniqueId: function(el) { 25 | var anchorBase = this.generateUniqueIdBase(el); 26 | for (var i = 0; ; i++) { 27 | var anchor = anchorBase; 28 | if (i > 0) { 29 | // add suffix 30 | anchor += '-' + i; 31 | } 32 | // check if ID already exists 33 | if (!document.getElementById(anchor)) { 34 | return anchor; 35 | } 36 | } 37 | }, 38 | 39 | generateAnchor: function(el) { 40 | if (el.id) { 41 | return el.id; 42 | } else { 43 | var anchor = this.generateUniqueId(el); 44 | el.id = anchor; 45 | return anchor; 46 | } 47 | }, 48 | 49 | createNavList: function() { 50 | return $(''); 51 | }, 52 | 53 | createChildNavList: function($parent) { 54 | var $childList = this.createNavList(); 55 | $parent.append($childList); 56 | return $childList; 57 | }, 58 | 59 | generateNavEl: function(anchor, text) { 60 | var $a = $(''); 61 | $a.attr('href', '#' + anchor); 62 | $a.text(text); 63 | var $li = $('
  • '); 64 | $li.append($a); 65 | return $li; 66 | }, 67 | 68 | generateNavItem: function(headingEl) { 69 | var anchor = this.generateAnchor(headingEl); 70 | var $heading = $(headingEl); 71 | var text = $heading.data('toc-text') || $heading.text(); 72 | return this.generateNavEl(anchor, text); 73 | }, 74 | 75 | // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). 76 | getTopLevel: function($scope) { 77 | for (var i = 1; i <= 6; i++) { 78 | var $headings = this.findOrFilter($scope, 'h' + i); 79 | if ($headings.length > 1) { 80 | return i; 81 | } 82 | } 83 | 84 | return 1; 85 | }, 86 | 87 | // returns the elements for the top level, and the next below it 88 | getHeadings: function($scope, topLevel) { 89 | var topSelector = 'h' + topLevel; 90 | 91 | var secondaryLevel = topLevel + 1; 92 | var secondarySelector = 'h' + secondaryLevel; 93 | 94 | return this.findOrFilter($scope, topSelector + ',' + secondarySelector); 95 | }, 96 | 97 | getNavLevel: function(el) { 98 | return parseInt(el.tagName.charAt(1), 10); 99 | }, 100 | 101 | populateNav: function($topContext, topLevel, $headings) { 102 | var $context = $topContext; 103 | var $prevNav; 104 | 105 | var helpers = this; 106 | $headings.each(function(i, el) { 107 | var $newNav = helpers.generateNavItem(el); 108 | var navLevel = helpers.getNavLevel(el); 109 | 110 | // determine the proper $context 111 | if (navLevel === topLevel) { 112 | // use top level 113 | $context = $topContext; 114 | } else if ($prevNav && $context === $topContext) { 115 | // create a new level of the tree and switch to it 116 | $context = helpers.createChildNavList($prevNav); 117 | } // else use the current $context 118 | 119 | $context.append($newNav); 120 | 121 | $prevNav = $newNav; 122 | }); 123 | }, 124 | 125 | parseOps: function(arg) { 126 | var opts; 127 | if (arg.jquery) { 128 | opts = { 129 | $nav: arg 130 | }; 131 | } else { 132 | opts = arg; 133 | } 134 | opts.$scope = opts.$scope || $(document.body); 135 | return opts; 136 | } 137 | }, 138 | 139 | // accepts a jQuery object, or an options object 140 | init: function(opts) { 141 | opts = this.helpers.parseOps(opts); 142 | 143 | // ensure that the data attribute is in place for styling 144 | opts.$nav.attr('data-toggle', 'toc'); 145 | 146 | var $topContext = this.helpers.createChildNavList(opts.$nav); 147 | var topLevel = this.helpers.getTopLevel(opts.$scope); 148 | var $headings = this.helpers.getHeadings(opts.$scope, topLevel); 149 | this.helpers.populateNav($topContext, topLevel, $headings); 150 | } 151 | }; 152 | 153 | $(function() { 154 | $('nav[data-toggle="toc"]').each(function(i, el) { 155 | var $nav = $(el); 156 | Toc.init($nav); 157 | }); 158 | }); 159 | })(); 160 | -------------------------------------------------------------------------------- /vignettes/SimulationAndLinearModel.bib: -------------------------------------------------------------------------------- 1 | @article{Zhou2014, 2 | abstract = {Multivariate linear mixed models (mvLMMs) are powerful tools for testing associations between single-nucleotide polymorphisms and multiple correlated phenotypes while controlling for population stratification in genome-wide association studies. We present efficient algorithms in the genome-wide efficient mixed model association (GEMMA) software for fitting mvLMMs and computing likelihood ratio tests. These algorithms offer improved computation speed, power and P-value calibration over existing methods, and can deal with more than two phenotypes.}, 3 | author = {Zhou, Xiang and Stephens, Matthew}, 4 | doi = {10.1038/nmeth.2848}, 5 | file = {:Users/hannah/Documents/Mendeley Desktop/2014{\_}Nature Methods{\_}Zhou, Stephens(3).pdf:pdf;:Users/hannah/Documents/Mendeley Desktop/2014{\_}Nature Methods{\_}Zhou, Stephens(4).pdf:pdf}, 6 | isbn = {1548-7105 (Electronic)$\backslash$r1548-7091 (Linking)}, 7 | issn = {1548-7105}, 8 | journal = {Nature Methods}, 9 | keywords = {Algorithms,Genome,Likelihood Functions,Linear Models,Multivariate Analysis,Polymorphism,Single Nucleotide,Single Nucleotide: genetics,Software}, 10 | number = {4}, 11 | pages = {407--9}, 12 | pmid = {24531419}, 13 | title = {{Efficient multivariate linear mixed model algorithms for genome-wide association studies.}}, 14 | url = {http://www.ncbi.nlm.nih.gov/pubmed/24531419}, 15 | volume = {11}, 16 | year = {2014} 17 | } 18 | @article{Chang2015, 19 | abstract = {PLINK 1 is a widely used open-source C/C++ toolset for genome-wide association studies (GWAS) and research in population genetics. However, the steady accumulation of data from imputation and whole-genome sequencing studies has exposed a strong need for even faster and more scalable implementations of key functions. In addition, GWAS and population-genetic data now frequently contain probabilistic calls, phase information, and/or multiallelic variants, none of which can be represented by PLINK 1's primary data format. To address these issues, we are developing a second-generation codebase for PLINK. The first major release from this codebase, PLINK 1.9, introduces extensive use of bit-level parallelism, O(sqrt(n))-time/constant-space Hardy-Weinberg equilibrium and Fisher's exact tests, and many other algorithmic improvements. In combination, these changes accelerate most operations by 1-4 orders of magnitude, and allow the program to handle datasets too large to fit in RAM. This will be followed by PLINK 2.0, which will introduce (a) a new data format capable of efficiently representing probabilities, phase, and multiallelic variants, and (b) extensions of many functions to account for the new types of information. The second-generation versions of PLINK will offer dramatic improvements in performance and compatibility. For the first time, users without access to high-end computing resources can perform several essential analyses of the feature-rich and very large genetic datasets coming into use.}, 20 | author = {Chang, Christopher C and Chow, Carson C and Tellier, Laurent CAM and Vattikuti, Shashaank and Purcell, Shaun M and Lee, James J}, 21 | doi = {10.1186/s13742-015-0047-8}, 22 | issn = {2047-217X}, 23 | journal = {GigaScience}, 24 | month = {feb}, 25 | number = {1}, 26 | pages = {7}, 27 | title = {{Second-generation PLINK: rising to the challenge of larger and richer datasets}}, 28 | url = {http://arxiv.org/abs/1410.4803}, 29 | volume = {4}, 30 | year = {2015} 31 | } 32 | @article{Halsey2015, 33 | author = {Halsey, Lewis G and Curran-Everett, Douglas and Vowler, Sarah L and Drummond, Gordon B}, 34 | doi = {10.1038/nmeth.3288}, 35 | issn = {1548-7091}, 36 | journal = {Nature Methods}, 37 | month = {feb}, 38 | number = {3}, 39 | pages = {179--185}, 40 | pmid = {25719825}, 41 | title = {{The fickle P value generates irreproducible results}}, 42 | url = {http://www.ncbi.nlm.nih.gov/pubmed/25719825 http://www.nature.com/doifinder/10.1038/nmeth.3288}, 43 | volume = {12}, 44 | year = {2015} 45 | } 46 | @article{Cohen1992, 47 | abstract = {One possible reason for the continued neglect of statistical power analysis in research in the behavioral sciences is the inaccessibility of or difficulty with the standard material. A convenient, although not comprehensive, presentation of required sample sizes is provided here. Effect-size indexes and conventional values for these are given for operationally defined small, medium, and large effects. The sample sizes necessary for .80 power to detect effects at these levels are tabled for eight standard statistical tests: (a) the difference between independent means, (b) the significance of a product-moment correlation, (c) the difference between independent rs, (d) the sign test, (e) the difference between independent proportions, (f) chi-square tests for goodness of fit and contingency tables, (g) one-way analysis of variance, and (h) the significance of a multiple or multiple partial correlation.}, 48 | author = {Cohen, J}, 49 | issn = {0033-2909}, 50 | journal = {Psychological Bulletin}, 51 | month = {jul}, 52 | number = {1}, 53 | pages = {155--9}, 54 | pmid = {19565683}, 55 | title = {{A power primer.}}, 56 | url = {http://www.ncbi.nlm.nih.gov/pubmed/19565683}, 57 | volume = {112}, 58 | year = {1992} 59 | } 60 | @article{Su2011, 61 | author = {Su, Zhan and Marchini, Jonathan and Donnelly, Peter}, 62 | doi = {10.1093/bioinformatics/btr341}, 63 | file = {:Users/hannah/Documents/Mendeley Desktop/2011{\_}Bioinformatics{\_}Su, Marchini, Donnelly.pdf:pdf}, 64 | issn = {1460-2059}, 65 | journal = {Bioinformatics}, 66 | month = {aug}, 67 | number = {16}, 68 | pages = {2304--2305}, 69 | publisher = {Oxford University Press}, 70 | title = {{HAPGEN2: simulation of multiple disease SNPs}}, 71 | url = {https://academic.oup.com/bioinformatics/article-lookup/doi/10.1093/bioinformatics/btr341}, 72 | volume = {27}, 73 | year = {2011} 74 | } 75 | -------------------------------------------------------------------------------- /tests/testthat/test-utility.r: -------------------------------------------------------------------------------- 1 | context('Test utility functions') 2 | 3 | test_that("vmessage fails when non-character specified as separator", { 4 | expect_error(vmessage(c("hello", "world"), sep=9)) 5 | }) 6 | 7 | test_that("vmessage returns correct messsage", { 8 | expect_that(vmessage(c("Hello", "World"), sep="Little"), 9 | shows_message("HelloLittleWorld")) 10 | }) 11 | 12 | test_that('vmessage returns NULL when verbose set to FALSE', { 13 | expect_equal(vmessage("Hello world", verbose=FALSE), NULL) 14 | }) 15 | 16 | test_that('commaList2vector returns vector from comma-separated inputlist', { 17 | expect_equal(commaList2vector("1,2,3"), c(1,2,3)) 18 | }) 19 | 20 | test_that('commaList2vector returns NULL', { 21 | expect_equal(commaList2vector(), NULL) 22 | }) 23 | 24 | test_that('commaList2vector fails with unknown type', { 25 | expect_error(commaList2vector(type='matrix', commastring="1,2,2,3,4"), 26 | "Unknown type of comma-separated list elements") 27 | }) 28 | test_that('addNonNulls fails when dimensions of list elements are not the same', 29 | { 30 | expect_error(addNonNulls(list(matrix(1:10, ncol=2), matrix(11:20, ncol=2), 31 | matrix(21:30, ncol=5), NULL, NULL)), 32 | "Column dimensions of list elements are different") 33 | expect_error(addNonNulls(list(matrix(1:10, ncol=2), matrix(11:20, ncol=2), 34 | matrix(21:40, ncol=2), NULL, NULL)), 35 | "Row dimensions of list elements are different") 36 | }) 37 | 38 | test_that('addNonNulls fails when non-list supplied as input', { 39 | expect_error(addNonNulls(matrix(1:10, ncol=2)), 40 | "addNonNulls expects input of type list") 41 | }) 42 | 43 | test_that('simulateDist fails when distr provided is not one of "unif", "norm", 44 | "bin", "cat_norm" or "cat_unif" ', { 45 | expect_error(simulateDist(x=10, dist="gamma"),"Unknown distribution") 46 | }) 47 | 48 | test_that('simulateDist fails when number of observations is less than 0', { 49 | expect_error(simulateDist(x=-10, dist="bin"), 50 | "The number of observations to simulate") 51 | }) 52 | 53 | test_that('simulateDist fails when standard deviation for normal distribution 54 | less than 0', { 55 | expect_error(simulateDist(x=10, dist="norm", std=-0.3), 56 | "Simulating normal distribution") 57 | }) 58 | 59 | test_that('simulateDist fails when probability for binomial dist is not 60 | provided', { 61 | expect_error(simulateDist(x=10, dist="bin"), 62 | "Simulating binomial distribution") 63 | }) 64 | 65 | test_that('simulateDist fails when probability for binomial dist is less 66 | than zero', { 67 | expect_error(simulateDist(x=10, dist="bin", prob=-0.02), 68 | "Simulating binomial distribution") 69 | }) 70 | 71 | test_that('simulateDist fails with unknown distribution', { 72 | expect_error(simulateDist(x=10, dist="beta"), "Unknown distribution") 73 | }) 74 | 75 | test_that('simulateDist fails with length of distribution argument', { 76 | dist=c("unif", "norm", "bin", "cat_norm", "cat_unif") 77 | expect_error(simulateDist(x=10), 78 | paste("Please specify exactly one distribution to sample from,", 79 | "currently ", length(dist), " provided.", sep="")) 80 | }) 81 | 82 | test_that('simulateDist fails when number of categories for categorical dist 83 | is not provided', { 84 | expect_error(simulateDist(x=10, dist="cat_unif"), 85 | "Simulating categorical distribution") 86 | }) 87 | 88 | test_that('simulateDist fails when number of categories for categorical dist 89 | is less than zero', { 90 | expect_error(simulateDist(x=10, dist="cat_unif", categories=-2), 91 | "Simulating categorical distribution") 92 | }) 93 | 94 | test_that("probGen2expGen fails when input is not a numeric vector", { 95 | expect_error( probGen2expGen(list(c(0.1, 0.9, 0))), 96 | "probGen2expGen takes") 97 | }) 98 | 99 | test_that("probGen2expGen fails when input vector is not a multiple of three", { 100 | expect_error( probGen2expGen(c(0.1, 0.9)), 101 | "Length of genotype probabilty vector") 102 | }) 103 | 104 | test_that("probGen2expGen fails with NA", { 105 | expect_error( probGen2expGen(c(0.1, 0.8, NA)), 106 | "Samples need to be fully genotyped") 107 | }) 108 | 109 | test_that("probGen2expGen fails with incorrect probabilities", { 110 | expect_error( probGen2expGen(c(0.1, 0.8, 0)), 111 | "Genotype probabilities do not sum to 1") 112 | }) 113 | 114 | test_that('expGen2probGen fails when wrong encoding is given', { 115 | expect_error(expGen2probGen(c(0,2,3)), 116 | "Genotypes can only be encoded as 0,1,2") 117 | }) 118 | 119 | test_that('expGen2probGen fails when wrong input format is given', { 120 | expect_error(expGen2probGen(list(c(0,2,1))), 121 | "expGen2probGen takes a vector of ") 122 | }) 123 | 124 | test_that('expGen2probGen returns triple NA', { 125 | expect_equal(expGen2probGen(c(NA)), c(NA,NA,NA)) 126 | }) 127 | 128 | test_that('expGen2probGen returns expected output', { 129 | expect_equal(expGen2probGen(c(2)), c(0,0,1)) 130 | }) 131 | test_that('probGen2expGen and expGen2probGen conversions work',{ 132 | nrSamples <- 10 133 | genotype_prob <- rep(0, 3*nrSamples) 134 | genotype_prob[seq(1, nrSamples*3, 3) + sample(0:2, 10, replace=TRUE)] <- 1 135 | expect_equal(genotype_prob, expGen2probGen(probGen2expGen(genotype_prob))) 136 | }) 137 | 138 | -------------------------------------------------------------------------------- /man/getCausalSNPs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/genotypeFunctions.R 3 | \name{getCausalSNPs} 4 | \alias{getCausalSNPs} 5 | \title{Draw random SNPs from genotypes.} 6 | \usage{ 7 | getCausalSNPs( 8 | N, 9 | NrCausalSNPs = 20, 10 | genotypes = NULL, 11 | chr = NULL, 12 | NrSNPsOnChromosome = NULL, 13 | NrChrCausal = NULL, 14 | genoFilePrefix = NULL, 15 | genoFileSuffix = NULL, 16 | format = "delim", 17 | delimiter = ",", 18 | header = FALSE, 19 | skipFields = NULL, 20 | probabilities = FALSE, 21 | sampleID = "ID_", 22 | verbose = TRUE 23 | ) 24 | } 25 | \arguments{ 26 | \item{N}{Number [integer] of samples to simulate.} 27 | 28 | \item{NrCausalSNPs}{Number [integer] of SNPs to chose at random.} 29 | 30 | \item{genotypes}{[NrSamples x totalNrSNPs] Matrix of genotypes [integer]/ 31 | [double].} 32 | 33 | \item{chr}{Vector of chromosome(s) [integer] to chose NrCausalSNPs from; only 34 | used when external genotype data is provided i.e. !is.null(genoFilePrefix).} 35 | 36 | \item{NrSNPsOnChromosome}{Vector of number(s) of SNPs [integer] per entry in 37 | chr (see above); has to be the same length as chr. If not provided, number of 38 | SNPS in file will be determined from line count (which can be slow for large 39 | files); (optional) header lines will be ignored, so accurate number of SNPs 40 | not lines in file should be specified.} 41 | 42 | \item{NrChrCausal}{Number [integer] of causal chromosomes to sample 43 | NrCausalSNPs from (as opposed to the actual chromosomes to chose from via chr 44 | ); only used when external genotype data is provided i.e. 45 | !is.null(genoFilePrefix).} 46 | 47 | \item{genoFilePrefix}{full path/to/chromosome-wise-genotype-file-ending- 48 | before-"chrChromosomeNumber" (no '~' expansion!) [string].} 49 | 50 | \item{genoFileSuffix}{[string] Following chromosome number including 51 | .fileformat (e.g. ".csv"); File described by genoFilePrefix-genoFileSuffix 52 | has to be a text format i.e. comma/tab/space separated.} 53 | 54 | \item{format}{Name [string] of genotype file format. Options are: 55 | "oxgen", "bimbam" or "delim". See \link{readStandardGenotypes} for details.} 56 | 57 | \item{delimiter}{Field separator [string] of genotypefile or 58 | genoFilePrefix-genoFileSuffix file if format == 'delim'.} 59 | 60 | \item{header}{[logical] Can be set to indicate if 61 | genoFilePrefix-genoFileSuffix file has a header for format == 'delim'. 62 | See details.} 63 | 64 | \item{skipFields}{Number [integer] of fields (columns) to skip in 65 | genoFilePrefix-genoFileSuffix file if format == 'delim'. See details.} 66 | 67 | \item{probabilities}{[boolean]. If set to TRUE, the genotypes in the files 68 | described by genoFilePrefix-genoFileSuffix are provided as triplets of 69 | probabilities (p(AA), p(Aa), p(aa)) and are converted into their expected 70 | genotype frequencies by 0*p(AA) + p(Aa) + 2p(aa) via \link{probGen2expGen}.} 71 | 72 | \item{sampleID}{Prefix [string] for naming samples (will be followed by 73 | sample number from 1 to N when constructing id_samples)} 74 | 75 | \item{verbose}{[boolean] If TRUE, progress info is printed to standard out} 76 | } 77 | \value{ 78 | [N x NrCausalSNPs] Matrix of randomly drawn genotypes [integer]/ 79 | [double] 80 | } 81 | \description{ 82 | Draw random SNPs from genotypes provided or external genotype files. 83 | When drawing from external genotype files, only lines of randomly 84 | chosen SNPs are read, which is recommended for large genotype files. See 85 | details for more information. The latter option currently supports file in 86 | simple delim-formats (with specified delimiter and optional number of fields 87 | to skip) and the bimbam and the oxgen format. 88 | } 89 | \details{ 90 | In order to chose SNPs from external genotype files without reading 91 | them into memory, genotypes for each chromosome need to be accesible as 92 | [SNPs x samples] in a separate file, containing "chrChromosomenumber" (e.g 93 | chr22) in the file name (e.g. /path/to/dir/related_nopopstructure_chr22.csv). 94 | All genotype files need to be saved in the same directory. genoFilePrefix 95 | (/path/to/dir/related_nopopstructure_) and genoFileSuffix (.csv) specify the 96 | strings leading and following the "chrChromosomenumber". If format== delim, 97 | the first column in each file needs to be the SNP_ID, the first row can 98 | either contain sample IDs or the first row of genotypes (specified with 99 | header). Subsequent columns containing additional SNP information can be 100 | skipped by setting skipFields. If format==oxgen or bimbam, files need to be 101 | in the oxgen or bimbam format (see \link{readStandardGenotypes} for details) 102 | and no additional information about delim, header or skipFields will be 103 | considered. 104 | getCausalSNPs generates a vector of chromosomes from which to sample the 105 | SNPs. For each of the chromosomes, it counts the number of SNPs in the 106 | chromosome file and creates vectors of random numbers ranging 107 | from 1:NrSNPSinFile. Only the lines corresponding to these numbers are then 108 | read into R. The example data provided for chromosome 22 contains genotypes 109 | (50 samples) of the first 500 SNPs on chromosome 22 with a minor allele 110 | frequency of greater than 2% from the European populations of the the 1000 111 | Genomes project. 112 | } 113 | \examples{ 114 | # get causal SNPs from genotypes simulated within PhenotypeSimulator 115 | geno <- simulateGenotypes(N=10, NrSNP=10) 116 | causalSNPsFromSimulatedGenoStandardised <- getCausalSNPs(N=10, 117 | NrCausalSNPs=10, genotypes=geno$genotypes) 118 | 119 | # Get causal SNPs by sampling lines from large SNP files 120 | genotypeFile <- system.file("extdata/genotypes/", 121 | "genotypes_chr22.csv", 122 | package = "PhenotypeSimulator") 123 | genoFilePrefix <- gsub("chr.*", "", genotypeFile) 124 | genoFileSuffix <- ".csv" 125 | causalSNPsFromLines <- getCausalSNPs(N=50, NrCausalSNPs=10, chr=22, 126 | genoFilePrefix=genoFilePrefix, 127 | genoFileSuffix=genoFileSuffix) 128 | } 129 | \seealso{ 130 | \code{\link{standardiseGenotypes}} 131 | } 132 | -------------------------------------------------------------------------------- /man/noiseFixedEffects.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/variancecomponentFunctions.R 3 | \name{noiseFixedEffects} 4 | \alias{noiseFixedEffects} 5 | \title{Simulate noise fixed effects.} 6 | \usage{ 7 | noiseFixedEffects( 8 | N, 9 | P, 10 | NrConfounders = 10, 11 | sampleID = "ID_", 12 | phenoID = "Trait_", 13 | id_samples = NULL, 14 | id_phenos = NULL, 15 | pTraitsAffected = 1, 16 | NrFixedEffects = 1, 17 | pIndependentConfounders = 0.4, 18 | pTraitIndependentConfounders = 0.2, 19 | keepSameIndependent = FALSE, 20 | distConfounders = "norm", 21 | mConfounders = 0, 22 | sdConfounders = 1, 23 | catConfounders = NULL, 24 | probConfounders = NULL, 25 | distBeta = "norm", 26 | mBeta = 0, 27 | sdBeta = 1, 28 | verbose = FALSE 29 | ) 30 | } 31 | \arguments{ 32 | \item{N}{Number [integer] of samples to simulate.} 33 | 34 | \item{P}{Number [integer] of phenotypes to simulate.} 35 | 36 | \item{NrConfounders}{Vector of number(s) [integer] of confounders from a 37 | specified distribution to simulate.} 38 | 39 | \item{sampleID}{Prefix [string] for naming samples.} 40 | 41 | \item{phenoID}{Prefix [string] for naming traits.} 42 | 43 | \item{id_samples}{Vector of [NrSamples] sample IDs [string]; if not provided 44 | constructed by paste(sampleID, 1:N, sep="").} 45 | 46 | \item{id_phenos}{Vector of [NrTraits] phenotype IDs [string]; if not provided 47 | constructed by paste(phenoID, 1:P, sep="").} 48 | 49 | \item{pTraitsAffected}{Vector of proportion(s) [double] of traits affected by 50 | the confounders. For non-integer results of pTraitsAffected*P, the ceiling of 51 | the result is used.} 52 | 53 | \item{NrFixedEffects}{Number [integer] of different confounder effects to 54 | simulate; allows to simulate fixed effects from different distributions or 55 | with different parameters; if only one type of confounder distribution is 56 | wanted, set NrFixedEffects=1 and choose the number of confounders with eg 57 | NrConfounders=10.} 58 | 59 | \item{pIndependentConfounders}{Vector of proportion(s) [double] of 60 | confounders to have a trait-independent effect.} 61 | 62 | \item{pTraitIndependentConfounders}{Vector of proportion(s) [double] of 63 | traits influenced by independent confounder effects.} 64 | 65 | \item{keepSameIndependent}{[boolean] If set to TRUE, the independent genetic 66 | effects always influence the same subset of traits.} 67 | 68 | \item{distConfounders}{Vector of name(s) [string] of distribution to use to 69 | simulate confounders; one of "unif", "norm", "bin", "cat_norm", "cat_unif".} 70 | 71 | \item{mConfounders}{Vector of mean/midpoint(s) [double] of normal/uniform 72 | distribution for confounders.} 73 | 74 | \item{sdConfounders}{Vector of standard deviation(s)/distance from 75 | midpoint(s) [double] of normal/uniform distribution for confounders.} 76 | 77 | \item{catConfounders}{Vector of number(s) of confounder categories [integer]; 78 | required if distConfounders "cat_norm" or "cat_unif".} 79 | 80 | \item{probConfounders}{Vector of probability(s) [double] of binomial 81 | confounders (0/1); required if distConfounders "bin".} 82 | 83 | \item{distBeta}{Vector of name(s) [string] of distribution to use to simulate 84 | effect sizes of confounders; one of "unif" or "norm".} 85 | 86 | \item{mBeta}{Vector of mean/midpoint [double] of normal/uniform distribution 87 | for effect sizes of confounders.} 88 | 89 | \item{sdBeta}{Vector of standard deviation/distance from midpoint [double] 90 | of normal/uniform distribution for effect sizes of confounders.} 91 | 92 | \item{verbose}{[boolean] If TRUE, progress info is printed to standard out} 93 | } 94 | \value{ 95 | Named list of shared confounder effects (shared: [N x P] matrix), 96 | independent confoudner effects (independent: [N x P] matrix), 97 | the confounders labeled as shared or independent effect 98 | (cov: [NrConfounders x N] matrix) and the simulated effect sizes of the 99 | confounders (cov_effect: [P x NrConfounders] dataframe). 100 | } 101 | \description{ 102 | noiseFixedEffects simulates a number of non-genetic covariate effects 103 | (confounders). Confounders can have effects across all traits (shared) 104 | or to a number of traits only (independent); in addition, only a certain 105 | proportion of traits can be affected by the confounders. 106 | Confounders can be simulated as categorical variables or following a binomial 107 | , uniform or normal distribution. Effect sizes for the noise effects can be 108 | simulated from a uniform or normal distribution. Multiple confounder sets 109 | drawn from different distributions/different parameters of the same 110 | distribution can be simulated by specifying NrFixedEffects and supplying the 111 | respective distribution parameters. 112 | } 113 | \examples{ 114 | # fixed noise effect with default setting 115 | noiseFE <- noiseFixedEffects(P=5, N=20) 116 | 117 | # 1 categorical fixed noise effect with uniform distribution of the 118 | # categories 119 | noiseFE_catUnif <- noiseFixedEffects(P=10, N=20, NrConfounders=1, 120 | distConfounders="cat_unif", catConfounders=3) 121 | 122 | # 10 fixed noise effect with uniform distribution between 1 and 5 (3 +/- 2) 123 | # categories 124 | noiseFE_uniformConfounders_normBetas <- noiseFixedEffects(P=10, N=20, 125 | NrConfounders=10, distConfounders="unif", mConfounders=3, sdConfounders=2, 126 | distBeta="norm", sdBeta=2) 127 | 128 | # 4 fixed noise effect with binomial distribution with p=0.2 129 | noiseFE_binomialConfounders_uniformBetas <- noiseFixedEffects(P=10, N=20, 130 | NrConfounders=4, distConfounders="bin", probConfounders=0.2, distBeta="norm", 131 | sdBeta=2) 132 | 133 | # 2 fixed noise effect with 1 binomial confounders and 1 normally 134 | # distributed confounder; the latter only affects 2 traits 135 | noiseFE_binomialandNormalConfounders <- noiseFixedEffects(P=10, N=20, 136 | NrFixedEffects=2, pTraitsAffected =c (1,0.2), NrConfounders=c(2,2), 137 | distConfounders=c("bin", "norm"), probConfounders=0.2) 138 | } 139 | \seealso{ 140 | \code{\link{simulateDist}} 141 | } 142 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # PhenotypeSimulator 0.3.4 2 | ## Minor changes 3 | 1. Fixed missing --genotypefile flag [issue 27](https://github.com/HannahVMeyer/PhenotypeSimulator/issues/27) 4 | 2. Update vignettes with new location for impute files and commands to get the 5 | CEU samples [issue 24](https://github.com/HannahVMeyer/PhenotypeSimulator/issues/24), 6 | thanks to @zfuller5280 for the suggestion!) 7 | 3. Standardise genotypes on row with major alleles [issue 21](https://github.com/HannahVMeyer/PhenotypeSimulator/issues/21). 8 | Thank you for the detailed bug report by @alanw1! 9 | 4. Add option to imput missing genotypes to standardise genotype function; 10 | otherwise, if genotypes are missing, function will fail 11 | [issue 17](https://github.com/HannahVMeyer/PhenotypeSimulator/issues/17) 12 | 5. Fix function description and passing of SNP IDs in readStandardGenotypes with 13 | delim option [issue 25](https://github.com/HannahVMeyer/PhenotypeSimulator/issues/25), 14 | thanks @BSchmidt1. 15 | 16 | # PhenotypeSimulator 0.3.3 17 | ## Minor changes 18 | 1. Fixed bug that failed to return causal SNP name when only one SNP was chosen 19 | to be causal [issue 20 | 13](https://github.com/HannahVMeyer/PhenotypeSimulator/issues/13). 21 | 22 | # PhenotypeSimulator 0.3.2 23 | ## Minor changes 24 | 1. Option for external, delimited genotype file to contain a header; 25 | additional checks to make sure the right data is received when 26 | sampling from the genotypes file [issue 10](https://github.com/HannahVMeyer/PhenotypeSimulator/issues/10) 27 | 1. Fixed bug for reading external genotypes file [issue 28 | 9](https://github.com/HannahVMeyer/PhenotypeSimulator/issues/9) 29 | 30 | # PhenotypeSimulator 0.3.1 31 | ## Minor changes 32 | 1. Adapted output file names for genotypes consistent with other 33 | filenames from genotypes.txt to Genotypes.txt 34 | 35 | # PhenotypeSimulator 0.3.0 36 | ## Major changes 37 | 1. Add option for non-linear transformation of simulated phenotypes: function (transformNonlinear)[https://github.com/HannahVMeyer/PhenotypeSimulator/blob/master/R/createphenotypeFunctions.R], accessible from [runSimulation](https://github.com/HannahVMeyer/PhenotypeSimulator/blob/master/R/createphenotypeFunctions.R). Both transformed and original phenotypes are automatically returned with [savePheno](https://github.com/HannahVMeyer/PhenotypeSimulator/blob/master/R/outputFunctions.R) 38 | 1. Replace parameter 'oxgen' in [readStandardGenotypes](https://github.com/HannahVMeyer/PhenotypeSimulator/blob/master/R/genotypeFunctions.R) and [getCausalSNPs](https://github.com/HannahVMeyer/PhenotypeSimulator/blob/master/R/genotypeFunctions.R) with 'format' - ensures proper 39 | specification of genotype format for all cases. 40 | ## Minor changes 41 | 1. In addition to full kinship, [savePheno](https://github.com/HannahVMeyer/PhenotypeSimulator/blob/master/R/outputFunctions.R) and [writeStandardOutput](https://github.com/HannahVMeyer/PhenotypeSimulator/blob/master/R/outputFunctions.R) write eigenvalues and eigenvalues of kinship matrix. 42 | 1. Output file names have been made more consistent in [savePheno](https://github.com/HannahVMeyer/PhenotypeSimulator/blob/master/R/outputFunctions.R) and [writeStandardOutput](https://github.com/HannahVMeyer/PhenotypeSimulator/blob/master/R/outputFunctions.R). 43 | 1. Causal SNPs are now also saved in specified standard output format. 44 | 1. LiMMBo has been added as output format in [savePheno](https://github.com/HannahVMeyer/PhenotypeSimulator/blob/master/R/outputFunctions.R) and [writeStandardOutput](https://github.com/HannahVMeyer/PhenotypeSimulator/blob/master/R/outputFunctions.R)([LiMMBo format](https://limmbo.readthedocs.io/en/latest/)) 45 | 46 | # PhenotypeSimulator 0.2.2 47 | ## Minor changes 48 | 1. Update readStandardGenotypes to be compatible with latest 49 | release of data.table (v1.11.2), see 50 | [here](https://github.com/HannahVMeyer/PhenotypeSimulator/issues/7) 51 | 52 | # PhenotypeSimulator 0.2.1 53 | ## Minor changes 54 | 1. Additional tests for compatibility of input parameters with variance 55 | components functions, genotype functions and output functions. 56 | 1. Bug fix in output function: savePheno now properly saves kinship matrix as 57 | .rds. 58 | 59 | # PhenotypeSimulator 0.2.0 60 | ## Major changes 61 | **Input** 62 | 1. *PhenotypeSimulator* now includes readStandardGenotypes which can read externally simulated or user-provided genotypes in plink, genome, oxgen (hapgen/impute2), bimbam or simple delimited format. 63 | 1. A user-specified correlation matrix can be provided for the simulation of the correlatedBdEffects. 64 | 1. Short option flags for command-line use of *PhenotypeSimulator* were removed. 65 | 66 | **Output** 67 | 1. *PhenotypeSimulator* provides the option to save the simulated phenotypes and genotypes in formats compatible with a number of commonly used genetic association software (gemma, bimbam, plink, snptest) via writeStandardOutput. 68 | 1. Intermediate phenotype components are now saved per default. 69 | 1. Saving additional subsets of the simulated data has been removed. 70 | 71 | **Variance components** 72 | 1. Genotype simulation and kinship estimation: functions for genotype simulation and kinship estimation have been rewritten for 73 | significant speed-ups of the computation time [benchmarking](https://github.com/HannahVMeyer/PhenotypeSimulator-profiling). 74 | 75 | 1. geneticFixedEffects and noiseFixedEffects: 76 | 1. The effect size distributions of the shared effects are now modelled as the product of two exponential distributions 77 | (to yield an approximately uniform distributions) or the product of a normal distribution with user-specified 78 | parameters and a standard normal distribution. 79 | 80 | 1. The independent effects can now be specified to affect the same subset or different subsets of traits (via 81 | keepSameIndependent). 82 | 83 | 1. The overall number of traits affected by the effects can now be specified via pTraitsAffected. 84 | 85 | 86 | 1. correlatedBgEffects: the additional correlation between the traits can be specified by the user by providing an external 87 | correlation matrix. 88 | -------------------------------------------------------------------------------- /vignettes/sample-scripts-external-genotype-simulation.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Genotype simulation supported by *PhenotypeSimulator*" 3 | author: "Hannah Meyer" 4 | date: "`r Sys.Date()`" 5 | output: pdf_document 6 | bibliography: genotype-simulation.bib 7 | csl: plos-genetics.csl 8 | vignette: > 9 | %\VignetteIndexEntry{Supported Genotype Simulation} 10 | %\VignetteEngine{knitr::rmarkdown} 11 | %\VignetteEncoding{UTF-8} 12 | --- 13 | ```{r, echo = FALSE, message=FALSE} 14 | library(knitr) 15 | knitr::opts_chunk$set(collapse = TRUE, comment = "#>") 16 | ``` 17 | 18 | There are a number of different strategies to generate genotype data for genetic 19 | association studies. 20 | 21 | 1. **Simple bi-allelic SNPs without structure**: 22 | In the most simple case and assuming bi-allelic SNPs, each SNP is simulated 23 | from a binomial distribution with two trials and probability equal to the 24 | given allele frequencies. This simple approach does not simulate any 25 | dependency between the genotypes as is observed with LD structure in the 26 | genome. Simple bi-allelic SNPs can be simulated with 27 | PhenotypeSimulator::simulateGenotypes or via PLINK @Chang2015. For large 28 | datasets (~ 1 million SNPs), simulation via PLINK is recommended. 29 | 30 | 1. **Coalescent approaches**: 31 | Coalescent methods simulate genealogical events backward in time. These 32 | events typically include the coalescence of two sequences into a single 33 | ancestral lineage, recombination within a sequence or migration between 34 | populations. A coalescent-based approach to simulate whole genome data is 35 | implemented in GENOME @Liang2007 and its output format is supported as an 36 | input format for *PhenotypeSimulator*. 37 | 38 | 1. **Forward-time approaches**: 39 | Forward-time simulation methods evolve a population forward in time, subject 40 | to arbitrary genetic and demographic factors @Peng2010. Several algorithms 41 | are available, many of which allow customisation by building the simulation 42 | scheme in R or python, hence the output format of the genotypes can be 43 | specified by the user. *PhenotypeSimulator* offers reading genotypes from 44 | delimited-files and as such, any genotypes generated by these programmes can 45 | be read (e.g. MetaSim @Strand2002 or simuPop @Peng2005). 46 | 47 | 1. **Resampling approaches**: 48 | Resampling-based approaches combine existing genotype data into the 49 | genotypes of the simulated samples, thereby retaining allele frequency and 50 | LD patterns @Wright2007. A standard resampling-based approach that uses 51 | common genotype formats (common for the 52 | [oxford genetics format](http://www.stats.ox.ac.uk/~marchini/software/gwas/file_format.html)) 53 | is Hapgen2 and an example usage is given below. 54 | 55 | Examples for genotype simulation via PLINK, GENOME and Hapgen2 are given below. 56 | The corresponding data can be found in the extdata folder. 57 | 58 | ## Simple bi-allelic SNPs without structure via PLINK 59 | Download [PLINK](https://www.cog-genomics.org/plink/1.9/) and create a folder 60 | for the PLINK output files. The example below uses PLINK to simulate 1000 SNPs, 61 | with allele frequencies between 0 and 1 for 100 controls and 0 cases. 62 | PhenotypeSimulator::readStandardGenotypes reads the resulting .bim, .fam, .bed 63 | files. 64 | 65 | ```{bash, eval=FALSE} 66 | # Serves as output directory for simulation and parameter file 67 | mkdir -p ~/PhenotypeSimulator/inst/extdata/genotypes/plink 68 | cd ~/PhenotypeSimulator/inst/extdata/genotypes/plink 69 | 70 | # Write paramter file to simulate 1000 SNPs, with allele frequencies between 0 71 | # and 1 for 100 controls and 0 cases 72 | echo -e "1000\tSNP\t0.00\t1.00\t1.00\t1.00" > plink_sim_par.txt 73 | 74 | plink --simulate plink_sim_par.txt \ 75 | --simulate-ncases 0 \ 76 | --simulate-ncontrols 100 \ 77 | --out genotypes_plink 78 | ``` 79 | 80 | 81 | 82 | ## Coalescent simulation via Genome 83 | Download [GENOME](http://csg.sph.umich.edu/liang/genome/download.html) and 84 | create a folder for the GENOME output files. The example below uses GENOME to 85 | simulate genetic data for a population comprised of three sub-populations with 86 | 30, 30 and 40 samples. The simulated POPULATION PROFILE, SNP positions and the 87 | genotypes are all saved in genotypes_genome.txt. 88 | PhenotypeSimulator::readStandardGenotypes reads genotype information by parsing 89 | this output file and extracting the samples information following the line 90 | 'Samples:' 91 | 92 | ```{bash, eval=FALSE} 93 | mkdir -p ~/PhenotypeSimulator/inst/extdata/genotypes/genome 94 | cd ~/PhenotypeSimulator/inst/extdata/genotypes/genome 95 | 96 | # subpopulation with 30, 30 and 40 individuals each 97 | genome -pop 3 30 30 40 > genotypes_genome.txt 98 | ``` 99 | 100 | ## Resampling-based simulation via Hapgen2 101 | Download [hapgen2](http://mathgen.stats.ox.ac.uk/genetics_software/hapgen/hapgen2.html), 102 | [hapgen example files](http://mathgen.stats.ox.ac.uk/genetics_software/hapgen/download/example/hapgen2.example.tgz) 103 | and the 1000Genomes data from the 104 | [impute2 webpage](https://mathgen.stats.ox.ac.uk/impute/impute_v1.html#Using_IMPUTE_with_the_HapMap_Data) 105 | as starting point for the resampling-based genotype simulation with hapgen2. 106 | For formating of the 1000Genomes data, have a look at this [vignette](https://hannahvmeyer.github.io/PhenotypeSimulator/articles/Simulation-and-LinearModel.html#genotype-simulation-via-hapgen2). 107 | The example files contain example haplotypes (ex.haps), legend files (ex.leg) map 108 | (ex.map) and TagSNP files (ex.tags). The following examples simulates genotype 109 | data for 100 controls and 0 cases with 1000 SNPs from chromosome 1. 110 | PhenotypeSimulator::readStandardGenotypes reads the resulting .gen and .samples 111 | files. 112 | 113 | ```{bash, eval=FALSE} 114 | # contains ex.leg file and serves as output directory 115 | mkdir -p ~/PhenotypeSimulator/inst/extdata/genotypes/hapgen 116 | cd ~/PhenotypeSimulator/inst/extdata/genotypes/hapgen 117 | 118 | # contains 1000Genomes haplotype data used for sampling 119 | hapdir=/path/to/CEU.0908.impute.files 120 | 121 | hapgen2 -m $hapdir/genetic_map_chr1_combined_b37.txt \ 122 | -l ex.leg \ 123 | -h $hapdir/chr1.ceu_subset.hap \ 124 | -o genotypes_hapgen \ 125 | -n 100 0 \ 126 | -dl 45162 0 0 0 \ 127 | -no_haps_output 128 | ``` 129 | 130 | ## References 131 | -------------------------------------------------------------------------------- /docs/LICENSE-text.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | License • PhenotypeSimulator 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
    64 |
    65 | 139 | 140 | 141 | 142 |
    143 | 144 |
    145 |
    146 | 149 | 150 |
    YEAR: 2017
    151 | COPYRIGHT HOLDER: Hannah Verena Meyer
    152 | 
    153 | 154 |
    155 | 156 | 161 | 162 |
    163 | 164 | 165 | 166 |
    167 | 170 | 171 |
    172 |

    Site built with pkgdown 1.6.1.

    173 |
    174 | 175 |
    176 |
    177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Page not found (404) • PhenotypeSimulator 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
    64 |
    65 | 139 | 140 | 141 | 142 |
    143 | 144 |
    145 |
    146 | 149 | 150 | Content not found. Please use links in the navbar. 151 | 152 |
    153 | 154 | 159 | 160 |
    161 | 162 | 163 | 164 |
    165 | 168 | 169 |
    170 |

    Site built with pkgdown 1.6.1.

    171 |
    172 | 173 |
    174 |
    175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /docs/articles/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Articles • PhenotypeSimulator 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
    64 |
    65 | 139 | 140 | 141 | 142 |
    143 | 144 | 167 | 168 | 169 |
    170 | 173 | 174 |
    175 |

    Site built with pkgdown 1.6.1.

    176 |
    177 | 178 |
    179 |
    180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | -------------------------------------------------------------------------------- /docs/reference/PhenotypeSimulator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | PhenotypeSimulator: A package for simulating phenotypes from different 10 | genetic and noise components — PhenotypeSimulator • PhenotypeSimulator 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 47 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
    68 |
    69 | 143 | 144 | 145 | 146 |
    147 | 148 |
    149 |
    150 | 156 | 157 |
    158 |

    PhenotypeSimulator: A package for simulating phenotypes from different 159 | genetic and noise components

    160 |
    161 | 162 | 163 | 164 | 165 |
    166 | 171 |
    172 | 173 | 174 |
    175 | 178 | 179 |
    180 |

    Site built with pkgdown 1.6.1.

    181 |
    182 | 183 |
    184 |
    185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | -------------------------------------------------------------------------------- /docs/authors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Citation and Authors • PhenotypeSimulator 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
    64 |
    65 | 139 | 140 | 141 | 142 |
    143 | 144 |
    145 |
    146 | 150 | 151 |

    Hannah V Meyer, Ewan Birney (2018). PhenotypeSimulator: A comprehensive framework for simulating multi-trait, multi-locus genotype to phenotype relationships. Bioinformatics, 34(17), 2951-2956. URL https://doi.org/10.1093/bioinformatics/bty197.

    152 |
    @Article{,
    153 |   title = {PhenotypeSimulator: A comprehensive framework for simulating multi-trait, multi-locus genotype to phenotype relationships},
    154 |   author = {Hannah V Meyer and Ewan Birney},
    155 |   journal = {Bioinformatics},
    156 |   year = {2018},
    157 |   volume = {34},
    158 |   number = {17},
    159 |   pages = {2951--2956},
    160 |   url = {https://doi.org/10.1093/bioinformatics/bty197},
    161 | }
    162 | 163 | 166 | 167 |
      168 |
    • 169 |

      Hannah Meyer. Author, maintainer. 170 |

      171 |
    • 172 |
    • 173 |

      Konrad Rudolph. Contributor. 174 |

      175 |
    • 176 |
    177 | 178 |
    179 | 180 |
    181 | 182 | 183 | 184 |
    185 | 188 | 189 |
    190 |

    Site built with pkgdown 1.6.1.

    191 |
    192 | 193 |
    194 |
    195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | -------------------------------------------------------------------------------- /docs/reference/addNonNulls.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Add all non-NULL elements of list. — addNonNulls • PhenotypeSimulator 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 58 | 59 | 60 | 61 | 62 | 63 | 64 |
    65 |
    66 | 140 | 141 | 142 | 143 |
    144 | 145 |
    146 |
    147 | 152 | 153 |
    154 |

    Add all non-NULL elements of list.

    155 |
    156 | 157 |
    addNonNulls(compList)
    158 | 159 |

    Arguments

    160 | 161 | 162 | 163 | 164 | 166 | 167 |
    compList

    List of numeric matrices or data.frames of the equal 165 | dimensions.

    168 | 169 |

    Value

    170 | 171 |

    Matrix or data.frame containing sum of all list elements where 172 | is.null is FALSE.

    173 | 174 |
    175 | 180 |
    181 | 182 | 183 |
    184 | 187 | 188 |
    189 |

    Site built with pkgdown 1.6.1.

    190 |
    191 | 192 |
    193 |
    194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | -------------------------------------------------------------------------------- /docs/reference/read_lines.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Scan file for specific line numbers — read_lines • PhenotypeSimulator 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 58 | 59 | 60 | 61 | 62 | 63 | 64 |
    65 |
    66 | 140 | 141 | 142 | 143 |
    144 | 145 |
    146 |
    147 | 152 | 153 |
    154 |

    Scan file for specific line numbers

    155 |
    156 | 157 |
    read_lines(filename, lines, sep = "\n")
    158 | 159 |

    Arguments

    160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 |
    filename

    /path/to/chromosomefile [string]

    lines

    vector of line numbers [integer] to be read

    sep

    [string] end-of-line delimiter

    175 | 176 | 177 |
    178 | 183 |
    184 | 185 | 186 | 196 |
    197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | -------------------------------------------------------------------------------- /tests/testthat/test-createphenotypeFunctions.r: -------------------------------------------------------------------------------- 1 | context('Test createphenotype functions') 2 | 3 | noiseBg <- noiseBgEffects(N=100, P=10) 4 | noiseFixed <- noiseFixedEffects(N=100, P=10) 5 | noiseCorrelated <- correlatedBgEffects(N=100, P=10, pcorr=0.6) 6 | genotypes <- simulateGenotypes(N=100, NrSNP=20, verbose=FALSE) 7 | kinship <- getKinship(N=100, X=genotypes$genotypes, standardise=TRUE, 8 | verbose=FALSE) 9 | causalSNPs <- getCausalSNPs(N=100, genotypes=genotypes$genotypes, verbose=FALSE) 10 | geneticFixed <- geneticFixedEffects(X_causal=causalSNPs, P=10, N=100, 11 | verbose=FALSE) 12 | geneticBg <- geneticBgEffects(P=10, N=100, kinship=kinship) 13 | 14 | context("Tests rescaleVariance") 15 | test_that("rescaleVariance fails when propvar is not numeric", { 16 | expect_error(rescaleVariance(noiseBg$shared, propvar = 'a'), 17 | "propvar needs to be numeric") 18 | }) 19 | test_that("rescaleVariance fails when propvar is out of range", { 20 | expect_error(rescaleVariance(noiseBg$shared, propvar = 1.1), 21 | "propvar cannot be less than 0 and or greater than 1") 22 | }) 23 | test_that("rescaleVariance fails when component is not a matrix", { 24 | expect_error(rescaleVariance(data.frame(noiseBg$shared), propvar = 0.1), 25 | "component needs to be a matrix") 26 | }) 27 | test_that("rescaleVariance returns NULL when no propvar is specified", { 28 | expect_equal(rescaleVariance(noiseBg$shared, propvar = 0), NULL) 29 | }) 30 | 31 | test_that("rescaleVariance returns correclty scaled average column variance", { 32 | tmp <- rescaleVariance(noiseBg$shared, propvar = 0.1) 33 | expect_equal(mean(diag(var(tmp$component))), 0.1, tolerance=5e-5) 34 | }) 35 | 36 | 37 | context("Tests setModel") 38 | test_that("setModel fails with input error", { 39 | expect_error(setModel(), "No variance components specified") 40 | }) 41 | 42 | test_that("setModel fails with out of range error", { 43 | expect_error(setModel(genVar=0.4, h2s=1.2, theta=0.8, eta=0.8, 44 | delta=0.2, gamma=0.8, rho=0.2, phi=0.6, 45 | alpha=0.8, pcorr=0.6, pIndependentConfounders=0.4, 46 | pTraitIndependentConfounders=0.2, 47 | pIndependentGenetic=0.4, 48 | pTraitIndependentGenetic=0.2, verbose=FALSE), 49 | "Proportions have to be specified between 0 and 1:") 50 | }) 51 | test_that("setModel fails with missing variance error", { 52 | expect_error(setModel(h2s=1, theta=0.8, eta=0.8, 53 | delta=0.2, gamma=0.8, rho=0.2, phi=0.6, 54 | alpha=0.8, pcorr=0.6, pIndependentConfounders=0.4, 55 | pTraitIndependentConfounders=0.2, 56 | pIndependentGenetic=0.4, 57 | pTraitIndependentGenetic=0.2, verbose=FALSE), 58 | "Neither genVar nor noiseVar are provided, thus") 59 | }) 60 | 61 | test_that("setModel fails with sum of variance error", { 62 | expect_error(setModel(genVar=0.2, noiseVar=0.9, h2s=1, theta=0.8, eta=0.8, 63 | delta=0.2, gamma=0.8, rho=0.2, phi=0.6, 64 | alpha=0.8, pcorr=0.6, pIndependentConfounders=0.4, 65 | pTraitIndependentConfounders=0.2, 66 | pIndependentGenetic=0.4, 67 | pTraitIndependentGenetic=0.2, verbose=FALSE), 68 | "Sum of genetic variance and noise variance is greater than 1") 69 | }) 70 | 71 | test_that("setModel fails with extra noise component error", { 72 | expect_error(setModel(noiseVar=0, h2s=1, theta=0.8, eta=0.8, 73 | delta=0.2, gamma=0.8, rho=0.2, phi=0.6, 74 | alpha=0.8, pcorr=0.6, pIndependentConfounders=0.4, 75 | pTraitIndependentConfounders=0.2, 76 | pIndependentGenetic=0.4, 77 | pTraitIndependentGenetic=0.2, verbose=FALSE), 78 | "The noise variance is set to 0 ") 79 | }) 80 | 81 | test_that("setModel fails with extra genetic component error", { 82 | expect_error(setModel(genVar=0, h2s=1, theta=0.8, eta=0.8, 83 | delta=0.2, gamma=0.8, rho=0.2, phi=0.6, 84 | alpha=0.8, pcorr=0.6, pIndependentConfounders=0.4, 85 | pTraitIndependentConfounders=0.2, 86 | pIndependentGenetic=0.4, 87 | pTraitIndependentGenetic=0.2, verbose=FALSE), 88 | "The genetic variance is set to 0 ") 89 | }) 90 | 91 | test_that("setModel fails with missing noise component error", { 92 | expect_error(setModel(noiseVar=0.8, h2s=1, theta=0.8, eta=0.8, 93 | pcorr=0.6, pIndependentConfounders=0.4, 94 | pTraitIndependentConfounders=0.2, 95 | pIndependentGenetic=0.4, 96 | pTraitIndependentGenetic=0.2, 97 | verbose=FALSE), 98 | "Neither delta ") 99 | }) 100 | 101 | test_that("setModel fails with proportions larger than 1 error", { 102 | expect_error(setModel(noiseVar=0.8, h2s=1, theta=0.8, delta=0.8, phi=0.2, 103 | rho=0.2, eta=0.8, 104 | pcorr=0.6, pIndependentConfounders=0.4, 105 | pTraitIndependentConfounders=0.2, 106 | pIndependentGenetic=0.4, 107 | pTraitIndependentGenetic=0.2, 108 | verbose=FALSE), 109 | "Sum of the proportion of the variance of noise") 110 | }) 111 | 112 | test_that("setModel fails with proportions less than 1 error", { 113 | expect_error(setModel(noiseVar=0.8, h2s=1, theta=0.8, delta=0.2, phi=0.2, 114 | rho=0.2, eta=0.8, 115 | pcorr=0.6, pIndependentConfounders=0.4, 116 | pTraitIndependentConfounders=0.2, 117 | pIndependentGenetic=0.4, 118 | pTraitIndependentGenetic=0.2, 119 | verbose=FALSE), 120 | "Sum of the proportion of the variance of noise") 121 | }) 122 | 123 | test_that("setModel fails with insufficient noise component error", { 124 | expect_error(setModel(noiseVar=0.8, h2s=1, theta=0.8, eta=0.8, 125 | delta=0.8, pcorr=0.6, pIndependentConfounders=0.4, 126 | pTraitIndependentConfounders=0.2, 127 | pIndependentGenetic=0.4, 128 | pTraitIndependentGenetic=0.2, 129 | verbose=FALSE), 130 | "Not enough components provided to set proportions of") 131 | }) 132 | 133 | test_that("setModel fails with insufficient genetic component error", { 134 | expect_error(setModel(genVar=0.8, theta=0.8, eta=0.8, 135 | delta=0.2, gamma=0.8, rho=0.2, phi=0.6, 136 | alpha=0.8, pcorr=0.6, pIndependentConfounders=0.4, 137 | pTraitIndependentConfounders=0.2, 138 | pIndependentGenetic=0.4, 139 | pTraitIndependentGenetic=0.2, verbose=FALSE), 140 | "Neither genetic variant effect variance") 141 | }) 142 | 143 | test_that("setModel fails with sum of genetic component error", { 144 | expect_error(setModel(genVar=0.8, h2s=0.4, h2bg=0.3, theta=0.8, eta=0.8, 145 | delta=0.2, gamma=0.8, rho=0.2, phi=0.6, 146 | alpha=0.8, pcorr=0.6, pIndependentConfounders=0.4, 147 | pTraitIndependentConfounders=0.2, 148 | pIndependentGenetic=0.4, 149 | pTraitIndependentGenetic=0.2, verbose=FALSE), 150 | "Sum of the proportion of the variance of genetic") 151 | }) 152 | 153 | context("Tests runSimulation") 154 | test_that("runSimulation returns correct output", { 155 | expect_equal(length(runSimulation(N=10, P=5, genVar=1, h2s=0.2)), 5) 156 | }) --------------------------------------------------------------------------------