Skip to content

Commit e6c4648

Browse files
Merge pull request #43 from R-Computing-Lab/dev_main
changed test to hopefully pass
2 parents 965bf0d + 6d2865b commit e6c4648

7 files changed

Lines changed: 143 additions & 124 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: BGmisc
22
Title: An R Package for Extended Behavior Genetics Analysis
3-
Version: 1.3.1
3+
Version: 1.3.1.1
44
Authors@R: c(
55
person("S. Mason", "Garrison", , email= "garrissm@wfu.edu", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0002-4804-6003")),

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# BGmisc 1.3.1.1
22
* Added some more tests of identifyModel.R
3+
* Modified tests to be MKL friendly
34

45
# BGmisc 1.3.1
56
* Confirmed that all orcids are correct

cran-comments.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11

22
# Description
33

4-
This update removes an invalid ORCID iD that was included in the package.
5-
Thanks Kurt Hornik for pointing it out to me! I'm also using this as an excuse to push the current version of the package. It also adds a new function to import GEDCOM files, among other fun things we're presenting at BGA at the end of June.
4+
This update tweaks how one test is handled for the MKL check. ( https://www.stats.ox.ac.uk/pub/bdr/Rblas/MKL/BGmisc.out ) We have changed the test from expect_true(all(diag(add) == 1)) to expect_true(sum((diag(add) - 1)^2) < 1e-10). This test should work on all platforms. While we were at it, we also allowed some of the expect_equal tests to have a tolerance of 1e-10.
5+
6+
67

78
# Test Environments
89

9-
1. Local OS: Windows 11 x64 (build 22635), R version 4.4.0 (2024-04-24 ucrt)
10+
1. Local OS: Windows 11 x64 (build 22635), R version 4.4.1 (2024-06-14 ucrt)
1011
2. **GitHub Actions**:
11-
- [Link](https://github.com/R-Computing-Lab/BGmisc/actions/runs/9537687414)
12+
- [Link](https://github.com/R-Computing-Lab/BGmisc/actions/runs/9555870410)
1213
- macOS (latest version) with the latest R release.
1314
- Windows (latest version) with the latest R release.
1415
- Ubuntu (latest version) with:
@@ -18,9 +19,9 @@ Thanks Kurt Hornik for pointing it out to me! I'm also using this as an excuse t
1819

1920
## R CMD check results
2021

21-
── R CMD check ────────────────────────────────────────────────
22-
─ using log directory 'E:/Dropbox/Lab/Research/Projects/2024/BGMiscJoss/BGmisc.Rcheck'
23-
─ using R version 4.4.0 (2024-04-24 ucrt)
22+
── R CMD check ────────────────────────────────────────
23+
─ using log directory 'E:/Dropbox/Lab/Research/Projects/2024/BGMiscJoss/BGmisc.Rcheck' (719ms)
24+
─ using R version 4.4.1 (2024-06-14 ucrt)
2425
─ using platform: x86_64-w64-mingw32
2526
─ R was compiled by
2627
gcc.exe (GCC) 13.2.0
@@ -29,11 +30,11 @@ Thanks Kurt Hornik for pointing it out to me! I'm also using this as an excuse t
2930
─ using session charset: UTF-8
3031
─ using options '--no-manual --as-cran'
3132
✔ checking for file 'BGmisc/DESCRIPTION'
32-
─ this is package 'BGmisc' version '1.3.1'
33+
─ this is package 'BGmisc' version '1.3.1.1'
3334
─ package encoding: UTF-8
3435
.... boring stuff
35-
── R CMD check results ────────────────────── BGmisc 1.3.1 ────
36-
Duration: 50.9s
36+
── R CMD check results ──────────── BGmisc 1.3.1.1 ────
37+
Duration: 54s
3738

3839
0 errors ✔ | 0 warnings ✔ | 0 notes ✔
3940

tests/testthat/test-identifyModel.R

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,3 @@ test_that("comp2vech handles lists correctly", {
7979
expect_length(comp2vech(list_input, include.zeros = TRUE), 10) # Adjust based on expected vector length
8080
})
8181

82-
83-
# Test for incorrect input types in comp2vech
84-
test_that("comp2vech handles incorrect input types", {
85-
expect_error(comp2vech("some non-matrix input"), "x is neither a list nor a matrix")
86-
})

tests/testthat/test-networks.R

Lines changed: 69 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ test_that("ped2graph produces a graph for inbreeding data", {
3535

3636

3737
test_that("ped2add produces correct matrix dims, values, and dimnames for hazard", {
38+
tolerance <- 1e-10
3839
data(hazard)
3940
add <- ped2add(hazard)
4041
# Check dimension
4142
expect_equal(dim(add), c(nrow(hazard), nrow(hazard)))
4243
# Check several values
43-
expect_true(all(diag(add) == 1))
44+
#expect_true(all(diag(add) == 1))
45+
expect_true(sum((diag(add) - 1)^2) < tolerance)
4446
expect_equal(add, t(add))
4547
expect_equal(add[2, 1], 0)
4648
expect_equal(add[10, 1], .25)
@@ -53,16 +55,18 @@ test_that("ped2add produces correct matrix dims, values, and dimnames for hazard
5355
})
5456

5557
test_that("ped2add produces correct matrix dims, values, and dimnames for alternative transpose", {
58+
tolerance <- 1e-10
5659
data(hazard)
5760
add <- ped2add(hazard, tcross.alt.crossprod = TRUE)
5861
# Check dimension
59-
expect_equal(dim(add), c(nrow(hazard), nrow(hazard)))
62+
expect_equal(dim(add), c(nrow(hazard), nrow(hazard)),tolerance = tolerance)
6063
# Check several values
61-
expect_true(all(diag(add) == 1))
62-
expect_equal(add, t(add))
63-
expect_equal(add[2, 1], 0)
64-
expect_equal(add[10, 1], .25)
65-
expect_equal(add[9, 1], 0)
64+
#expect_true(all(diag(add) == 1))
65+
expect_true(sum((diag(add) - 1)^2) < tolerance)
66+
expect_equal(add, t(add),tolerance = tolerance)
67+
expect_equal(add[2, 1], 0,tolerance = tolerance)
68+
expect_equal(add[10, 1], .25,tolerance = tolerance)
69+
expect_equal(add[9, 1], 0,tolerance = tolerance)
6670
expect_equal(add["5", "6"], .5)
6771
# Check that dimnames are correct
6872
dn <- dimnames(add)
@@ -72,16 +76,17 @@ test_that("ped2add produces correct matrix dims, values, and dimnames for altern
7276
# to do, combine the sets that are equalivant. shouldn't need to run 1000 expect equals
7377

7478
test_that("ped2add produces correct matrix dims, values, and dimnames for inbreeding data", {
79+
tolerance <- 1e-10
7580
data(inbreeding)
7681
add <- ped2add(inbreeding)
7782
# Check dimension
78-
expect_equal(dim(add), c(nrow(inbreeding), nrow(inbreeding)))
83+
expect_equal(dim(add), c(nrow(inbreeding), nrow(inbreeding)),tolerance = tolerance)
7984
# Check several values
80-
expect_true(all(diag(add) >= 1))
81-
expect_equal(add, t(add))
82-
expect_equal(add[2, 1], 0)
83-
expect_equal(add[6, 1], .5)
84-
expect_equal(add[113, 113], 1.1250)
85+
expect_true(all(diag(add) >= 1-tolerance))
86+
expect_equal(add, t(add),tolerance = tolerance)
87+
expect_equal(add[2, 1], 0,tolerance = tolerance)
88+
expect_equal(add[6, 1], .5,tolerance = tolerance)
89+
expect_equal(add[113, 113], 1.1250,tolerance = tolerance)
8590
expect_equal(add["113", "112"], 0.62500)
8691
# Check that dimnames are correct
8792
dn <- dimnames(add)
@@ -91,89 +96,99 @@ test_that("ped2add produces correct matrix dims, values, and dimnames for inbree
9196

9297

9398
test_that("ped2add produces correct matrix dims, values, and dimnames for inbreeding data with alternative transpose", {
99+
tolerance <- 1e-10
94100
data(inbreeding)
95101
add <- ped2add(inbreeding, tcross.alt.star = TRUE)
96102
# Check dimension
97103
expect_equal(dim(add), c(nrow(inbreeding), nrow(inbreeding)))
98104
# Check several values
99105
expect_true(all(diag(add) >= 1))
100-
expect_equal(add, t(add))
101-
expect_equal(add[2, 1], 0)
102-
expect_equal(add[6, 1], .5)
103-
expect_equal(add[113, 113], 1.1250)
106+
expect_equal(add, t(add), tolerance = tolerance)
107+
expect_equal(add[2, 1], 0, tolerance = tolerance)
108+
expect_equal(add[6, 1], .5, tolerance = tolerance)
109+
expect_equal(add[113, 113], 1.1250, tolerance = tolerance)
104110
expect_equal(add["113", "112"], 0.62500)
105111
# Check that dimnames are correct
106112
dn <- dimnames(add)
107113
expect_equal(dn[[1]], dn[[2]])
108114
expect_equal(dn[[1]], as.character(inbreeding$ID))
109115
})
110116
test_that("ped2add flattens diagonal for inbreeding data", {
117+
tolerance <- 1e-10
111118
data(inbreeding)
112119
add <- ped2add(inbreeding, flatten.diag = TRUE)
113120
# Check dimension
114-
expect_equal(dim(add), c(nrow(inbreeding), nrow(inbreeding)))
121+
expect_equal(dim(add), c(nrow(inbreeding), nrow(inbreeding)), tolerance = tolerance)
115122
# Check several values
116-
expect_true(all(diag(add) == 1))
117-
expect_equal(add, t(add))
118-
expect_equal(add[2, 1], 0)
119-
expect_equal(add[6, 1], .5)
120-
expect_equal(add[113, 113], 1)
123+
# expect_true(all(diag(add) == 1))
124+
expect_true(sum((diag(add) - 1)^2) < tolerance)
125+
expect_equal(add, t(add), tolerance = tolerance)
126+
expect_equal(add[2, 1], 0, tolerance = tolerance)
127+
expect_equal(add[6, 1], .5, tolerance = tolerance)
128+
expect_equal(add[113, 113], 1, tolerance = tolerance)
121129
expect_equal(add["113", "112"], 0.62500)
122130
# Check that dimnames are correct
123131
dn <- dimnames(add)
124132
expect_equal(dn[[1]], dn[[2]])
125133
expect_equal(dn[[1]], as.character(inbreeding$ID))
126134
})
127135
test_that("ped2mit produces correct matrix dims, values, and dimnames for inbreeding", {
136+
tolerance <- 1e-10
128137
# Check dimension
129138
data(inbreeding)
130139
mit <- ped2mit(inbreeding)
131140
# Check dimension
132141
expect_equal(dim(mit), c(nrow(inbreeding), nrow(inbreeding)))
133142
# Check several values
134-
expect_true(all(diag(mit) == 1))
135-
expect_equal(mit, t(mit))
136-
expect_equal(mit[2, 1], 0)
137-
expect_equal(mit[6, 1], 1)
138-
expect_equal(mit[113, 113], 1)
139-
expect_equal(mit["113", "112"], 1)
143+
# expect_true(all(diag(mit) == 1))
144+
expect_true(sum((diag(mit) - 1)^2) < tolerance)
145+
expect_equal(mit, t(mit), tolerance = tolerance)
146+
expect_equal(mit[2, 1], 0, tolerance = tolerance)
147+
expect_equal(mit[6, 1], 1, tolerance = tolerance)
148+
expect_equal(mit[113, 113], 1, tolerance = tolerance)
149+
expect_equal(mit["113", "112"], 1, tolerance = tolerance)
140150
# Check that dimnames are correct
141151
dn <- dimnames(mit)
142152
expect_equal(dn[[1]], dn[[2]])
143153
expect_equal(dn[[1]], as.character(inbreeding$ID))
144154
})
145155

146156
test_that("ped2mit produces correct matrix dims, values, and dimnames for inbreeding", {
157+
tolerance <- 1e-10
147158
# Check dimension
148159
data(inbreeding)
149160
mit <- ped2mit(inbreeding)
150161
# Check dimension
151-
expect_equal(dim(mit), c(nrow(inbreeding), nrow(inbreeding)))
162+
expect_equal(dim(mit), c(nrow(inbreeding), nrow(inbreeding)), tolerance = tolerance)
152163
# Check several values
153-
expect_true(all(diag(mit) == 1))
154-
expect_equal(mit, t(mit))
155-
expect_equal(mit[2, 1], 0)
156-
expect_equal(mit[6, 1], 1)
157-
expect_equal(mit[113, 113], 1)
158-
expect_equal(mit["113", "112"], 1)
164+
# expect_true(all(diag(mit) == 1))
165+
expect_true(sum((diag(mit) - 1)^2) < tolerance)
166+
expect_equal(mit, t(mit), tolerance = tolerance)
167+
expect_equal(mit[2, 1], 0, tolerance = tolerance)
168+
expect_equal(mit[6, 1], 1, tolerance = tolerance)
169+
expect_equal(mit[113, 113], 1, tolerance = tolerance)
170+
expect_equal(mit["113", "112"], 1, tolerance = tolerance)
159171
# Check that dimnames are correct
160172
dn <- dimnames(mit)
161173
expect_equal(dn[[1]], dn[[2]])
162174
expect_equal(dn[[1]], as.character(inbreeding$ID))
163175
})
164176

165177
test_that("ped2cn produces correct matrix dims, values, and dimnames", {
166-
# # Check dimension
178+
tolerance <- 1e-10
179+
180+
# Check dimension
167181
data(inbreeding)
168182
cn <- ped2cn(inbreeding)
169-
expect_equal(dim(cn), c(nrow(inbreeding), nrow(inbreeding)))
183+
expect_equal(dim(cn), c(nrow(inbreeding), nrow(inbreeding)), tolerance = tolerance)
170184
# Check several values
171-
expect_true(all(diag(cn) == 1))
172-
expect_equal(cn, t(cn))
173-
expect_equal(cn[2, 1], 0)
174-
expect_equal(cn[6, 1], 0)
175-
expect_equal(cn[113, 113], 1)
176-
expect_equal(cn["113", "112"], 1)
185+
# expect_true(all(diag(cn) == 1))
186+
expect_true(sum((diag(cn) - 1)^2) < tolerance)
187+
expect_equal(cn, t(cn), tolerance = tolerance)
188+
expect_equal(cn[2, 1], 0, tolerance = tolerance)
189+
expect_equal(cn[6, 1], 0, tolerance = tolerance)
190+
expect_equal(cn[113, 113], 1, tolerance = tolerance)
191+
expect_equal(cn["113", "112"], 1, tolerance = tolerance)
177192
# Check that dimnames are correct
178193
dn <- dimnames(cn)
179194
expect_equal(dn[[1]], dn[[2]])
@@ -182,16 +197,18 @@ test_that("ped2cn produces correct matrix dims, values, and dimnames", {
182197
})
183198

184199
test_that("ped2ce produces correct matrix dims, values, and dimnames", {
200+
tolerance <- 1e-10
185201
data(inbreeding)
186202
ce <- ped2ce(inbreeding)
187-
expect_equal(dim(ce), c(nrow(inbreeding), nrow(inbreeding)))
203+
expect_equal(dim(ce), c(nrow(inbreeding), nrow(inbreeding)), tolerance = tolerance)
188204
# Check several values
189-
expect_true(all(diag(ce) == 1))
190-
expect_equal(ce, t(ce))
191-
expect_equal(ce[2, 1], 1)
192-
expect_equal(ce[6, 1], 1)
193-
expect_equal(ce[113, 113], 1)
194-
expect_equal(ce["113", "112"], 1)
205+
# expect_true(all(diag(ce) == 1))
206+
expect_true(sum((diag(ce) - 1)^2) < tolerance)
207+
expect_equal(ce, t(ce), tolerance = tolerance)
208+
expect_equal(ce[2, 1], 1, tolerance = tolerance)
209+
expect_equal(ce[6, 1], 1, tolerance = tolerance)
210+
expect_equal(ce[113, 113], 1, tolerance = tolerance)
211+
expect_equal(ce["113", "112"], 1, tolerance = tolerance)
195212
# Check that dimnames are correct
196213
dn <- dimnames(ce)
197214
expect_equal(dn[[1]], dn[[2]])
@@ -207,6 +224,7 @@ test_that("ped2add verbose prints updates", {
207224

208225
test_that("ped2maternal/paternal produces correct matrix dims", {
209226
data(hazard)
227+
tolerance <- 1e-10
210228
mat <- ped2maternal(hazard)
211229
expect_equal(dim(mat), c(nrow(hazard), ncol(hazard) + 1))
212230
data(hazard)

vignettes/analyticrelatedness.html

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -343,20 +343,22 @@ <h1 class="title toc-ignore">Calculating and Inferring Relatedness
343343

344344
<div id="introduction" class="section level1">
345345
<h1>Introduction</h1>
346-
<p>This vignette focuses on the calculation and inference of relatedness
347-
coefficients using the <code>BGmisc</code> package. The relatedness
348-
coefficient is a measure of the genetic relationship between two
349-
individuals. Here, we introduce two functions:
350-
<code>calculateRelatedness</code> and <code>inferRelatedness</code>,
351-
which allow users to compute and infer the relatedness coefficient
352-
respectively.</p>
346+
<p>This vignette demonstrates analytic methods for determining
347+
relatedness in a pedigree. The relatedness coefficient is a measure of
348+
the genetic overlap between two individuals. In the simplest terms, it
349+
quantifies the genetic overlap between two individuals. The relatedness
350+
coefficient ranges from 0 to 1, with 1 indicating a perfect genetic
351+
match (which occurs when comparing an individual to themselves, their
352+
identical twin, or their clone), whereas 0 indicates no genetic overlap.
353+
We introduce two functions: <code>calculateRelatedness</code> and
354+
<code>inferRelatedness</code>, which allow users to compute and infer
355+
the relatedness coefficient, respectively.</p>
353356
<div id="loading-required-libraries" class="section level2">
354357
<h2>Loading Required Libraries</h2>
355358
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a><span class="fu">library</span>(BGmisc)</span></code></pre></div>
356359
</div>
357-
</div>
358-
<div id="calculating-relatedness-coefficient" class="section level1">
359-
<h1>Calculating Relatedness Coefficient</h1>
360+
<div id="calculating-relatedness-coefficient" class="section level2">
361+
<h2>Calculating Relatedness Coefficient</h2>
360362
<p>The <code>calculateRelatedness</code> function offers a method to
361363
compute the relatedness coefficient based on shared ancestry, as
362364
described by Wright (1922). This function utilizes the formula:</p>
@@ -373,12 +375,14 @@ <h1>Calculating Relatedness Coefficient</h1>
373375
<span id="cb3-2"><a href="#cb3-2" tabindex="-1"></a><span class="fu">calculateRelatedness</span>(<span class="at">generations =</span> <span class="dv">1</span>, <span class="at">full =</span> <span class="cn">FALSE</span>)</span>
374376
<span id="cb3-3"><a href="#cb3-3" tabindex="-1"></a><span class="co">#&gt; [1] 0.25</span></span></code></pre></div>
375377
</div>
378+
</div>
376379
<div id="inferring-relatedness-coefficient" class="section level1">
377380
<h1>Inferring Relatedness Coefficient</h1>
378381
<p>The <code>inferRelatedness</code> function is designed to infer the
379382
relatedness coefficient between two groups based on the observed
380383
correlation between their additive genetic variance and shared
381-
environmental variance. This function leverages the ACE framework.</p>
384+
environmental variance. This function leverages the <code>ACE</code>
385+
framework.</p>
382386
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" tabindex="-1"></a><span class="co"># Example usage:</span></span>
383387
<span id="cb4-2"><a href="#cb4-2" tabindex="-1"></a><span class="co"># Infer the relatedness coefficient:</span></span>
384388
<span id="cb4-3"><a href="#cb4-3" tabindex="-1"></a><span class="fu">inferRelatedness</span>(<span class="at">obsR =</span> <span class="fl">0.5</span>, <span class="at">aceA =</span> <span class="fl">0.9</span>, <span class="at">aceC =</span> <span class="dv">0</span>, <span class="at">sharedC =</span> <span class="dv">0</span>)</span>

0 commit comments

Comments
 (0)