diff --git a/DESCRIPTION b/DESCRIPTION index 7418d853..f0624ddf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,17 +1,17 @@ Package: MiscMetabar Type: Package Title: Miscellaneous Functions for Metabarcoding Analysis -Version: 0.7.8 +Version: 0.7.10 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 bioinformatics pipelines 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. +Description: Facilitate the description, transformation, exploration, and reproducibility of metabarcoding analyses. 'MiscMetabar' is mainly built on top of the 'phyloseq', 'dada2' and 'targets' R packages. It helps to build reproducible and robust bioinformatics pipelines in R. 'MiscMetabar' makes ecological analysis of alpha and beta-diversity easier, more reproducible and more powerful by integrating a large number of tools. Important features are described in Taudière A. (2023) . License: AGPL-3 Encoding: UTF-8 LazyData: true Depends: R (>= 3.5.0), phyloseq, - ggplot2, + ggplot2 (>= 3.5.0), dada2, dplyr Suggests: diff --git a/NAMESPACE b/NAMESPACE index d7f480ca..1ad99c88 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -51,7 +51,12 @@ export(hill_pq) export(hill_tuckey_phyloseq) export(hill_tuckey_pq) export(iNEXT_pq) -export(install_pkg_needed) +export(is_cutadapt_installed) +export(is_falco_installed) +export(is_krona_installed) +export(is_mumu_installed) +export(is_swarm_installed) +export(is_vsearch_installed) export(krona) export(list_fastq_files) export(lulu) diff --git a/NEWS.md b/NEWS.md index ef1093bb..a0899928 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# MiscMetabar 0.8 (in development) + +- Add param `plot_with_tuckey` to `hill_pq()`. + + + # MiscMetabar 0.7 (in development) - Add functions `chimera_detection_vs()` and `chimera_removal_vs()` to process chimera detection and removal using [vsearch](https://github.com/torognes/vsearch) software @@ -8,7 +14,7 @@ - Add function `cutadapt_remove_primers()` to remove primers using [cutadapt](https://github.com/marcelm/cutadapt/) - Add internal functions `is_swarm_installed()`, `is_cutadapt_installed()`, `is_vsearch_installed()` and `is_falco_installed()` to test for the availability of external software in order to run examples and test from testthat. -- Submit to CRAN and change code to comply with their rules (patch 0.7.1 to 0.7.8) +- Submit to CRAN and change code to comply with their rules (patch 0.7.1 to 0.7.9) - Numerous examples and tests are skipped on CRAN because it spends to much time to run. Rules vignettes is updated to details the strategy for this. @@ -25,6 +31,7 @@ - `sequences` -> `seq2search` in function `search_exact_seq_pq()` - `seq_names` -> `dna_seq` in function `asv2otu` +- Removing the function `install_pkg_needed()` which do not comply with CRAN policies # MiscMetabar 0.6.0 diff --git a/R/beta_div_test.R b/R/beta_div_test.R index 8940e745..621de7af 100644 --- a/R/beta_div_test.R +++ b/R/beta_div_test.R @@ -23,9 +23,9 @@ #' [phyloseqGraphTest::graph_perm_test()] function #' #' @examples +#' \donttest{ #' data(enterotype) #' graph_test_pq(enterotype, fact = "SeqTech") -#' \donttest{ #' graph_test_pq(enterotype, fact = "Enterotype", na_remove = TRUE) #' } #' @author Adrien Taudière @@ -119,6 +119,7 @@ graph_test_pq <- function(physeq, #' `phyloseq::rarefy_even_depth()`. #' if `correction_for_sample_size` is TRUE, rarefy_nb_seqs will have no #' effect. +#' @param verbose (logical, default TRUE) If TRUE, prompt some messages. #' @param ... Other arguments passed on to [vegan::adonis2()] function. #' @return The function returns an anova.cca result object with a #' new column for partial R^2. See help of [vegan::adonis2()] for @@ -144,6 +145,7 @@ adonis_pq <- function(physeq, na_remove = FALSE, correction_for_sample_size = FALSE, rarefy_nb_seqs = FALSE, + verbose = TRUE, ...) { physeq <- clean_pq( physeq, @@ -175,7 +177,9 @@ adonis_pq <- function(physeq, if (na_remove) { new_physeq <- physeq for (tl in term_lab) { - print(tl) + if (verbose) { + message(tl) + } new_physeq <- subset_samples_pq(new_physeq, !is.na(physeq@sam_data[[tl]])) } @@ -257,8 +261,6 @@ LCBD_pq <- function(physeq, silent = TRUE ) - install_pkg_needed("adespatial") - mat <- as.matrix(unclass(physeq@otu_table)) resBeta <- adespatial::beta.div(mat, adj = FALSE, ...) @@ -301,20 +303,21 @@ LCBD_pq <- function(physeq, #' nperm = 100, only_plot_significant = TRUE, #' pval = 0.2 #' ) -#' library("patchwork") -#' plot_LCBD_pq(data_fungi_mini, -#' nperm = 100, only_plot_significant = FALSE, -#' sam_variables = c("Time", "Height") -#' ) -#' plot_LCBD_pq(data_fungi_mini, -#' nperm = 100, only_plot_significant = TRUE, pval = 0.2, -#' sam_variables = c("Time", "Height", "Tree_name") -#' ) & -#' theme( -#' legend.key.size = unit(0.4, "cm"), -#' legend.text = element_text(size = 10), -#' axis.title.x = element_text(size = 6) +#' if (!requireNamespace("patchwork")) { +#' plot_LCBD_pq(data_fungi_mini, +#' nperm = 100, only_plot_significant = FALSE, +#' sam_variables = c("Time", "Height") #' ) +#' plot_LCBD_pq(data_fungi_mini, +#' nperm = 100, only_plot_significant = TRUE, pval = 0.2, +#' sam_variables = c("Time", "Height", "Tree_name") +#' ) & +#' theme( +#' legend.key.size = unit(0.4, "cm"), +#' legend.text = element_text(size = 10), +#' axis.title.x = element_text(size = 6) +#' ) +#' } #' } #' @author Adrien Taudière #' @details diff --git a/R/blast.R b/R/blast.R index b4795ae2..705a500a 100644 --- a/R/blast.R +++ b/R/blast.R @@ -46,13 +46,13 @@ #' @examples #' \dontrun{ #' -#' # blastpath <- "...YOUR_PATH_TO_BLAST..." -#' # blast_to_phyloseq(data_fungi, -#' # seq2search = system.file("extdata", "ex.fasta", -#' # package = "MiscMetabar", mustWork = TRUE -#' # ), -#' # blastpath = blastpath -#' # ) +#' blastpath <- "...YOUR_PATH_TO_BLAST..." +#' blast_to_phyloseq(data_fungi, +#' seq2search = system.file("extdata", "ex.fasta", +#' package = "MiscMetabar", mustWork = TRUE +#' ), +#' blastpath = blastpath +#' ) #' } blast_to_phyloseq <- function(physeq, seq2search, diff --git a/R/dada_phyloseq.R b/R/dada_phyloseq.R index b673ae2a..244a988b 100644 --- a/R/dada_phyloseq.R +++ b/R/dada_phyloseq.R @@ -527,10 +527,10 @@ track_wkflow_samples <- function(list_pq_obj, ...) { #' \donttest{ #' asv2otu(data_fungi_mini, method_clusterize = "longest") #' -#' if (MiscMetabar:::is_swarm_installed()) { +#' if (MiscMetabar::is_swarm_installed()) { #' d_swarm <- asv2otu(data_fungi_mini, method = "swarm") #' } -#' if (MiscMetabar:::is_vsearch_installed()) { +#' if (MiscMetabar::is_vsearch_installed()) { #' d_vs <- asv2otu(data_fungi_mini, method = "vsearch") #' } #' } @@ -667,11 +667,9 @@ asv2otu <- function(physeq = NULL, #' @export #' @author Adrien Taudière #' @examples -#' \dontrun{ -#' write_pq(data_fungi, path = "phyloseq") -#' write_pq(data_fungi, path = "phyloseq", one_file = TRUE) -#' } - +#' write_pq(data_fungi, path = paste0(tempdir(), "/phyloseq")) +#' write_pq(data_fungi, path = paste0(tempdir(), "/phyloseq"), one_file = TRUE) +#' unlink(paste0(tempdir(), "/phyloseq"), recursive = TRUE) #' @seealso [MiscMetabar::save_pq()] write_pq <- function(physeq, @@ -875,9 +873,8 @@ write_pq <- function(physeq, #' @export #' @author Adrien Taudière #' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows" -#' \dontrun{ -#' save_pq(data_fungi, path = "phyloseq") -#' } +#' save_pq(data_fungi, path = paste0(tempdir(), "/phyloseq")) +#' unlink(paste0(tempdir(), "/phyloseq"), recursive = TRUE) #' @seealso [MiscMetabar::write_pq()] save_pq <- function(physeq, path = NULL, ...) { write_pq(physeq, @@ -913,9 +910,9 @@ save_pq <- function(physeq, path = NULL, ...) { #' @export #' #' @examples -#' # read_pq(path = "phyloseq_folder") -#' # read_pq(path = "phyloseq_folder", taxa_are_rows = TRUE) -#' +#' write_pq(data_fungi, path = paste0(tempdir(), "/phyloseq")) +#' read_pq(path = paste0(tempdir(), "/phyloseq")) +#' unlink(paste0(tempdir(), "/phyloseq"), recursive = TRUE) read_pq <- function(path = NULL, taxa_are_rows = FALSE, sam_names = NULL, @@ -1016,9 +1013,8 @@ read_pq <- function(path = NULL, #' - "merged_ASV": the data.frame used to merged ASV #' #' @export -#' @examples -#' \dontrun{ -#' data(data_fungi_sp_known) +#' @examplesIf MiscMetabar::is_vsearch_installed() +#' \donttest{ #' lulu_pq(data_fungi_sp_known) #' } #' @author Tobias Guldberg Frøslev \email{tobiasgf@snm.ku.dk} @@ -1163,7 +1159,7 @@ lulu_pq <- function(physeq, #' bash to obtain details about columns' signification. #' #' @export -#' @examples +#' @examplesIf MiscMetabar::is_mumu_installed() #' \dontrun{ #' mumu_pq(data_fungi_sp_known) #' } @@ -1327,7 +1323,7 @@ mumu_pq <- function(physeq, #' Mostly for internal use in MiscMetabar functions. #' #' @inheritParams clean_pq -#' @param verbose (logical, default FALSE) If true, prompt some warnings. +#' @param verbose (logical, default FALSE) If TRUE, prompt some warnings. #' @param min_nb_seq_sample (numeric) Only used if verbose = TRUE. #' Minimum number of sequences per samples to not show warning. #' @param min_nb_seq_taxa (numeric) Only used if verbose = TRUE. @@ -1652,7 +1648,6 @@ add_new_taxonomy_pq <- function(physeq, ref_fasta, suffix = NULL, ...) { #' @export #' @author Adrien Taudière #' @examples -#' data(data_fungi) #' tbl_sum_samdata(data_fungi) %>% #' gtsummary::as_kable() #' @@ -1661,11 +1656,12 @@ add_new_taxonomy_pq <- function(physeq, ref_fasta, suffix = NULL, ...) { #' type = list(Time ~ "continuous2", Height ~ "categorical"), #' statistic = list(Time ~ c("{median} ({p25}, {p75})", "{min}, {max}")) #' ) -#' +#' \donttest{ #' data(enterotype) #' #' summary_samdata <- tbl_sum_samdata(enterotype) #' summary_samdata <- tbl_sum_samdata(enterotype, include = !contains("SampleId")) +#' } #' @details #' This function is mainly a wrapper of the work of others. #' Please make a reference to `gtsummary::tbl_summary()` if you @@ -1698,16 +1694,19 @@ tbl_sum_samdata <- function(physeq, remove_col_unique_value = TRUE, ...) { #' @export #' @author Adrien Taudière #' @examples -#' -#' df <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 5000) -#' \dontrun{ -#' df <- add_funguild_info(df, +#' \donttest{ +#' d_fung_mini <- add_funguild_info(data_fungi_mini, #' taxLevels = c( -#' "Domain", "Phylum", "Class", "Order", -#' "Family", "Genus", "Species" +#' "Domain", +#' "Phylum", +#' "Class", +#' "Order", +#' "Family", +#' "Genus", +#' "Species" #' ) #' ) -#' sort(table(df@tax_table[, "guild"]), decreasing = TRUE) +#' sort(table(d_fung_mini@tax_table[, "guild"]), decreasing = TRUE) #' } #' @details #' This function is mainly a wrapper of the work of others. @@ -1766,23 +1765,29 @@ add_funguild_info <- function(physeq, #' @export #' @author Adrien Taudière #' @examples -#' \dontrun{ -#' -#' df <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 5000) -#' df <- add_funguild_info(df, +#' \donttest{ +#' d_fung_mini <- add_funguild_info(data_fungi_mini, #' taxLevels = c( -#' "Domain", "Phylum", "Class", "Order", -#' "Family", "Genus", "Species" +#' "Domain", +#' "Phylum", +#' "Class", +#' "Order", +#' "Family", +#' "Genus", +#' "Species" #' ) #' ) -#' p <- plot_guild_pq(df) -#' library("patchwork") -#' (plot_guild_pq(subset_samples(df, Height == "Low"), -#' levels_order = p$data$Guild[order(p$data$nb_seq)] -#' ) + theme(legend.position = "none")) + -#' (plot_guild_pq(subset_samples(df, Height == "High"), +#' sort(table(d_fung_mini@tax_table[, "guild"]), decreasing = TRUE) +#' +#' p <- plot_guild_pq(d_fung_mini) +#' if (!requireNamespace("patchwork")) { +#' (plot_guild_pq(subset_samples(d_fung_mini, Height == "Low"), #' levels_order = p$data$Guild[order(p$data$nb_seq)] -#' ) + ylab("") + theme(axis.text.y = element_blank())) +#' ) + theme(legend.position = "none")) + +#' (plot_guild_pq(subset_samples(d_fung_mini, Height == "High"), +#' levels_order = p$data$Guild[order(p$data$nb_seq)] +#' ) + ylab("") + theme(axis.text.y = element_blank())) +#' } #' } #' @seealso [add_funguild_info()] @@ -1930,25 +1935,26 @@ plot_guild_pq <- #' use this function. #' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows" #' \donttest{ -#' library("phangorn") -#' df <- subset_taxa_pq(data_fungi_mini, taxa_sums(data_fungi_mini) > 9000) -#' df_tree <- build_phytree_pq(df, nb_bootstrap = 2) -#' plot(df_tree$UPGMA) -#' plotBS(df_tree$UPGMA, df_tree$UPGMA_bs, main = "UPGMA") -#' plot(df_tree$NJ, "unrooted") -#' plot(df_tree$ML) -#' # plotBS(df_tree$ML_bs) -#' plotBS(df_tree$ML$tree, df_tree$ML_bs, p = 20, frame = "circle") -#' plotBS( -#' df_tree$ML$tree, -#' df_tree$ML_bs, -#' p = 20, -#' frame = "circle", -#' method = "TBE" -#' ) -#' plot(consensusNet(df_tree$ML_bs)) -#' plot(consensusNet(df_tree$NJ_bs)) -#' ps_tree <- merge_phyloseq(df, df_tree$ML$tree) +#' if (!requireNamespace("phangorn")) { +#' df <- subset_taxa_pq(data_fungi_mini, taxa_sums(data_fungi_mini) > 9000) +#' df_tree <- build_phytree_pq(df, nb_bootstrap = 2) +#' plot(df_tree$UPGMA) +#' phangorn::plotBS(df_tree$UPGMA, df_tree$UPGMA_bs, main = "UPGMA") +#' plot(df_tree$NJ, "unrooted") +#' plot(df_tree$ML) +#' +#' phangorn::plotBS(df_tree$ML$tree, df_tree$ML_bs, p = 20, frame = "circle") +#' phangorn::plotBS( +#' df_tree$ML$tree, +#' df_tree$ML_bs, +#' p = 20, +#' frame = "circle", +#' method = "TBE" +#' ) +#' plot(phangorn::consensusNet(df_tree$ML_bs)) +#' plot(phangorn::consensusNet(df_tree$NJ_bs)) +#' ps_tree <- merge_phyloseq(df, df_tree$ML$tree) +#' } #' } build_phytree_pq <- function(physeq, nb_bootstrap = 0, @@ -2341,7 +2347,7 @@ physeq_or_string_to_dna <- function(physeq = NULL, #' ) #' #' -#' # unlink(tempdir(), recursive = TRUE) +#' unlink(tempdir(), recursive = TRUE) #' } #' @details #' This function is mainly a wrapper of the work of others. diff --git a/R/krona.R b/R/krona.R index 2ad7ca14..8c4e0e58 100644 --- a/R/krona.R +++ b/R/krona.R @@ -18,7 +18,7 @@ #' @param name A name for intermediary files, Useful to name #' your krona result files before merging using [merge_krona()] #' -#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows" +#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows" && MiscMetabar::is_krona_installed() #' data("GlobalPatterns", package = "phyloseq") #' GA <- subset_taxa(GlobalPatterns, Phylum == "Acidobacteria") #' \dontrun{ @@ -108,7 +108,7 @@ krona <- #' @param files (required) path to html files to merged #' @param output path to the output file #' -#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows" +#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows" && MiscMetabar::is_krona_installed() #' \dontrun{ #' data("GlobalPatterns", package = "phyloseq") #' GA <- subset_taxa(GlobalPatterns, Phylum == "Acidobacteria") diff --git a/R/miscellanous.R b/R/miscellanous.R index f22e9550..0d904796 100644 --- a/R/miscellanous.R +++ b/R/miscellanous.R @@ -288,13 +288,14 @@ funky_color <- #' @author Adrien Taudière #' @export #' @examples -#' \dontrun{ +#' \donttest{ #' ex_file <- system.file("extdata", "ex_R1_001.fastq.gz", #' package = "MiscMetabar", #' mustWork = TRUE #' ) -#' subsample_fastq(ex_file, "your_path_to_output") -#' subsample_fastq(list_fastq_files("extdata"), "your_path_to_output", n = 10) +#' subsample_fastq(ex_file, paste0(tempdir(), "/output_fastq")) +#' subsample_fastq(list_fastq_files("extdata"), paste0(tempdir(), "/output_fastq"), n = 10) +#' unlink(paste0(tempdir(), "/output_fastq"), recursive = TRUE) #' } subsample_fastq <- function(fastq_files, folder_output = "subsample", @@ -312,57 +313,6 @@ subsample_fastq <- function(fastq_files, ################################################################################ -################################################################################ -#' Install a package if not present -#' -#' @description -#' `r lifecycle::badge("experimental")` -#' -#' @param pkg The name of the package -#' @param use_pak (logical, default TRUE) Use of `pak::pkg_install()`. If FALSE -#' use the base `install.package()` function or the function -#' `BiocManager::install()` if bioconductor_pkg is true or the function -#' @param bioconductor_pkg (logical, default FALSE). If use_pak is TRUE, -#' do nothing, else use `BiocManager::install()` to install the package. -#' @param github_pkg (logical, default FALSE). If use_pak is TRUE, -#' do nothing, else use `devtools::install_github` to install the package. -#' @param verbose (logical, default FALSE) Does the function print message? -#' @return Nothing -#' @author Adrien Taudière -#' @export -install_pkg_needed <- function(pkg, use_pak = TRUE, bioconductor_pkg = FALSE, - github_pkg = FALSE, verbose = FALSE) { - if (!requireNamespace(pkg, quietly = TRUE)) { - if (verbose) { - message(paste0("Installation of the package : ", pkg)) - } - if (use_pak) { - if (!requireNamespace("pak", quietly = TRUE)) { - install.packages("pak") - } - pak::pkg_install(pkg) - } else { - if (bioconductor_pkg) { - if (!requireNamespace("BiocManager", quietly = TRUE)) { - install.packages("BiocManager") - } - BiocManager::install(pkg) - } else if (github_pkg) { - if (!requireNamespace("devtools", quietly = TRUE)) { - install.packages("devtools", quietly = TRUE) - } - devtools::install_github(pkg) - } else { - install.packages(pkg) - } - } - } else { - if (verbose) { - message(paste0(pkg, " is already present.")) - } - } -} - ################################################################################ #' Test if cutadapt is installed. #' @@ -374,12 +324,11 @@ install_pkg_needed <- function(pkg, use_pak = TRUE, bioconductor_pkg = FALSE, #' #' @param args_before_cutadapt : (String) A one line bash command to run before #' to run cutadapt. For examples, "source ~/miniconda3/etc/profile.d/conda.sh && conda activate cutadaptenv &&" allow to bypass the conda init which asks to restart the shell -#' @keywords internal -#' @noRd +#' @export #' @return A logical that say if cutadapt is install in #' #' @examples -#' MiscMetabar:::is_cutadapt_installed() +#' MiscMetabar::is_cutadapt_installed() #' @author Adrien Taudière is_cutadapt_installed <- function(args_before_cutadapt = "source ~/miniconda3/etc/profile.d/conda.sh && conda activate cutadaptenv && ") { @@ -399,12 +348,11 @@ is_cutadapt_installed <- function(args_before_cutadapt = "source ~/miniconda3/et #' test coverage #' #' @param path (default: falco) Path to falco -#' @keywords internal -#' @noRd +#' @export #' @return A logical that say if falco is install in #' #' @examples -#' MiscMetabar:::is_falco_installed() +#' MiscMetabar::is_falco_installed() #' @author Adrien Taudière is_falco_installed <- function(path = "falco") { @@ -422,12 +370,11 @@ is_falco_installed <- function(path = "falco") { #' test coverage #' #' @param path (default: swarm) Path to falco -#' @keywords internal -#' @noRd +#' @export #' @return A logical that say if swarm is install in #' #' @examples -#' MiscMetabar:::is_swarm_installed() +#' MiscMetabar::is_swarm_installed() #' @author Adrien Taudière is_swarm_installed <- function(path = "swarm") { @@ -445,12 +392,11 @@ is_swarm_installed <- function(path = "swarm") { #' test coverage #' #' @param path (default: vsearch) Path to vsearch -#' @keywords internal -#' @noRd +#' @export #' @return A logical that say if vsearch is install in #' #' @examples -#' MiscMetabar:::is_vsearch_installed() +#' MiscMetabar::is_vsearch_installed() #' @author Adrien Taudière is_vsearch_installed <- function(path = "vsearch") { @@ -458,4 +404,49 @@ is_vsearch_installed <- function(path = "vsearch") { silent = TRUE )) != "try-error") } + +#' Test if mumu is installed. +#' +#' @description +#' `r lifecycle::badge("maturing")` +#' +#' Useful for testthat and examples compilation for R CMD CHECK and +#' test coverage +#' +#' @param path (default: mumu) Path to mumu +#' @export +#' @return A logical that say if mumu is install in +#' +#' @examples +#' MiscMetabar::is_mumu_installed() +#' @author Adrien Taudière + +is_mumu_installed <- function(path = "mumu") { + return(class(try(system(paste0(path, " 2>&1"), intern = TRUE), + silent = TRUE + )) != "try-error") +} + + +#' Test if krona is installed. +#' +#' @description +#' `r lifecycle::badge("maturing")` +#' +#' Useful for testthat and examples compilation for R CMD CHECK and +#' test coverage +#' +#' @param path (default: krona) Path to krona +#' @export +#' @return A logical that say if krona is install in +#' +#' @examples +#' MiscMetabar::is_krona_installed() +#' @author Adrien Taudière + +is_krona_installed <- function(path = "ktImportKrona") { + return(class(try(system(paste0(path, " 2>&1"), intern = TRUE), + silent = TRUE + )) != "try-error") +} ################################################################################ diff --git a/R/plot_functions.R b/R/plot_functions.R index b239829b..c084b60c 100644 --- a/R/plot_functions.R +++ b/R/plot_functions.R @@ -10,12 +10,11 @@ #' @param taxa (default: "Species") The taxonomic level you choose for x-positioning. #' @author Adrien Taudière #' @examples -#' -#' # Filter samples that don't have Enterotype -#' data_fungi <- subset_samples(data_fungi, !is.na(Time)) -#' res <- mt(data_fungi, "Time", method = "fdr", test = "f", B = 300) -#' plot_mt(res) #' \donttest{ +#' # Filter samples that don't have Time +#' data_fungi_mini2 <- subset_samples(data_fungi_mini, !is.na(Time)) +#' res <- mt(data_fungi_mini2, "Time", method = "fdr", test = "f", B = 300) +#' plot_mt(res) #' plot_mt(res, taxa = "Genus", color_tax = "Order") #' } #' @return a \code{\link{ggplot}}2 plot of result of a mt test @@ -1207,6 +1206,9 @@ multiplot <- #' Note that if letters and one_plot are both TRUE, tuckey HSD results #' are discarded from the unique plot. In that case, use one_plot = FALSE #' to see the tuckey HSD results in the fourth plot of the resulting list. +#' @param plot_with_tuckey (logical, default TRUE). If one_plot is set to +#' TRUE and letters to FALSE, allow to discard the tuckey plot part with +#' plot_with_tuckey = FALSE #' @param correction_for_sample_size (logical, default TRUE) This function #' use a sqrt of the read numbers in the linear model in order to #' correct for uneven sampling depth. @@ -1224,19 +1226,20 @@ multiplot <- #' @author Adrien Taudière #' @examples #' -#' p <- hill_pq(data_fungi, "Height") +#' p <- hill_pq(data_fungi_mini, "Height") #' p_h1 <- p[[1]] + theme(legend.position = "none") #' p_h2 <- p[[2]] + theme(legend.position = "none") #' p_h3 <- p[[3]] + theme(legend.position = "none") #' multiplot(plotlist = list(p_h1, p_h2, p_h3, p[[4]]), cols = 4) #' +#' \donttest{ #' # Artificially modify data_fungi to force alpha-diversity effect #' data_fungi_modif <- clean_pq(subset_samples_pq(data_fungi, !is.na(data_fungi@sam_data$Height))) #' data_fungi_modif@otu_table[data_fungi_modif@sam_data$Height == "High", ] <- #' data_fungi_modif@otu_table[data_fungi_modif@sam_data$Height == "High", ] + #' sample(c(rep(0, ntaxa(data_fungi_modif) / 2), rep(100, ntaxa(data_fungi_modif) / 2))) #' p2 <- hill_pq(data_fungi_modif, "Height", letters = TRUE) -#' +#' } hill_pq <- function(physeq, variable, @@ -1245,6 +1248,7 @@ hill_pq <- add_points = FALSE, add_info = TRUE, one_plot = FALSE, + plot_with_tuckey = TRUE, correction_for_sample_size = TRUE) { var <- sym(variable) if (is.na(color_fac)) { @@ -1400,9 +1404,8 @@ hill_pq <- ) if (one_plot) { - install_pkg_needed("patchwork") requireNamespace("patchwork", quietly = TRUE) - if (letters) { + if (letters || !plot_with_tuckey) { res <- ((p_0 + theme(legend.position = "none")) + labs(subtitle = element_blank()) + (p_1 + theme(legend.position = "none", axis.text.y = element_blank()) + labs(subtitle = element_blank()) + ylab(NULL)) + (p_2 + theme(legend.position = "none", axis.text.y = element_blank()) + labs(subtitle = element_blank()) + ylab(NULL))) @@ -1494,7 +1497,6 @@ ggbetween_pq <- function(physeq, variable, one_plot = FALSE, rarefy_by_sample = ) if (one_plot) { - install_pkg_needed("patchwork") requireNamespace("patchwork", quietly = TRUE) res <- res[[1]] + res[[2]] + res[[3]] } @@ -1725,14 +1727,14 @@ summary_plot_pq <- function(physeq, #' use this function. #' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows" #' \donttest{ -#' library("rotl") -#' tr <- rotl_pq(data_fungi_mini, species_colnames = "Genus_species") -#' plot(tr) +#' if (!requireNamespace("rotl")) { +#' tr <- rotl_pq(data_fungi_mini, species_colnames = "Genus_species") +#' plot(tr) #' -#' tr_Asco <- rotl_pq(data_fungi, species_colnames = "Genus_species", context_name = "Ascomycetes") -#' plot(tr_Asco) +#' tr_Asco <- rotl_pq(data_fungi, species_colnames = "Genus_species", context_name = "Ascomycetes") +#' plot(tr_Asco) +#' } #' } -#' rotl_pq <- function(physeq, species_colnames = "Genus_species", context_name = "All life") { @@ -1783,41 +1785,41 @@ rotl_pq <- function(physeq, #' #' @examples #' \donttest{ -#' library("metacoder") -#' data("GlobalPatterns", package = "phyloseq") +#' if (!requireNamespace("metacoder")) { +#' data("GlobalPatterns", package = "phyloseq") #' -#' GPsubset <- subset_taxa( -#' GlobalPatterns, -#' GlobalPatterns@tax_table[, 1] == "Bacteria" -#' ) +#' GPsubset <- subset_taxa( +#' GlobalPatterns, +#' GlobalPatterns@tax_table[, 1] == "Bacteria" +#' ) #' -#' GPsubset <- subset_taxa( -#' GPsubset, -#' rowSums(GPsubset@otu_table) > 5000 -#' ) +#' GPsubset <- subset_taxa( +#' GPsubset, +#' rowSums(GPsubset@otu_table) > 5000 +#' ) #' -#' GPsubset <- subset_taxa( -#' GPsubset, -#' rowSums(is.na(GPsubset@tax_table)) == 0 -#' ) +#' GPsubset <- subset_taxa( +#' GPsubset, +#' rowSums(is.na(GPsubset@tax_table)) == 0 +#' ) #' -#' heat_tree_pq(GPsubset, -#' node_size = n_obs, -#' node_color = n_obs, -#' node_label = taxon_names, -#' tree_label = taxon_names, -#' node_size_trans = "log10 area" -#' ) +#' heat_tree_pq(GPsubset, +#' node_size = n_obs, +#' node_color = n_obs, +#' node_label = taxon_names, +#' tree_label = taxon_names, +#' node_size_trans = "log10 area" +#' ) #' -#' heat_tree_pq(GPsubset, -#' node_size = nb_sequences, -#' node_color = n_obs, -#' node_label = taxon_names, -#' tree_label = taxon_names, -#' node_size_trans = "log10 area" -#' ) +#' heat_tree_pq(GPsubset, +#' node_size = nb_sequences, +#' node_color = n_obs, +#' node_label = taxon_names, +#' tree_label = taxon_names, +#' node_size_trans = "log10 area" +#' ) +#' } #' } -#' heat_tree_pq <- function(physeq, taxonomic_level = NULL, ...) { requireNamespace("metacoder", quietly = TRUE) if (!is.null(taxonomic_level)) { @@ -1877,8 +1879,7 @@ heat_tree_pq <- function(physeq, taxonomic_level = NULL, ...) { #' @return A plot #' #' @examples -#' -#' data_fungi_2Height <- subset_samples(data_fungi, Height %in% c("Low", "High")) +#' data_fungi_2Height <- subset_samples(data_fungi_mini, Height %in% c("Low", "High")) #' biplot_pq(data_fungi_2Height, "Height", merge_sample_by = "Height") #' @export #' @author Adrien Taudière @@ -2651,8 +2652,12 @@ plot_tsne_pq <- function(physeq, #' @return A plot #' @export #' -#' - +#' @examples +#' SRS_curve_pq(data_fungi_mini, +#' max.sample.size = 200, +#' rarefy.comparison = TRUE, rarefy.repeats = 3 +#' ) +#' SRS_curve_pq(data_fungi_mini, max.sample.size = 500, metric = "shannon") SRS_curve_pq <- function(physeq, clean_pq = FALSE, ...) { if (clean_pq) { physeq <- clean_pq(physeq) @@ -2688,33 +2693,34 @@ SRS_curve_pq <- function(physeq, clean_pq = FALSE, ...) { #' @export #' #' @examples -#' \dontrun{ -#' library("iNEXT") -#' data("GlobalPatterns", package = "phyloseq") -#' GPsubset <- subset_taxa( -#' GlobalPatterns, -#' GlobalPatterns@tax_table[, 1] == "Bacteria" -#' ) -#' GPsubset <- subset_taxa( -#' GPsubset, -#' rowSums(GPsubset@otu_table) > 20000 -#' ) -#' GPsubset <- subset_taxa( -#' GPsubset, -#' rowSums(is.na(GPsubset@tax_table)) == 0 -#' ) -#' GPsubset@sam_data$human <- GPsubset@sam_data$SampleType %in% -#' c("Skin", "Feces", "Tong") -#' res_iNEXT <- iNEXT_pq( -#' GPsubset, -#' merge_sample_by = "human", -#' q = 1, -#' datatype = "abundance", -#' nboot = 2 -#' ) -#' ggiNEXT(res_iNEXT) -#' ggiNEXT(res_iNEXT, type = 2) -#' ggiNEXT(res_iNEXT, type = 3) +#' \donttest{ +#' if (!requireNamespace("iNEXT")) { +#' data("GlobalPatterns", package = "phyloseq") +#' GPsubset <- subset_taxa( +#' GlobalPatterns, +#' GlobalPatterns@tax_table[, 1] == "Bacteria" +#' ) +#' GPsubset <- subset_taxa( +#' GPsubset, +#' rowSums(GPsubset@otu_table) > 20000 +#' ) +#' GPsubset <- subset_taxa( +#' GPsubset, +#' rowSums(is.na(GPsubset@tax_table)) == 0 +#' ) +#' GPsubset@sam_data$human <- GPsubset@sam_data$SampleType %in% +#' c("Skin", "Feces", "Tong") +#' res_iNEXT <- iNEXT_pq( +#' GPsubset, +#' merge_sample_by = "human", +#' q = 1, +#' datatype = "abundance", +#' nboot = 2 +#' ) +#' iNEXT::ggiNEXT(res_iNEXT) +#' iNEXT::ggiNEXT(res_iNEXT, type = 2) +#' iNEXT::ggiNEXT(res_iNEXT, type = 3) +#' } #' } #' @author Adrien Taudière #' This function is mainly a wrapper of the work of others. diff --git a/R/speedyseq_functions.R b/R/speedyseq_functions.R index 1d5a03d7..bab3473a 100644 --- a/R/speedyseq_functions.R +++ b/R/speedyseq_functions.R @@ -38,7 +38,8 @@ #' @param tax_adjust 0: no adjustment; 1: phyloseq-compatible adjustment; 2: #' conservative adjustment #' @export -#' +#' @return A new phyloseq-class, otu_table, tax_table, XStringset or +#' sam_data object depending on the class of the x param #' @seealso #' Function in MiscMetabar that use this function: [asv2otu()] #' @@ -334,7 +335,8 @@ bad_flush_right <- function(x, bad = "BAD", na_bad = FALSE, k = length(x)) { #' samples by name #' #' @export -#' +#' @return A new phyloseq-class, otu_table or sam_data object depending on +#' the class of the x param #' @examples #' data(enterotype) #' @@ -510,6 +512,7 @@ setMethod( #' #' @param x A vector #' @export +#' @return Either a single value (if `unique(x)` return a single value) or a NA #' @author Michael R. McLaren (orcid: [0000-0003-1575-473X](https://orcid.org/0000-0003-1575-473X)) #' @examples #' f <- factor(c("a", "a", "b", "c"), ordered = TRUE) @@ -579,13 +582,6 @@ merge_groups <- function(x, group, f = unique_or_na) { #' @keywords internal #' @noRd #' -#' @examples -#' \dontrun{ -#' x <- data.frame(var1 = letters[1:3], var2 = 7:9) -#' rownames(x) -#' sample_data(x) -#' MiscMetabar:::sample_data_stable(x) -#' } #' @author Michael R. McLaren (orcid: [0000-0003-1575-473X](https://orcid.org/0000-0003-1575-473X)) sample_data_stable <- function(object) { # Modified from phyloseq's sample_data data.frame method; see diff --git a/R/vsearch.R b/R/vsearch.R index c7d0d6c5..0ee651f5 100644 --- a/R/vsearch.R +++ b/R/vsearch.R @@ -16,7 +16,7 @@ #' - temp.fasta (refseq in fasta) #' - cluster.fasta (centroid) #' - temp.uc (clusters) -#' @examplesIf MiscMetabar:::is_vsearch_installed() +#' @examplesIf MiscMetabar::is_vsearch_installed() #' \donttest{ #' file_dna <- tempfile("dna.fa") #' seqinr::write.fasta("GCCCATTAGTATTCTAGTGGGCATGCCTGTTCGAGCGTCATTTTCAACC", @@ -163,7 +163,7 @@ vs_search_global <- function(physeq, #' \url{https://github.com/torognes/swarm/}. #' #' @export -#' @examplesIf MiscMetabar:::is_swarm_installed() +#' @examplesIf MiscMetabar::is_swarm_installed() #' summary_plot_pq(data_fungi) #' system2("swarm", "-h") #' @@ -372,7 +372,7 @@ swarm_clustering <- function(physeq = NULL, #' @export #' @author Adrien Taudière #' -#' @examplesIf MiscMetabar:::is_vsearch_installed() +#' @examplesIf MiscMetabar::is_vsearch_installed() #' \donttest{ #' summary_plot_pq(data_fungi) #' d_vs <- vsearch_clustering(data_fungi) @@ -500,7 +500,7 @@ vsearch_clustering <- function(physeq = NULL, #' #' @export #' -#' @examplesIf MiscMetabar:::is_vsearch_installed() +#' @examplesIf MiscMetabar::is_vsearch_installed() #' \donttest{ #' data_fungi_nochim <- chimera_removal_vs(data_fungi) #' data_fungi_nochim_16 <- chimera_removal_vs(data_fungi, @@ -623,7 +623,7 @@ chimera_removal_vs <- #' (`$chimera`) and bordeline taxa (`$borderline`) #' @export #' -#' @examplesIf MiscMetabar:::is_vsearch_installed() +#' @examplesIf MiscMetabar::is_vsearch_installed() #' \donttest{ #' chimera_detection_vs( #' seq2search = data_fungi@refseq, diff --git a/_pkgdown.yml b/_pkgdown.yml index d0427af8..361bceb2 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -213,7 +213,12 @@ reference: - dist_pos_control - funky_color - get_file_extension - - install_pkg_needed + - is_cutadapt_installed + - is_falco_installed + - is_krona_installed + - is_mumu_installed + - is_swarm_installed + - is_vsearch_installed - multiplot - perc - are_modality_even_depth diff --git a/cran-comments.md b/cran-comments.md index b3b233da..592bcde6 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,9 +1,18 @@ -## R CMD check results +## Benjamin Altmann comments -0 errors | 0 warnings | 1 note +1. Examples for unexported function + plot_guild_pq() in: + merge_samples2.Rd +Please export those functions or omit the example. -* This is a First release. +2. You still have some \dontrun{} examples. Please change that to \donttest{} or let us know why \dontrun{} is necessary in your case. -- Examples with CPU (user + system) or elapsed time > 5s --> Answer: This is an intrinsic problem with metabarcoding analyses that deal with large datasets. I've often reduced the datasets for the examples, but occasionally the use of quite large dataset is necessary. The functions ancombc_pq() and build_phytree_pq() rely on already time-consuming functions from other packages. The total example run time is 166s on my computer, which appears to be reasonable given the high number of examples in this package. +3. Note, please wrap examples that need packages in 'Suggests' in if(requireNamespace("pkgname")){} instead. +## Answers + +1. Sorry, I don't understand this error. merge_samples2() and plot_guild_pq() are exported. Moreover, there is no reference to plot_guild_pq() in the file merge_samples2.Rd. + +2. There are 5 still \dontrun in examples for functions relying on external software (namely blast, cutadapt, mumu and krona x2). + +3. Done. There's no more library() calls in examples. Thanks for the comment. \ No newline at end of file diff --git a/man/SRS_curve_pq.Rd b/man/SRS_curve_pq.Rd index 50326a2c..d64d6e16 100644 --- a/man/SRS_curve_pq.Rd +++ b/man/SRS_curve_pq.Rd @@ -21,3 +21,10 @@ A plot \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} } +\examples{ +SRS_curve_pq(data_fungi_mini, + max.sample.size = 200, + rarefy.comparison = TRUE, rarefy.repeats = 5 +) +SRS_curve_pq(data_fungi_mini, max.sample.size = 1000, metric = "shannon") +} diff --git a/man/add_funguild_info.Rd b/man/add_funguild_info.Rd index ff5641a3..dcf55fea 100644 --- a/man/add_funguild_info.Rd +++ b/man/add_funguild_info.Rd @@ -31,16 +31,19 @@ Please make a reference to \code{FUNGuildR} package and the associate use this function. } \examples{ - -df <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 5000) -\dontrun{ -df <- add_funguild_info(df, +\donttest{ +d_fung_mini <- add_funguild_info(data_fungi_mini, taxLevels = c( - "Domain", "Phylum", "Class", "Order", - "Family", "Genus", "Species" + "Domain", + "Phylum", + "Class", + "Order", + "Family", + "Genus", + "Species" ) ) -sort(table(df@tax_table[, "guild"]), decreasing = TRUE) +sort(table(d_fung_mini@tax_table[, "guild"]), decreasing = TRUE) } } \seealso{ diff --git a/man/adonis_pq.Rd b/man/adonis_pq.Rd index ec79cd25..3ac5edd4 100644 --- a/man/adonis_pq.Rd +++ b/man/adonis_pq.Rd @@ -12,6 +12,7 @@ adonis_pq( na_remove = FALSE, correction_for_sample_size = FALSE, rarefy_nb_seqs = FALSE, + verbose = TRUE, ... ) } @@ -47,6 +48,8 @@ the form \code{y~Library_Size + Biological_Effect} following recommendation of if \code{correction_for_sample_size} is TRUE, rarefy_nb_seqs will have no effect.} +\item{verbose}{(logical, default TRUE) If TRUE, prompt some messages.} + \item{...}{Other arguments passed on to \code{\link[vegan:adonis]{vegan::adonis2()}} function.} } \value{ diff --git a/man/asv2otu.Rd b/man/asv2otu.Rd index c98c9774..ca21885b 100644 --- a/man/asv2otu.Rd +++ b/man/asv2otu.Rd @@ -104,10 +104,10 @@ asv2otu(data_fungi_mini) \donttest{ asv2otu(data_fungi_mini, method_clusterize = "longest") -if (MiscMetabar:::is_swarm_installed()) { +if (MiscMetabar::is_swarm_installed()) { d_swarm <- asv2otu(data_fungi_mini, method = "swarm") } -if (MiscMetabar:::is_vsearch_installed()) { +if (MiscMetabar::is_vsearch_installed()) { d_vs <- asv2otu(data_fungi_mini, method = "vsearch") } } diff --git a/man/biplot_pq.Rd b/man/biplot_pq.Rd index 471f0eee..e37d064d 100644 --- a/man/biplot_pq.Rd +++ b/man/biplot_pq.Rd @@ -98,8 +98,7 @@ A plot \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}} } \examples{ - -data_fungi_2Height <- subset_samples(data_fungi, Height \%in\% c("Low", "High")) +data_fungi_2Height <- subset_samples(data_fungi_mini, Height \%in\% c("Low", "High")) biplot_pq(data_fungi_2Height, "Height", merge_sample_by = "Height") } \author{ diff --git a/man/blast_to_phyloseq.Rd b/man/blast_to_phyloseq.Rd index 04ac05c7..0755c137 100644 --- a/man/blast_to_phyloseq.Rd +++ b/man/blast_to_phyloseq.Rd @@ -80,13 +80,13 @@ the blast table \examples{ \dontrun{ -# blastpath <- "...YOUR_PATH_TO_BLAST..." -# blast_to_phyloseq(data_fungi, -# seq2search = system.file("extdata", "ex.fasta", -# package = "MiscMetabar", mustWork = TRUE -# ), -# blastpath = blastpath -# ) +blastpath <- "...YOUR_PATH_TO_BLAST..." +blast_to_phyloseq(data_fungi, + seq2search = system.file("extdata", "ex.fasta", + package = "MiscMetabar", mustWork = TRUE + ), + blastpath = blastpath +) } } \seealso{ diff --git a/man/build_phytree_pq.Rd b/man/build_phytree_pq.Rd index da8c130a..6418a37d 100644 --- a/man/build_phytree_pq.Rd +++ b/man/build_phytree_pq.Rd @@ -75,25 +75,26 @@ use this function. \examples{ \dontshow{if (tolower(Sys.info()[["sysname"]]) != "windows") (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} \donttest{ -library("phangorn") -df <- subset_taxa_pq(data_fungi_mini, taxa_sums(data_fungi_mini) > 9000) -df_tree <- build_phytree_pq(df, nb_bootstrap = 2) -plot(df_tree$UPGMA) -plotBS(df_tree$UPGMA, df_tree$UPGMA_bs, main = "UPGMA") -plot(df_tree$NJ, "unrooted") -plot(df_tree$ML) -# plotBS(df_tree$ML_bs) -plotBS(df_tree$ML$tree, df_tree$ML_bs, p = 20, frame = "circle") -plotBS( - df_tree$ML$tree, - df_tree$ML_bs, - p = 20, - frame = "circle", - method = "TBE" -) -plot(consensusNet(df_tree$ML_bs)) -plot(consensusNet(df_tree$NJ_bs)) -ps_tree <- merge_phyloseq(df, df_tree$ML$tree) +if (!requireNamespace("phangorn")) { + df <- subset_taxa_pq(data_fungi_mini, taxa_sums(data_fungi_mini) > 9000) + df_tree <- build_phytree_pq(df, nb_bootstrap = 2) + plot(df_tree$UPGMA) + phangorn::plotBS(df_tree$UPGMA, df_tree$UPGMA_bs, main = "UPGMA") + plot(df_tree$NJ, "unrooted") + plot(df_tree$ML) + + phangorn::plotBS(df_tree$ML$tree, df_tree$ML_bs, p = 20, frame = "circle") + phangorn::plotBS( + df_tree$ML$tree, + df_tree$ML_bs, + p = 20, + frame = "circle", + method = "TBE" + ) + plot(phangorn::consensusNet(df_tree$ML_bs)) + plot(phangorn::consensusNet(df_tree$NJ_bs)) + ps_tree <- merge_phyloseq(df, df_tree$ML$tree) +} } \dontshow{\}) # examplesIf} } diff --git a/man/chimera_detection_vs.Rd b/man/chimera_detection_vs.Rd index 4478d01c..5f6c0218 100644 --- a/man/chimera_detection_vs.Rd +++ b/man/chimera_detection_vs.Rd @@ -57,7 +57,7 @@ This function is mainly a wrapper of the work of others. Please make \href{https://github.com/torognes/vsearch}{vsearch}. } \examples{ -\dontshow{if (MiscMetabar:::is_vsearch_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (MiscMetabar::is_vsearch_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} \donttest{ chimera_detection_vs( seq2search = data_fungi@refseq, diff --git a/man/chimera_removal_vs.Rd b/man/chimera_removal_vs.Rd index fee96251..c9a4c581 100644 --- a/man/chimera_removal_vs.Rd +++ b/man/chimera_removal_vs.Rd @@ -45,7 +45,7 @@ This function is mainly a wrapper of the work of others. Please make \href{https://github.com/torognes/vsearch}{vsearch}. } \examples{ -\dontshow{if (MiscMetabar:::is_vsearch_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (MiscMetabar::is_vsearch_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} \donttest{ data_fungi_nochim <- chimera_removal_vs(data_fungi) data_fungi_nochim_16 <- chimera_removal_vs(data_fungi, diff --git a/man/cutadapt_remove_primers.Rd b/man/cutadapt_remove_primers.Rd index c89ed56f..dc5a10ef 100644 --- a/man/cutadapt_remove_primers.Rd +++ b/man/cutadapt_remove_primers.Rd @@ -91,7 +91,7 @@ cutadapt_remove_primers( ) -# unlink(tempdir(), recursive = TRUE) +unlink(tempdir(), recursive = TRUE) } \dontshow{\}) # examplesIf} } diff --git a/man/figures/README-unnamed-chunk-4-1.png b/man/figures/README-unnamed-chunk-4-1.png index 031cb5e5..05678638 100644 Binary files a/man/figures/README-unnamed-chunk-4-1.png and b/man/figures/README-unnamed-chunk-4-1.png differ diff --git a/man/figures/README-unnamed-chunk-6-1.png b/man/figures/README-unnamed-chunk-6-1.png index 8daaae12..d3e90bd5 100644 Binary files a/man/figures/README-unnamed-chunk-6-1.png and b/man/figures/README-unnamed-chunk-6-1.png differ diff --git a/man/graph_test_pq.Rd b/man/graph_test_pq.Rd index ae3fc845..eba436cc 100644 --- a/man/graph_test_pq.Rd +++ b/man/graph_test_pq.Rd @@ -55,9 +55,9 @@ This function is mainly a wrapper of the work of others. Please cite \code{phyloseqGraphTest} package. } \examples{ +\donttest{ data(enterotype) graph_test_pq(enterotype, fact = "SeqTech") -\donttest{ graph_test_pq(enterotype, fact = "Enterotype", na_remove = TRUE) } } diff --git a/man/heat_tree_pq.Rd b/man/heat_tree_pq.Rd index 23ed1677..a2de7aa7 100644 --- a/man/heat_tree_pq.Rd +++ b/man/heat_tree_pq.Rd @@ -27,41 +27,41 @@ and the number of sequences under the name \code{nb_sequences} } \examples{ \donttest{ -library("metacoder") -data("GlobalPatterns", package = "phyloseq") +if (!requireNamespace("metacoder")) { + data("GlobalPatterns", package = "phyloseq") -GPsubset <- subset_taxa( - GlobalPatterns, - GlobalPatterns@tax_table[, 1] == "Bacteria" -) + GPsubset <- subset_taxa( + GlobalPatterns, + GlobalPatterns@tax_table[, 1] == "Bacteria" + ) -GPsubset <- subset_taxa( - GPsubset, - rowSums(GPsubset@otu_table) > 5000 -) + GPsubset <- subset_taxa( + GPsubset, + rowSums(GPsubset@otu_table) > 5000 + ) -GPsubset <- subset_taxa( - GPsubset, - rowSums(is.na(GPsubset@tax_table)) == 0 -) + GPsubset <- subset_taxa( + GPsubset, + rowSums(is.na(GPsubset@tax_table)) == 0 + ) -heat_tree_pq(GPsubset, - node_size = n_obs, - node_color = n_obs, - node_label = taxon_names, - tree_label = taxon_names, - node_size_trans = "log10 area" -) + heat_tree_pq(GPsubset, + node_size = n_obs, + node_color = n_obs, + node_label = taxon_names, + tree_label = taxon_names, + node_size_trans = "log10 area" + ) -heat_tree_pq(GPsubset, - node_size = nb_sequences, - node_color = n_obs, - node_label = taxon_names, - tree_label = taxon_names, - node_size_trans = "log10 area" -) + heat_tree_pq(GPsubset, + node_size = nb_sequences, + node_color = n_obs, + node_label = taxon_names, + tree_label = taxon_names, + node_size_trans = "log10 area" + ) +} } - } \author{ Adrien Taudière diff --git a/man/hill_pq.Rd b/man/hill_pq.Rd index c22202af..94d62bb6 100644 --- a/man/hill_pq.Rd +++ b/man/hill_pq.Rd @@ -12,6 +12,7 @@ hill_pq( add_points = FALSE, add_info = TRUE, one_plot = FALSE, + plot_with_tuckey = TRUE, correction_for_sample_size = TRUE ) } @@ -41,6 +42,10 @@ Note that if letters and one_plot are both TRUE, tuckey HSD results are discarded from the unique plot. In that case, use one_plot = FALSE to see the tuckey HSD results in the fourth plot of the resulting list.} +\item{plot_with_tuckey}{(logical, default TRUE). If one_plot is set to +TRUE and letters to FALSE, allow to discard the tuckey plot part with +plot_with_tuckey = FALSE} + \item{correction_for_sample_size}{(logical, default TRUE) This function use a sqrt of the read numbers in the linear model in order to correct for uneven sampling depth.} @@ -65,19 +70,20 @@ model in order to correct for uneven sampling depth. } \examples{ -p <- hill_pq(data_fungi, "Height") +p <- hill_pq(data_fungi_mini, "Height") p_h1 <- p[[1]] + theme(legend.position = "none") p_h2 <- p[[2]] + theme(legend.position = "none") p_h3 <- p[[3]] + theme(legend.position = "none") multiplot(plotlist = list(p_h1, p_h2, p_h3, p[[4]]), cols = 4) +\donttest{ # Artificially modify data_fungi to force alpha-diversity effect data_fungi_modif <- clean_pq(subset_samples_pq(data_fungi, !is.na(data_fungi@sam_data$Height))) data_fungi_modif@otu_table[data_fungi_modif@sam_data$Height == "High", ] <- data_fungi_modif@otu_table[data_fungi_modif@sam_data$Height == "High", ] + sample(c(rep(0, ntaxa(data_fungi_modif) / 2), rep(100, ntaxa(data_fungi_modif) / 2))) p2 <- hill_pq(data_fungi_modif, "Height", letters = TRUE) - +} } \author{ Adrien Taudière diff --git a/man/iNEXT_pq.Rd b/man/iNEXT_pq.Rd index f32d7a81..289c3d46 100644 --- a/man/iNEXT_pq.Rd +++ b/man/iNEXT_pq.Rd @@ -24,33 +24,34 @@ see \code{\link[iNEXT:iNEXT]{iNEXT::iNEXT()}} documentation \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} } \examples{ -\dontrun{ -library("iNEXT") -data("GlobalPatterns", package = "phyloseq") -GPsubset <- subset_taxa( - GlobalPatterns, - GlobalPatterns@tax_table[, 1] == "Bacteria" -) -GPsubset <- subset_taxa( - GPsubset, - rowSums(GPsubset@otu_table) > 20000 -) -GPsubset <- subset_taxa( - GPsubset, - rowSums(is.na(GPsubset@tax_table)) == 0 -) -GPsubset@sam_data$human <- GPsubset@sam_data$SampleType \%in\% - c("Skin", "Feces", "Tong") -res_iNEXT <- iNEXT_pq( - GPsubset, - merge_sample_by = "human", - q = 1, - datatype = "abundance", - nboot = 2 -) -ggiNEXT(res_iNEXT) -ggiNEXT(res_iNEXT, type = 2) -ggiNEXT(res_iNEXT, type = 3) +\donttest{ +if (!requireNamespace("iNEXT")) { + data("GlobalPatterns", package = "phyloseq") + GPsubset <- subset_taxa( + GlobalPatterns, + GlobalPatterns@tax_table[, 1] == "Bacteria" + ) + GPsubset <- subset_taxa( + GPsubset, + rowSums(GPsubset@otu_table) > 20000 + ) + GPsubset <- subset_taxa( + GPsubset, + rowSums(is.na(GPsubset@tax_table)) == 0 + ) + GPsubset@sam_data$human <- GPsubset@sam_data$SampleType \%in\% + c("Skin", "Feces", "Tong") + res_iNEXT <- iNEXT_pq( + GPsubset, + merge_sample_by = "human", + q = 1, + datatype = "abundance", + nboot = 2 + ) + iNEXT::ggiNEXT(res_iNEXT) + iNEXT::ggiNEXT(res_iNEXT, type = 2) + iNEXT::ggiNEXT(res_iNEXT, type = 3) +} } } \author{ diff --git a/man/install_pkg_needed.Rd b/man/install_pkg_needed.Rd deleted file mode 100644 index b6dd7bc5..00000000 --- a/man/install_pkg_needed.Rd +++ /dev/null @@ -1,38 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/miscellanous.R -\name{install_pkg_needed} -\alias{install_pkg_needed} -\title{Install a package if not present} -\usage{ -install_pkg_needed( - pkg, - use_pak = TRUE, - bioconductor_pkg = FALSE, - github_pkg = FALSE, - verbose = FALSE -) -} -\arguments{ -\item{pkg}{The name of the package} - -\item{use_pak}{(logical, default TRUE) Use of \code{pak::pkg_install()}. If FALSE -use the base \code{install.package()} function or the function -\code{BiocManager::install()} if bioconductor_pkg is true or the function} - -\item{bioconductor_pkg}{(logical, default FALSE). If use_pak is TRUE, -do nothing, else use \code{BiocManager::install()} to install the package.} - -\item{github_pkg}{(logical, default FALSE). If use_pak is TRUE, -do nothing, else use \code{devtools::install_github} to install the package.} - -\item{verbose}{(logical, default FALSE) Does the function print message?} -} -\value{ -Nothing -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -} -\author{ -Adrien Taudière -} diff --git a/man/is_cutadapt_installed.Rd b/man/is_cutadapt_installed.Rd new file mode 100644 index 00000000..f074e0ae --- /dev/null +++ b/man/is_cutadapt_installed.Rd @@ -0,0 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/miscellanous.R +\name{is_cutadapt_installed} +\alias{is_cutadapt_installed} +\title{Test if cutadapt is installed.} +\usage{ +is_cutadapt_installed( + args_before_cutadapt = + "source ~/miniconda3/etc/profile.d/conda.sh && conda activate cutadaptenv && " +) +} +\arguments{ +\item{args_before_cutadapt}{: (String) A one line bash command to run before +to run cutadapt. For examples, "source ~/miniconda3/etc/profile.d/conda.sh && conda activate cutadaptenv &&" allow to bypass the conda init which asks to restart the shell} +} +\value{ +A logical that say if cutadapt is install in +} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}} + +Useful for testthat and examples compilation for R CMD CHECK and +test coverage +} +\examples{ +MiscMetabar::is_cutadapt_installed() +} +\author{ +Adrien Taudière +} diff --git a/man/is_falco_installed.Rd b/man/is_falco_installed.Rd new file mode 100644 index 00000000..8bb22150 --- /dev/null +++ b/man/is_falco_installed.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/miscellanous.R +\name{is_falco_installed} +\alias{is_falco_installed} +\title{Test if falco is installed.} +\usage{ +is_falco_installed(path = "falco") +} +\arguments{ +\item{path}{(default: falco) Path to falco} +} +\value{ +A logical that say if falco is install in +} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}} + +Useful for testthat and examples compilation for R CMD CHECK and +test coverage +} +\examples{ +MiscMetabar::is_falco_installed() +} +\author{ +Adrien Taudière +} diff --git a/man/is_krona_installed.Rd b/man/is_krona_installed.Rd new file mode 100644 index 00000000..1f529ab5 --- /dev/null +++ b/man/is_krona_installed.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/miscellanous.R +\name{is_krona_installed} +\alias{is_krona_installed} +\title{Test if krona is installed.} +\usage{ +is_krona_installed(path = "ktImportKrona") +} +\arguments{ +\item{path}{(default: krona) Path to krona} +} +\value{ +A logical that say if krona is install in +} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}} + +Useful for testthat and examples compilation for R CMD CHECK and +test coverage +} +\examples{ +MiscMetabar::is_krona_installed() +} +\author{ +Adrien Taudière +} diff --git a/man/is_mumu_installed.Rd b/man/is_mumu_installed.Rd new file mode 100644 index 00000000..caf4c768 --- /dev/null +++ b/man/is_mumu_installed.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/miscellanous.R +\name{is_mumu_installed} +\alias{is_mumu_installed} +\title{Test if mumu is installed.} +\usage{ +is_mumu_installed(path = "mumu") +} +\arguments{ +\item{path}{(default: mumu) Path to mumu} +} +\value{ +A logical that say if mumu is install in +} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}} + +Useful for testthat and examples compilation for R CMD CHECK and +test coverage +} +\examples{ +MiscMetabar::is_mumu_installed() +} +\author{ +Adrien Taudière +} diff --git a/man/is_swarm_installed.Rd b/man/is_swarm_installed.Rd new file mode 100644 index 00000000..ecb8d7c9 --- /dev/null +++ b/man/is_swarm_installed.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/miscellanous.R +\name{is_swarm_installed} +\alias{is_swarm_installed} +\title{Test if swarm is installed.} +\usage{ +is_swarm_installed(path = "swarm") +} +\arguments{ +\item{path}{(default: swarm) Path to falco} +} +\value{ +A logical that say if swarm is install in +} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}} + +Useful for testthat and examples compilation for R CMD CHECK and +test coverage +} +\examples{ +MiscMetabar::is_swarm_installed() +} +\author{ +Adrien Taudière +} diff --git a/man/is_vsearch_installed.Rd b/man/is_vsearch_installed.Rd new file mode 100644 index 00000000..5ba9089d --- /dev/null +++ b/man/is_vsearch_installed.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/miscellanous.R +\name{is_vsearch_installed} +\alias{is_vsearch_installed} +\title{Test if vsearch is installed.} +\usage{ +is_vsearch_installed(path = "vsearch") +} +\arguments{ +\item{path}{(default: vsearch) Path to vsearch} +} +\value{ +A logical that say if vsearch is install in +} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}} + +Useful for testthat and examples compilation for R CMD CHECK and +test coverage +} +\examples{ +MiscMetabar::is_vsearch_installed() +} +\author{ +Adrien Taudière +} diff --git a/man/krona.Rd b/man/krona.Rd index 3b8d5dd4..cbd31d92 100644 --- a/man/krona.Rd +++ b/man/krona.Rd @@ -47,7 +47,7 @@ Please cite \href{https://github.com/marbl/Krona}{Krona} if you use this function. } \examples{ -\dontshow{if (tolower(Sys.info()[["sysname"]]) != "windows") (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (tolower(Sys.info()[["sysname"]]) != "windows" && MiscMetabar::is_krona_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} data("GlobalPatterns", package = "phyloseq") GA <- subset_taxa(GlobalPatterns, Phylum == "Acidobacteria") \dontrun{ diff --git a/man/lulu_pq.Rd b/man/lulu_pq.Rd index 351e9b92..7a5cfc1f 100644 --- a/man/lulu_pq.Rd +++ b/man/lulu_pq.Rd @@ -60,10 +60,11 @@ The version of LULU is a fork of Adrien Taudière (\url{https://github.com/adrie from \url{https://github.com/tobiasgf/lulu} } \examples{ -\dontrun{ -data(data_fungi_sp_known) +\dontshow{if (MiscMetabar::is_vsearch_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\donttest{ lulu_pq(data_fungi_sp_known) } +\dontshow{\}) # examplesIf} } \references{ \itemize{ diff --git a/man/merge_krona.Rd b/man/merge_krona.Rd index eeed6f22..404630d7 100644 --- a/man/merge_krona.Rd +++ b/man/merge_krona.Rd @@ -31,7 +31,7 @@ Please cite \href{https://github.com/marbl/Krona}{Krona} if you use this function. } \examples{ -\dontshow{if (tolower(Sys.info()[["sysname"]]) != "windows") (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (tolower(Sys.info()[["sysname"]]) != "windows" && MiscMetabar::is_krona_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} \dontrun{ data("GlobalPatterns", package = "phyloseq") GA <- subset_taxa(GlobalPatterns, Phylum == "Acidobacteria") diff --git a/man/merge_samples2.Rd b/man/merge_samples2.Rd index 44ea0722..4efbd947 100644 --- a/man/merge_samples2.Rd +++ b/man/merge_samples2.Rd @@ -31,6 +31,10 @@ is \code{sum}. Can be a formula to be converted to a function by \item{reorder}{Logical specifying whether to reorder the new (merged) samples by name} } +\value{ +A new phyloseq-class, otu_table or sam_data object depending on +the class of the x param +} \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} diff --git a/man/merge_taxa_vec.Rd b/man/merge_taxa_vec.Rd index 3c2d54d3..ceb7933a 100644 --- a/man/merge_taxa_vec.Rd +++ b/man/merge_taxa_vec.Rd @@ -33,6 +33,10 @@ defines the new groups. see \code{base::rowsum()}.} \item{tax_adjust}{0: no adjustment; 1: phyloseq-compatible adjustment; 2: conservative adjustment} } +\value{ +A new phyloseq-class, otu_table, tax_table, XStringset or +sam_data object depending on the class of the x param +} \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} diff --git a/man/mumu_pq.Rd b/man/mumu_pq.Rd index 581abac3..5cf1359a 100644 --- a/man/mumu_pq.Rd +++ b/man/mumu_pq.Rd @@ -59,9 +59,11 @@ Please cite \href{https://github.com/frederic-mahe/mumu/blob/main/CITATION.cff}{ for your work. } \examples{ +\dontshow{if (MiscMetabar::is_mumu_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} \dontrun{ mumu_pq(data_fungi_sp_known) } +\dontshow{\}) # examplesIf} } \references{ \itemize{ diff --git a/man/plot_LCBD_pq.Rd b/man/plot_LCBD_pq.Rd index 9a8ce56c..69a46793 100644 --- a/man/plot_LCBD_pq.Rd +++ b/man/plot_LCBD_pq.Rd @@ -55,20 +55,21 @@ plot_LCBD_pq(data_fungi_mini, nperm = 100, only_plot_significant = TRUE, pval = 0.2 ) -library("patchwork") -plot_LCBD_pq(data_fungi_mini, - nperm = 100, only_plot_significant = FALSE, - sam_variables = c("Time", "Height") -) -plot_LCBD_pq(data_fungi_mini, - nperm = 100, only_plot_significant = TRUE, pval = 0.2, - sam_variables = c("Time", "Height", "Tree_name") -) & - theme( - legend.key.size = unit(0.4, "cm"), - legend.text = element_text(size = 10), - axis.title.x = element_text(size = 6) +if (!requireNamespace("patchwork")) { + plot_LCBD_pq(data_fungi_mini, + nperm = 100, only_plot_significant = FALSE, + sam_variables = c("Time", "Height") ) + plot_LCBD_pq(data_fungi_mini, + nperm = 100, only_plot_significant = TRUE, pval = 0.2, + sam_variables = c("Time", "Height", "Tree_name") + ) & + theme( + legend.key.size = unit(0.4, "cm"), + legend.text = element_text(size = 10), + axis.title.x = element_text(size = 6) + ) +} } } \seealso{ diff --git a/man/plot_guild_pq.Rd b/man/plot_guild_pq.Rd index ca7aacaa..e56df866 100644 --- a/man/plot_guild_pq.Rd +++ b/man/plot_guild_pq.Rd @@ -27,23 +27,29 @@ A ggplot2 object \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} } \examples{ -\dontrun{ - -df <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 5000) -df <- add_funguild_info(df, +\donttest{ +d_fung_mini <- add_funguild_info(data_fungi_mini, taxLevels = c( - "Domain", "Phylum", "Class", "Order", - "Family", "Genus", "Species" + "Domain", + "Phylum", + "Class", + "Order", + "Family", + "Genus", + "Species" ) ) -p <- plot_guild_pq(df) -library("patchwork") -(plot_guild_pq(subset_samples(df, Height == "Low"), - levels_order = p$data$Guild[order(p$data$nb_seq)] -) + theme(legend.position = "none")) + - (plot_guild_pq(subset_samples(df, Height == "High"), +sort(table(d_fung_mini@tax_table[, "guild"]), decreasing = TRUE) + +p <- plot_guild_pq(d_fung_mini) +if (!requireNamespace("patchwork")) { + (plot_guild_pq(subset_samples(d_fung_mini, Height == "Low"), levels_order = p$data$Guild[order(p$data$nb_seq)] - ) + ylab("") + theme(axis.text.y = element_blank())) + ) + theme(legend.position = "none")) + + (plot_guild_pq(subset_samples(d_fung_mini, Height == "High"), + levels_order = p$data$Guild[order(p$data$nb_seq)] + ) + ylab("") + theme(axis.text.y = element_blank())) +} } } \seealso{ diff --git a/man/plot_mt.Rd b/man/plot_mt.Rd index 77f7d362..1676ebe5 100644 --- a/man/plot_mt.Rd +++ b/man/plot_mt.Rd @@ -22,12 +22,11 @@ a \code{\link{ggplot}}2 plot of result of a mt test \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}} } \examples{ - -# Filter samples that don't have Enterotype -data_fungi <- subset_samples(data_fungi, !is.na(Time)) -res <- mt(data_fungi, "Time", method = "fdr", test = "f", B = 300) -plot_mt(res) \donttest{ +# Filter samples that don't have Time +data_fungi_mini2 <- subset_samples(data_fungi_mini, !is.na(Time)) +res <- mt(data_fungi_mini2, "Time", method = "fdr", test = "f", B = 300) +plot_mt(res) plot_mt(res, taxa = "Genus", color_tax = "Order") } } diff --git a/man/read_pq.Rd b/man/read_pq.Rd index 6373a198..eb317610 100644 --- a/man/read_pq.Rd +++ b/man/read_pq.Rd @@ -35,7 +35,7 @@ and if present a phy_tree in Newick format. At least the otu_table.csv need to b \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}} } \examples{ -# read_pq(path = "phyloseq_folder") -# read_pq(path = "phyloseq_folder", taxa_are_rows = TRUE) - +write_pq(data_fungi, path = paste0(tempdir(), "/phyloseq")) +read_pq(path = paste0(tempdir(), "/phyloseq")) +unlink(paste0(tempdir(), "/phyloseq"), recursive = TRUE) } diff --git a/man/rotl_pq.Rd b/man/rotl_pq.Rd index 77f3aeb1..c76d2d9d 100644 --- a/man/rotl_pq.Rd +++ b/man/rotl_pq.Rd @@ -33,12 +33,13 @@ use this function. \examples{ \dontshow{if (tolower(Sys.info()[["sysname"]]) != "windows") (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} \donttest{ -library("rotl") -tr <- rotl_pq(data_fungi_mini, species_colnames = "Genus_species") -plot(tr) +if (!requireNamespace("rotl")) { + tr <- rotl_pq(data_fungi_mini, species_colnames = "Genus_species") + plot(tr) -tr_Asco <- rotl_pq(data_fungi, species_colnames = "Genus_species", context_name = "Ascomycetes") -plot(tr_Asco) + tr_Asco <- rotl_pq(data_fungi, species_colnames = "Genus_species", context_name = "Ascomycetes") + plot(tr_Asco) +} } \dontshow{\}) # examplesIf} } diff --git a/man/save_pq.Rd b/man/save_pq.Rd index 78698e37..0e7a4d0a 100644 --- a/man/save_pq.Rd +++ b/man/save_pq.Rd @@ -34,9 +34,8 @@ Write : } \examples{ \dontshow{if (tolower(Sys.info()[["sysname"]]) != "windows") (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -\dontrun{ -save_pq(data_fungi, path = "phyloseq") -} +save_pq(data_fungi, path = paste0(tempdir(), "/phyloseq")) +unlink(paste0(tempdir(), "/phyloseq"), recursive = TRUE) \dontshow{\}) # examplesIf} } \seealso{ diff --git a/man/subsample_fastq.Rd b/man/subsample_fastq.Rd index 9cdc0b2a..8c9c809d 100644 --- a/man/subsample_fastq.Rd +++ b/man/subsample_fastq.Rd @@ -22,13 +22,14 @@ Nothing, create subsampled fastq files in a folder \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} } \examples{ -\dontrun{ +\donttest{ ex_file <- system.file("extdata", "ex_R1_001.fastq.gz", package = "MiscMetabar", mustWork = TRUE ) -subsample_fastq(ex_file, "your_path_to_output") -subsample_fastq(list_fastq_files("extdata"), "your_path_to_output", n = 10) +subsample_fastq(ex_file, paste0(tempdir(), "/output_fastq")) +subsample_fastq(list_fastq_files("extdata"), paste0(tempdir(), "/output_fastq"), n = 10) +unlink(paste0(tempdir(), "/output_fastq"), recursive = TRUE) } } \author{ diff --git a/man/swarm_clustering.Rd b/man/swarm_clustering.Rd index 083ef83f..407e8c08 100644 --- a/man/swarm_clustering.Rd +++ b/man/swarm_clustering.Rd @@ -70,7 +70,7 @@ This function is mainly a wrapper of the work of others. Please cite \href{https://github.com/torognes/swarm}{SWARM}. } \examples{ -\dontshow{if (MiscMetabar:::is_swarm_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (MiscMetabar::is_swarm_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} summary_plot_pq(data_fungi) system2("swarm", "-h") diff --git a/man/tbl_sum_samdata.Rd b/man/tbl_sum_samdata.Rd index d31a0ba0..8fbb98f3 100644 --- a/man/tbl_sum_samdata.Rd +++ b/man/tbl_sum_samdata.Rd @@ -31,7 +31,6 @@ Please make a reference to \code{gtsummary::tbl_summary()} if you use this function. } \examples{ -data(data_fungi) tbl_sum_samdata(data_fungi) \%>\% gtsummary::as_kable() @@ -40,12 +39,13 @@ summary_samdata <- tbl_sum_samdata(data_fungi, type = list(Time ~ "continuous2", Height ~ "categorical"), statistic = list(Time ~ c("{median} ({p25}, {p75})", "{min}, {max}")) ) - +\donttest{ data(enterotype) summary_samdata <- tbl_sum_samdata(enterotype) summary_samdata <- tbl_sum_samdata(enterotype, include = !contains("SampleId")) } +} \author{ Adrien Taudière } diff --git a/man/unique_or_na.Rd b/man/unique_or_na.Rd index f0aada44..797d501a 100644 --- a/man/unique_or_na.Rd +++ b/man/unique_or_na.Rd @@ -9,6 +9,9 @@ unique_or_na(x) \arguments{ \item{x}{A vector} } +\value{ +Either a single value (if \code{unique(x)} return a single value) or a NA +} \description{ If \code{unique(x)} is a single value, return it; otherwise, return an NA of the same type as \code{x}. If \code{x} is a factor, then the levels and ordered status diff --git a/man/verify_pq.Rd b/man/verify_pq.Rd index 2aea37c9..85ab413c 100644 --- a/man/verify_pq.Rd +++ b/man/verify_pq.Rd @@ -15,7 +15,7 @@ verify_pq( \item{physeq}{(required): a \code{\link{phyloseq-class}} object obtained using the \code{phyloseq} package.} -\item{verbose}{(logical, default FALSE) If true, prompt some warnings.} +\item{verbose}{(logical, default FALSE) If TRUE, prompt some warnings.} \item{min_nb_seq_sample}{(numeric) Only used if verbose = TRUE. Minimum number of sequences per samples to not show warning.} diff --git a/man/vs_search_global.Rd b/man/vs_search_global.Rd index e92502c6..7e06345c 100644 --- a/man/vs_search_global.Rd +++ b/man/vs_search_global.Rd @@ -49,7 +49,7 @@ This function is mainly a wrapper of the work of others. Please cite \href{https://github.com/torognes/vsearch}{vsearch}. } \examples{ -\dontshow{if ( MiscMetabar:::is_vsearch_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (MiscMetabar::is_vsearch_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} \donttest{ file_dna <- tempfile("dna.fa") seqinr::write.fasta("GCCCATTAGTATTCTAGTGGGCATGCCTGTTCGAGCGTCATTTTCAACC", diff --git a/man/vsearch_clustering.Rd b/man/vsearch_clustering.Rd index c1cf8f29..423e7d3f 100644 --- a/man/vsearch_clustering.Rd +++ b/man/vsearch_clustering.Rd @@ -73,7 +73,7 @@ This function is mainly a wrapper of the work of others. Please cite \href{https://github.com/torognes/vsearch}{vsearch}. } \examples{ -\dontshow{if (MiscMetabar:::is_vsearch_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (MiscMetabar::is_vsearch_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} \donttest{ summary_plot_pq(data_fungi) d_vs <- vsearch_clustering(data_fungi) diff --git a/man/write_pq.Rd b/man/write_pq.Rd index 4b2eb4e1..f89a5839 100644 --- a/man/write_pq.Rd +++ b/man/write_pq.Rd @@ -84,10 +84,9 @@ and if present a phy_tree in Newick format \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}} } \examples{ -\dontrun{ -write_pq(data_fungi, path = "phyloseq") -write_pq(data_fungi, path = "phyloseq", one_file = TRUE) -} +write_pq(data_fungi, path = paste0(tempdir(), "/phyloseq")) +write_pq(data_fungi, path = paste0(tempdir(), "/phyloseq"), one_file = TRUE) +unlink(paste0(tempdir(), "/phyloseq"), recursive = TRUE) } \seealso{ \code{\link[=save_pq]{save_pq()}} diff --git a/tests/testthat/Rplots.pdf b/tests/testthat/Rplots.pdf new file mode 100644 index 00000000..f9d44f59 Binary files /dev/null and b/tests/testthat/Rplots.pdf differ diff --git a/tests/testthat/log.txt b/tests/testthat/log.txt new file mode 100644 index 00000000..30187a37 --- /dev/null +++ b/tests/testthat/log.txt @@ -0,0 +1,33 @@ +ASV107 ASV12 99.70 5158 38237 5146 20726 13 34 8 0.00 12109.74 931.52 0.02 1513.72 8328.00 0.62 rejected +ASV107 ASV67 99.40 5158 8521 996 8518 13 6 3 0.00 4344.90 334.22 0.90 1448.30 3285.00 0.23 rejected +ASV107 ASV105 95.80 5158 5467 0 0 13 4 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 rejected +ASV99 ASV53 99.70 5699 10038 5699 10035 3 5 3 1.16 4.67 1.56 1.16 1.56 1.94 1.00 accepted +ASV93 ASV7 99.40 5886 47410 5886 9503 2 44 2 1.52 540.52 270.26 1.52 270.26 539.00 1.00 accepted +ASV82 ASV54 87.70 7356 9895 0 0 2 1 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 rejected +ASV82 ASV48 86.00 7356 10784 0 0 2 3 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 rejected +ASV42 ASV25 99.40 12270 21522 12194 9899 11 16 1 0.00 0.81 0.07 0.81 0.81 0.81 0.09 rejected +ASV18 ASV8 99.20 27368 46857 27335 45885 33 92 32 0.00 974.12 29.52 0.00 30.44 158.29 0.97 rejected +ASV18 ASV7 95.30 27368 47410 3632 32353 33 44 26 0.00 1184.16 35.88 0.22 45.54 175.76 0.79 rejected +ASV105 ASV12 96.10 5467 38237 5465 13 4 34 2 0.00 0.02 0.00 0.00 0.01 0.01 0.50 rejected +ASV105 ASV67 95.80 5467 8521 0 0 4 6 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 rejected +ASV108 ASV82 99.70 5137 7356 5137 7354 1 2 1 1.43 1.43 1.43 1.43 1.43 1.43 1.00 accepted +ASV63 ASV27 88.50 8872 20584 0 0 3 4 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 rejected +ASV8 ASV7 95.20 46857 47410 35102 47248 92 44 39 0.00 2749.18 29.88 0.02 70.49 1131.89 0.42 rejected +ASV26 ASV7 96.30 20660 47410 19653 1741 13 44 6 0.00 63.19 4.86 0.00 10.53 31.40 0.46 rejected +ASV26 ASV18 93.60 20660 27368 361 224 13 33 2 0.00 19.49 1.50 0.09 9.74 19.40 0.15 rejected +ASV26 ASV8 93.30 20660 46857 20413 614 13 92 9 0.00 8.14 0.63 0.00 0.90 6.00 0.69 rejected +ASV68 ASV25 99.70 8417 21522 8417 20973 2 16 2 1.18 3692.51 1846.25 1.18 1846.25 3691.33 1.00 accepted +ASV77 ASV25 99.70 7818 21522 7818 10335 2 16 2 1.27 437.27 218.63 1.27 218.63 436.00 1.00 accepted +ASV94 ASV7 98.30 5842 47410 5842 32509 29 44 29 1.37 200.54 6.92 1.37 6.92 39.00 1.00 accepted +ASV53 ASV35 99.70 10038 15298 10038 6476 5 8 5 0.51 420.52 84.10 0.51 84.10 399.50 1.00 rejected +ASV54 ASV48 84.10 9895 10784 0 0 1 3 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 rejected +ASV58 ASV35 99.70 9172 15298 9171 15297 8 8 7 0.00 2943.47 367.93 0.11 420.50 2131.33 0.88 rejected +ASV58 ASV53 99.40 9172 10038 9165 10038 8 5 5 0.00 4.39 0.55 0.00 0.88 2.19 0.62 rejected +ASV72 ASV63 99.70 8167 8872 8111 8872 6 3 3 0.00 1.21 0.20 0.01 0.40 1.18 0.50 rejected +ASV72 ASV27 88.80 8167 20584 0 0 6 4 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 rejected +ASV64 ASV53 85.30 8849 10038 0 0 3 5 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 rejected +ASV64 ASV35 85.00 8849 15298 0 0 3 8 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 rejected +ASV64 ASV58 84.70 8849 9172 0 0 3 8 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 rejected +ASV91 ASV54 91.80 6319 9895 0 0 7 1 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 rejected +ASV91 ASV82 87.20 6319 7356 0 0 7 2 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 rejected +ASV67 ASV12 99.70 8521 38237 8520 23112 6 34 5 0.00 7091.18 1181.86 0.17 1418.24 3896.00 0.83 rejected diff --git a/tests/testthat/test_clean_pq.R b/tests/testthat/test_clean_pq.R index 7e12cb86..ed81edef 100644 --- a/tests/testthat/test_clean_pq.R +++ b/tests/testthat/test_clean_pq.R @@ -1,5 +1,3 @@ -data("data_fungi") - data_fungi_test <- data_fungi data_fungi_test@otu_table[, 1] <- rep(0, nrow(data_fungi_test@otu_table)) data_fungi_test@otu_table[10, ] <- rep(0, ncol(data_fungi_test@otu_table)) diff --git a/tests/testthat/test_controls.R b/tests/testthat/test_controls.R index f705d564..9db9ed42 100644 --- a/tests/testthat/test_controls.R +++ b/tests/testthat/test_controls.R @@ -4,6 +4,7 @@ sam_name_factice <- gsub("TS1_V2", "TS10_V2", sample_names(enterotype)) test_that("dist_pos_control function works fine", { expect_type(dist_pos_control(enterotype, sam_name_factice), "list") + skip_on_cran() expect_s3_class(dist_pos_control(enterotype, sam_name_factice)[[1]], "data.frame") expect_s3_class(dist_pos_control(enterotype, sam_name_factice)[[2]], "data.frame") expect_equal(length(dist_pos_control(enterotype, sam_name_factice)), 2) @@ -42,6 +43,7 @@ test_that("subset_taxa_tax_control function works fine", { library(Biostrings) test_that("search_exact_seq_pq function works fine", { + skip_on_cran() expect_silent(search_primers <- search_exact_seq_pq(data_fungi, seq2search = Biostrings::DNAStringSet(c("TTGAACGCACATTGCGCC", "ATCCCTACCTGATCCGAG")))) expect_equal(search_primers[[1]][3, 1], "932") }) diff --git a/tests/testthat/test_deprecated.R b/tests/testthat/test_deprecated.R index f9fdf38d..90f60b5b 100644 --- a/tests/testthat/test_deprecated.R +++ b/tests/testthat/test_deprecated.R @@ -56,6 +56,7 @@ if (class(vsearch_error_or_not) == "try-error") { message("lulu_phyloseq() can't be tested when vsearch is not installed") } else { test_that("lulu_phyloseq works fine", { + skip_on_cran() expect_s4_class(suppressWarnings(lulu_phyloseq(data_fungi_sp_known)$new_physeq), "phyloseq") }) } diff --git a/tests/testthat/test_deseq2_edgeR.R b/tests/testthat/test_deseq2_edgeR.R index 2073d3e9..f43bdb68 100644 --- a/tests/testthat/test_deseq2_edgeR.R +++ b/tests/testthat/test_deseq2_edgeR.R @@ -37,8 +37,8 @@ test_that("plot_edgeR_pq works with GP dataset", { }) test_that("plot_deseq2_pq works with results on GP dataset", { - expect_message(res <- DESeq2::DESeq(phyloseq_to_deseq2(GP, ~SampleType), test = "Wald", fitType = "local"), "fitting model and testing") skip_on_cran() + expect_message(res <- DESeq2::DESeq(phyloseq_to_deseq2(GP, ~SampleType), test = "Wald", fitType = "local"), "fitting model and testing") expect_silent(suppressWarnings(plot_deseq2_pq(res, c("SampleType", "Soil", "Skin"), tax_table = GP@tax_table, color_tax = "Kingdom"))) expect_silent(suppressWarnings(plot_deseq2_pq(res, c("SampleType", "Soil", "Skin"), tax_table = GP@tax_table, tax_depth = "Genus"))) expect_silent(suppressWarnings(plot_deseq2_pq(res, c("SampleType", "Soil", "Skin"), @@ -69,6 +69,7 @@ test_that("plot_deseq2_pq works with GP dataset", { GP_row <- clean_pq(GP, force_taxa_as_columns = TRUE) test_that("phyloseq_to_edgeR gives the good class", { + skip_on_cran() expect_s4_class(phyloseq_to_edgeR(GP_archae, "SampleType"), "DGEList") expect_s4_class(phyloseq_to_edgeR(GP_row, "SampleType"), "DGEList") }) diff --git a/tests/testthat/test_figures_alpha_div.R b/tests/testthat/test_figures_alpha_div.R index 44941868..72b2c741 100644 --- a/tests/testthat/test_figures_alpha_div.R +++ b/tests/testthat/test_figures_alpha_div.R @@ -60,8 +60,8 @@ test_that("hill_pq works with data_fungi dataset", { }) test_that("hill_pq works with GP dataset", { - expect_message(hill_pq(GP, "SampleType")) skip_on_cran() + expect_message(hill_pq(GP, "SampleType")) expect_message(hill_pq(GP, "SampleType", add_points = TRUE)) expect_silent(suppressMessages(hill_pq(GP, "SampleType", letters = TRUE))) expect_silent(suppressMessages(hill_pq(GP, "SampleType", add_points = TRUE))) @@ -92,8 +92,8 @@ test_that("iNEXT_pq works with data_fungi_mini dataset", { test_that("accu_plot works with GlobalPatterns dataset", { - expect_silent(suppressWarnings(accu_plot(GP_archae, fact = "X.SampleID", by.fact = TRUE))) skip_on_cran() + expect_silent(suppressWarnings(accu_plot(GP_archae, fact = "X.SampleID", by.fact = TRUE))) expect_silent(suppressWarnings(accu_plot(GP_archae, fact = "X.SampleID", by.fact = FALSE))) expect_silent(suppressWarnings(accu_plot( GP_archae, @@ -148,6 +148,7 @@ test_that("accu_plot works with data_fungi dataset", { test_that("accu_samp_threshold works with GlobalPatterns dataset", { + skip_on_cran() expect_s3_class(p <- accu_plot(GP_archae, "SampleType", add_nb_seq = TRUE, by.fact = TRUE, step = 10), "ggplot") expect_equal(length(accu_samp_threshold(p)), 5) }) diff --git a/tests/testthat/test_figures_beta_div.R b/tests/testthat/test_figures_beta_div.R index 28529b60..5c104189 100644 --- a/tests/testthat/test_figures_beta_div.R +++ b/tests/testthat/test_figures_beta_div.R @@ -331,8 +331,8 @@ test_that("plot_LCBD_pq works with data_fungi dataset", { test_that("LCBD_pq works with data_fungi_mini dataset", { - expect_s3_class(LCBD_pq(data_fungi_mini, nperm = 100), "beta.div") skip_on_cran() + expect_s3_class(LCBD_pq(data_fungi_mini, nperm = 100), "beta.div") expect_s3_class( LCBD_pq(data_fungi_mini, nperm = 100, method = "jaccard"), "beta.div" @@ -340,6 +340,7 @@ test_that("LCBD_pq works with data_fungi_mini dataset", { }) test_that("plot_LCBD_pq works with data_fungi_mini dataset", { + skip_on_cran() expect_s3_class( plot_LCBD_pq( data_fungi_mini, @@ -348,7 +349,6 @@ test_that("plot_LCBD_pq works with data_fungi_mini dataset", { ), "ggplot" ) - skip_on_cran() expect_s3_class( plot_LCBD_pq( data_fungi_mini, @@ -372,8 +372,8 @@ test_that("plot_LCBD_pq works with data_fungi_mini dataset", { test_that("plot_SCBD_pq works with data_fungi_mini dataset", { - expect_s3_class(plot_SCBD_pq(data_fungi_mini), "ggplot") skip_on_cran() + expect_s3_class(plot_SCBD_pq(data_fungi_mini), "ggplot") expect_s3_class( plot_SCBD_pq( data_fungi_mini, diff --git a/tests/testthat/test_figures_biplot.R b/tests/testthat/test_figures_biplot.R index 4d6afec7..5165bf7a 100644 --- a/tests/testthat/test_figures_biplot.R +++ b/tests/testthat/test_figures_biplot.R @@ -11,6 +11,7 @@ data_fungi_abun <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 10000) test_that("biplot_pq works", { + skip_on_cran() expect_message(biplot_pq(data_fungi_2trees, merge_sample_by = "Tree_name")) expect_s3_class( biplot_pq( @@ -20,7 +21,6 @@ test_that("biplot_pq works", { ), "plotly" ) - skip_on_cran() expect_s3_class( biplot_pq( data_fungi_2trees, @@ -49,6 +49,7 @@ test_that("biplot_pq works", { test_that("multi_biplot_pq works with data_fungi dataset", { + skip_on_cran() p1 <- multi_biplot_pq(data_fungi_abun, split_by = "Time", na_remove = FALSE) p2 <- multi_biplot_pq(data_fungi_abun, "Height") @@ -59,7 +60,6 @@ test_that("multi_biplot_pq works with data_fungi dataset", { p3 <- multi_biplot_pq(data_fungi_abun, pairs = "Random_pairs") expect_s3_class(p1[[1]], "ggplot") expect_type(p1, "list") - skip_on_cran() expect_s3_class(p2[[1]], "ggplot") expect_type(p2, "list") expect_s3_class(p3[[1]], "ggplot") diff --git a/tests/testthat/test_figures_misc.R b/tests/testthat/test_figures_misc.R index e9de6db0..cc41bf3e 100644 --- a/tests/testthat/test_figures_misc.R +++ b/tests/testthat/test_figures_misc.R @@ -23,8 +23,8 @@ test_that("plot_tsne_pq works with data_fungi_mini dataset", { }) test_that("SRS_curve_pq works with data_fungi_mini dataset", { - expect_silent(suppressMessages(sc <- SRS_curve_pq(data_fungi_mini))) skip_on_cran() + expect_silent(suppressMessages(sc <- SRS_curve_pq(data_fungi_mini))) expect_silent(suppressMessages(sc <- SRS_curve_pq(data_fungi_mini, clean_pq = TRUE))) expect_s3_class(sc, "recordedplot") expect_silent(suppressMessages(sc <- SRS_curve_pq(data_fungi_mini, metric = "shannon"))) diff --git a/tests/testthat/test_figures_taxo.R b/tests/testthat/test_figures_taxo.R index 58ef1956..1b8c901a 100644 --- a/tests/testthat/test_figures_taxo.R +++ b/tests/testthat/test_figures_taxo.R @@ -61,6 +61,7 @@ test_that("heat_tree_pq works with GlobalPatterns dataset", { test_that("plot_tax_pq works with data_fungi dataset", { + skip_on_cran() expect_silent(suppressMessages( pt <- plot_tax_pq( @@ -71,7 +72,6 @@ test_that("plot_tax_pq works with data_fungi dataset", { add_info = FALSE ) )) - skip_on_cran() expect_silent(suppressMessages( pt <- plot_tax_pq( @@ -162,11 +162,11 @@ test_that("plot_tax_pq works with data_fungi dataset", { test_that("multitax_bar_pq works with data_fungi_sp_known dataset", { + skip_on_cran() expect_s3_class( multitax_bar_pq(data_fungi_mini, "Phylum", "Class", "Order", "Time"), "ggplot" ) - skip_on_cran() expect_s3_class( multitax_bar_pq(data_fungi_mini, "Phylum", "Class", "Order"), "ggplot" @@ -345,8 +345,8 @@ test_that("treemap_pq work with data_fungi_sp_known dataset", { }) test_that("tax_bar_pq work with data_fungi dataset", { - expect_s3_class(tax_bar_pq(data_fungi_mini, taxa = "Class"), "ggplot") skip_on_cran() + expect_s3_class(tax_bar_pq(data_fungi_mini, taxa = "Class"), "ggplot") expect_s3_class(tax_bar_pq(data_fungi_mini, taxa = "Class", fact = "Time"), "ggplot") expect_s3_class( tax_bar_pq( diff --git a/tests/testthat/test_misc.R b/tests/testthat/test_misc.R index ab2057d0..b157fa0d 100644 --- a/tests/testthat/test_misc.R +++ b/tests/testthat/test_misc.R @@ -93,15 +93,6 @@ withr::local_envvar( .local_envir = teardown_env() ) -test_that("install_pkg_needed works fine", { - expect_message(install_pkg_needed("abc", verbose = TRUE)) - skip_on_cran() - expect_message(install_pkg_needed("MiscMetabar", verbose = TRUE)) - expect_silent(install_pkg_needed("MiscMetabar")) - expect_silent(suppressMessages(install_pkg_needed("microbiomeDataSets"))) - expect_silent(suppressMessages(install_pkg_needed("microbiomeDataSets", bioconductor_pkg = TRUE, use_pak = FALSE))) -}) - test_that("add_funguild_info works fine", { skip_on_cran() data_f <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 5000) diff --git a/tests/testthat/test_phyloseq_class.R b/tests/testthat/test_phyloseq_class.R index a63c3e57..9ab00c2e 100644 --- a/tests/testthat/test_phyloseq_class.R +++ b/tests/testthat/test_phyloseq_class.R @@ -25,6 +25,7 @@ if (!is_vsearch_installed()) { message("lulu_pq() can't be tested when vsearch is not installed") } else { test_that("lulu_pq works fine", { + skip_on_cran() expect_s4_class(lulu_pq(data_fungi)$new_physeq, "phyloseq") expect_error(lulu_pq(enterotype)$new_physeq) expect_s4_class(lulu_pq(data_fungi_sp_known, clean_pq = TRUE, verbose = TRUE)$new_physeq, "phyloseq") @@ -38,6 +39,7 @@ if (class(mumu_error_or_not) == "try-error") { message("mumu_pq() can't be tested when mumu is not installed") } else { test_that("mumu_pq works fine", { + skip_on_cran() expect_s4_class(mumu_pq(data_fungi_mini)$new_physeq, "phyloseq") expect_error(mumu_pq(enterotype)$new_physeq, "phyloseq") expect_s4_class(mumu_pq(data_fungi_mini, clean_pq = TRUE, verbose = TRUE)$new_physeq, "phyloseq") @@ -46,6 +48,7 @@ if (class(mumu_error_or_not) == "try-error") { test_that("as_binary_otu_table works fine", { + skip_on_cran() expect_s4_class(as_binary_otu_table(data_fungi_mini), "phyloseq") expect_s4_class(as_binary_otu_table(enterotype), "phyloseq") }) diff --git a/tests/testthat/test_rw.R b/tests/testthat/test_rw.R index 4e92e578..6e862cb8 100644 --- a/tests/testthat/test_rw.R +++ b/tests/testthat/test_rw.R @@ -5,6 +5,7 @@ test_that("write_pq function works fine with enterotype dataset", { testFolder <- tempdir() unlink(list.files(testFolder, full.names = TRUE), recursive = TRUE) expect_silent(write_pq(enterotype, path = testFolder, silent = TRUE)) + skip_on_cran() expect_silent(write_pq(enterotype, path = testFolder, silent = TRUE, sam_data_first = TRUE)) expect_silent(write_pq(enterotype, path = testFolder, silent = TRUE, write_sam_data = TRUE)) expect_message(write_pq(enterotype, path = testFolder)) @@ -20,6 +21,7 @@ test_that("write_pq function works fine with data_fungi dataset", { testFolder <- tempdir() unlink(list.files(testFolder, full.names = TRUE), recursive = TRUE) expect_silent(write_pq(data_fungi, path = testFolder, silent = TRUE)) + skip_on_cran() expect_silent(write_pq(data_fungi, path = testFolder, silent = TRUE, sam_data_first = TRUE)) expect_silent(write_pq(data_fungi, path = testFolder, silent = TRUE, write_sam_data = FALSE)) expect_message(write_pq(data_fungi, path = testFolder, silent = TRUE, sam_data_first = TRUE, one_file = TRUE)) @@ -34,6 +36,7 @@ test_that("write_pq function works fine with data_fungi dataset", { test_that("save_pq function works fine with data_fungi dataset", { skip_on_os("windows") + skip_on_cran() testFolder <- tempdir() unlink(list.files(testFolder, full.names = TRUE), recursive = TRUE) expect_message(save_pq(data_fungi, path = testFolder, silent = TRUE)) diff --git a/tests/testthat/test_table_functions.R b/tests/testthat/test_table_functions.R index 61484635..998ab905 100644 --- a/tests/testthat/test_table_functions.R +++ b/tests/testthat/test_table_functions.R @@ -3,8 +3,9 @@ data(enterotype) test_that("tax_datatable function works fine with data_fungi dataset", { skip_on_os("windows") - expect_silent(taxdt <- tax_datatable(data_fungi)) skip_on_cran() + expect_silent(taxdt <- tax_datatable(data_fungi)) + expect_s3_class(taxdt, "datatables") expect_silent(taxdt <- tax_datatable(data_fungi, taxonomic_level = 1:2)) expect_s3_class(taxdt, "datatables") @@ -15,8 +16,8 @@ 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)) skip_on_cran() + expect_silent(tax_datatable(enterotype)) expect_s3_class(tax_datatable(enterotype), "datatables") expect_silent(tax_datatable(enterotype, modality = enterotype@sam_data$SeqTech)) expect_s3_class(tax_datatable(enterotype, modality = enterotype@sam_data$SeqTech), "datatables") diff --git a/tests/testthat/test_targets.R b/tests/testthat/test_targets.R index 94e3ef83..d6158d6d 100644 --- a/tests/testthat/test_targets.R +++ b/tests/testthat/test_targets.R @@ -2,6 +2,7 @@ data(enterotype) data(data_fungi) test_that("list_fastq_files function works fine", { + skip_on_cran() expect_type( list_fastq_files( "inst/extdata", @@ -52,6 +53,7 @@ test_that("rename_samples_otu_table function works fine when taxa_are_rows", { data_fungi_row <- clean_pq(data_fungi, force_taxa_as_rows = TRUE) test_that("rename_samples_otu_table function works fine when taxa_are_columns", { + skip_on_cran() expect_s4_class( rename_samples_otu_table(data_fungi_row, as.character(1:nsamples(data_fungi_row))), "otu_table" @@ -79,6 +81,7 @@ data_fungi_test@otu_table[10, ] <- test_that("track_wkflow function works fine", { skip_on_os("windows") + skip_on_cran() expect_message(track_wkflow(list( unlist(list_fastq_files("inst/extdata/")), data_fungi, enterotype ))) @@ -95,6 +98,7 @@ test_that("track_wkflow function works fine", { }) test_that("track_wkflow function works fine with taxonomy_rank", { + skip_on_cran() expect_error(track_wkflow(list( unlist(list_fastq_files("inst/extdata/")), data_fungi, enterotype ), taxonomy_rank = c(3, 5))) @@ -104,6 +108,7 @@ test_that("track_wkflow function works fine with taxonomy_rank", { tree_A10_005 <- subset_samples(data_fungi, Tree_name == "A10-005") test_that("track_wkflow_samples function works fine", { + skip_on_cran() expect_message(track_wkflow_samples(tree_A10_005)) expect_equal(length(track_wkflow_samples(tree_A10_005)), 3) expect_type(track_wkflow_samples(tree_A10_005), "list") diff --git a/tests/testthat/test_tuckey.R b/tests/testthat/test_tuckey.R index 02d8499a..1e768f62 100644 --- a/tests/testthat/test_tuckey.R +++ b/tests/testthat/test_tuckey.R @@ -2,8 +2,9 @@ data("GlobalPatterns", package = "phyloseq") GlobalPatterns@sam_data[, "Soil_logical"] <- ifelse(GlobalPatterns@sam_data[, "SampleType"] == "Soil", "Soil", "Not Soil") test_that("hill_tuckey_pq function works fine with GlobalPatterns dataset", { - expect_silent(suppressMessages(hill_tuckey_pq(GlobalPatterns, "Soil_logical"))) skip_on_cran() + expect_silent(suppressMessages(hill_tuckey_pq(GlobalPatterns, "Soil_logical"))) + expect_silent(suppressMessages(hill_tuckey_pq(GlobalPatterns, "SampleType"))) expect_message(hill_tuckey_pq(GlobalPatterns, "SampleType", silent = FALSE)) expect_s3_class(hill_tuckey_pq(GlobalPatterns, "SampleType"), "ggplot") @@ -13,8 +14,8 @@ test_that("hill_tuckey_pq function works fine with GlobalPatterns dataset", { data("enterotype") test_that("hill_tuckey_pq function works fine with enterotype dataset", { - expect_silent(hill_tuckey_pq(enterotype, "Nationality")) skip_on_cran() + expect_silent(hill_tuckey_pq(enterotype, "Nationality")) expect_message(hill_tuckey_pq(enterotype, "Nationality", silent = FALSE)) expect_s3_class(hill_tuckey_pq(enterotype, "Nationality"), "ggplot") expect_error(hill_tuckey_pq(enterotype, "NAtionnality")) @@ -22,8 +23,8 @@ test_that("hill_tuckey_pq function works fine with enterotype dataset", { data("data_fungi") test_that("hill_tuckey_pq function works fine with data_fungi dataset", { - expect_silent(hill_tuckey_pq(data_fungi, "Time")) skip_on_cran() + expect_silent(hill_tuckey_pq(data_fungi, "Time")) expect_message(hill_tuckey_pq(data_fungi, "Time", silent = FALSE)) expect_s3_class(hill_tuckey_pq(data_fungi, "Time"), "ggplot") expect_error(hill_tuckey_pq(data_fungi, "Timmes")) diff --git a/vignettes/articles/Reclustering.Rmd b/vignettes/articles/Reclustering.Rmd index 4a3193a5..44ce5a10 100644 --- a/vignettes/articles/Reclustering.Rmd +++ b/vignettes/articles/Reclustering.Rmd @@ -27,7 +27,7 @@ library(MiscMetabar) The choice between ASV and OTU is important because they lead to different results (@joos2020, Box 2 in @tedersoo2022, @chiarello2022). Most articles recommend making a choice depending on the question. For example, ASV may be better than OTU for describing a group of very closely related species. In addition, ASV are comparable across different datasets (obtained using identical marker genes). On the other hand, [@tedersoo2022] report that ASV approaches overestimate the richness of common fungal species (due to haplotype variation), but underestimate the richness of rare species. They therefore recommend the use of OTUs in metabarcoding analyses of fungal communities. Finally, [@kauserud2023] argues that the ASV term falls within the original OTU term and recommends adopting only the OTU terms, but with a concise and clear report on how the OTUs were generated. -Recent articles [@forster2019; @antich2021] propose to use both approach together. They recommend (i) using ASV to denoise the dataset and (ii) for some questions, clustering the ASV sequences into OTUs. This is the goal of the function `asv2otu()`, using either the `DECIPHER::Clusterize` function from R or the [vsearch](https://github.com/torognes/vsearch) software. +Recent articles [@forster2019; @antich2021] propose to use both approach together. They recommend (i) using ASV to denoise the dataset and (ii) for some questions, clustering the ASV sequences into OTUs. [@garcia2019] used both concept to demonstrate that ecotypes (ASV within OTUs) are adapted to different values of environmental factors favoring the persistence of OTU across changing environmental conditions. This is the goal of the function `asv2otu()`, using either the `DECIPHER::Clusterize` function from R or the [vsearch](https://github.com/torognes/vsearch) software. ## Using decipher or Vsearch algorithm ```{r} diff --git a/vignettes/articles/explore_data.Rmd b/vignettes/articles/explore_data.Rmd index 82abc8dc..c83eb668 100644 --- a/vignettes/articles/explore_data.Rmd +++ b/vignettes/articles/explore_data.Rmd @@ -11,7 +11,8 @@ vignette: > knitr::opts_chunk$set( collapse = TRUE, comment = "#>", - message = FALSE + message = FALSE, + results = "hide" ) ``` diff --git a/vignettes/bibliography.bib b/vignettes/bibliography.bib index 8ab7ce49..db036233 100644 --- a/vignettes/bibliography.bib +++ b/vignettes/bibliography.bib @@ -10,6 +10,22 @@ @article{altschul1990 publisher = {Elsevier} } +@article{garcia2019, + author = {García-García, Natalia and Tamames, Javier and Linz, Alexandra M and Pedrós-Alió, Carlos and Puente-Sánchez, Fernando}, + title = "{Microdiversity ensures the maintenance of functional microbial communities under changing environmental conditions}", + journal = {The ISME Journal}, + volume = {13}, + number = {12}, + pages = {2969-2983}, + year = {2019}, + month = {08}, + abstract = "{Microdiversity can lead to different ecotypes within the same species. These are assumed to provide stability in time and space to those species. However, the role of microdiversity in the stability of whole microbial communities remains underexplored. Understanding the drivers of microbial community stability is necessary to predict community response to future disturbances. Here, we analyzed 16S rRNA gene amplicons from eight different temperate bog lakes at the 97\\% OTU and amplicon sequence variant (ASV) levels and found ecotypes within the same OTU with different distribution patterns in space and time. We observed that these ecotypes are adapted to different values of environmental factors such as water temperature and oxygen concentration. Our results showed that the existence of several ASVs within a OTU favored its persistence across changing environmental conditions. We propose that microdiversity aids the stability of microbial communities in the face of fluctuations in environmental factors.}", + issn = {1751-7362}, + doi = {10.1038/s41396-019-0487-8}, + url = {https://doi.org/10.1038/s41396-019-0487-8}, + eprint = {https://academic.oup.com/ismej/article-pdf/13/12/2969/55551090/41396\_2019\_article\_487.pdf}, +} + @article{antich2021, title = {To denoise or to cluster, that is not the question: optimizing pipelines for COI metabarcoding and metaphylogeography},