Commit 6032b619 authored by francois's avatar francois
Browse files

v1.1.3: genepopExample

parent cddec3c5
Package: genepop
Type: Package
Title: Population Genetic Data Analysis Using Genepop
Version: 1.1.2
Date: 2019-06-23
Version: 1.1.3
Date: 2019-07-14
Authors@R: c(person("François", "Rousset", role = c("aut", "cre", "cph"),
email = "francois.rousset@umontpellier.fr"),
person("Jimmy","Lopez", role="ctb"),
......
......@@ -47,9 +47,7 @@
#' @param iterations integer: Iterations per batch
#' @param verbose logical: whether to print some information
#' @return The path of the output file is returned invisibly.
#' @examples infile <- system.file('extdata', 'sample.txt',package='genepop')
#' locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
#' check <- file.copy(infile,locinfile,overwrite=TRUE)
#' @examples locinfile <- genepopExample('sample.txt')
#' test_HW(locinfile, which='deficit', 'sample.txt.D')
#' if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
test_HW <- function(inputFile, which = "Proba", outputFile = "", settingsFile = "", enumeration = FALSE, dememorization = 10000,
......@@ -97,9 +95,7 @@ test_HW <- function(inputFile, which = "Proba", outputFile = "", settingsFile =
#' @rdname Hardy-Weinberg
#' @examples # Example in Guo & Thompson 1992 Table 5
#' infile <- system.file('extdata', 'Rhesus.txt',package='genepop')
#' locinfile <- 'Rhesus.txt'
#' check <- file.copy(infile,locinfile,overwrite=TRUE)
#' locinfile <- genepopExample('Rhesus.txt')
#' outfile <- HWtable_analysis(locinfile,which='Proba',batches = 1000,iterations = 1000)
#' readLines(outfile)[21]
#' #clean_workdir(otherfiles='Rhesus.txt')
......@@ -142,9 +138,7 @@ HWtable_analysis <- function(inputFile, which = "Proba", settingsFile = "", enum
#' @param iterations integer: Iterations per batch
#' @param verbose logical: whether to print some information
#' @return The path of the output file is returned invisibly.
#' @examples infile <- system.file('extdata', 'sample.txt',package='genepop')
#' locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
#' check <- file.copy(infile,locinfile,overwrite=TRUE)
#' @examples locinfile <- genepopExample('sample.txt')
#' test_LD(locinfile,'sample.txt.DIS')
#' if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
test_LD <- function(inputFile, outputFile = "", settingsFile = "", dememorization = 10000, batches = 100, iterations = 5000,
......@@ -162,9 +156,7 @@ test_LD <- function(inputFile, outputFile = "", settingsFile = "", dememorizatio
}
#' @rdname Linkage
#' @examples infile <- system.file('extdata', 'sample.txt',package='genepop')
#' locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
#' check <- file.copy(infile,locinfile,overwrite=TRUE)
#' @examples locinfile <- genepopExample('sample.txt')
#' write_LD_tables(locinfile,'sample.txt.TAB')
#' if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
write_LD_tables <- function(inputFile, outputFile = "", verbose = interactive()) {
......@@ -185,9 +177,7 @@ write_LD_tables <- function(inputFile, outputFile = "", verbose = interactive())
#' @param iterations integer: Iterations per batch
#' @param verbose logical: whether to print some information
#' @return The path of the output file is returned invisibly.
#' @examples infile <- system.file('extdata', 'sample.txt',package='genepop')
#' locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
#' check <- file.copy(infile,locinfile,overwrite=TRUE)
#' @examples locinfile <- genepopExample('sample.txt')
#' test_diff(locinfile,outputFile='sample.txt.GE')
#' if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
test_diff <- function(inputFile, genic = TRUE, pairs = FALSE, outputFile = "", settingsFile = "", dememorization = 10000,
......@@ -244,9 +234,7 @@ test_diff <- function(inputFile, genic = TRUE, pairs = FALSE, outputFile = "", s
#' @param iterations integer: Iterations per batch
#' @param verbose logical: whether to print some information
#' @return The path of the output file is returned invisibly.
#' @examples infile <- system.file('extdata', 'structest.txt',package='genepop')
#' locinfile <- 'structest.txt'
#' check <- file.copy(infile,locinfile,overwrite=TRUE)
#' @examples locinfile <- genepopExample('structest.txt')
#' struc(locinfile)
#' if ( ! interactive()) clean_workdir(otherfiles='structest.txt')
struc <- function(inputFile, settingsFile = "", dememorization = 10000, batches = 100, iterations = 5000, verbose = interactive()) {
......@@ -267,9 +255,7 @@ struc <- function(inputFile, settingsFile = "", dememorization = 10000, batches
#' @param dataType character: The haploid and diploid data
#' @param verbose logical: whether to print some information
#' @return The path of the output file is returned invisibly.
#' @examples infile <- system.file('extdata', 'sample.txt',package='genepop')
#' locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
#' check <- file.copy(infile,locinfile,overwrite=TRUE)
#' @examples locinfile <- genepopExample('sample.txt')
#' Nm_private(locinfile,'sample.txt.PRI')
#' if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
Nm_private <- function(inputFile, outputFile = "", dataType = "Diploid", verbose = interactive()) {
......@@ -285,9 +271,7 @@ Nm_private <- function(inputFile, outputFile = "", dataType = "Diploid", verbose
#' @param outputFile character: The path of the output file
#' @param verbose logical: whether to print some information
#' @return The path of the output file is returned invisibly.
#' @examples infile <- system.file('extdata', 'sample.txt',package='genepop')
#' locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
#' check <- file.copy(infile,locinfile,overwrite=TRUE)
#' @examples locinfile <- genepopExample('sample.txt')
#' basic_info(locinfile,'sample.txt.INF')
#' if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
basic_info <- function(inputFile, outputFile = "", verbose = interactive()) {
......@@ -305,9 +289,7 @@ basic_info <- function(inputFile, outputFile = "", verbose = interactive()) {
#' @param dataType character: The haploid and diploid data
#' @param verbose logical: whether to print some information
#' @return The path of the output file is returned invisibly.
#' @examples infile <- system.file('extdata', 'sample.txt',package='genepop')
#' locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
#' check <- file.copy(infile,locinfile,overwrite=TRUE)
#' @examples locinfile <- genepopExample('sample.txt')
#' genedivFis(locinfile,outputFile = 'sample.txt.DIV')
#' if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
genedivFis <- function(inputFile, sizes = FALSE, outputFile = "", dataType = "Diploid", verbose = interactive()) {
......@@ -332,9 +314,7 @@ genedivFis <- function(inputFile, sizes = FALSE, outputFile = "", dataType = "Di
#' @param dataType character: The haploid and diploid data
#' @param verbose logical: whether to print some information
#' @return The path of the output file is returned invisibly.
#' @examples infile <- system.file('extdata', 'sample.txt',package='genepop')
#' locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
#' check <- file.copy(infile,locinfile,overwrite=TRUE)
#' @examples locinfile <- genepopExample('sample.txt')
#' Fst(locinfile, outputFile= 'sample.txt.DIV')
#' if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
Fst <- function(inputFile, sizes = FALSE, pairs = FALSE, outputFile = "", dataType = "Diploid", verbose = interactive()) {
......@@ -378,15 +358,11 @@ Fst <- function(inputFile, sizes = FALSE, pairs = FALSE, outputFile = "", dataTy
#' @return The path of the output file is returned invisibly.
#' @examples
#' \dontrun{
#' infile <- system.file('extdata', 'w2.txt',package='genepop')
#' locinfile <- 'w2.txt'
#' check <- file.copy(infile,locinfile,overwrite=TRUE)
#' locinfile <- genepopExample('w2.txt')
#' outfile <- ibd(locinfile,'w2.txt.ISO', geographicScale = 'Log', statistic='e')
#' if ( ! interactive()) clean_workdir(otherfiles='w2.txt')
#'
#' infile <- system.file('extdata', 'PEL1600withCoord.txt',package='genepop')
#' locinfile <- 'PEL1600withCoord.txt'
#' check <- file.copy(infile,locinfile,overwrite=TRUE)
#' locinfile <- genepopExample('PEL1600withCoord.txt')
#' outfile <- ibd(locinfile,'PEL1600withCoord.ISO', statistic = 'SingleGeneDiv',
#' geographicScale = '1D')
#' if ( ! interactive()) clean_workdir(otherfiles='PEL1600withCoord.txt')
......@@ -446,9 +422,7 @@ ibd <- function(inputFile, outputFile = "", settingsFile = "", dataType = "Diplo
#' @param outputFile character: The path of the output file
#' @param verbose logical: whether to print some information
#' @return The path of the output file is returned invisibly.
#' @examples infile <- system.file('extdata', 'sample.txt',package='genepop')
#' locinfile <- 'sample.txt'
#' check <- file.copy(infile,locinfile,overwrite=TRUE)
#' @examples locinfile <- genepopExample('sample.txt')
#' conversion(locinfile, format='Fstat', 'sample.txt.DAT')
#' if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
conversion <- function(inputFile, format, outputFile = "", verbose = interactive()) {
......@@ -490,9 +464,7 @@ nulls <- function(inputFile, outputFile = "", settingsFile = "", nullAlleleMetho
#' @param outputFile character: The path of the output file
#' @param coordinates Either \code{'population'} (use population coordinates) or anything else (use individual coordinates).
#' @param verbose logical: whether to print some information
#' @examples infile <- system.file('extdata', 'sample.txt',package='genepop')
#' locinfile <- "sample.txt"
#' check <- file.copy(infile,locinfile,overwrite=TRUE)
#' @examples locinfile <- genepopExample('sample.txt')
#' outfile <- diploidize(inputFile = locinfile,outputFile="Dsample.txt")
#' if ( ! interactive()) clean_workdir(c("sample.txt", "Dsample.txt"))
......@@ -564,3 +536,17 @@ clean_workdir <- function(otherfiles=NULL, path=".", suffixes=c("GRA", "ISO", "M
if ( cmdline && file.exists("cmdline.txt")) file.remove("cmdline.txt")
setwd(oldpath)
}
#'@rdname genepopExample
#' @title Copy an example file from the Genepop package distribution
#' @description This function is used to copy an example file to the user's directory. It should not be used when analysing one's own data!
#' @param filename The name of an example file from the Genepop distribution.
#' @return Returns the \code{filename}
genepopExample <- function(filename) {
infile <- system.file('extdata', filename, package='genepop')
if (infile=="") stop("There is no such file in the package 'extdata' directory.")
locinfile <- filename ## file in user's directory not in R's extdata directory
check <- file.copy(infile,locinfile,overwrite=TRUE)
if ( ! check) stop("The file could not be copied into the user's directory.")
return(filename)
}
\ No newline at end of file
......@@ -84,9 +84,7 @@ En sortie un fichier au format texte <br/>
#' @param iterations integer: Iterations per batch
#' @param verbose logical: whether to print some information
#' @return The path of the output file is returned invisibly.
#' @examples infile <- system.file('extdata', 'sample.txt',package='genepop')
#' locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
#' check <- file.copy(infile,locinfile,overwrite=TRUE)
#' @examples locinfile <- genepopExample('sample.txt')
#' test_HW(locinfile, which='deficit', 'sample.txt.D')
test_HW(inputFile, which = "Proba", outputFile = "", enumeration = FALSE, dememorization = 10000, batches = 20, iterations = 5000, verbose = interactive()
......
......@@ -3,7 +3,14 @@
\encoding{UTF-8}
% cf ?news for the format and usage of this file
%
\section{CHANGES UP TO VERSION 1.1.1}{
\section{CHANGES UP TO VERSION 1.1.3}{ % _F I X M E_
\subsection{NEW FEATURES}{
\itemize{
\item New convenience function genepopExample() replacing potentially confusing code in the Examples
}
}
}
\section{CHANGES UP TO VERSION 1.1.2}{
\subsection{NEW FEATURES}{
\itemize{
\item New keyword `intra_all_types` for setting "popTypeSelection" allows one to perform a single spatial regression for all pairs of individuals or populations within several types of subpopulations.
......
......@@ -28,9 +28,7 @@ The path of the output file is returned invisibly.
Performs an exact conditional contingency-table test. There are many other ways of doing this in R but this function replicates the functionality of earlier genepop code analysing a contingency table provided in a file with ad hoc format. See \href{../doc/all-menu-options.html#analyzing-a-single-contingency-table}{this section} of the Genepop executable documentation for more information on the statistical methods.
}
\examples{
infile <- system.file('extdata', 'structest.txt',package='genepop')
locinfile <- 'structest.txt'
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('structest.txt')
struc(locinfile)
if ( ! interactive()) clean_workdir(otherfiles='structest.txt')
}
......@@ -35,9 +35,7 @@ The path of the output file is returned invisibly.
Exact conditional contingency-table tests for genic or genotypic differentiation. A single test for all populations, or distinct tests for all pairs of populations, may be computed. See \href{../doc/all-menu-options.html#option-3-population-differentiation}{this section} of the Genepop executable documentation for more information on the statistical methods.
}
\examples{
infile <- system.file('extdata', 'sample.txt',package='genepop')
locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('sample.txt')
test_diff(locinfile,outputFile='sample.txt.GE')
if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
}
......@@ -27,9 +27,7 @@ The path of the output file is returned invisibly.
Evaluates Fst or related measures based on allele sizes, for all populations of for all pairs of populations. See \href{../doc/all-menu-options.html#sub-options-14-f-statistics-and-rho-statistics}{this section} of the Genepop executable documentation for more information on the statistical methods.
}
\examples{
infile <- system.file('extdata', 'sample.txt',package='genepop')
locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('sample.txt')
Fst(locinfile, outputFile= 'sample.txt.DIV')
if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
}
......@@ -40,15 +40,11 @@ The path of the output file is returned invisibly.
Compute variants of the exact conditional test for Hardy-Weinberg genotypic proportions. The tests differ by their test statistics. \code{HWtable_analysis} handles a single table of genotype counts, and \code{test_HW} requires a standard genepop input file. See \href{../doc/all-menu-options.html#option-1-hardy-weinberg-hw-exact-tests}{this section} of the Genepop-executable documentation for more information on the statistical methods.
}
\examples{
infile <- system.file('extdata', 'sample.txt',package='genepop')
locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('sample.txt')
test_HW(locinfile, which='deficit', 'sample.txt.D')
if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
# Example in Guo & Thompson 1992 Table 5
infile <- system.file('extdata', 'Rhesus.txt',package='genepop')
locinfile <- 'Rhesus.txt'
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('Rhesus.txt')
outfile <- HWtable_analysis(locinfile,which='Proba',batches = 1000,iterations = 1000)
readLines(outfile)[21]
#clean_workdir(otherfiles='Rhesus.txt')
......
......@@ -47,15 +47,11 @@ Estimates isolation by distance by regression of genetic distance to geographica
}
\examples{
\dontrun{
infile <- system.file('extdata', 'w2.txt',package='genepop')
locinfile <- 'w2.txt'
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('w2.txt')
outfile <- ibd(locinfile,'w2.txt.ISO', geographicScale = 'Log', statistic='e')
if ( ! interactive()) clean_workdir(otherfiles='w2.txt')
infile <- system.file('extdata', 'PEL1600withCoord.txt',package='genepop')
locinfile <- 'PEL1600withCoord.txt'
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('PEL1600withCoord.txt')
outfile <- ibd(locinfile,'PEL1600withCoord.ISO', statistic = 'SingleGeneDiv',
geographicScale = '1D')
if ( ! interactive()) clean_workdir(otherfiles='PEL1600withCoord.txt')
......
......@@ -34,14 +34,10 @@ The path of the output file is returned invisibly.
Exact test for each pair of loci in each population. See \href{../doc/all-menu-options.html#option-2-tests-and-tables-for-linkage-disequilibrium}{this section} of the Genepop executable documentation for more information on the statistical methods.
}
\examples{
infile <- system.file('extdata', 'sample.txt',package='genepop')
locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('sample.txt')
test_LD(locinfile,'sample.txt.DIS')
if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
infile <- system.file('extdata', 'sample.txt',package='genepop')
locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('sample.txt')
write_LD_tables(locinfile,'sample.txt.TAB')
if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
}
......@@ -23,9 +23,7 @@ The path of the output file is returned invisibly.
Estimation of Nm by private allele method of Slatkin and Barton. See \href{../doc/all-menu-options.html#option-4-private-alleles}{this section} of the Genepop executable documentation for more information on the statistical methods.
}
\examples{
infile <- system.file('extdata', 'sample.txt',package='genepop')
locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('sample.txt')
Nm_private(locinfile,'sample.txt.PRI')
if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
}
......@@ -20,9 +20,7 @@ The path of the output file is returned invisibly.
Allele and genotype frequencies per locus and per sample. See \href{../doc/all-menu-options.html#sub-option-1-allele-and-genotype-frequencies}{this section} of the Genepop executable documentation for more information on the statistical methods.
}
\examples{
infile <- system.file('extdata', 'sample.txt',package='genepop')
locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('sample.txt')
basic_info(locinfile,'sample.txt.INF')
if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
}
......@@ -22,9 +22,7 @@ The path of the output file is returned invisibly.
Converts input files from genepop format to some other formats (some maybe only of historical interest): Fstat, two Biosys formats. and linkdos. See \href{../doc/all-menu-options.html#option-7-file-conversions}{this section} of the Genepop executable documentation for more information on the statistical methods.
}
\examples{
infile <- system.file('extdata', 'sample.txt',package='genepop')
locinfile <- 'sample.txt'
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('sample.txt')
conversion(locinfile, format='Fstat', 'sample.txt.DAT')
if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
}
......@@ -25,9 +25,7 @@ The path of the output file is returned invisibly.
Evaluates Fis and gene diversities, or related measures based on allele sizes. See \href{../doc/all-menu-options.html#sub-option-2-identity-based-gene-diversities-and-f_mathrmis}{this section} of the Genepop executable documentation for more information on the identity-based statistical methods, and \href{../doc/all-menu-options.html#sub-option-3-allele-size-based-gene-diversities-and-rho_mathrmis}{this one} for allele-size based ones.
}
\examples{
infile <- system.file('extdata', 'sample.txt',package='genepop')
locinfile <- 'sample.txt' ## file in user's directory not in R's extdata directory
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('sample.txt')
genedivFis(locinfile,outputFile = 'sample.txt.DIV')
if ( ! interactive()) clean_workdir(otherfiles='sample.txt')
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Genepop.R
\name{genepopExample}
\alias{genepopExample}
\title{Copy an example file from the Genepop package distribution}
\usage{
genepopExample(filename)
}
\arguments{
\item{filename}{The name of an example file from the Genepop distribution.}
}
\value{
Returns the \code{filename}
}
\description{
This function is used to copy an example file to the user's directory. It should not be used when analysing one's own data!
}
......@@ -30,9 +30,7 @@ sample_haploid(inputFile, outputFile = "", verbose = interactive())
Various procedures described in the linked sections of the Genepop executable documentation: \href{../doc/all-menu-options.html#sub-option-2-diploidisation-of-haploid-data}{diploidize} haploid data, \href{../doc/all-menu-options.html#sub-option-3-relabeling-alleles-names}{relabel_alleles}, \href{../doc/all-menu-options.html#sub-option-6-random-sampling-of-haploid-genotypes-from-diploid-ones}{sample_haploid}, and \href{../doc/all-menu-options.html#sub-options-4-and-5-conversion-of-population-data-to-individual-data}{pop_to_indiv}. The latter procedure converts population samples (several individuals in each population) to individual data. The names given to the individuals in the new file created (names which are to be interpreted as coordinates in a spatial analysis) may be the population coordinates (given as the name of the last individual in the original data file), or each individual's coordinates (given as the name of each individual in the original data file).
}
\examples{
infile <- system.file('extdata', 'sample.txt',package='genepop')
locinfile <- "sample.txt"
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('sample.txt')
outfile <- diploidize(inputFile = locinfile,outputFile="Dsample.txt")
if ( ! interactive()) clean_workdir(c("sample.txt", "Dsample.txt"))
}
cat("test_Fis.R:\n")
infile <- system.file("extdata", "sample.txt",package="genepop")
locinfile <- "sample.txt"
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('sample.txt')
outfile <- genedivFis(locinfile,outputFile = "sample.txt.DIV")
expect_equal(readLines(outfile)[130], " 0.6736 -0.0722")
testthat::expect_equal(readLines(outfile)[130], " 0.6736 -0.0722")
outfile <- genedivFis(locinfile, sizes=TRUE
, outputFile = "sample.txt.MSD")
expect_equal(readLines(outfile)[141], " 4.0556 0.4658")
testthat::expect_equal(readLines(outfile)[141], " 4.0556 0.4658")
cat("test_Fst.R:\n")
infile <- system.file("extdata", "sample.txt",package="genepop")
locinfile <- "sample.txt"
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('sample.txt')
outfile <- Fst(locinfile,outputFile="sample.txt.FST")
expect_equal(readLines(outfile)[141],
testthat::expect_equal(readLines(outfile)[141],
" All: 0.0225 0.1921 0.2103")
outfile <- Fst(locinfile,pairs=TRUE,outputFile="sample.txt.ST2")
expect_equal(readLines(outfile)[68], "4 0.1514 0.0469 0.2688 ")
testthat::expect_equal(readLines(outfile)[68], "4 0.1514 0.0469 0.2688 ")
outfile <- Fst(locinfile,sizes=TRUE,outputFile="sample.txt.RHO")
expect_equal(readLines(outfile)[153],
testthat::expect_equal(readLines(outfile)[153],
" All: 0.2777 0.3095 0.5013")
outfile <- Fst(locinfile,sizes=TRUE,pairs=TRUE,outputFile="sample.txt.ST2")
expect_equal(readLines(outfile)[80], "4 0.6250 0.2408 0.2812 ")
testthat::expect_equal(readLines(outfile)[80], "4 0.6250 0.2408 0.2812 ")
cat("test_IBD.R:\n")
infile <- system.file("extdata", "w2.txt",package="genepop")
locinfile <- "w2.txt"
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('w2.txt')
outfile <- ibd(locinfile,"w2.txt.ISO", geographicScale = "Log", statistic="e")
if (sessionInfo()[["R.version"]][["arch"]]=="i386") { # i386 vs x64
expect_equal(readLines(outfile)[229], "0.01514 [ -0.0143952 , 0.0374583 ]")
testthat::expect_equal(readLines(outfile)[229], "0.01514 [ -0.0143952 , 0.0374583 ]")
} else testthat::expect_equal(readLines(outfile)[229], "0.01514 [ -0.0143947 , 0.0374584 ]")
infile <- system.file("extdata", "PEL1600withCoord.txt",package="genepop")
locinfile <- "PEL1600withCoord.txt"
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('PEL1600withCoord.txt')
outfile <- ibd(locinfile,"PEL1600withCoord.ISO", statistic = "SingleGeneDiv",
geographicScale = "1D")
nums <- as.numeric(unlist(strsplit(readLines(outfile)[59], "[^0-9e.-]+")))
......
cat("tests_HW.R:\n")
infile <- system.file("extdata", "sample.txt",package="genepop")
locinfile <- "sample.txt"
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('sample.txt')
outfile <- test_HW(locinfile,"deficit","sample.txt.D")
expect_equal(readLines(outfile)[133],
testthat::expect_equal(readLines(outfile)[133],
"ADH-5 1.0000 0.0000 -0.3333 -0.3750 19903 switches")
outfile <- test_HW(locinfile,"global deficit")
expect_equal(readLines(outfile)[48], " 0.3329 0.0048 24797.00")
testthat::expect_equal(readLines(outfile)[48], " 0.3329 0.0048 24797.00")
outfile <- nulls(locinfile, "sample.txt.NUL") ## FR->FR no testthat check !
# Example in Guo & Thompson 1992 Table 5
infile <- system.file("extdata", "Rhesus.txt",package="genepop")
locinfile <- "Rhesus.txt"
check <- file.copy(infile,locinfile,overwrite=TRUE)
locinfile <- genepopExample('Rhesus.txt')
outfile <- HWtable_analysis(locinfile,which="Proba",batches = 1000,iterations = 1000)
expect_equal(readLines(outfile)[21],"P-value=0.684292; S.E=0.00830887 (241565 switches)")
testthat::expect_equal(readLines(outfile)[21],"P-value=0.684292; S.E=0.00830887 (241565 switches)")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment