Subject: [bug#61891]

From: Mădălin Ionel Patrașcu<[email-masked]>
Date: Wed, 1 Mar 2023 11:53:39 +0100

Date: Wed, 1 Mar 2023 11:50:40 +0100
Subject: [PATCH] gnu: Test builds for r-maaslin and r-mmuphin.scm

This is my try to make the build of these two package reproducible.

I send this only in the case if the reviewer wants to dig more and maybe he can
solve the non deterministic build.
---
 gnu/packages/bioconductor.scm | 138 ++++++++++++++++++++++++++++++++++
 1 file changed, 138 insertions(+)

diff --git a/gnu/packages/bioconductor.scm b/gnu/packages/bioconductor.scm
index 7de5750e09..15fad711af 100644
--- a/gnu/packages/bioconductor.scm
+++ b/gnu/packages/bioconductor.scm
@@ -33,6 +33,7 @@ (define-module (gnu packages bioconductor)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix gexp)
   #:use-module (guix git-download)
   #:use-module (guix build-system r)
   #:use-module (gnu packages)
@@ -6533,6 +6534,80 @@ (define-public r-limma
 different technologies, including microarrays, RNA-seq, and quantitative PCR.")
     (license license:gpl2+)))
 
+(define-public r-maaslin2
+  (package
+    (name "r-maaslin2")
+    (version "1.12.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (bioconductor-uri "Maaslin2" version))
+       (sha256
+        (base32 "0ncvsywn9f8766gjb8nxzg82p3w30g8pjs85sy8s0bz9ilanpy89"))))
+    (properties `((upstream-name . "Maaslin2")))
+    (build-system r-build-system)
+    (arguments (list ;;#:tests? #f)) ;test suite is non-deterministic :(
+      #:phases
+      #~(modify-phases %standard-phases
+          ;; During the check there is needed for writable cache directory
+          ;; Fontconfig error: No writable cache directories
+          (add-before 'check 'set-cache
+            (lambda _
+              (setenv "XDG_CACHE_HOME" "/tmp/xdg-cache")))
+          ;; The check phase generates some log and pdf files. This cause that
+          ;; the build to be not reproducible
+          (add-after 'check 'make-reproducible
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let* ((out (string-append (assoc-ref outputs "out") "/site-library/Maaslin2/")))
+                (for-each delete-file-recursively
+                   (list ;;(string-append out "Maaslin2-Ex.Rout")
+                       ;;(string-append #$output "/Maaslin2-Ex.pdf")
+                       ;;(string-append #$output "/Maaslin2-tests/testthat/output")
+                       ;;(string-append #$output "/Maaslin2-tests/testthat/output2")
+                       ;;(string-append #$output "Maaslin2-tests/testthat.Rout")
+                       (string-append out "doc/demo_output/maaslin2.log")
+                       (string-append out "doc/demo_output/figures")
+                       ;;"doc/demo_output"
+                       )))))
+                       )))
+    (propagated-inputs
+     (list r-biglm
+           r-car
+           r-chemometrics
+           r-cplm
+           r-data-table
+           r-dplyr
+           r-edger
+           r-ggplot2
+           r-glmmtmb
+           r-hash
+           r-lme4
+           r-lmertest
+           r-logging
+           r-lpsymphony
+           r-mass
+           r-mumin
+           r-metagenomeseq
+           r-optparse
+           r-pbapply
+           r-pcapp
+           r-pheatmap
+           r-pscl
+           r-rmarkdown
+           r-robustbase
+           r-vegan))
+    (native-inputs (list r-knitr))
+    (home-page "http://huttenhower.sph.harvard.edu/maaslin2")
+    (synopsis
+     "Multivariable association discovery in population-scale meta-omics studies")
+    (description
+     "MaAsLin2 is comprehensive R package for efficiently determining multivariable
+association between clinical metadata and microbial meta'omic features.  This
+package relies on general linear models to accommodate most modern epidemiological
+study designs, including cross-sectional and longitudinal, and offers a variety
+of data exploration, normalization, and transformation methods.")
+    (license license:expat)))
+
 (define-public r-made4
   (package
     (name "r-made4")
@@ -6760,6 +6835,69 @@ (define-public r-methylkit
 TAB-Seq.")
     (license license:artistic2.0)))
 
+(define-public r-mmuphin
+  (package
+    (name "r-mmuphin")
+    (version "1.12.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (bioconductor-uri "MMUPHin" version))
+       (sha256
+        (base32 "0vpap3avmrjy187s3dva6f008al6d935kpdf816xzl5gxl7zvf62"))))
+    (properties `((upstream-name . "MMUPHin")))
+    (build-system r-build-system)
+    (arguments
+     (list ;;#:tests? #f)) ;; non deterministic, also it requieres http access
+      #:phases
+      #~(modify-phases %standard-phases
+        (add-after 'unpack 'adjusts-paths
+          (lambda* (#:key inputs outputs #:allow-other-keys)
+            (substitute* "inst/doc/MMUPHin.Rmd"
+                       (("../man/figures")
+                        (string-append #$output "/site-library/MMUPHin/help/figures")))
+            ;;(substitute* "inst/doc/MMUPHin.R"
+            ;;           (("library(ggplot2)") "library(ggplot2)\ngetwd()"))
+            ))
+        (add-after 'install 'add-files
+          (lambda* (#:key inputs outputs #:allow-other-keys)
+            (install-file "man/figures/structure_types.PNG"
+                          (string-append #$output "/site-library/MMUPHin/help/figures"))
+            (install-file "vignettes/references.bib"
+                          (string-append #$output "/site-library/MMUPHin/doc"))))
+        (add-before 'check 'set-cache
+          (lambda _
+            (setenv "XDG_CACHE_HOME" "/tmp/xdg-cache")))
+        )))
+    (inputs (list glpk
+ ;                 ;;pandoc
+ ;                 ;;r-rmarkdown
+                  ))
+    (propagated-inputs
+     (list r-cowplot
+           r-biocstyle
+           r-dplyr
+           r-fpc
+           r-ggplot2
+           r-igraph
+           r-maaslin2
+           r-metafor
+           r-stringr
+           r-tidyr))
+    (native-inputs (list r-knitr))
+    (home-page "https://bioconductor.org/packages/MMUPHin")
+    (synopsis "Meta-analysis with uniform pipeline for heterogeneity in microbiome")
+    (description
+     "MMUPHin is an R package for meta-analysis tasks of microbiome cohorts.  It
+has function interfaces for:
+@itemize
+@item covariate-controlled batch- and cohort effect adjustment;
+@item meta-analysis differential abundance testing;
+@item meta-analysis unsupervised discrete structure (clustering) discovery;
+@item meta-analysis unsupervised continuous structure discovery.
+@end itemize")
+    (license license:expat)))
+
 (define-public r-motifrg
   (package
     (name "r-motifrg")

base-commit: efa091f9f4e77068353dff24f0ccd2d0613c3f48
prerequisite-patch-id: 9e08f9ff2621a13d751e3d82c0837144b09494e4
prerequisite-patch-id: 4cfeb51eeb402b18b0d23c6782255a3bc1f1ff43
prerequisite-patch-id: cf4c417ccd15ef1f795ada39f3faee9f59bb3c36
prerequisite-patch-id: d79a8e82e46ec03cf54f25ec101a5b54592fdb1b
prerequisite-patch-id: 81871608ddab1ba624de7432ad473e52221efc08
-- 
2.39.1