From c53c4cae46bc4d197b21aa8022e41fc6bbb7ee97 Mon Sep 17 00:00:00 2001 From: Mason Garrison Date: Sat, 28 Mar 2026 16:53:14 -0400 Subject: [PATCH 01/11] Update _pkgdown.yml --- _pkgdown.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_pkgdown.yml b/_pkgdown.yml index cc6460d3..3015a1c5 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,4 +1,4 @@ +url: https://r-computing-lab.github.io/BGmisc/ template: bootstrap: 5 light-switch: false -url: https://R-Computing-Lab.github.io/BGmisc From f0d3ab3cb4d77b9db8c8f4792f192e7103474b5e Mon Sep 17 00:00:00 2001 From: Mason Garrison Date: Fri, 3 Apr 2026 17:19:42 -0400 Subject: [PATCH 02/11] ce --- NEWS.md | 2 ++ R/segmentPedigree.R | 31 ++++++++++++++++++++--- man/ped2fam.Rd | 3 +++ vignettes/articles/tutorialmanuscript.Xmd | 14 +++++----- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/NEWS.md b/NEWS.md index 60caf000..5e3afbc2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ * Optimized sliceFamilies to be more abstract * Created `.require_openmx()` to make it easier to use OpenMx functions without making OpenMx a dependency +* Smarter string ID handling for ped2id + # BGmisc 1.7.0.0 * Fixed bug in parList diff --git a/R/segmentPedigree.R b/R/segmentPedigree.R index d74abfb3..8bc6d5bc 100644 --- a/R/segmentPedigree.R +++ b/R/segmentPedigree.R @@ -11,6 +11,7 @@ #' @param dadID character. Name of the column in ped for the father ID variable #' @param famID character. Name of the column to be created in ped for the family ID variable #' @param twinID character. Name of the column in ped for the twin ID variable, if applicable +#' @param overwrite logical. If TRUE, will overwrite existing famID variable if it exists. Default is TRUE. #' @param ... additional arguments to be passed to \code{\link{ped2com}} #' @details #' The general idea of this function is to use person ID, mother ID, and father ID to @@ -31,18 +32,20 @@ ped2fam <- function(ped, personID = "ID", momID = "momID", dadID = "dadID", famID = "famID", twinID = "twinID", + overwrite = TRUE, ...) { # Call to wrapper function .ped2id( ped = ped, personID = personID, momID = momID, dadID = dadID, famID = famID, twinID = twinID, - type = "parents" + type = "parents", + overwrite = overwrite ) } .ped2id <- function(ped, personID = "ID", momID = "momID", dadID = "dadID", famID = "famID", twinID = "twinID", - type, + type, overwrite = TRUE, ...) { # Turn pedigree into family pg <- ped2graph( @@ -55,16 +58,23 @@ ped2fam <- function(ped, personID = "ID", # Create famID data.frame # Convert IDs to numeric, with warning if coercion collapses IDs + uniques <- suppressWarnings(unique(as.numeric(names(wcc$membership)))) + keep_string <- FALSE if (length(uniques) == 1L && is.na(uniques)) { warning("After converting IDs to numeric, all IDs became NA. This indicates ID coercion collapsed IDs. Please ensure IDs aren't character or factor variables.") - + keep_string <- TRUE + } else if (length(uniques) < length(wcc$membership)) { + warning("After converting IDs to numeric, some IDs became NA. This indicates ID coercion collapsed some IDs. Please ensure IDs aren't character or factor variables.") + keep_string <- TRUE +} +if(keep_string==TRUE) { fam <- data.frame( V1 = names(wcc$membership), V2 = wcc$membership ) - } else { + } else { fam <- data.frame( V1 = as.numeric(names(wcc$membership)), V2 = wcc$membership @@ -72,6 +82,19 @@ ped2fam <- function(ped, personID = "ID", } names(fam) <- c(personID, famID) + + if(famID %in% names(ped)) { + if(overwrite) { + overwrite_message <- "be overwritten." + ped[[famID]] <- NULL + } else { + overwrite_message <- "not be overwritten." + } + + warning(sprintf("The famID variable '%s' already exists in the pedigree. The existing variable will %s", famID, overwrite_message)) + + } + ped2 <- merge(fam, ped, by = personID, all.x = FALSE, all.y = TRUE ) diff --git a/man/ped2fam.Rd b/man/ped2fam.Rd index b3cf1e07..d49c7d48 100644 --- a/man/ped2fam.Rd +++ b/man/ped2fam.Rd @@ -11,6 +11,7 @@ ped2fam( dadID = "dadID", famID = "famID", twinID = "twinID", + overwrite = TRUE, ... ) } @@ -27,6 +28,8 @@ ped2fam( \item{twinID}{character. Name of the column in ped for the twin ID variable, if applicable} +\item{overwrite}{logical. If TRUE, will overwrite existing famID variable if it exists. Default is TRUE.} + \item{...}{additional arguments to be passed to \code{\link{ped2com}}} } \value{ diff --git a/vignettes/articles/tutorialmanuscript.Xmd b/vignettes/articles/tutorialmanuscript.Xmd index 9deb99fc..6b756a27 100644 --- a/vignettes/articles/tutorialmanuscript.Xmd +++ b/vignettes/articles/tutorialmanuscript.Xmd @@ -7,7 +7,7 @@ author: corresponding: true email: "garrissm@wfu.edu" abstract: | - Twin studies remain the dominant design in behavior genetics, yet most twin half-siblings, cousins, and multi-generational relatives whose distinct kinship coefficients jointly identify a richer set of variance components than any MZ/DZ comparison alone. We demonstrate how to fit extended pedigree models using the BGmisc package and OpenMx. + Twin studies remain the dominant design in behavior genetics, yet most twin half-siblings, cousins, and multi-generational relatives whose distinct kinship coefficients jointly identify a richer set of variance components than any MZ/DZ comparison alone. We demonstrate how to fit extended pedigree models using the BGmisc package and OpenMx. We apply the extended pedigree model to mutiple datasets of Youth (a large human panel study with researcher-linked kinship), the Kluane Red Squirrel Project (a multi-generational animal field study), and a children-of-twins dataset. @@ -31,8 +31,8 @@ vignette: > %\VignetteIndexEntry{Extended Family Modeling with BGmisc} %\VignetteEncoding{UTF-8} %\VignetteEngine{knitr::rmarkdown} -editor_options: - markdown: +editor_options: + markdown: wrap: 100 --- @@ -65,7 +65,7 @@ studies, either intentionally (e.g., twin registries that also include siblings byproduct of large panel studies (e.g., the National Longitudinal Survey of Youth, which includes researcher-linked kinship). In most cases, the additional relatives are excluded from analysis, and the twin design is applied to a subset of the data, even though these relatives carry independent -information about the genetic and environmental architecture of the phenotype. +information about the genetic and environmental architecture of the phenotype. For example, many of the twin registries reviewed in FOO, include triplets, sibles, children, parents. https://helda.helsinki.fi/server/api/core/bitstreams/f0b6dc08-69df-449e-a8fe-e2c78abf7f60/content The extended pedigree model, which we have introduced elsewhere (see ETC), leverages the full range of kinship coefficients in a pedigree to identify a richer set of variance components than the @@ -87,15 +87,15 @@ value provides independent leverage for disentangling genetic from environmental the number of distinct kinship types increases, so does the number of identifiable variance components. -Extended pedigree designs have been used in behavior genetics since at least the 1970s [@eaves1978; @fulker_multiple_1988], but they have remained a minority practice. Partially over concerns about model identification and power (Wilson, 1982, 1989), the complexity of fitting these models, and the relative costs of collecting twin data compared to extended family data. +Extended pedigree designs have been used in behavior genetics since at least the 1970s [@eaves1978; @fulker_multiple_1988], but they have remained a minority practice. Partially over concerns about model identification and power (Wilson, 1982, 1989), the complexity of fitting these models, and the relative costs of collecting twin data compared to extended family data. - but also because the twin design has been so successful and widely adopted. The twin design is often seen as the "gold standard" in behavior genetics, and many researchers may be hesitant to deviate from this established approach. Additionally, many human datasets simply do not include the necessary family structure to fit extended pedigree models, which may limit their applicability in certain contexts. Date: Wed, 8 Apr 2026 19:01:31 -0400 Subject: [PATCH 03/11] Subset matrices to smallest in com2links com2links now selects the smallest provided relationship matrix (by column count) as the ID guide, extracts IDs from it, and subsets any larger matrices to that ID set and ordering. Adds error checks when no matrices or IDs are available and emits verbose messages when subsetting. Includes unit tests covering mismatched-dimension scenarios and updates NEWS.md to document the fix. --- NEWS.md | 2 +- R/makeLinks.R | 45 ++++++++++++++----- tests/testthat/test-makeLinks.R | 79 +++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 12 deletions(-) diff --git a/NEWS.md b/NEWS.md index 5e3afbc2..28714a53 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,7 +5,7 @@ * Optimized sliceFamilies to be more abstract * Created `.require_openmx()` to make it easier to use OpenMx functions without making OpenMx a dependency * Smarter string ID handling for ped2id - +* fixed how different sized matrixes are handled by build links # BGmisc 1.7.0.0 * Fixed bug in parList diff --git a/R/makeLinks.R b/R/makeLinks.R index cc9aef1b..97abb654 100644 --- a/R/makeLinks.R +++ b/R/makeLinks.R @@ -79,22 +79,45 @@ com2links <- function( # Extract individual IDs from the first available matrix. ids <- NULL + # Find the smallest matrix by ncol (avoids extracting IDs from large matrices). + mat_refs <- list() + if (!is.null(ad_ped_matrix)) mat_refs[["ad"]] <- ncol(ad_ped_matrix) + if (!is.null(mit_ped_matrix)) mat_refs[["mt"]] <- ncol(mit_ped_matrix) + if (!is.null(cn_ped_matrix)) mat_refs[["cn"]] <- ncol(cn_ped_matrix) + + if (length(mat_refs) == 0L) { + stop("At least one relationship matrix must be provided.") + } + smallest <- names(which.min(unlist(mat_refs))) + guide_mat <- switch(smallest, + ad = ad_ped_matrix, + mt = mit_ped_matrix, + cn = cn_ped_matrix + ) - if (!is.null(cn_ped_matrix)) { - ids <- as.numeric(dimnames(cn_ped_matrix)[[1]]) - nc <- ncol(cn_ped_matrix) - } else if (!is.null(ad_ped_matrix)) { - ids <- as.numeric(dimnames(ad_ped_matrix)[[1]]) - nc <- ncol(ad_ped_matrix) - } else if (!is.null(mit_ped_matrix)) { - ids <- as.numeric(dimnames(mit_ped_matrix)[[1]]) - nc <- ncol(mit_ped_matrix) + # Extract IDs only from the smallest matrix. + guide_ids <- dimnames(guide_mat)[[1]] + if (is.null(guide_ids) || length(guide_ids) == 0L) { + stop("Could not extract IDs from the smallest matrix.") } + ids <- as.numeric(guide_ids) + nc <- length(ids) - if (is.null(ids)) { - stop("Could not extract IDs from the provided matrices.") + # Subset only the larger matrices to match the smallest matrix's IDs and ordering. + if (!is.null(ad_ped_matrix) && ncol(ad_ped_matrix) > nc) { + if (verbose) message("Subsetting ad_ped_matrix from ", ncol(ad_ped_matrix), " to ", nc, " IDs.") + ad_ped_matrix <- ad_ped_matrix[guide_ids, guide_ids, drop = FALSE] } + if (!is.null(mit_ped_matrix) && ncol(mit_ped_matrix) > nc) { + if (verbose) message("Subsetting mit_ped_matrix from ", ncol(mit_ped_matrix), " to ", nc, " IDs.") + mit_ped_matrix <- mit_ped_matrix[guide_ids, guide_ids, drop = FALSE] + } + if (!is.null(cn_ped_matrix) && ncol(cn_ped_matrix) > nc) { + if (verbose) message("Subsetting cn_ped_matrix from ", ncol(cn_ped_matrix), " to ", nc, " IDs.") + cn_ped_matrix <- cn_ped_matrix[guide_ids, guide_ids, drop = FALSE] + } + # --- matrix_case construction and switch dispatch --- matrix_case <- paste(sort(c( diff --git a/tests/testthat/test-makeLinks.R b/tests/testthat/test-makeLinks.R index 5a5e4475..f2340485 100644 --- a/tests/testthat/test-makeLinks.R +++ b/tests/testthat/test-makeLinks.R @@ -324,3 +324,82 @@ test_that("com2links garbage collection does not affect output, using two compon expect_equal(result_gc, result_no_gc) }) + + +test_that("com2links handles mismatched matrix dimensions by subsetting to smallest", { + data(hazard) + subset_ids <- hazard$ID[seq_len(ceiling(nrow(hazard) / 2))] + + ad_small <- ped2add(hazard, sparse = TRUE, keep_ids = subset_ids) + mit_ped_matrix <- ped2mit(hazard, sparse = TRUE) + cn_ped_matrix <- ped2cn(hazard, sparse = TRUE) + + # All three matrices, ad is smaller + result_mismatch <- com2links( + ad_ped_matrix = ad_small, + mit_ped_matrix = mit_ped_matrix, + cn_ped_matrix = cn_ped_matrix, + writetodisk = FALSE + ) + + # Reference: all three matrices built from the same subset + result_ref <- com2links( + ad_ped_matrix = ad_small, + mit_ped_matrix = ped2mit(hazard, sparse = TRUE, keep_ids = subset_ids), + cn_ped_matrix = ped2cn(hazard, sparse = TRUE, keep_ids = subset_ids), + writetodisk = FALSE + ) + + expect_equal(result_mismatch, result_ref) + + # Only IDs from the smaller matrix should appear + all_output_ids <- unique(c(result_mismatch$ID1, result_mismatch$ID2)) + expect_true(all(all_output_ids %in% as.numeric(dimnames(ad_small)[[1]]))) +}) + +test_that("com2links mismatched dimensions with two matrices", { + data(hazard) + subset_ids <- hazard$ID[seq_len(ceiling(nrow(hazard) / 2))] + + ad_ped_matrix <- ped2add(hazard, sparse = TRUE) + cn_small <- ped2cn(hazard, sparse = TRUE, keep_ids = subset_ids) + + # cn is smaller than ad + result_mismatch <- com2links( + ad_ped_matrix = ad_ped_matrix, + cn_ped_matrix = cn_small, + writetodisk = FALSE + ) + + result_ref <- com2links( + ad_ped_matrix = ped2add(hazard, sparse = TRUE, keep_ids = subset_ids), + cn_ped_matrix = cn_small, + writetodisk = FALSE + ) + + expect_equal(result_mismatch, result_ref) +}) + +test_that("com2links mismatched dimensions with mit smaller", { + data(hazard) + subset_ids <- hazard$ID[seq_len(ceiling(nrow(hazard) / 2))] + + ad_ped_matrix <- ped2add(hazard, sparse = TRUE) + mit_small <- ped2mit(hazard, sparse = TRUE, keep_ids = subset_ids) + + result_mismatch <- com2links( + ad_ped_matrix = ad_ped_matrix, + mit_ped_matrix = mit_small, + writetodisk = FALSE + ) + + result_ref <- com2links( + ad_ped_matrix = ped2add(hazard, sparse = TRUE, keep_ids = subset_ids), + mit_ped_matrix = mit_small, + writetodisk = FALSE + ) + + expect_equal(result_mismatch, result_ref) + expect_true(all(unique(c(result_mismatch$ID1, result_mismatch$ID2)) %in% as.numeric(dimnames(mit_small)[[1]]))) + expect_true(all(unique(c(result_mismatch$ID1, result_mismatch$ID2)) %in% as.numeric(dimnames(ad_ped_matrix)[[1]]))) +}) From 7aed335814a9f778b208fad1c28a5b9bfabfc270 Mon Sep 17 00:00:00 2001 From: Mason Garrison <6001608+smasongarrison@users.noreply.github.com> Date: Wed, 8 Apr 2026 19:04:53 -0400 Subject: [PATCH 04/11] Update DESCRIPTION --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 109e097b..f357497f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: BGmisc Title: An R Package for Extended Behavior Genetics Analysis -Version: 1.7.0.1 +Version: 1.7.0.1.1 Authors@R: c( person("S. Mason", "Garrison", , "garrissm@wfu.edu", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-4804-6003")), From 8a80c8d92a06d3a1c5aca0f4617aa4bfaebc10ae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Apr 2026 13:02:56 +0000 Subject: [PATCH 05/11] Fix overwrite=FALSE bug in .ped2id and add overwrite tests for ped2fam Agent-Logs-Url: https://github.com/R-Computing-Lab/BGmisc/sessions/f8a84ab6-f22c-49f1-8cdb-c72741ea5e09 Co-authored-by: smasongarrison <6001608+smasongarrison@users.noreply.github.com> --- R/segmentPedigree.R | 22 ++++++++++------- tests/testthat/test-segmentPedigree.R | 34 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/R/segmentPedigree.R b/R/segmentPedigree.R index 8bc6d5bc..1413682e 100644 --- a/R/segmentPedigree.R +++ b/R/segmentPedigree.R @@ -83,17 +83,23 @@ if(keep_string==TRUE) { names(fam) <- c(personID, famID) - if(famID %in% names(ped)) { - if(overwrite) { - overwrite_message <- "be overwritten." - ped[[famID]] <- NULL + if (famID %in% names(ped)) { + if (overwrite) { + overwrite_message <- "be overwritten." + ped[[famID]] <- NULL } else { - overwrite_message <- "not be overwritten." - } + overwrite_message <- "not be overwritten." + } - warning(sprintf("The famID variable '%s' already exists in the pedigree. The existing variable will %s", famID, overwrite_message)) + warning(sprintf( + "The famID variable '%s' already exists in the pedigree. The existing variable will %s", + famID, overwrite_message + )) - } + if (!overwrite) { + return(ped) + } + } ped2 <- merge(fam, ped, by = personID, all.x = FALSE, all.y = TRUE diff --git a/tests/testthat/test-segmentPedigree.R b/tests/testthat/test-segmentPedigree.R index cf1cce02..137296e4 100644 --- a/tests/testthat/test-segmentPedigree.R +++ b/tests/testthat/test-segmentPedigree.R @@ -42,6 +42,40 @@ test_that("ped2fam gets the right families for inbreeding data", { expect_equal(ds$famID, ds$newFamID) }) +test_that("ped2fam overwrite = TRUE warns and replaces existing famID", { + data(hazard) + # Add a fake existing famID column with wrong values + hazard$famID <- 999L + + # Should warn that famID will be overwritten + expect_warning( + ds <- ped2fam(hazard, famID = "famID", overwrite = TRUE), + regexp = "already exists.*be overwritten" + ) + + # The result should have the correctly computed famID, not the placeholder + expect_false(all(ds$famID == 999L)) + # No duplicate columns + expect_equal(sum(names(ds) == "famID"), 1L) +}) + +test_that("ped2fam overwrite = FALSE warns and preserves existing famID", { + data(hazard) + # Add a known existing famID column + hazard$famID <- 999L + + # Should warn that famID will NOT be overwritten + expect_warning( + ds <- ped2fam(hazard, famID = "famID", overwrite = FALSE), + regexp = "already exists.*not be overwritten" + ) + + # The result should preserve the original famID values + expect_true(all(ds$famID == 999L)) + # No duplicate columns + expect_equal(sum(names(ds) == "famID"), 1L) +}) + test_that("ped2graph produces a graph for hazard data with mothers", { expect_silent(data(hazard)) g <- ped2graph(hazard, adjacent = "mothers") From e4d7a6c39a4f1bf7f89940699212e083006deb20 Mon Sep 17 00:00:00 2001 From: Mason Garrison Date: Thu, 9 Apr 2026 09:07:03 -0400 Subject: [PATCH 06/11] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Mason Garrison --- NEWS.md | 2 +- vignettes/articles/tutorialmanuscript.Xmd | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 28714a53..afeeae70 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,7 +5,7 @@ * Optimized sliceFamilies to be more abstract * Created `.require_openmx()` to make it easier to use OpenMx functions without making OpenMx a dependency * Smarter string ID handling for ped2id -* fixed how different sized matrixes are handled by build links +* Fixed how different-sized matrices are handled by `com2links()` # BGmisc 1.7.0.0 * Fixed bug in parList diff --git a/vignettes/articles/tutorialmanuscript.Xmd b/vignettes/articles/tutorialmanuscript.Xmd index 6b756a27..5460ad4e 100644 --- a/vignettes/articles/tutorialmanuscript.Xmd +++ b/vignettes/articles/tutorialmanuscript.Xmd @@ -65,7 +65,8 @@ studies, either intentionally (e.g., twin registries that also include siblings byproduct of large panel studies (e.g., the National Longitudinal Survey of Youth, which includes researcher-linked kinship). In most cases, the additional relatives are excluded from analysis, and the twin design is applied to a subset of the data, even though these relatives carry independent -information about the genetic and environmental architecture of the phenotype. For example, many of the twin registries reviewed in FOO, include triplets, sibles, children, parents. https://helda.helsinki.fi/server/api/core/bitstreams/f0b6dc08-69df-449e-a8fe-e2c78abf7f60/content +information about the genetic and environmental architecture of the phenotype. For example, many twin registries also include triplets, siblings, children, and parents, all of whom provide additional information about the genetic and environmental architecture of the phenotype. + The extended pedigree model, which we have introduced elsewhere (see ETC), leverages the full range of kinship coefficients in a pedigree to identify a richer set of variance components than the @@ -89,7 +90,7 @@ components. Extended pedigree designs have been used in behavior genetics since at least the 1970s [@eaves1978; @fulker_multiple_1988], but they have remained a minority practice. Partially over concerns about model identification and power (Wilson, 1982, 1989), the complexity of fitting these models, and the relative costs of collecting twin data compared to extended family data. - + but also because the twin design has been so successful and widely adopted. The twin design is often seen as the "gold standard" in behavior genetics, and many researchers may be hesitant to deviate from this established approach. Additionally, many human datasets simply do not include the necessary family structure to fit extended pedigree models, which may limit their applicability in certain contexts. From 34a260db27de93ac81d52d330bf2dd29899eb168 Mon Sep 17 00:00:00 2001 From: Mason Garrison Date: Thu, 9 Apr 2026 15:06:55 -0400 Subject: [PATCH 07/11] Partial Revert "Fix overwrite=FALSE bug in .ped2id and add overwrite tests for ped2fam" This reverts commit 8a80c8d92a06d3a1c5aca0f4617aa4bfaebc10ae. --- R/segmentPedigree.R | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/R/segmentPedigree.R b/R/segmentPedigree.R index 1413682e..8bc6d5bc 100644 --- a/R/segmentPedigree.R +++ b/R/segmentPedigree.R @@ -83,23 +83,17 @@ if(keep_string==TRUE) { names(fam) <- c(personID, famID) - if (famID %in% names(ped)) { - if (overwrite) { - overwrite_message <- "be overwritten." - ped[[famID]] <- NULL + if(famID %in% names(ped)) { + if(overwrite) { + overwrite_message <- "be overwritten." + ped[[famID]] <- NULL } else { - overwrite_message <- "not be overwritten." - } + overwrite_message <- "not be overwritten." + } - warning(sprintf( - "The famID variable '%s' already exists in the pedigree. The existing variable will %s", - famID, overwrite_message - )) + warning(sprintf("The famID variable '%s' already exists in the pedigree. The existing variable will %s", famID, overwrite_message)) - if (!overwrite) { - return(ped) - } - } + } ped2 <- merge(fam, ped, by = personID, all.x = FALSE, all.y = TRUE From 8bb42feaa29f87c195162941ca418a0594b97e94 Mon Sep 17 00:00:00 2001 From: Mason Garrison Date: Thu, 9 Apr 2026 15:17:10 -0400 Subject: [PATCH 08/11] alternative is to drop from fam --- R/segmentPedigree.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/segmentPedigree.R b/R/segmentPedigree.R index 8bc6d5bc..fe8a47a2 100644 --- a/R/segmentPedigree.R +++ b/R/segmentPedigree.R @@ -89,6 +89,7 @@ if(keep_string==TRUE) { ped[[famID]] <- NULL } else { overwrite_message <- "not be overwritten." + fam[[famID]] <- NULL } warning(sprintf("The famID variable '%s' already exists in the pedigree. The existing variable will %s", famID, overwrite_message)) From e67fb0b32a9b36146ba6e6df0627960c25598a1c Mon Sep 17 00:00:00 2001 From: Mason Garrison Date: Thu, 9 Apr 2026 15:39:39 -0400 Subject: [PATCH 09/11] Update R/makeLinks.R Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- R/makeLinks.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/makeLinks.R b/R/makeLinks.R index 97abb654..fabd49cc 100644 --- a/R/makeLinks.R +++ b/R/makeLinks.R @@ -101,7 +101,12 @@ com2links <- function( if (is.null(guide_ids) || length(guide_ids) == 0L) { stop("Could not extract IDs from the smallest matrix.") } - ids <- as.numeric(guide_ids) + ids <- suppressWarnings(as.numeric(guide_ids)) + if (anyNA(ids)) { + warning( + "Matrix dimnames used as IDs should be strictly numeric for 'com2links()'. Found non-numeric or non-coercible IDs in the smallest matrix." + ) + } nc <- length(ids) # Subset only the larger matrices to match the smallest matrix's IDs and ordering. From 198987547adc800249aa7b2b2b7618ed6bd2e825 Mon Sep 17 00:00:00 2001 From: Mason Garrison Date: Fri, 10 Apr 2026 12:37:46 -0400 Subject: [PATCH 10/11] add helper funciton --- R/buildmxPedigrees.R | 16 ++++++++++++++++ man/alignPhenToMatrix.Rd | 19 +++++++++++++++++++ .../articles/v61_pedigree_model_fitting.Rmd | 10 ++-------- 3 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 man/alignPhenToMatrix.Rd diff --git a/R/buildmxPedigrees.R b/R/buildmxPedigrees.R index 3ad4207d..b3ae2926 100644 --- a/R/buildmxPedigrees.R +++ b/R/buildmxPedigrees.R @@ -420,3 +420,19 @@ fitPedigreeModel <- function( } fitted_model } + + +#' Align Phenotype Vector to Matrix Format for OpenMx +#' +#' This function takes a pedigree data frame, a specified phenotype column, and a vector of IDs to keep, and returns a matrix formatted for use in OpenMx models. The resulting matrix has one row and columns corresponding to the specified IDs, with values taken from the phenotype column of the pedigree. +#' @param ped A data frame representing the pedigree, containing at least the columns specified by \code{phenotype} and \code{id_col}. +#' @param phenotype A character string specifying the column name in \code{ped} that +#' contains the phenotype values to be aligned. +#' @param keep_ids A vector of IDs for which the phenotype values should be extracted and aligned. These IDs should correspond to the values in the \code{id_col} of \code{ped}. +#' @param id_col A character string specifying the column name in \code{ped} that contains the individual IDs. Default is "ID". + +alignPhenToMatrix <- function(ped, phenotype, keep_ids, id_col = "ID") { + obs_ids <- make.names(as.character(keep_ids)) + pheno_vals <- ped[[phenotype]][match(as.character(keep_ids), as.character(ped[[id_col]]))] + matrix(as.double(pheno_vals), nrow = 1, dimnames = list(NULL, obs_ids)) +} diff --git a/man/alignPhenToMatrix.Rd b/man/alignPhenToMatrix.Rd new file mode 100644 index 00000000..1b0d7504 --- /dev/null +++ b/man/alignPhenToMatrix.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/buildmxPedigrees.R +\name{alignPhenToMatrix} +\alias{alignPhenToMatrix} +\title{Align Phenotype Vector to Matrix Format for OpenMx} +\usage{ +alignPhenToMatrix(ped, phenotype, keep_ids, id_col = "ID") +} +\arguments{ +\item{ped}{A data frame representing the pedigree, containing at least the columns specified by \code{phenotype} and \code{id_col}.} + +\item{phenotype}{A character string specifying the column name in \code{ped} that +contains the phenotype values to be aligned. +@param keep_ids A vector of IDs for which the phenotype values should be extracted and aligned. These IDs should correspond to the values in the \code{id_col} of \code{ped}. +@param id_col A character string specifying the column name in \code{ped} that contains the individual IDs. Default is "ID".} +} +\description{ +This function takes a pedigree data frame, a specified phenotype column, and a vector of IDs to keep, and returns a matrix formatted for use in OpenMx models. The resulting matrix has one row and columns corresponding to the specified IDs, with values taken from the phenotype column of the pedigree. +} diff --git a/vignettes/articles/v61_pedigree_model_fitting.Rmd b/vignettes/articles/v61_pedigree_model_fitting.Rmd index 464e5709..51ef9ec3 100644 --- a/vignettes/articles/v61_pedigree_model_fitting.Rmd +++ b/vignettes/articles/v61_pedigree_model_fitting.Rmd @@ -131,14 +131,8 @@ for (i in seq_len(n_families)) { n_i <- nrow(A_i) id_order_i <- rownames(A_i) - pheno_vals <- ped_i$lrs[match(id_order_i, as.character(ped_i$ID))] - - obs_ids_i <- make.names(id_order_i[!is.na(pheno_vals)]) - pheno_row_i <- matrix(as.double(pheno_vals[!is.na(pheno_vals)]), - nrow = 1, - dimnames = list(NULL, obs_ids_i) - ) - + pheno_row_i <- alignPhenToMatrix(ped_i, "lrs", phenotypic_ids) + obs_ids_i <- colnames(pheno_row_i) rownames(A_i) <- colnames(A_i) <- obs_ids_i rownames(Cn_i) <- colnames(Cn_i) <- obs_ids_i rownames(Mt_i) <- colnames(Mt_i) <- obs_ids_i From 76b6b244f8f03b9dc50944a30549f196fec1d316 Mon Sep 17 00:00:00 2001 From: Mason Garrison Date: Fri, 10 Apr 2026 12:37:50 -0400 Subject: [PATCH 11/11] Update references.bib --- vignettes/articles/references.bib | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/vignettes/articles/references.bib b/vignettes/articles/references.bib index 3da703ce..b35e8e93 100644 --- a/vignettes/articles/references.bib +++ b/vignettes/articles/references.bib @@ -256,3 +256,56 @@ @article{eaves1978 note = {ISBN: 0018-067X (Print)\r0018-067X (Linking)}, langid = {en} } + +@article{hur2012, + title = {Twin Registries Worldwide: An Important Resource for Scientific Research}, + author = {Hur, Yoon-Mi and Craig, Jeffrey M}, + year = {2012}, + date = {2012}, + journal = {Twin Research and Human Genetics}, + pages = {1--12}, + volume = {16}, + number = {1}, + doi = {10/f4pfck} +} + +@article{hur2019, + title = {Twin Family Registries Worldwide: An Important Resource for Scientific Research}, + author = {Hur, Yoon-Mi and Bogl, Leonie H. and {Ordoñana}, Juan R. and Taylor, Jeanette and Hart, Sara A. and Tuvblad, Catherine and Ystrom, Eivind and {Dalgård}, Christine and Skytthe, Axel and Willemsen, Gonneke}, + year = {2019}, + month = {12}, + date = {2019-12}, + journal = {Twin Research and Human Genetics}, + pages = {1--11}, + volume = {22}, + number = {6}, + doi = {10.1017/thg.2019.121}, + url = {https://www.cambridge.org/core/journals/twin-research-and-human-genetics/article/twin-family-registries-worldwide-an-important-resource-for-scientific-research/21A2EF37C57DCDEBBC3BA677510FE1A8}, + langid = {en} +} + +@article{roth2018, + title = {Global, regional, and national age-sex-specific mortality for 282 causes of death in 195 countries and territories, 1980{\textendash}2017: a systematic analysis for the Global Burden of Disease Study 2017}, + author = {Roth, Gregory A. and Abate, Degu and Abate, Kalkidan Hassen and Abay, Solomon M. and Abbafati, Cristiana and Abbasi, Nooshin and Abbastabar, Hedayat and Abd-Allah, Foad and Abdela, Jemal and Abdelalim, Ahmed and Abdollahpour, Ibrahim and Abdulkader, Rizwan Suliankatchi and Abebe, Haftom Temesgen and Abebe, Molla and Abebe, Zegeye and Abejie, Ayenew Negesse and Abera, Semaw F. and Abil, Olifan Zewdie and Abraha, Haftom Niguse and Abrham, Aklilu Roba and Abu-Raddad, Laith Jamal and Accrombessi, Manfred Mario Kokou and Acharya, Dilaram and Adamu, Abdu A. and Adebayo, Oladimeji M. and Adedoyin, Rufus Adesoji and Adekanmbi, Victor and Adetokunboh, Olatunji O. and Adhena, Beyene Meressa and Adib, Mina G. and Admasie, Amha and Afshin, Ashkan and Agarwal, Gina and Agesa, Kareha M. and Agrawal, Anurag and Agrawal, Sutapa and Ahmadi, Alireza and Ahmadi, Mehdi and Ahmed, Muktar Beshir and Ahmed, Sayem and Aichour, Amani Nidhal and Aichour, Ibtihel and Aichour, Miloud Taki Eddine and Akbari, Mohammad Esmaeil and Akinyemi, Rufus Olusola and Akseer, Nadia and Al-Aly, Ziyad and Al-Eyadhy, Ayman and Al-Raddadi, Rajaa M. and Alahdab, Fares and Alam, Khurshid and Alam, Tahiya and Alebel, Animut and Alene, Kefyalew Addis and Alijanzadeh, Mehran and Alizadeh-Navaei, Reza and Aljunid, Syed Mohamed and Alkerwi, {Ala'a} and Alla, {François} and Allebeck, Peter and Alonso, Jordi and Altirkawi, Khalid and Alvis-Guzman, Nelson and Amare, Azmeraw T. and Aminde, Leopold N. and Amini, Erfan and Ammar, Walid and Amoako, Yaw Ampem and Anber, Nahla Hamed and Andrei, Catalina Liliana and Androudi, Sofia and Animut, Megbaru Debalkie and Anjomshoa, Mina and Ansari, Hossein and Ansha, Mustafa Geleto and Antonio, Carl Abelardo T. and Anwari, Palwasha and Aremu, Olatunde and {Ärnlöv}, Johan and Arora, Amit and Arora, Monika and Artaman, Al and Aryal, Krishna K. and Asayesh, Hamid and Asfaw, Ephrem Tsegay and Ataro, Zerihun and Atique, Suleman and Atre, Sachin R. and Ausloos, Marcel and Avokpaho, Euripide F. G. A. and Awasthi, Ashish and Quintanilla, Beatriz Paulina Ayala and Ayele, Yohanes and Ayer, Rakesh and Azzopardi, Peter S. and Babazadeh, Arefeh and Bacha, Umar and Badali, Hamid and Badawi, Alaa and Bali, Ayele Geleto and Ballesteros, Katherine E. and Banach, Maciej and Banerjee, Kajori and Bannick, Marlena S. and Banoub, Joseph Adel Mattar and Barboza, Miguel A. and Barker-Collo, Suzanne Lyn and {Bärnighausen}, Till Winfried and Barquera, Simon and Barrero, Lope H. and Bassat, Quique and Basu, Sanjay and Baune, Bernhard T. and Baynes, Habtamu Wondifraw and Bazargan-Hejazi, Shahrzad and Bedi, Neeraj and Beghi, Ettore and Behzadifar, Masoud and Behzadifar, Meysam and {Béjot}, Yannick and Bekele, Bayu Begashaw and Belachew, Abate Bekele and Belay, Ezra and Belay, Yihalem Abebe and Bell, Michelle L. and Bello, Aminu K. and Bennett, Derrick A. and Bensenor, Isabela M. and Berman, Adam E. and Bernabe, Eduardo and Bernstein, Robert S. and Bertolacci, Gregory J. and Beuran, Mircea and Beyranvand, Tina and Bhalla, Ashish and Bhattarai, Suraj and Bhaumik, Soumyadeeep and Bhutta, Zulfiqar A. and Biadgo, Belete and Biehl, Molly H. and Bijani, Ali and Bikbov, Boris and Bilano, Ver and Bililign, Nigus and Sayeed, Muhammad Shahdaat Bin and Bisanzio, Donal and Biswas, Tuhin and Blacker, Brigette F. and Basara, Berrak Bora and Borschmann, Rohan and Bosetti, Cristina and Bozorgmehr, Kayvan and Brady, Oliver J. and Brant, Luisa C. and Brayne, Carol and Brazinova, Alexandra and Breitborde, Nicholas J. K. and Brenner, Hermann and Briant, Paul Svitil and Britton, Gabrielle and Brugha, Traolach and Busse, Reinhard and Butt, Zahid A. and Callender, Charlton S. K. H. and Campos-Nonato, Ismael R. and Rincon, Julio Cesar Campuzano and Cano, Jorge and Car, Mate and {Cárdenas}, Rosario and Carreras, Giulia and Carrero, Juan J. and Carter, Austin and Carvalho, {Félix} and {Castañeda-Orjuela}, Carlos A. and Rivas, Jacqueline Castillo and Castle, Chris D. and Castro, Clara and Castro, Franz and {Catalá-López}, {Ferrán} and Cerin, Ester and Chaiah, Yazan and Chang, Jung-Chen and Charlson, Fiona J. and Chaturvedi, Pankaj and Chiang, Peggy Pei-Chia and Chimed-Ochir, Odgerel and Chisumpa, Vesper Hichilombwe and Chitheer, Abdulaal and Chowdhury, Rajiv and Christensen, Hanne and Christopher, Devasahayam J. and Chung, Sheng-Chia and Cicuttini, Flavia M. and Ciobanu, Liliana G. and Cirillo, Massimo and Cohen, Aaron J. and Cooper, Leslie Trumbull and Cortesi, Paolo Angelo and Cortinovis, Monica and Cousin, Ewerton and Cowie, Benjamin C. and Criqui, Michael H. and Cromwell, Elizabeth A. and Crowe, Christopher Stephen and Crump, John A. and Cunningham, Matthew and Daba, Alemneh Kabeta and Dadi, Abel Fekadu and Dandona, Lalit and Dandona, Rakhi and Dang, Anh Kim and Dargan, Paul I. and Daryani, Ahmad and Das, Siddharth K. and Gupta, Rajat Das and Neves, {José Das} and Dasa, Tamirat Tesfaye and Dash, Aditya Prasad and Davis, Adrian C. and Weaver, Nicole Davis and Davitoiu, Dragos Virgil and Davletov, Kairat and Hoz, Fernando Pio De La and Neve, Jan-Walter De and Degefa, Meaza Girma and Degenhardt, Louisa and Degfie, Tizta T. and Deiparine, Selina and Demoz, Gebre Teklemariam and Demtsu, Balem Betsu and {Denova-Gutiérrez}, Edgar and Deribe, Kebede and Dervenis, Nikolaos and Jarlais, Don C. Des and Dessie, Getenet Ayalew and Dey, Subhojit and Dharmaratne, Samath D. and Dicker, Daniel and Dinberu, Mesfin Tadese and Ding, Eric L. and Dirac, M. Ashworth and Djalalinia, Shirin and Dokova, Klara and Doku, David Teye and Donnelly, Christl A. and Dorsey, E. Ray and Doshi, Pratik P. and Douwes-Schultz, Dirk and Doyle, Kerrie E. and Driscoll, Tim R. and Dubey, Manisha and Dubljanin, Eleonora and Duken, Eyasu Ejeta and Duncan, Bruce B. and Duraes, Andre R. and Ebrahimi, Hedyeh and Ebrahimpour, Soheil and Edessa, Dumessa and Edvardsson, David and Eggen, Anne Elise and Bcheraoui, Charbel El and Zaki, Maysaa El Sayed and El-Khatib, Ziad and Elkout, Hajer and Ellingsen, Christian Lycke and Endres, Matthias and Endries, Aman Yesuf and Er, Benjamin and Erskine, Holly E. and Eshrati, Babak and Eskandarieh, Sharareh and Esmaeili, Reza and Esteghamati, Alireza and Fakhar, Mahdi and Fakhim, Hamed and Faramarzi, Mahbobeh and Fareed, Mohammad and Farhadi, Farzaneh and Farinha, {Carla Sofia E. sá} and Faro, Andre and Farvid, Maryam S. and Farzadfar, Farshad and Farzaei, Mohammad Hosein and Feigin, Valery L. and Feigl, Andrea B. and Fentahun, Netsanet and Fereshtehnejad, Seyed-Mohammad and Fernandes, Eduarda and Fernandes, Joao C. and Ferrari, Alize J. and Feyissa, Garumma Tolu and Filip, Irina and Finegold, Samuel and Fischer, Florian and Fitzmaurice, Christina and Foigt, Nataliya A. and Foreman, Kyle J. and Fornari, Carla and Frank, Tahvi D. and Fukumoto, Takeshi and Fuller, John E. and Fullman, Nancy and {Fürst}, Thomas and Furtado, {João M.} and Futran, Neal D. and Gallus, Silvano and Garcia-Basteiro, Alberto L. and Garcia-Gordillo, Miguel A. and Gardner, William M. and Gebre, Abadi Kahsu and Gebrehiwot, Tsegaye Tewelde and Gebremedhin, Amanuel Tesfay and Gebremichael, Bereket and Gebremichael, Teklu Gebrehiwo and Gelano, Tilayie Feto and Geleijnse, Johanna M. and Genova-Maleras, Ricard and Geramo, Yilma Chisha Dea and Gething, Peter W. and Gezae, Kebede Embaye and Ghadami, Mohammad Rasoul and Ghadimi, Reza and Falavarjani, Khalil Ghasemi and Ghasemi-Kasman, Maryam and Ghimire, Mamata and Gibney, Katherine B. and Gill, Paramjit Singh and Gill, Tiffany K. and Gillum, Richard F. and Ginawi, Ibrahim Abdelmageed and Giroud, Maurice and Giussani, Giorgia and Goenka, Shifalika and Goldberg, Ellen M. and Goli, Srinivas and {Gómez-Dantés}, Hector and Gona, Philimon N. and Gopalani, Sameer Vali and Gorman, Taren M. and Goto, Atsushi and Goulart, Alessandra C. and Gnedovskaya, Elena V. and Grada, Ayman and Grosso, Giuseppe and Gugnani, Harish Chander and Guimaraes, Andre Luiz Sena and Guo, Yuming and Gupta, Prakash C. and Gupta, Rahul and Gupta, Rajeev and Gupta, Tanush and {Gutiérrez}, Reyna Alma and Gyawali, Bishal and Haagsma, Juanita A. and Hafezi-Nejad, Nima and Hagos, Tekleberhan B. and Hailegiyorgis, Tewodros Tesfa and Hailu, Gessessew Bugssa and Haj-Mirzaian, Arvin and Haj-Mirzaian, Arya and Hamadeh, Randah R. and Hamidi, Samer and Handal, Alexis J. and Hankey, Graeme J. and Harb, Hilda L. and Harikrishnan, Sivadasanpillai and Haro, Josep Maria and Hasan, Mehedi and Hassankhani, Hadi and Hassen, Hamid Yimam and Havmoeller, Rasmus and Hay, Roderick J. and Hay, Simon I. and He, Yihua and Hedayatizadeh-Omran, Akbar and Hegazy, Mohamed I. and Heibati, Behzad and Heidari, Mohsen and Hendrie, Delia and Henok, Andualem and Henry, Nathaniel J. and Herteliu, Claudiu and Heydarpour, Fatemeh and Heydarpour, Pouria and Heydarpour, Sousan and Hibstu, Desalegn Tsegaw and Hoek, Hans W. and Hole, Michael K. and Rad, Enayatollah Homaie and Hoogar, Praveen and Hosgood, H. Dean and Hosseini, Seyed Mostafa and Hosseinzadeh, Mehdi and Hostiuc, Mihaela and Hostiuc, Sorin and Hotez, Peter J. and Hoy, Damian G. and Hsiao, Thomas and Hu, Guoqing and Huang, John J. and Husseini, Abdullatif and Hussen, Mohammedaman Mama and Hutfless, Susan and Idrisov, Bulat and Ilesanmi, Olayinka Stephen and Iqbal, Usman and Irvani, Seyed Sina Naghibi and Irvine, Caleb Mackay Salpeter and Islam, Nazrul and Islam, Sheikh Mohammed Shariful and Islami, Farhad and Jacobsen, Kathryn H. and Jahangiry, Leila and Jahanmehr, Nader and Jain, Sudhir Kumar and Jakovljevic, Mihajlo and Jalu, Moti Tolera and James, Spencer L. and Javanbakht, Mehdi and Jayatilleke, Achala Upendra and Jeemon, Panniyammakal and Jenkins, Kathy J. and Jha, Ravi Prakash and Jha, Vivekanand and Johnson, Catherine O. and Johnson, Sarah C. and Jonas, Jost B. and Joshi, Ankur and Jozwiak, Jacek Jerzy and Jungari, Suresh Banayya and {Jürisson}, Mikk and Kabir, Zubair and Kadel, Rajendra and Kahsay, Amaha and Kalani, Rizwan and Karami, Manoochehr and Matin, Behzad Karami and Karch, {André} and Karema, Corine and Karimi-Sari, Hamidreza and Kasaeian, Amir and Kassa, Dessalegn H. and Kassa, Getachew Mullu and Kassa, Tesfaye Dessale and Kassebaum, Nicholas J. and Katikireddi, Srinivasa Vittal and Kaul, Anil and Kazemi, Zhila and Karyani, Ali Kazemi and Kazi, Dhruv Satish and Kefale, Adane Teshome and Keiyoro, Peter Njenga and Kemp, Grant Rodgers and Kengne, Andre Pascal and Keren, Andre and Kesavachandran, Chandrasekharan Nair and Khader, Yousef Saleh and Khafaei, Behzad and Khafaie, Morteza Abdullatif and Khajavi, Alireza and Khalid, Nauman and Khalil, Ibrahim A. and Khan, Ejaz Ahmad and Khan, Muhammad Shahzeb and Khan, Muhammad Ali and Khang, Young-Ho and Khater, Mona M. and Khoja, Abdullah T. and Khosravi, Ardeshir and Khosravi, Mohammad Hossein and Khubchandani, Jagdish and Kiadaliri, Aliasghar A. and Kibret, Getiye D. and Kidanemariam, Zelalem Teklemariam and Kiirithio, Daniel N. and Kim, Daniel and Kim, Young-Eun and Kim, Yun Jin and Kimokoti, Ruth W. and Kinfu, Yohannes and Kisa, Adnan and Kissimova-Skarbek, Katarzyna and {Kivimäki}, Mika and Knudsen, Ann Kristin Skrindo and Kocarnik, Jonathan M. and Kochhar, Sonali and Kokubo, Yoshihiro and Kolola, Tufa and Kopec, Jacek A. and Koul, Parvaiz A. and Koyanagi, Ai and Kravchenko, Michael A. and Krishan, Kewal and Defo, Barthelemy Kuate and Bicer, Burcu Kucuk and Kumar, G. Anil and Kumar, Manasi and Kumar, Pushpendra and Kutz, Michael J. and Kuzin, Igor and Kyu, Hmwe Hmwe and Lad, Deepesh P. and Lad, Sheetal D. and Lafranconi, Alessandra and Lal, Dharmesh Kumar and Lalloo, Ratilal and Lallukka, Tea and Lam, Jennifer O. and Lami, Faris Hasan and Lansingh, Van C. and Lansky, Sonia and Larson, Heidi J. and Latifi, Arman and Lau, Kathryn Mei-Ming and Lazarus, Jeffrey V. and Lebedev, Georgy and Lee, Paul H. and Leigh, James and Leili, Mostafa and Leshargie, Cheru Tesema and Li, Shanshan and Li, Yichong and Liang, Juan and Lim, Lee-Ling and Lim, Stephen S. and Limenih, Miteku Andualem and Linn, Shai and Liu, Shiwei and Liu, Yang and Lodha, Rakesh and Lonsdale, Chris and Lopez, Alan D. and Lorkowski, Stefan and Lotufo, Paulo A. and Lozano, Rafael and Lunevicius, Raimundas and Ma, Stefan and Macarayan, Erlyn Rachelle King and Mackay, Mark T. and MacLachlan, Jennifer H. and Maddison, Emilie R. and Madotto, Fabiana and Razek, Hassan Magdy Abd El and Razek, Muhammed Magdy Abd El and Maghavani, Dhaval P. and Majdan, Marek and Majdzadeh, Reza and Majeed, Azeem and Malekzadeh, Reza and Malta, Deborah Carvalho and Manda, Ana-Laura and Mandarano-Filho, Luiz Garcia and Manguerra, Helena and Mansournia, Mohammad Ali and Mapoma, Chabila Christopher and Marami, Dadi and Maravilla, Joemer C. and Marcenes, Wagner and Marczak, Laurie and Marks, Ashley and Marks, Guy B. and Martinez, Gabriel and Martins-Melo, {Francisco Rogerlândio} and Martopullo, Ira and {März}, Winfried and Marzan, Melvin B. and Masci, Joseph R. and Massenburg, Benjamin Ballard and Mathur, Manu Raj and Mathur, Prashant and Matzopoulos, Richard and Maulik, Pallab K. and Mazidi, Mohsen and McAlinden, Colm and McGrath, John J. and McKee, Martin and McMahon, Brian J. and Mehata, Suresh and Mehndiratta, Man Mohan and Mehrotra, Ravi and Mehta, Kala M. and Mehta, Varshil and Mekonnen, Tefera C. and Melese, Addisu and Melku, Mulugeta and Memiah, Peter T. N. and Memish, Ziad A. and Mendoza, Walter and Mengistu, Desalegn Tadese and Mengistu, Getnet and Mensah, George A. and Mereta, Seid Tiku and Meretoja, Atte and Meretoja, Tuomo J. and Mestrovic, Tomislav and Mezgebe, Haftay Berhane and Miazgowski, Bartosz and Miazgowski, Tomasz and Millear, Anoushka I. and Miller, Ted R. and Miller-Petrie, Molly Katherine and Mini, G. K. and Mirabi, Parvaneh and Mirarefin, Mojde and Mirica, Andreea and Mirrakhimov, Erkin M. and Misganaw, Awoke Temesgen and Mitiku, Habtamu and Moazen, Babak and Mohammad, Karzan Abdulmuhsin and Mohammadi, Moslem and Mohammadifard, Noushin and Mohammed, Mohammed A. and Mohammed, Shafiu and Mohan, Viswanathan and Mokdad, Ali H. and Molokhia, Mariam and Monasta, Lorenzo and Moradi, Ghobad and Moradi-Lakeh, Maziar and Moradinazar, Mehdi and Moraga, Paula and Morawska, Lidia and {Velásquez}, Ilais Moreno and Morgado-Da-Costa, Joana and Morrison, Shane Douglas and Moschos, Marilita M. and Mouodi, Simin and Mousavi, Seyyed Meysam and Muchie, Kindie Fentahun and Mueller, Ulrich Otto and Mukhopadhyay, Satinath and Muller, Kate and Mumford, John Everett and Musa, Jonah and Musa, Kamarul Imran and Mustafa, Ghulam and Muthupandian, Saravanan and Nachega, Jean B. and Nagel, Gabriele and Naheed, Aliya and Nahvijou, Azin and Naik, Gurudatta and Nair, Sanjeev and Najafi, Farid and Naldi, Luigi and Nam, Hae Sung and Nangia, Vinay and Nansseu, Jobert Richie and Nascimento, Bruno Ramos and Natarajan, Gopalakrishnan and Neamati, Nahid and Negoi, Ionut and Negoi, Ruxandra Irina and Neupane, Subas and Newton, Charles R. J. and Ngalesoni, Frida N. and Ngunjiri, Josephine W. and Nguyen, Anh Quynh and Nguyen, Grant and Nguyen, Ha Thu and Nguyen, Huong Thanh and Nguyen, Long Hoang and Nguyen, Minh and Nguyen, Trang Huyen and Nichols, Emma and Ningrum, Dina Nur Anggraini and Nirayo, Yirga Legesse and Nixon, Molly R. and Nolutshungu, Nomonde and Nomura, Shuhei and Norheim, Ole F. and Noroozi, Mehdi and Norrving, Bo and Noubiap, Jean Jacques and Nouri, Hamid Reza and Shiadeh, Malihe Nourollahpour and Nowroozi, Mohammad Reza and Nyasulu, Peter S. and Odell, Christopher M. and Ofori-Asenso, Richard and Ogbo, Felix Akpojene and Oh, In-Hwan and Oladimeji, Olanrewaju and Olagunju, Andrew T. and Olivares, Pedro R. and Olsen, Helen Elizabeth and Olusanya, Bolajoko Olubukunola and Olusanya, Jacob Olusegun and Ong, Kanyin L. and Ong, Sok King Sk and Oren, Eyal and Orpana, Heather M. and Ortiz, Alberto and Ortiz, Justin R. and Otstavnov, Stanislav S. and {Øverland}, Simon and Owolabi, Mayowa Ojo and {Özdemir}, Raziye and A, Mahesh P. and Pacella, Rosana and Pakhale, Smita and Pakhare, Abhijit P. and Pakpour, Amir H. and Pana, Adrian and Panda-Jonas, Songhomitra and Pandian, Jeyaraj Durai and Parisi, Andrea and Park, Eun-Kee and Parry, Charles D. H. and Parsian, Hadi and Patel, Shanti and Pati, Sanghamitra and Patton, George C. and Paturi, Vishnupriya Rao and Paulson, Katherine R. and Pereira, Alexandre and Pereira, David M. and Perico, Norberto and Pesudovs, Konrad and Petzold, Max and Phillips, Michael R. and Piel, {Frédéric B.} and Pigott, David M. and Pillay, Julian David and Pirsaheb, Meghdad and Pishgar, Farhad and Polinder, Suzanne and Postma, Maarten J. and Pourshams, Akram and Poustchi, Hossein and Pujar, Ashwini and Prakash, Swayam and Prasad, Narayan and Purcell, Caroline A. and Qorbani, Mostafa and Quintana, Hedley and Quistberg, D. Alex and Rade, Kirankumar Waman and Radfar, Amir and Rafay, Anwar and Rafiei, Alireza and Rahim, Fakher and Rahimi, Kazem and Rahimi-Movaghar, Afarin and Rahman, Mahfuzar and Rahman, Mohammad Hifz Ur and Rahman, Muhammad Aziz and Rai, Rajesh Kumar and Rajsic, Sasa and Ram, Usha and Ranabhat, Chhabi Lal and Ranjan, Prabhat and Rao, Puja C. and Rawaf, David Laith and Rawaf, Salman and {Razo-García}, Christian and Reddy, K. Srinath and Reiner, Robert C. and Reitsma, Marissa B. and Remuzzi, Giuseppe and Renzaho, Andre M. N. and Resnikoff, Serge and Rezaei, Satar and Rezaeian, Shahab and Rezai, Mohammad Sadegh and Riahi, Seyed Mohammad and Ribeiro, Antonio Luiz P. and Rios-Blancas, Maria Jesus and Roba, Kedir Teji and Roberts, Nicholas L. S. and Robinson, Stephen R. and Roever, Leonardo and Ronfani, Luca and Roshandel, Gholamreza and Rostami, Ali and Rothenbacher, Dietrich and Roy, Ambuj and Rubagotti, Enrico and Sachdev, Perminder S. and Saddik, Basema and Sadeghi, Ehsan and Safari, Hosein and Safdarian, Mahdi and Safi, Sare and Safiri, Saeid and Sagar, Rajesh and Sahebkar, Amirhossein and Sahraian, Mohammad Ali and Salam, Nasir and Salama, Joseph S. and Salamati, Payman and Saldanha, Raphael De Freitas and Saleem, Zikria and Salimi, Yahya and Salvi, Sundeep Santosh and Salz, Inbal and Sambala, Evanson Zondani and Samy, Abdallah M. and Sanabria, Juan and {Sanchez-Niño}, Maria Dolores and Santomauro, Damian Francesco and Santos, Itamar S. and Santos, {João Vasco} and Milicevic, Milena M. Santric and Jose, Bruno Piassi Sao and Sarker, Abdur Razzaque and {Sarmiento-Suárez}, Rodrigo and Sarrafzadegan, Nizal and Sartorius, Benn and Sarvi, Shahabeddin and Sathian, Brijesh and Satpathy, Maheswar and Sawant, Arundhati R. and Sawhney, Monika and Saxena, Sonia and Sayyah, Mehdi and Schaeffner, Elke and Schmidt, {Maria Inês} and Schneider, Ione J. C. and {Schöttker}, Ben and Schutte, Aletta Elisabeth and Schwebel, David C. and Schwendicke, Falk and Scott, James G. and Sekerija, Mario and Sepanlou, Sadaf G. and {Serván-Mori}, Edson and Seyedmousavi, Seyedmojtaba and Shabaninejad, Hosein and Shackelford, Katya Anne and Shafieesabet, Azadeh and Shahbazi, Mehdi and Shaheen, Amira A. and Shaikh, Masood Ali and Shams-Beyranvand, Mehran and Shamsi, Mohammadbagher and Shamsizadeh, Morteza and Sharafi, Kiomars and Sharif, Mehdi and Sharif-Alhoseini, Mahdi and Sharma, Rajesh and She, Jun and Sheikh, Aziz and Shi, Peilin and Shiferaw, Mekonnen Sisay and Shigematsu, Mika and Shiri, Rahman and Shirkoohi, Reza and Shiue, Ivy and Shokraneh, Farhad and Shrime, Mark G. and Si, Si and Siabani, Soraya and Siddiqi, Tariq J. and Sigfusdottir, Inga Dora and Sigurvinsdottir, Rannveig and Silberberg, Donald H. and Silva, Diego Augusto Santos and Silva, {João Pedro} and Silva, Natacha Torres Da and Silveira, Dayane Gabriele Alves and Singh, Jasvinder A. and Singh, Narinder Pal and Singh, Prashant Kumar and Singh, Virendra and Sinha, Dhirendra Narain and Sliwa, Karen and Smith, Mari and Sobaih, Badr Hasan and Sobhani, Soheila and Sobngwi, {Eugène} and Soneji, Samir S. and Soofi, Moslem and Sorensen, Reed J. D. and Soriano, Joan B. and Soyiri, Ireneous N. and Sposato, Luciano A. and Sreeramareddy, Chandrashekhar T. and Srinivasan, Vinay and Stanaway, Jeffrey D. and Starodubov, Vladimir I. and Stathopoulou, Vasiliki and Stein, Dan J. and Steiner, Caitlyn and Stewart, Leo G. and Stokes, Mark A. and Subart, Michelle L. and Sudaryanto, Agus and Sufiyan, {Mu'awiyyah Babale} and Sur, Patrick John and Sutradhar, Ipsita and Sykes, Bryan L. and Sylaja, P. N. and Sylte, Dillon O. and Szoeke, Cassandra E. I. and {Tabarés-Seisdedos}, Rafael and Tabuchi, Takahiro and Tadakamadla, Santosh Kumar and Takahashi, Ken and Tandon, Nikhil and Tassew, Segen Gebremeskel and Taveira, Nuno and Tehrani-Banihashemi, Arash and Tekalign, Tigist Gashaw and Tekle, Merhawi Gebremedhin and Temsah, Mohamad-Hani and Temsah, Omar and Terkawi, Abdullah Sulieman and Teshale, Manaye Yihune and Tessema, Belay and Tessema, Gizachew Assefa and Thankappan, Kavumpurathu Raman and Thirunavukkarasu, Sathish and Thomas, Nihal and Thrift, Amanda G. and Thurston, George D. and Tilahun, Binyam and To, Quyen G. and Tobe-Gai, Ruoyan and Tonelli, Marcello and Topor-Madry, Roman and Torre, Anna E. and {Tortajada-Girbés}, Miguel and Touvier, Mathilde and Tovani-Palone, Marcos Roberto and Tran, Bach Xuan and Tran, Khanh Bao and Tripathi, Suryakant and Troeger, Christopher E. and Truelsen, Thomas Clement and Truong, Nu Thi and Tsadik, Afewerki Gebremeskel and Tsoi, Derrick and Car, Lorainne Tudor and Tuzcu, E. Murat and Tyrovolas, Stefanos and Ukwaja, Kingsley N. and Ullah, Irfan and Undurraga, Eduardo A. and Updike, Rachel L. and Usman, Muhammad Shariq and Uthman, Olalekan A. and Uzun, {Selen Begüm} and Vaduganathan, Muthiah and Vaezi, Afsane and Vaidya, Gaurang and Valdez, Pascual R. and Varavikova, Elena and Vasankari, Tommi Juhani and Venketasubramanian, Narayanaswamy and Villafaina, Santos and Violante, Francesco S. and Vladimirov, Sergey Konstantinovitch and Vlassov, Vasily and Vollset, Stein Emil and Vos, Theo and Wagner, Gregory R. and Wagnew, Fasil Shiferaw and Waheed, Yasir and Wallin, Mitchell Taylor and Walson, Judd L. and Wang, Yanping and Wang, Yuan-Pang and Wassie, Molla Mesele and Weiderpass, Elisabete and Weintraub, Robert G. and Weldegebreal, Fitsum and Weldegwergs, Kidu Gidey and Werdecker, Andrea and Werkneh, Adhena Ayaliew and West, T. Eoin and Westerman, Ronny and Whiteford, Harvey A. and Widecka, Justyna and Wilner, Lauren B. and Wilson, Shadrach and Winkler, Andrea Sylvia and Wiysonge, Charles Shey and Wolfe, Charles D. A. and Wu, Shouling and Wu, Yun-Chun and Wyper, Grant M. A. and Xavier, Denis and Xu, Gelin and Yadgir, Simon and Yadollahpour, Ali and Jabbari, Seyed Hossein Yahyazadeh and Yakob, Bereket and Yan, Lijing L. and Yano, Yuichiro and Yaseri, Mehdi and Yasin, Yasin Jemal and {Yentür}, {Gökalp Kadri} and Yeshaneh, Alex and Yimer, Ebrahim M. and Yip, Paul and Yirsaw, Biruck Desalegn and Yisma, Engida and Yonemoto, Naohiro and Yonga, Gerald and Yoon, Seok-Jun and Yotebieng, Marcel and Younis, Mustafa Z. and Yousefifard, Mahmoud and Yu, Chuanhua and Zadnik, Vesna and Zaidi, Zoubida and Zaman, Sojib Bin and Zamani, Mohammad and Zare, Zohreh and Zeleke, Ayalew Jejaw and Zenebe, Zerihun Menlkalew and Zhang, Anthony Lin and Zhang, Kai and Zhou, Maigeng and Zodpey, Sanjay and Zuhlke, Liesl Joanna and Naghavi, Mohsen and Murray, Christopher J. L.}, + year = {2018}, + month = {11}, + date = {2018-11-10}, + journal = {The Lancet}, + pages = {1736--1788}, + volume = {392}, + number = {10159}, + doi = {10.1016/S0140-6736(18)32203-7}, + url = {https://www.thelancet.com/journals/lancet/article/PIIS0140-6736(18)32203-7/abstract}, + langid = {English} +} + +@article{"asurve1920, + title = {{"}A Survey of Higher Education, 1916-1918.{"} U.S. Bureau of Education Bulletin, 1919}, + year = {1920}, + date = {1920}, + journal = {Bulletin of the American Association of University Professors (1915-1955)}, + pages = {12--13}, + volume = {6}, + number = {2}, + url = {http://www.jstor.org/stable/40216948} +}