diff --git a/DESCRIPTION b/DESCRIPTION index 71b1097..c7de546 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,8 +2,8 @@ Encoding: UTF-8 Package: bigsnpr Type: Package Title: Analysis of Massive SNP Arrays -Version: 1.12.9 -Date: 2024-05-15 +Version: 1.12.10 +Date: 2024-08-13 Authors@R: c( person("Florian", "Privé", email = "florian.prive.21@gmail.com", role = c("aut", "cre")), person("Michael", "Blum", role = "ths"), diff --git a/NEWS.md b/NEWS.md index 7597a48..f1b1711 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +## bigsnpr 1.12.10 + +- In function `snp_ancestry_summary()`, add parameter `sum_to_one` to optionally allows for ancestry coefficients to have a sum lower than 1 (when `FALSE`; default is `TRUE`). + ## bigsnpr 1.12.9 - In function `snp_modifyBuild()`, you can now provide `local_chain` as a vector of two, for when using `check_reverse`. You can now also modify the `base_url` from where to download the chain files. diff --git a/R/ancestry-summary.R b/R/ancestry-summary.R index 1f1400d..6822bc8 100644 --- a/R/ancestry-summary.R +++ b/R/ancestry-summary.R @@ -15,6 +15,8 @@ #' Default is 0.4. When correlation is lower, an error is returned. #' For individual genotypes, this should be larger than 0.6. #' For allele frequencies, this should be larger than 0.9. +#' @param sum_to_one Whether to force ancestry coefficients to sum to 1? +#' Default is `TRUE` (otherwise, the sum can be lower than 1). #' #' @return Vector of coefficients representing the ancestry proportions. #' Also (as attributes) `cor_each`, the correlation between input @@ -27,7 +29,7 @@ #' @example examples/example-ancestry-summary.R #' snp_ancestry_summary <- function(freq, info_freq_ref, projection, correction, - min_cor = 0.4) { + min_cor = 0.4, sum_to_one = TRUE) { assert_package("quadprog") assert_nona(freq) @@ -53,9 +55,9 @@ snp_ancestry_summary <- function(freq, info_freq_ref, projection, correction, res <- quadprog::solve.QP( Dmat = cp_X_pd$mat, dvec = crossprod(y, X), - Amat = cbind(1, diag(ncol(X))), - bvec = c(1, rep(0, ncol(X))), - meq = 1 + Amat = cbind(-1, diag(ncol(X))), + bvec = c(-1, rep(0, ncol(X))), + meq = `if`(sum_to_one, 1, 0) ) cor_pred <- drop(cor(drop(X0 %*% res$solution), freq)) diff --git a/docs/news/index.html b/docs/news/index.html index e7febc0..1738759 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -17,7 +17,7 @@ bigsnpr - 1.12.9 + 1.12.10 @@ -91,6 +91,10 @@

Changelog

Source: NEWS.md +
+ +