From f9fddd2c24bb37a66ecb4695d73262e75d677243 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Sat, 21 Sep 2024 20:23:17 -0700 Subject: [PATCH 1/5] add test to confirm extra byte bug --- tests/testthat/test_genlight.R | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/testthat/test_genlight.R b/tests/testthat/test_genlight.R index b4c1e90..320135a 100644 --- a/tests/testthat/test_genlight.R +++ b/tests/testthat/test_genlight.R @@ -28,6 +28,24 @@ test_that("Genlight objects can be created predictably", { }) +test_that("(#363) genlight objects don't gain extra byte after subsetting", { + # https://github.com/thibautjombart/adegenet/issues/363 + + dat <- list(toto=c(1,2,0,0), titi=c(NA,1,2,0), tata=c(NA,0,2, NA))#3 individuals, 4 binary snps + + x <- new("genlight", gen = dat, ploidy = c(2,2,2,2), + loc.names = c("m1", "m2", "m3", "m4"), + loc.all = c("A/T", "A/T", "A/T", "A/T") + ) + x2 <- x[] + # the output tables should be equal + expect_equal(tab(x), tab(x2)) + # the snps should be equal + expect_equal(x, x2) + +}) + + x <- new("genlight", list(a=1,b=0,c=1), other=list(1:3, letters, data.frame(2:4)), parallel = FALSE) pop(x) <- c("pop1","pop1", "pop2") From f61ec5c7fb599905beccf1631781615e69296b33 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Sat, 21 Sep 2024 20:29:18 -0700 Subject: [PATCH 2/5] apply patch suggested by @maxcoulter This will fix #363 --- ChangeLog | 7 +++++++ DESCRIPTION | 2 +- R/glHandle.R | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d9eceeb..1c50356 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ + CHANGES IN ADEGENET VERSION 2.1.11 + +BUG FIX + +- genlight objects subset without any arguments to loci no longer gain an + extra byte. (reported: @maxcoulter, #363) + CHANGES IN ADEGENET VERSION 2.1.10 CRAN MAINTENANCE diff --git a/DESCRIPTION b/DESCRIPTION index 075e7e0..9a568e1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: adegenet Title: Exploratory Analysis of Genetic and Genomic Data -Version: 2.1.10 +Version: 2.1.11 Authors@R: c(person(given = "Thibaut", family = "Jombart", diff --git a/R/glHandle.R b/R/glHandle.R index 2971fae..dc7c105 100644 --- a/R/glHandle.R +++ b/R/glHandle.R @@ -4,7 +4,10 @@ # Take a raw vector, subset the bits and then convert to integers. xint <- as.integer(rawToBits(x)[i]) # Figure out how many zeroes are needed to pad the end. - zeroes <- 8 - (length(xint) %% 8) + extra_bits <- length(xint) %% 8 + # https://github.com/thibautjombart/adegenet/issues/363 + # Fix to a bug caught by @maxcoulter. In the case + zeroes <- if (extra_bits > 0) 8 - extra_bits else 0 # Convert the integer vector with zeroes on the end back into a raw vector. return(packBits(c(xint, rep(0L, zeroes)))) } From 03f4c53bec814b3f73d90744b4ae5dd2cba294dd Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Sat, 21 Sep 2024 20:41:46 -0700 Subject: [PATCH 3/5] add revdepcheck action --- .github/workflows/recheck.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/recheck.yml diff --git a/.github/workflows/recheck.yml b/.github/workflows/recheck.yml new file mode 100644 index 0000000..9bec389 --- /dev/null +++ b/.github/workflows/recheck.yml @@ -0,0 +1,18 @@ +on: + workflow_dispatch: + inputs: + which: + type: choice + description: Which dependents to check + options: + - strong + - most + +name: Reverse dependency check + +jobs: + revdep_check: + name: Reverse check ${{ inputs.which }} dependents + uses: r-devel/recheck/.github/workflows/recheck.yml@v1 + with: + which: ${{ inputs.which }} From c27d90b95b4417039fafaea52d3ee8cff6172285 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Sat, 21 Sep 2024 20:45:20 -0700 Subject: [PATCH 4/5] add Max Coulter as contributor --- DESCRIPTION | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9a568e1..ba267db 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -67,7 +67,10 @@ Authors@R: person(given = "Pavel", family = "Dimens", role = "ctb", - comment = c(ORCID = "0000-0003-3823-0373")) + comment = c(ORCID = "0000-0003-3823-0373")), + person(given = "Max", + family = "Coulter", + role = "ctb") ) Description: Toolset for the exploration of genetic and genomic data. Adegenet provides formal (S4) classes for storing and handling From a42857be704356687f1fe3241a235ce09f483205 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Sat, 21 Sep 2024 20:46:58 -0700 Subject: [PATCH 5/5] fix github handle --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1c50356..46b6c7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,7 @@ BUG FIX - genlight objects subset without any arguments to loci no longer gain an - extra byte. (reported: @maxcoulter, #363) + extra byte. (reported: @maxecoulter, #363) CHANGES IN ADEGENET VERSION 2.1.10