Skip to content

Commit c5e5d1a

Browse files
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 12697b5 commit c5e5d1a

5 files changed

Lines changed: 22 additions & 16 deletions

File tree

R/buildComponent.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,12 @@ ped2com <- function(ped, component,
235235
verbose_message = "Subsetting adjacency matrix to %d target individuals\n"
236236
) # also need to drop columns here because the adjacency matrix is used in the path tracing and we want to make sure the paths are correct for the target individuals. We will keep all columns for the path tracing but subset to the target rows so that the relatedness values are correct for the target individuals.
237237

238-
if (length(rownames(isPar) > 1)) {
239-
isPar <- isPar[, rownames(isPar), drop = FALSE]
240-
} # else {
241-
# isPar <- isPar[rownames(isPar)]
242-
# }
243-
# isPar <- isPar[, rownames(isPar)] #
238+
if (length(rownames(isPar)) > 1) {
239+
isPar <- isPar[, rownames(isPar), drop = FALSE]
240+
} # else {
241+
# isPar <- isPar[rownames(isPar)]
242+
# }
243+
# isPar <- isPar[, rownames(isPar)] #
244244
}
245245
if (config$sparse == FALSE) {
246246
isPar <- as.matrix(isPar)

R/trimPedigree.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,14 @@ trimPedigree <- function(ped,
230230

231231
# Nullify dangling parent references introduced by removals
232232
if (momID %in% names(ped)) {
233-
ped[[momID]][!as.character(ped[[momID]]) %in% as.character(ped[[personID]])] <- NA
233+
mom_vec <- ped[[momID]]
234+
mom_idx <- !is.na(mom_vec) & !as.character(mom_vec) %in% as.character(ped[[personID]])
235+
ped[[momID]][mom_idx] <- NA
234236
}
235237
if (dadID %in% names(ped)) {
236-
ped[[dadID]][!as.character(ped[[dadID]]) %in% as.character(ped[[personID]])] <- NA
238+
dad_vec <- ped[[dadID]]
239+
dad_idx <- !is.na(dad_vec) & !as.character(dad_vec) %in% as.character(ped[[personID]])
240+
ped[[dadID]][dad_idx] <- NA
237241
}
238242

239243
return(ped)

vignettes/articles/v61_pedigree_model_fitting.Rmd

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ if (has_openmx) {
3030
)
3131
}
3232
33-
run_models <- has_openmx && interactive() && !isTRUE(Sys.getenv("BGMISC_TESTING", unset = FALSE))
33+
bgmisc_testing_env <- Sys.getenv("BGMISC_TESTING", unset = "")
34+
bgmisc_testing <- tolower(bgmisc_testing_env) %in% c("1", "true", "yes")
35+
run_models <- has_openmx && interactive() && !bgmisc_testing
3436
rds_dir <- file.path( "inst/extdata/")
3537
rds_file <- file.path(rds_dir, "fitted_multi.rds")
3638
```
3739

3840
# Introduction
3941

40-
This vignette extends the example from `vignette("v60_pedigree_model_fitting.Rmd", package = "BGmisc")` to show how to fit models to multiple families simultaneously. The key functions are `buildOneFamilyGroup()` and `buildPedigreeMx()`, which translate pedigree data into OpenMx model specifications.
42+
This vignette extends the example from `vignette("v60_pedigree_model_fitting", package = "BGmisc")` to show how to fit models to multiple families simultaneously. The key functions are `buildOneFamilyGroup()` and `buildPedigreeMx()`, which translate pedigree data into OpenMx model specifications.
4143

4244
# Scaling Up to Many Families
4345

@@ -113,9 +115,9 @@ for (i in seq_len(n_families)) {
113115
dimnames = list(NULL, obs_ids_i)
114116
)
115117
116-
rownames(A_i) <- colnames(A_i) <- id_order_i
117-
rownames(Cn_i) <- colnames(Cn_i) <- id_order_i
118-
rownames(Mt_i) <- colnames(Mt_i) <- id_order_i
118+
rownames(A_i) <- colnames(A_i) <- obs_ids_i
119+
rownames(Cn_i) <- colnames(Cn_i) <- obs_ids_i
120+
rownames(Mt_i) <- colnames(Mt_i) <- obs_ids_i
119121
add_list[[i]] <- A_i
120122
cn_list[[i]] <- Cn_i
121123
mt_list[[i]] <- Mt_i

vignettes/v60_pedigree_model_fitting.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The `BGmisc` package provides a complete pipeline for pedigree-based variance co
2626
3. **Build** OpenMx group models with `buildOneFamilyGroup()`
2727
4. **Fit** the combined model with `buildPedigreeMx()` and `mxRun()` (or the wrapper `fitPedigreeModel()`)
2828

29-
This vignette builds up in three parts: a single-family model, a two-family multi-group model, and a scaled-up simulation study. An extension vignette `vignette("v61_pedigree_model_fitting.Rmd", package = "BGmisc")` covers more complex models using squirel data from the Kluane Red Squirrel Project.
29+
This vignette builds up in three parts: a single-family model, a two-family multi-group model, and a scaled-up simulation study. An extension vignette `vignette("v61_pedigree_model_fitting", package = "BGmisc")` covers more complex models using squirrel data from the Kluane Red Squirrel Project.
3030

3131
## Prerequisites
3232

vignettes/v7_trimPedigree.Xmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ ggpedigree(
168168
),
169169
config = list(
170170
overlay_include = TRUE,
171-
status_include = T,
171+
status_include = TRUE,
172172
code_male = 0,
173-
sex_color_include = T,
173+
sex_color_include = TRUE,
174174
overlay_mode = "shape"
175175
)
176176
)

0 commit comments

Comments
 (0)