Skip to content

Commit 52be0b7

Browse files
more hotfixs
fixed more saveable steps, moved generation comonent higher
1 parent 5066814 commit 52be0b7

8 files changed

Lines changed: 30 additions & 20 deletions

File tree

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# BGmisc 1.3.4.1
22
* Hot fix to resolve issue with list of adjacency matrix not loading saved version
3+
* Reoptimized generation calculation
34

45
# BGmisc 1.3.4
56
* Added alternative (and faster) methods to create the adjacency matrix

R/convertPedigree.R

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ ped2com <- function(ped, component,
175175
}
176176
# Garbage collection if gc is TRUE
177177
if (gc) {
178-
rm(parList, lens)
178+
rm(parList, lens,list_of_adjacencies)
179179
gc()
180180
}
181181
}
@@ -278,8 +278,17 @@ ped2com <- function(ped, component,
278278
rm(isPar, newIsPar)
279279
gc()
280280
}
281+
282+
if (component == "generation") { # no need to do the rest
283+
return(gen)
284+
} else {
285+
if (verbose) {
286+
cat("Completed RAM path tracing\n")
287+
}
288+
}
289+
281290
# --- Step 3: I-A inverse times diagonal multiplication ---
282-
if (resume && file.exists(checkpoint_files$final_matrix)) {
291+
if (resume && file.exists(checkpoint_files$r2_checkpoint)) {
283292
if (verbose) cat("Resuming: Loading I-A inverse...\n")
284293
r2 <- readRDS(checkpoint_files$r2_checkpoint)
285294
} else {
@@ -302,15 +311,13 @@ ped2com <- function(ped, component,
302311
if (verbose) cat("Resuming: Loading tcrossprod...\n")
303312
r <- readRDS(checkpoint_files$tcrossprod_checkpoint)
304313
} else {
305-
r <- compute_transpose(r2 = r2, transpose_method = transpose_method, verbose = verbose)
314+
r <- .computeTranspose(r2 = r2, transpose_method = transpose_method, verbose = verbose)
306315
if (saveable) {
307316
saveRDS(r, file = checkpoint_files$tcrossprod_checkpoint)
308317
}
309318
}
310319

311-
if (component == "generation") {
312-
return(gen)
313-
} else {
320+
314321
if (component == "mitochondrial") {
315322
r@x <- rep(1, length(r@x))
316323
# Assign 1 to all nonzero elements for mitochondrial component
@@ -326,7 +333,6 @@ ped2com <- function(ped, component,
326333
saveRDS(r, file = checkpoint_files$final_matrix)
327334
}
328335
return(r)
329-
}
330336
}
331337

332338
#' Take a pedigree and turn it into an additive genetics relatedness matrix
@@ -338,7 +344,7 @@ ped2add <- function(ped, max.gen = 25, sparse = FALSE, verbose = FALSE,
338344
gc = FALSE,
339345
flatten.diag = FALSE, standardize.colnames = TRUE,
340346
transpose_method = "tcrossprod",
341-
adjacency_method = "indexed",
347+
adjacency_method = "direct",
342348
saveable = FALSE,
343349
resume = FALSE,
344350
save_rate = 5,
@@ -377,7 +383,7 @@ ped2mit <- ped2mt <- function(ped, max.gen = 25,
377383
flatten.diag = FALSE,
378384
standardize.colnames = TRUE,
379385
transpose_method = "tcrossprod",
380-
adjacency_method = "indexed",
386+
adjacency_method = "direct",
381387
saveable = FALSE,
382388
resume = FALSE,
383389
save_rate = 5,
@@ -416,6 +422,7 @@ ped2cn <- function(ped, max.gen = 25, sparse = FALSE, verbose = FALSE,
416422
saveable = FALSE,
417423
resume = FALSE,
418424
save_rate = 5,
425+
adjacency_method = "indexed",
419426
save_rate_gen = save_rate,
420427
save_rate_parlist = 1000 * save_rate,
421428
save_path = "checkpoint/",
@@ -427,6 +434,7 @@ ped2cn <- function(ped, max.gen = 25, sparse = FALSE, verbose = FALSE,
427434
verbose = verbose,
428435
gc = gc,
429436
component = "common nuclear",
437+
adjacency_method = adjacency_method,
430438
flatten.diag = flatten.diag,
431439
standardize.colnames = standardize.colnames,
432440
transpose_method = transpose_method,
@@ -453,7 +461,7 @@ ped2ce <- function(ped,
453461
#' @inherit ped2com details
454462
#' @param r2 a relatedness matrix
455463
#'
456-
compute_transpose <- function(r2, transpose_method = "tcrossprod", verbose = FALSE) {
464+
.computeTranspose <- function(r2, transpose_method = "tcrossprod", verbose = FALSE) {
457465
if (!transpose_method %in% c("tcrossprod", "crossprod", "star", "tcross.alt.crossprod", "tcross.alt.star")) {
458466
stop("Invalid method specified. Choose from 'tcrossprod', 'crossprod', or 'star'.")
459467
}

README.Rmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ options(citation.bibtex.max = 0)
2424
[![R-CMD-check](https://github.com/R-Computing-Lab/BGmisc/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/R-Computing-Lab/BGmisc/actions/workflows/R-CMD-check.yaml)
2525
[![Dev Main
2626
branch](https://github.com/R-Computing-Lab/BGmisc/actions/workflows/R-CMD-dev_maincheck.yaml/badge.svg)](https://github.com/R-Computing-Lab/BGmisc/actions/workflows/R-CMD-dev_maincheck.yaml)
27-
[![codecov](https://codecov.io/gh/R-Computing-Lab/BGmisc/graph/badge.svg?token=2IARK2XSA6)](https://app.codecov.io/gh/R-Computing-Lab/BGmisc)
27+
[![Codecov test coverage](https://codecov.io/gh/R-Computing-Lab/BGmisc/graph/badge.svg?token=2IARK2XSA6)](https://app.codecov.io/gh/R-Computing-Lab/BGmisc)
2828
![License](https://img.shields.io/badge/License-GPL_v3-blue.svg)
29-
[![Codecov test coverage](https://codecov.io/gh/R-Computing-Lab/BGmisc/graph/badge.svg)](https://app.codecov.io/gh/R-Computing-Lab/BGmisc)
3029
<!-- badges: end -->
3130

3231
The BGmisc R package offers a comprehensive suite of functions tailored for extended behavior genetics analysis, including model identification, calculating relatedness, pedigree conversion, pedigree simulation, and more.

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ downloads](https://cranlogs.r-pkg.org/badges/grand-total/BGmisc)](https://cran.r
1616
[![R-CMD-check](https://github.com/R-Computing-Lab/BGmisc/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/R-Computing-Lab/BGmisc/actions/workflows/R-CMD-check.yaml)
1717
[![Dev Main
1818
branch](https://github.com/R-Computing-Lab/BGmisc/actions/workflows/R-CMD-dev_maincheck.yaml/badge.svg)](https://github.com/R-Computing-Lab/BGmisc/actions/workflows/R-CMD-dev_maincheck.yaml)
19-
[![codecov](https://codecov.io/gh/R-Computing-Lab/BGmisc/graph/badge.svg?token=2IARK2XSA6)](https://app.codecov.io/gh/R-Computing-Lab/BGmisc)
20-
![License](https://img.shields.io/badge/License-GPL_v3-blue.svg)
2119
[![Codecov test
22-
coverage](https://codecov.io/gh/R-Computing-Lab/BGmisc/graph/badge.svg)](https://app.codecov.io/gh/R-Computing-Lab/BGmisc)
20+
coverage](https://codecov.io/gh/R-Computing-Lab/BGmisc/graph/badge.svg?token=2IARK2XSA6)](https://app.codecov.io/gh/R-Computing-Lab/BGmisc)
21+
![License](https://img.shields.io/badge/License-GPL_v3-blue.svg)
2322
<!-- badges: end -->
2423

2524
The BGmisc R package offers a comprehensive suite of functions tailored
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ped2add.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ped2cn.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ped2mit.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)