From 1841bda1abe08cd70efc89063dd9650a0941ef68 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Tue, 4 Feb 2025 18:21:44 -0800 Subject: [PATCH 1/9] update changelog --- ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 46b6c7b..75e9033 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,14 @@ BUG FIX - genlight objects subset without any arguments to loci no longer gain an extra byte. (reported: @maxecoulter, #363) +MISC + +- `spca_randtest()` has been updated with a new p argument to include a + Bonferroni correction (fixed in #368, but initially implemented by @valemon + in #247) +- `find.clust()` data frame method now sets `scale = FALSE` to align with the + other methods. (reported: @cassondranewman, #362; fixed: @tiagomaie, #366) + CHANGES IN ADEGENET VERSION 2.1.10 CRAN MAINTENANCE From 9787efb3eedfe32540addf9ad3b05211f28c7d0f Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Wed, 5 Feb 2025 16:47:27 -0800 Subject: [PATCH 2/9] add catch to avoid overflow in byte conversion fns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I also fixed some indentation issues. This was prompted by a message I got from Ivan. I took his suggestion and applied it to `bytesToInt()` and `bytesToDouble()` Ivan Krylov 2:05 AM (14 hours ago) to me Dear Zhian, Thank you for undertaking the fix on such a short notice! I'm afraid there's still one reachable overflow. Consider the case of an SNPbin object with nLoc(.) = 201 byte-packed SNPs. They have to be stored in ceiling(201/8) = 26 bytes, with 7 last bits used for padding. Currently, the functions bytesToInt(), bytesToDouble() [*] always write (*veclength)*8 entries into the destination vector. When nLoc(.) is not divisible by 8, this will cause them to decode and write the padding bytes past the end of 'vecres'. The original case caught by dartR.base involves such an object (with nLoc(.) = 199). I think that the overflow can be avoided by adding a check to the innermost loop: for(j=0;j<=7;j++){ if (j+idres >= *reslength) break; // do not decode padding bytes --- src/snpbin.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/snpbin.c b/src/snpbin.c index 4beab92..94f6707 100644 --- a/src/snpbin.c +++ b/src/snpbin.c @@ -146,11 +146,11 @@ void bytesToBinInt(unsigned char *vecbytes, int *vecsize, int *vecres){ temp = (int *) calloc(8, sizeof(int)); for(i=0;i<*vecsize;i++){ - byteToBinInt(vecbytes[i], temp); - for(j=0;j<=7;j++){ - vecres[j+idres] = temp[j]; - } - idres = idres + 8; + byteToBinInt(vecbytes[i], temp); + for(j=0;j<=7;j++){ + vecres[j+idres] = temp[j]; + } + idres = idres + 8; } free(temp); @@ -186,19 +186,20 @@ void bytesToInt(unsigned char *vecbytes, int *veclength, int *nbvec, int *vecres /* initialize result vector to 0 */ for(i=0; i < *reslength; i++){ - vecres[i]=0; + vecres[i]=0; } /* build output */ for(k=0;k<*nbvec;k++){ /* for all input vector */ - idres = 0; - for(i=0;i<*veclength;i++){ /* for one input vector */ - byteToBinInt(vecbytes[i+ k* *veclength], temp); /* byte -> 8 int (0/1)*/ - for(j=0;j<=7;j++){ /* fill in the result*/ - vecres[j+idres] += temp[j]; - } - idres = idres + 8; - } + idres = 0; + for(i=0;i<*veclength;i++){ /* for one input vector */ + byteToBinInt(vecbytes[i+ k* *veclength], temp); /* byte -> 8 int (0/1)*/ + for(j=0;j<=7;j++){ /* fill in the result*/ + if (j+idres >= *reslength) break; // do not decode padding bytes + vecres[j+idres] += temp[j]; + } + idres = idres + 8; + } } free(temp); } /* end bytesToInt */ @@ -214,18 +215,19 @@ void bytesToDouble(unsigned char *vecbytes, int *veclength, int *nbvec, double * /* initialize result vector to 0 */ for(i=0; i < *reslength; i++){ - vecres[i]=0.0; + vecres[i]=0.0; } for(k=0;k<*nbvec;k++){ /* for all input vector */ - idres = 0; - for(i=0;i<*veclength;i++){ /* for one input vector */ - byteToBinDouble(vecbytes[i+ k* *veclength], temp); /* byte -> 8 double (0/1)*/ - for(j=0;j<=7;j++){ /* fill in the result*/ - vecres[j+idres] += temp[j]; - } - idres = idres + 8; - } + idres = 0; + for(i=0;i<*veclength;i++){ /* for one input vector */ + byteToBinDouble(vecbytes[i+ k* *veclength], temp); /* byte -> 8 double (0/1)*/ + for(j=0;j<=7;j++){ /* fill in the result*/ + if (j+idres >= *reslength) break; // do not decode padding bytes + vecres[j+idres] += temp[j]; + } + idres = idres + 8; + } } free(temp); } /* end bytesToInt */ From f3297efee2dd76cd717f2efec07342e318e890b6 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Wed, 5 Feb 2025 16:56:10 -0800 Subject: [PATCH 3/9] add Ivan as contributor --- ChangeLog | 2 ++ DESCRIPTION | 3 +++ 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 75e9033..e87678c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ BUG FIX - genlight objects subset without any arguments to loci no longer gain an extra byte. (reported: @maxecoulter, #363) +- internal C functions `bytesToInt()` and `bytesToDouble()` have a new + condition to prevent overflows (thanks for the suggested fix by Ivan Krylov) MISC diff --git a/DESCRIPTION b/DESCRIPTION index 8486086..048b820 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -70,6 +70,9 @@ Authors@R: comment = c(ORCID = "0000-0003-3823-0373")), person(given = "Max", family = "Coulter", + role = "ctb"), + person(given = "Ivan", + family = "Krylov", role = "ctb") ) Description: Toolset for the exploration of genetic and genomic From 369cbe2e6b89dcf5a68732315c40c1ad65db7dad Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Wed, 5 Feb 2025 17:45:24 -0800 Subject: [PATCH 4/9] fix CRAN notes --- R/import.R | 2 +- R/strataMethods.R | 2 +- inst/CITATION | 8 ++++---- man/df2genind.Rd | 2 +- man/pairDist.Rd | 2 +- man/strata-methods.Rd | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/R/import.R b/R/import.R index 96aafde..74d9e9c 100644 --- a/R/import.R +++ b/R/import.R @@ -62,7 +62,7 @@ #' for your samples. This is especially useful if you have a hierarchical or #' factorial sampling design. #' @param hierarchy a hierarchical formula that explicitely defines hierarchical -#' levels in your strata. see \code{\link{hierarchy}} for details. +#' levels in your strata. #' @param check.ploidy a boolean indicating if the ploidy should be checked (TRUE, #' default) or not (FALSE). Not checking the ploidy makes the import much faster, #' but might result in bugs/problems if the input file is misread or the ploidy is diff --git a/R/strataMethods.R b/R/strataMethods.R index d13032a..600e410 100644 --- a/R/strataMethods.R +++ b/R/strataMethods.R @@ -216,7 +216,7 @@ #' levels of the strata. An example of a hierarchical formula would #' be:\tabular{r}{ \code{~Country/City/Neighborhood}} This convention was #' chosen as it becomes easier to type and makes intuitive sense when defining -#' a \code{\link{hierarchy}}. Note: it is important to use hiearchical +#' a hierarchy. Note: it is important to use hiearchical #' formulas when specifying hierarchies as other types of formulas (eg. #' \code{~Country*City*Neighborhood}) will give incorrect results.} #' diff --git a/inst/CITATION b/inst/CITATION index 55baadc..31f9109 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -1,7 +1,7 @@ citHeader("To cite the adegenet package:") -citEntry( -entry="Article", +bibentry( +bibtype="Article", title = "adegenet: a R package for the multivariate analysis of genetic markers", journal= "Bioinformatics", year = "2008", @@ -13,8 +13,8 @@ textVersion = "Jombart, T. (2008) adegenet: a R package for the multivariate ana ) -citEntry( -entry="Article", +bibentry( +bibtype="Article", title = "adegenet 1.3-1: new tools for the analysis of genome-wide SNP data", journal= "Bioinformatics", year = "2011", diff --git a/man/df2genind.Rd b/man/df2genind.Rd index ef239aa..3af8558 100644 --- a/man/df2genind.Rd +++ b/man/df2genind.Rd @@ -52,7 +52,7 @@ for your samples. This is especially useful if you have a hierarchical or factorial sampling design.} \item{hierarchy}{a hierarchical formula that explicitely defines hierarchical -levels in your strata. see \code{\link{hierarchy}} for details.} +levels in your strata.} \item{check.ploidy}{a boolean indicating if the ploidy should be checked (TRUE, default) or not (FALSE). Not checking the ploidy makes the import much faster, diff --git a/man/pairDist.Rd b/man/pairDist.Rd index 1d21177..092a140 100644 --- a/man/pairDist.Rd +++ b/man/pairDist.Rd @@ -45,7 +45,7 @@ pairDistPlot(x, \dots) object. For \code{\linkS4class{genind}} objects, pairwise squared Euclidean distances are computed from the allele data. For \code{DNAbin} objects, distances are computed uing - \code{\link{dist.dna}}, and '...' is used to pass arguments to the + \code{dist.dna}, and '...' is used to pass arguments to the function. } \item{grp}{a factor defining a grouping of individuals.} diff --git a/man/strata-methods.Rd b/man/strata-methods.Rd index 11d7510..e6980fa 100644 --- a/man/strata-methods.Rd +++ b/man/strata-methods.Rd @@ -110,7 +110,7 @@ or genlight object. levels of the strata. An example of a hierarchical formula would be:\tabular{r}{ \code{~Country/City/Neighborhood}} This convention was chosen as it becomes easier to type and makes intuitive sense when defining - a \code{\link{hierarchy}}. Note: it is important to use hiearchical + a hierarchy. Note: it is important to use hiearchical formulas when specifying hierarchies as other types of formulas (eg. \code{~Country*City*Neighborhood}) will give incorrect results.} } From 3c133493ceeb63838143e8aea099f1a0a975e7b7 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Wed, 5 Feb 2025 17:48:04 -0800 Subject: [PATCH 5/9] submit to CRAN --- CRAN-SUBMISSION | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 95397d8..0340e7d 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 2.1.10 -Date: 2023-01-25 22:44:37 UTC -SHA: 67d986732c578ff8f65884b4ca622c39f36da995 +Version: 2.1.11 +Date: 2025-02-06 01:47:46 UTC +SHA: 369cbe2e6b89dcf5a68732315c40c1ad65db7dad From ec6a4fb07a8c7abe57b6b4e83353f4c6569d8286 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Thu, 6 Feb 2025 11:16:34 -0800 Subject: [PATCH 6/9] remove non-generic s3 methods --- NAMESPACE | 6 +++--- R/basicMethods.R | 2 -- R/haploGen.R | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 9628ab6..3eae3c0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -47,8 +47,6 @@ S3method(gengraph,genpop) S3method(gengraph,matrix) S3method(get.likelihood,seqTrack) S3method(graphMutations,DNAbin) -S3method(is,genind) -S3method(is,genpop) S3method(labels,haploGen) S3method(loadingplot,default) S3method(loadingplot,glPca) @@ -70,7 +68,6 @@ S3method(print,haploGen) S3method(print,monmonier) S3method(print,spca) S3method(rbind,genlight) -S3method(sample,haploGen) S3method(scatter,dapc) S3method(scatter,glPca) S3method(screeplot,spca) @@ -128,6 +125,8 @@ export(genind2genpop) export(genpop) export(hier) export(hybridize) +export(is.genind) +export(is.genpop) export(loadingplot) export(makefreq) export(minorAllele) @@ -142,6 +141,7 @@ export(read.genetix) export(read.snp) export(read.structure) export(repool) +export(sample.haploGen) export(scaleGen) export(seqTrack) export(setPop) diff --git a/R/basicMethods.R b/R/basicMethods.R index f19b59f..ba05ba3 100644 --- a/R/basicMethods.R +++ b/R/basicMethods.R @@ -543,14 +543,12 @@ print.genpopSummary <- function(x, ...){ ############### # Methods "is" ############### -#' @method is genind #' @export is.genind <- function(x){ res <- ( is(x, "genind") & validObject(x)) return(res) } -#' @method is genpop #' @export is.genpop <- function(x){ res <- ( is(x, "genpop") & validObject(x)) diff --git a/R/haploGen.R b/R/haploGen.R index 2f7ee48..e5b2dbc 100644 --- a/R/haploGen.R +++ b/R/haploGen.R @@ -526,7 +526,6 @@ plotHaploGen <- function(x, annot=FALSE, date.range=NULL, col=NULL, bg="grey", a ################### ## sample.haploGen ################### -#' @method sample haploGen #' @export sample.haploGen <- function(x, n){ ##sample.haploGen <- function(x, n, rDate=.rTimeSeq, arg.rDate=NULL){ From 01f3f3a6dea4668618b348cda3c9aa2e7287f42e Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Thu, 6 Feb 2025 12:06:17 -0800 Subject: [PATCH 7/9] submit to CRAN again --- CRAN-SUBMISSION | 4 ++-- cran-comments.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 0340e7d..4e02cee 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ Version: 2.1.11 -Date: 2025-02-06 01:47:46 UTC -SHA: 369cbe2e6b89dcf5a68732315c40c1ad65db7dad +Date: 2025-02-06 20:05:59 UTC +SHA: ec6a4fb07a8c7abe57b6b4e83353f4c6569d8286 diff --git a/cran-comments.md b/cran-comments.md index 0956d95..31e39db 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1 +1 @@ -This update fixes an error thrown by LLVM in C23 mode by removing the `typedef short bool` definition in `snpbin.h` +This fixes a buffer overflow that was negatively affecting dartR.base From 43a3b10c137ff05d1282f44eeab5d25418a7f841 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Thu, 6 Feb 2025 13:22:55 -0800 Subject: [PATCH 8/9] document exported function --- man/auxil.Rd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/man/auxil.Rd b/man/auxil.Rd index 6f043fd..f67dedb 100644 --- a/man/auxil.Rd +++ b/man/auxil.Rd @@ -5,6 +5,7 @@ \alias{.rmspaces} \alias{.genlab} \alias{.readExt} +\alias{.render.server.info} \alias{corner} \alias{num2col} \alias{fac2col} @@ -50,6 +51,7 @@ \item \code{.rmspaces}: remove peripheric spaces in a character string. \item \code{.genlab}: generate labels in a correct alphanumeric ordering. \item \code{.readExt}: read the extension of a given file. + \item \code{.render.server.info} used to display session information for the dapcServer } Color palettes include: From dc7c741356d5b709a45b166bd9fdb597e906bb07 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Thu, 6 Feb 2025 13:24:19 -0800 Subject: [PATCH 9/9] resubmit --- CRAN-SUBMISSION | 4 ++-- docker/testing/Dockerfile | 31 ++++++++++--------------------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 4e02cee..3dc23bf 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ Version: 2.1.11 -Date: 2025-02-06 20:05:59 UTC -SHA: ec6a4fb07a8c7abe57b6b4e83353f4c6569d8286 +Date: 2025-02-06 21:23:37 UTC +SHA: 43a3b10c137ff05d1282f44eeab5d25418a7f841 diff --git a/docker/testing/Dockerfile b/docker/testing/Dockerfile index 32c263c..75e584f 100644 --- a/docker/testing/Dockerfile +++ b/docker/testing/Dockerfile @@ -1,9 +1,9 @@ -FROM rocker/drd +FROM rocker/r-devel-san MAINTAINER Thibaut Jombart RUN apt-get update && apt-get upgrade -y -RUN apt-get install libssl-dev libxml2-dev pandoc pandoc-citeproc libblas-dev liblapack-dev git qpdf -y +RUN apt-get install -y libcurl4-openssl-dev libssl-dev libfontconfig1-dev libxml2-dev libharfbuzz-dev libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev gdal-bin proj-bin libgdal-dev libproj-dev libgmp3-dev jags libfftw3-dev ## add guest user @@ -15,35 +15,24 @@ RUN chmod a+rw /usr/local/lib/R/site-library -R ## install CRAN packages -RUN echo 'options(download.file.method = "libcurl", repos = c(CRAN = "https://cran.ma.imperial.ac.uk"))' > ~/.Rprofile +# RUN echo 'options(download.file.method = "libcurl", repos = c(CRAN = "https://cran.ma.imperial.ac.uk"))' > ~/.Rprofile RUN r -e "install.packages('devtools')" \ - && r -e "install.packages('roxygen2')" \ - && r -e "install.packages('testthat')" \ - && r -e "install.packages('rmarkdown')" \ - && r -e "install.packages('adegenet', dependencies = c('Depends', 'Imports'))" \ - && r -e "install.packages('pegas')" \ - && r -e "install.packages('hierfstat')" \ - && r -e "install.packages('poppr')" \ - && r -e "install.packages('akima')" \ - && r -e "install.packages('maps')" \ - && r -e "install.packages('splancs')" \ - && r -e "install.packages('tripack')" + && r -e "install.packages('adegenet', dependencies = TRUE)" - - -## install devel packages (github) - -RUN r -e "devtools::install_github('thibautjombart/adegenet')" +RUN r -e 'install.packages("BiocManager")' \ + && r -e 'BiocManager::install("SNPRelate")' \ + && r -e 'install.packages("dartR.base")' ## clone repos to get sources +RUN apt-get install -y git RUN su guest RUN mkdir ~/dev WORKDIR /home/guest/dev -RUN git clone https://github.com/thibautjombart/adegenet +COPY . . WORKDIR /home/guest/ -RUN ls='ls --color=auto' +CMD Rscript -e 'library(dartR.base); gl.pcoa(testset.gl)'