From ae6e9a7dcd46541e500a4b634b2744a5fa0b3986 Mon Sep 17 00:00:00 2001
From: Voorrips <roeland.voorrips@wur.nl>
Date: Tue, 30 Jun 2020 15:18:27 +0200
Subject: [PATCH] minor changes in DESCRIPTION, testthat, vignette until
 20200114

---
 DESCRIPTION                                  |  4 +--
 tests/testthat/test_1_supporting_functions.R | 34 ++++++++++++++++++++
 vignettes/PolyHaplotyper-vignette.Rmd        |  8 ++---
 3 files changed, 40 insertions(+), 6 deletions(-)
 create mode 100644 tests/testthat/test_1_supporting_functions.R

diff --git a/DESCRIPTION b/DESCRIPTION
index 7483e2c..0d29cd4 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
 Package: PolyHaplotyper
 Type: Package
 Title: Assignment of Haplotypes Based on SNP Dosages in Diploids and Polyploids
-Version: 0.2.1
+Version: 0.2.2
 Author: Roeland E. Voorrips
 Maintainer: Roeland E. Voorrips <roeland.voorrips@wur.nl>
 Description: Infer the genetic composition of individuals
@@ -10,7 +10,7 @@ Description: Infer the genetic composition of individuals
 License: GPL-2
 Encoding: UTF-8
 LazyData: true
-RoxygenNote: 6.0.1
+RoxygenNote: 7.0.2
 Suggests: knitr,
     rmarkdown
 VignetteBuilder: knitr
diff --git a/tests/testthat/test_1_supporting_functions.R b/tests/testthat/test_1_supporting_functions.R
new file mode 100644
index 0000000..3f25f81
--- /dev/null
+++ b/tests/testthat/test_1_supporting_functions.R
@@ -0,0 +1,34 @@
+context("tests of supporting functions")
+
+wd <- getwd()
+#wd <- setwd("m:/Polyploids/PolyHaplotyper/data")
+
+test_that("load the demo data") {
+  result <- data(demo)
+  #result <- load("demo.RData")
+  expect_equal(result, c("snpdos", "ped"))
+  expect_equal(dim(snpdos), c(28, 661))
+  expect_equal(names(ped), c("genotype", "mother", "father", "sample_nr"))
+}
+
+test_that("test several functions") {
+  result <- allHaplotypes(mrknames=letters[1:4])
+  expect_equal(dim(result), c(16, 4))
+  expect_true(all(result[nrow(result),] == 1))
+  expect_equal(result[1:2, ncol(result)], c(0, 1))
+  result <- mrkdos2mrkdid(
+    mrkDosage=matrix(c(1,2,3,4,4,3,2,1), ncol=2,
+                     dimnames=list(letters[1:4], c("ind1", "ind2"))),
+    ploidy=4)
+  expect_equal(result, c(195, 587))
+  parhac <- matrix(c(1,1,2,2,5,6,1,1,1,1,1,3), ncol=2,
+                   dimnames=list(NULL, c("P1", "P2")))
+  result <- getF1freqs(parhac=parhac, nhap=8, DRrate=0.1)
+  expect_equal(names(result), c("F1hac", "freq"))
+  expect_equal(dim(result$F1hac), c(6, 54))
+  expect_equal(sum(result$freq), 1, tolerance=1e-6)
+}
+
+test_that("inferHaplotypes without F1 populations") {
+
+}
diff --git a/vignettes/PolyHaplotyper-vignette.Rmd b/vignettes/PolyHaplotyper-vignette.Rmd
index d446f3b..fbbc739 100644
--- a/vignettes/PolyHaplotyper-vignette.Rmd
+++ b/vignettes/PolyHaplotyper-vignette.Rmd
@@ -6,7 +6,7 @@ output: rmarkdown::html_vignette
 vignette: >
   %\VignetteIndexEntry{PolyHaplotyper vignette}
   %\VignetteEngine{knitr::rmarkdown}
-  %\VignetteEncoding{UTF-8}
+  \usepackage[utf8]{inputenc}
 ---
 
 This vignette shows how to use the main functions provided in PolyHaplotyper and 
@@ -68,7 +68,7 @@ may be missing (NA) but individuals may not, and there may not be more
 than one line for the same individual.
 Additional columns may be present. In our case ped has a fourth column 
 containing the sample nr:
-```{r echo=FALSE}
+```{r}
 head(ped)
 ```
 Several individuals are represented by more than one line, because here the
@@ -151,8 +151,8 @@ sapply(hblist, length)
 This small example has data for 7 haploblocks, each with 4 markers.
 
 ## F1 populations
-Finally we specify the four F1 populations and their parents (note that the
-father of population 1 and 4 is the same individual):
+Finally we specify the four F1 populations and their parents (note that 
+individual 39287 is the father of two F1 populations):
 ```{r}
 parents <- cbind(c(36451, 41234, 9656, 32141),
                  c(39287, 40360, 9541, 39287))
-- 
GitLab