From 5b72e839d8593c778138c1c3a7514ab28da346f3 Mon Sep 17 00:00:00 2001 From: Adrien Taudiere Date: Sat, 10 Feb 2024 06:46:15 +0100 Subject: [PATCH 1/3] Improve test and examples for CRAN submission - mainly for windows build --- .github/workflows/pkgdown.yaml | 3 +++ DESCRIPTION | 16 ++-------------- R/Deseq2_edgeR.R | 2 +- R/dada_phyloseq.R | 7 +++++-- R/krona.R | 12 +++++++----- R/miscellanous.R | 2 +- man/count_seq.Rd | 2 ++ man/krona.Rd | 9 ++++++--- man/merge_krona.Rd | 3 +-- man/plot_edgeR_pq.Rd | 2 ++ man/track_wkflow.Rd | 9 +++++++++ man/track_wkflow_samples.Rd | 3 ++- tests/testthat/test_cutadapt.R | 2 ++ tests/testthat/test_figures_beta_div.R | 2 ++ tests/testthat/test_figures_taxo.R | 3 ++- tests/testthat/test_krona.R | 2 ++ tests/testthat/test_phyloseq_class.R | 1 + tests/testthat/test_table_functions.R | 2 ++ tests/testthat/test_targets.R | 2 ++ vignettes/MiscMetabar.Rmd | 2 +- 20 files changed, 55 insertions(+), 31 deletions(-) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 20ea224d..0364190d 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -34,6 +34,9 @@ jobs: - name: Install blastn run: sudo apt-get install ncbi-blast+ + - name: Install R packages not in DESCRIPTION + run: Rscript -e 'pak::pkg_install(c(datawizard, formattable, ggforce, ggtree, gtExtras, MicrobiotaProcess, pillar, pointblank, summarytools, svglite, tidytree, treeio))' + - name: Build site run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE, clean = TRUE) shell: Rscript {0} diff --git a/DESCRIPTION b/DESCRIPTION index 7e3b5bcc..bfb1f28f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: MiscMetabar Type: Package Title: Miscellaneous Functions for Metabarcoding Analysis -Version: 0.7.4 +Version: 0.7.5 Authors@R: person("Adrien", "Taudière", email = "adrien.taudiere@zaclys.net", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0003-1088-1182")) Description: The MiscMetabar package aims to facilitate the description, transformation, exploration, and reproducibility of metabarcoding analysis. Mainly build on the top of phyloseq, dada2 R packages. MiscMetabar help to build reproducible and robust bioinformatic pipeline in R. MiscMetabar make ecological analysis of alpha and beta-diversity simple and powerful by integrating a large number of analysis, some of them from other R packages. @@ -74,19 +74,7 @@ Suggests: venneuler, vctrs, viridis, - withr, - datawizard, - formattable, - ggforce, - ggtree, - gtExtras, - MicrobiotaProcess, - pillar, - pointblank, - summarytools, - svglite, - tidytree, - treeio + withr RoxygenNote: 7.3.1 URL: https://github.com/adrientaudiere/MiscMetabar, https://adrientaudiere.github.io/MiscMetabar/ diff --git a/R/Deseq2_edgeR.R b/R/Deseq2_edgeR.R index 13ad2106..60c8322b 100644 --- a/R/Deseq2_edgeR.R +++ b/R/Deseq2_edgeR.R @@ -19,7 +19,7 @@ #' or \code{\link[ggplot2]{ggplot}} #' #' @export -#' @examples +#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows" #' data("GlobalPatterns", package = "phyloseq") #' GP_archae <- subset_taxa(GlobalPatterns, GlobalPatterns@tax_table[, 1] == "Archaea") #' plot_edgeR_pq(GP_archae, c("SampleType", "Soil", "Feces"), diff --git a/R/dada_phyloseq.R b/R/dada_phyloseq.R index d454c999..76ae2361 100644 --- a/R/dada_phyloseq.R +++ b/R/dada_phyloseq.R @@ -227,6 +227,10 @@ clean_pq <- function(physeq, #' @return The number of sequences, clusters (e.g. OTUs, ASVs) and samples for #' each object. #' @export +#' @seealso [track_wkflow_samples()] +#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows" +#' data(enterotype) +#' track_wkflow(list(data_fungi, enterotype), taxonomy_rank = c(3, 5)) track_wkflow <- function(list_of_objects, obj_names = NULL, @@ -436,8 +440,7 @@ track_wkflow <- function(list_of_objects, #' @export #' @author Adrien Taudière #' -#' @examples -#' +#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows" #' tree_A10_005 <- subset_samples(data_fungi, Tree_name == "A10-005") #' track_wkflow_samples(tree_A10_005) track_wkflow_samples <- function(list_pq_obj, ...) { diff --git a/R/krona.R b/R/krona.R index af1c7ac1..fc44f7d3 100644 --- a/R/krona.R +++ b/R/krona.R @@ -19,11 +19,14 @@ #' your krona result files before merging using [merge_krona()] #' #' @examples +#' #' data("GlobalPatterns", package = "phyloseq") #' GA <- subset_taxa(GlobalPatterns, Phylum == "Acidobacteria") -#' # krona(GA, "Number.of.sequences.html") -#' # krona(GA, "Number.of.ASVs.html", nb_seq = FALSE) -#' # merge_krona(c("Number.of.sequences.html", "Number.of.ASVs.html")) +#' \dontrun{ +#' krona(GA, "Number.of.sequences.html") +#' krona(GA, "Number.of.ASVs.html", nb_seq = FALSE) +#' merge_krona(c("Number.of.sequences.html", "Number.of.ASVs.html")) +#' } #' @return A html file #' @export #' @seealso \code{\link{merge_krona}} @@ -107,8 +110,7 @@ krona <- #' @param output path to the output file #' #' @examples -#' krona_error_or_not <- try(system("ktImportText 2>&1", intern = TRUE)) -#' if (class(krona_error_or_not) != "try-error") { +#' \dontrun{ #' data("GlobalPatterns", package = "phyloseq") #' GA <- subset_taxa(GlobalPatterns, Phylum == "Acidobacteria") #' krona(GA, "Number.of.sequences.html", name = "Nb_seq_GP_acidobacteria") diff --git a/R/miscellanous.R b/R/miscellanous.R index 3dbd29ea..4a2e0080 100644 --- a/R/miscellanous.R +++ b/R/miscellanous.R @@ -195,7 +195,7 @@ perc <- function(x, y = NULL, accuracy = 0, add_symbol = FALSE) { #' @return the number of sequences #' @author Adrien Taudière #' @export -#' @examples +#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows" #' count_seq(file_path = system.file( #' "extdata", #' "ex.fasta", diff --git a/man/count_seq.Rd b/man/count_seq.Rd index 73949105..fa6375b5 100644 --- a/man/count_seq.Rd +++ b/man/count_seq.Rd @@ -22,6 +22,7 @@ Use grep to count the number of line with only one '+' (fastq, fastq.gz) or lines starting with a '>' (fasta) to count sequences. } \examples{ +\dontshow{if (tolower(Sys.info()[["sysname"]]) != "windows") (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} count_seq(file_path = system.file( "extdata", "ex.fasta", @@ -29,6 +30,7 @@ count_seq(file_path = system.file( mustWork = TRUE )) count_seq(folder_path = "extdata/", pattern = "*.fasta") +\dontshow{\}) # examplesIf} } \author{ Adrien Taudière diff --git a/man/krona.Rd b/man/krona.Rd index 5a0ad303..9532cc0e 100644 --- a/man/krona.Rd +++ b/man/krona.Rd @@ -47,11 +47,14 @@ Please cite \href{https://github.com/marbl/Krona}{Krona} if you use this function. } \examples{ + data("GlobalPatterns", package = "phyloseq") GA <- subset_taxa(GlobalPatterns, Phylum == "Acidobacteria") -# krona(GA, "Number.of.sequences.html") -# krona(GA, "Number.of.ASVs.html", nb_seq = FALSE) -# merge_krona(c("Number.of.sequences.html", "Number.of.ASVs.html")) +\dontrun{ + krona(GA, "Number.of.sequences.html") + krona(GA, "Number.of.ASVs.html", nb_seq = FALSE) + merge_krona(c("Number.of.sequences.html", "Number.of.ASVs.html")) +} } \seealso{ \code{\link{merge_krona}} diff --git a/man/merge_krona.Rd b/man/merge_krona.Rd index ba51e94b..44264414 100644 --- a/man/merge_krona.Rd +++ b/man/merge_krona.Rd @@ -31,8 +31,7 @@ Please cite \href{https://github.com/marbl/Krona}{Krona} if you use this function. } \examples{ -krona_error_or_not <- try(system("ktImportText 2>&1", intern = TRUE)) -if (class(krona_error_or_not) != "try-error") { +\dontrun{ data("GlobalPatterns", package = "phyloseq") GA <- subset_taxa(GlobalPatterns, Phylum == "Acidobacteria") krona(GA, "Number.of.sequences.html", name = "Nb_seq_GP_acidobacteria") diff --git a/man/plot_edgeR_pq.Rd b/man/plot_edgeR_pq.Rd index 9b13edbb..731321e9 100644 --- a/man/plot_edgeR_pq.Rd +++ b/man/plot_edgeR_pq.Rd @@ -44,6 +44,7 @@ A \code{\link{ggplot}}2 plot representing edgeR results \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}} } \examples{ +\dontshow{if ( tolower(Sys.info()[["sysname"]]) != "windows") (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} data("GlobalPatterns", package = "phyloseq") GP_archae <- subset_taxa(GlobalPatterns, GlobalPatterns@tax_table[, 1] == "Archaea") plot_edgeR_pq(GP_archae, c("SampleType", "Soil", "Feces"), @@ -54,6 +55,7 @@ plot_edgeR_pq(GP_archae, c("SampleType", "Soil", "Feces"), taxolev = "Class", color_tax = "Kingdom" ) } +\dontshow{\}) # examplesIf} } \seealso{ \code{\link[edgeR]{exactTest}} diff --git a/man/track_wkflow.Rd b/man/track_wkflow.Rd index 5099e998..1984231d 100644 --- a/man/track_wkflow.Rd +++ b/man/track_wkflow.Rd @@ -44,3 +44,12 @@ clusters and samples \item Phyloseq-class -> nb of reads, clusters and samples } } +\examples{ +\dontshow{if (tolower(Sys.info()[["sysname"]]) != "windows") (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +data(enterotype) +track_wkflow(list(data_fungi, enterotype), taxonomy_rank = c(3, 5)) +\dontshow{\}) # examplesIf} +} +\seealso{ +\code{\link[=track_wkflow_samples]{track_wkflow_samples()}} +} diff --git a/man/track_wkflow_samples.Rd b/man/track_wkflow_samples.Rd index 41b984d2..fe5373a3 100644 --- a/man/track_wkflow_samples.Rd +++ b/man/track_wkflow_samples.Rd @@ -23,9 +23,10 @@ Contrary to \code{\link[=track_wkflow]{track_wkflow()}}, only phyloseq object ar More information are available in the manual of the function \code{\link[=track_wkflow]{track_wkflow()}} } \examples{ - +\dontshow{if (tolower(Sys.info()[["sysname"]]) != "windows") (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} tree_A10_005 <- subset_samples(data_fungi, Tree_name == "A10-005") track_wkflow_samples(tree_A10_005) +\dontshow{\}) # examplesIf} } \author{ Adrien Taudière diff --git a/tests/testthat/test_cutadapt.R b/tests/testthat/test_cutadapt.R index ca4c2733..f46e5426 100644 --- a/tests/testthat/test_cutadapt.R +++ b/tests/testthat/test_cutadapt.R @@ -5,6 +5,8 @@ if (!MiscMetabar:::is_cutadapt_installed()) { ) } else { test_that("cutadapt_remove_primers works fine", { + skip_on_cran() + skip_on_os("windows") expect_silent(suppressMessages( res_cut <- cutadapt_remove_primers("inst/extdata", "TTC", "GAA", folder_output = paste0(tempdir(), "/output_cutadapt") diff --git a/tests/testthat/test_figures_beta_div.R b/tests/testthat/test_figures_beta_div.R index b5344e80..71adbd69 100644 --- a/tests/testthat/test_figures_beta_div.R +++ b/tests/testthat/test_figures_beta_div.R @@ -368,6 +368,7 @@ test_that("plot_SCBD_pq works with data_fungi_mini dataset", { }) test_that("multipatt_pq works with data_fungi_mini dataset", { + skip_on_os("windows") expect_s3_class( multipatt_pq(subset_samples(data_fungi_mini, !is.na(Time)), fact = "Time" @@ -378,6 +379,7 @@ test_that("multipatt_pq works with data_fungi_mini dataset", { }) test_that("multipatt_pq works with data_fungi_mini dataset", { + skip_on_os("windows") expect_type(suppressMessages(suppressWarnings(res_height <- ancombc_pq( subset_taxa_pq( data_fungi_sp_known, diff --git a/tests/testthat/test_figures_taxo.R b/tests/testthat/test_figures_taxo.R index fcff77a2..764dd9c1 100644 --- a/tests/testthat/test_figures_taxo.R +++ b/tests/testthat/test_figures_taxo.R @@ -13,6 +13,7 @@ GP_archae <- subset_taxa(GlobalPatterns, GlobalPatterns@tax_table[, 1] == "Archaea") test_that("rotl_pq works with data_fungi dataset", { + skip_on_os("windows") library("rotl") expect_s3_class(suppressWarnings(tr <- rotl_pq(data_fungi, species_colnames = "Genus_species")), "phylo") @@ -385,7 +386,7 @@ test_that("add_funguild_info and plot_guild_pq work with data_fungi_mini dataset test_that("build_phytree_pq work with data_fungi dataset", { - library("phangorn") + skip_on_os("windows") df <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 19000) expect_type(df_tree <- build_phytree_pq(df, nb_bootstrap = 2, rearrangement = "stochastic"), "list") expect_type(df_tree <- build_phytree_pq(df, nb_bootstrap = 2, rearrangement = "ratchet"), "list") diff --git a/tests/testthat/test_krona.R b/tests/testthat/test_krona.R index cdfcd3af..bb3eb6cb 100644 --- a/tests/testthat/test_krona.R +++ b/tests/testthat/test_krona.R @@ -4,6 +4,8 @@ GA <- subset_taxa(GlobalPatterns, Phylum == "Acidobacteria") krona_error_or_not <- try(system("ktImportText 2>&1", intern = TRUE)) if (class(krona_error_or_not) == "try-error") { + skip_on_cran() + skip_on_os("windows") test_that("krona send an error when krona is not installed", { expect_warning(krona(GA, "Number.of.sequences.html")) expect_warning(krona(GA, "Number.of.ASVs.html", nb_seq = FALSE)) diff --git a/tests/testthat/test_phyloseq_class.R b/tests/testthat/test_phyloseq_class.R index f8793ca5..02fd6d50 100644 --- a/tests/testthat/test_phyloseq_class.R +++ b/tests/testthat/test_phyloseq_class.R @@ -90,6 +90,7 @@ test_that("perc works fine", { }) test_that("count_seq works fine", { + skip_on_os("windows") expect_equal(count_seq("inst/extdata/ex_R1_001.fastq.gz"), 2500) expect_equal(count_seq("inst/extdata/ex_R2_001.fastq.gz"), 2500) expect_equal(count_seq("inst/extdata/ex.fasta"), 3) diff --git a/tests/testthat/test_table_functions.R b/tests/testthat/test_table_functions.R index 613e3d70..7d802e03 100644 --- a/tests/testthat/test_table_functions.R +++ b/tests/testthat/test_table_functions.R @@ -2,6 +2,7 @@ data(data_fungi) data(enterotype) test_that("tax_datatable function works fine with data_fungi dataset", { + skip_on_os("windows") expect_silent(taxdt <- tax_datatable(data_fungi)) expect_s3_class(taxdt, "datatables") expect_silent(taxdt <- tax_datatable(data_fungi, taxonomic_level = 1:2)) @@ -12,6 +13,7 @@ test_that("tax_datatable function works fine with data_fungi dataset", { test_that("tax_datatable function works fine with enterotype dataset", { + skip_on_os("windows") expect_silent(tax_datatable(enterotype)) expect_s3_class(tax_datatable(enterotype), "datatables") expect_silent(tax_datatable(enterotype, modality = enterotype@sam_data$SeqTech)) diff --git a/tests/testthat/test_targets.R b/tests/testthat/test_targets.R index 6e21f3c0..737229ad 100644 --- a/tests/testthat/test_targets.R +++ b/tests/testthat/test_targets.R @@ -78,6 +78,7 @@ data_fungi_test@otu_table[10, ] <- rep(0, ncol(data_fungi_test@otu_table)) test_that("track_wkflow function works fine", { + skip_on_os("windows") expect_message(track_wkflow(list( unlist(list_fastq_files("inst/extdata/")), data_fungi, enterotype ))) @@ -119,6 +120,7 @@ derep_R_001 <- "inst/extdata/ex_R2_001.fastq.gz" )) test_that("track_wkflow_samples function works fine with object of class matrix, dada and derep", { + skip_on_os("windows") expect_s3_class(track_wkflow( list( data_fungi@otu_table, diff --git a/vignettes/MiscMetabar.Rmd b/vignettes/MiscMetabar.Rmd index 042e390b..89353798 100644 --- a/vignettes/MiscMetabar.Rmd +++ b/vignettes/MiscMetabar.Rmd @@ -29,7 +29,7 @@ knitr::opts_chunk$set( For an introduction to metabarcoding in R, Please visite the [state of the field](https://adrientaudiere.github.io/MiscMetabar/articles/states_of_fields_in_R.html) vignettes. The [import, export and track](https://adrientaudiere.github.io/MiscMetabar/articles/import_export_track.html) vignette explains how import and export `phyloseq` object. Its also show how to summarize useful information (number of sequences, samples and clusters) accross bioinformatic pipelines. If you are interested in ecological metrics, see the vignettes describing [alpha-diversity](https://adrientaudiere.github.io/MiscMetabar/articles/alpha-div.html) and [beta-diversity](https://adrientaudiere.github.io/MiscMetabar/articles/beta-div.html) analysis. -The vignette [filter taxa and samples](https://adrientaudiere.github.io/MiscMetabar/articles/filter.html) describes some data-filtering processes using MiscMetabar and the [reclustering](https://adrientaudiere.github.io/MiscMetabar/articles/Reclustering.html) tutorial introduces the different way of clustering already-clustered OTU/ASV. The vignette [tengeler]() explore the dataset from Tengeler et al. (2020) using some MiscMetabar functions. +The vignette [filter taxa and samples](https://adrientaudiere.github.io/MiscMetabar/articles/filter.html) describes some data-filtering processes using MiscMetabar and the [reclustering](https://adrientaudiere.github.io/MiscMetabar/articles/Reclustering.html) tutorial introduces the different way of clustering already-clustered OTU/ASV. The vignette [tengeler](https://adrientaudiere.github.io/MiscMetabar/articles/tengeler.html) explore the dataset from Tengeler et al. (2020) using some MiscMetabar functions. For developers, I also wrote a vignette describing som [rules of codes](https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html). From fddfb8af19becfda0a26cdb947a765dc5d9f82d6 Mon Sep 17 00:00:00 2001 From: Adrien Taudiere Date: Sat, 10 Feb 2024 06:52:25 +0100 Subject: [PATCH 2/3] Improve test and examples for CRAN submission - mainly for windows build --- vignettes/MiscMetabar.Rmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vignettes/MiscMetabar.Rmd b/vignettes/MiscMetabar.Rmd index 89353798..91774e60 100644 --- a/vignettes/MiscMetabar.Rmd +++ b/vignettes/MiscMetabar.Rmd @@ -62,10 +62,10 @@ sankey_pq(gp, taxa = c(1:5)) ``` -### Circle for visualize distribution of taxa in function of samples variables +### Upset plot for visualize distribution of taxa in function of samples variables ```{r} -circle_pq(gp, "SampleType", taxa = "Class") +upset_pq(gp, "SampleType", taxa = "Class") ``` From b7f917f260f5077885667862d478ba417fa41912 Mon Sep 17 00:00:00 2001 From: Adrien Taudiere Date: Sat, 10 Feb 2024 07:07:41 +0100 Subject: [PATCH 3/3] Improve README for windows users --- README.Rmd | 9 +++++++-- README.md | 12 +++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.Rmd b/README.Rmd index 99aa4e0f..e4f9e993 100644 --- a/README.Rmd +++ b/README.Rmd @@ -76,7 +76,6 @@ The article [filter taxa and samples](https://adrientaudiere.github.io/MiscMetab For developers, I also wrote a article describing som [rules of codes](https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html). - ### Summarize a physeq object ```{r example} @@ -109,11 +108,17 @@ ggvenn_pq(data_fungi, fact = "Height") + labs(title = "Share number of ASV among Height in tree") ``` +### Note for non-linux users + +Some functions may not work on windows (*e.g.* [track_wflow()], [cutadapt_remove_primers()], [krona()], [vsearch_clustering()], ...). A solution is to exploit docker container, for example the using the great [rocker project](https://rocker-project.org/). + +MiscMetabar is developed under Linux and the vast majority of functions may works on Unix system, but its functionning is not test under iOS. + ### Installation of other softwares for debian Linux distributions If you encounter any errors or have any questions about the installation of these softwares, please visit their dedicated websites. -#### [blast@](https://blast.ncbi.nlm.nih.gov/doc/blast-help/downloadblastdata.html#downloadblastdata) +#### [blast+](https://blast.ncbi.nlm.nih.gov/doc/blast-help/downloadblastdata.html#downloadblastdata) ```sh sudo apt-get install ncbi-blast+ diff --git a/README.md b/README.md index fd6934a6..6b715877 100644 --- a/README.md +++ b/README.md @@ -155,12 +155,22 @@ ggvenn_pq(data_fungi, fact = "Height") + +### Note for non-linux users + +Some functions may not work on windows (*e.g.* \[track_wflow()\], +\[cutadapt_remove_primers()\], \[krona()\], \[vsearch_clustering()\], +…). A solution is to exploit docker container, for example the using the +great [rocker project](https://rocker-project.org/). + +MiscMetabar is developed under Linux and the vast majority of functions +may works on Unix system, but its functionning is not test under iOS. + ### Installation of other softwares for debian Linux distributions If you encounter any errors or have any questions about the installation of these softwares, please visit their dedicated websites. -#### [blast@](https://blast.ncbi.nlm.nih.gov/doc/blast-help/downloadblastdata.html#downloadblastdata) +#### [blast+](https://blast.ncbi.nlm.nih.gov/doc/blast-help/downloadblastdata.html#downloadblastdata) ``` sh sudo apt-get install ncbi-blast+