Skip to content

Commit

Permalink
properly errors
Browse files Browse the repository at this point in the history
  • Loading branch information
privefl committed Nov 25, 2024
1 parent b57ef5b commit 184094c
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 6 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Encoding: UTF-8
Package: bigsnpr
Type: Package
Title: Analysis of Massive SNP Arrays
Version: 1.12.16
Date: 2024-09-24
Version: 1.12.17
Date: 2024-11-25
Authors@R: c(
person("Florian", "Privé", email = "[email protected]", role = c("aut", "cre")),
person("Michael", "Blum", role = "ths"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## bigsnpr 1.12.17

- Now properly errors when `ncol(G) != length(infos.chr)` in `snp_clumping()`. Also when `nrow(gwas) != length(infos.chr)` in `snp_manhattan()`.

## bigsnpr 1.12.16

- Add function `snp_projectSelfPCA()` (only `bed_projectSelfPCA()` existed).
Expand Down
4 changes: 3 additions & 1 deletion R/clumping.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ snp_clumping <- function(G, infos.chr,
ncores = 1) {

check_args()
assert_lengths(infos.chr, cols_along(G))

if (!missing(is.size.in.bp))
warning2("Parameter 'is.size.in.bp' is deprecated.")

if (!is.null(S)) assert_lengths(infos.chr, S)
if (!is.null(infos.pos)) assert_lengths(infos.pos, infos.chr)
if (!is.null(S)) assert_lengths(S, infos.chr)

ind.noexcl <- setdiff(seq_along(infos.chr), exclude)

Expand Down
1 change: 1 addition & 0 deletions R/man-qq-gc.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ snp_manhattan <- function(gwas, infos.chr, infos.pos,
coeff = 1) {

check_args(infos.chr = "")
assert_lengths(infos.chr, infos.pos, rows_along(gwas))

# get ordering
ord <- order(infos.chr, infos.pos)
Expand Down
10 changes: 7 additions & 3 deletions docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/testthat/test-2-bed-clumping-SVD.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ test_that("Scales work", {

POS <- bigSNP$map$physical.pos
CHR0 <- sort(rep_len(1:2, ncol(G)))
expect_error(snp_clumping(G, infos.chr = CHR0[1:5], infos.pos = POS),
"Incompatibility between dimensions")
expect_error(snp_clumping(G, infos.chr = CHR0, infos.pos = POS[1:5]),
"Incompatibility between dimensions")
ind.keep0 <- snp_clumping(G, infos.chr = CHR0, infos.pos = POS,
exclude = which(CHR0 == 1))
expect_true(all(CHR0[ind.keep0] == 2))
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-4-manhattan.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ test_that("snp_manhattan() works with unordered data", {
N <- ncol(G)
CHR <- sort(rep_len(1:2, N))
POS <- 1:N * 1000
expect_error(snp_manhattan(gwas, CHR[1:5], POS[1:5]),
"Incompatibility between dimensions")

rand <- sample(N)
# plot_grid(
# snp_manhattan(gwas, CHR, POS, dist.sep.chrs = 0),
Expand Down

0 comments on commit 184094c

Please sign in to comment.