diff --git a/DESCRIPTION b/DESCRIPTION index 1498b543..7e3b5bcc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,10 +1,10 @@ Package: MiscMetabar Type: Package Title: Miscellaneous Functions for Metabarcoding Analysis -Version: 0.7.3 +Version: 0.7.4 Authors@R: person("Adrien", "Taudière", email = "adrien.taudiere@zaclys.net", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0003-1088-1182")) -Description: The MiscMetabar package aims to facilitate the description, transformation, exploration, and reproducibility of metabarcoding analysis. Mainly build on the top of phyloseq, dada2 R packages. MiscMetabar help to build reproducible and robust bioinformatic pipeline in R. MiscMetabar make ecological analysis of alpha and beta-diversity simple and powerfull by integrating a large number of analysis, some of them from other R packages. +Description: The MiscMetabar package aims to facilitate the description, transformation, exploration, and reproducibility of metabarcoding analysis. Mainly build on the top of phyloseq, dada2 R packages. MiscMetabar help to build reproducible and robust bioinformatic pipeline in R. MiscMetabar make ecological analysis of alpha and beta-diversity simple and powerful by integrating a large number of analysis, some of them from other R packages. License: AGPL-3 Encoding: UTF-8 LazyData: true diff --git a/NEWS.md b/NEWS.md index fc971f7d..8c20c8e9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,10 @@ - Add functions `swarm_clustering()` and `vsearch_clustering()` and add `swarm` method in the function `asv2otu()` - Add function `physeq_or_string_to_dna()` mostly for internal use - 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.4) + ## BREAKING CHANGES diff --git a/R/Deseq2_edgeR.R b/R/Deseq2_edgeR.R index afe968e8..13ad2106 100644 --- a/R/Deseq2_edgeR.R +++ b/R/Deseq2_edgeR.R @@ -21,12 +21,15 @@ #' @export #' @examples #' data("GlobalPatterns", package = "phyloseq") -#' plot_edgeR_pq(GlobalPatterns, c("SampleType", "Soil", "Feces"), +#' GP_archae <- subset_taxa(GlobalPatterns, GlobalPatterns@tax_table[, 1] == "Archaea") +#' plot_edgeR_pq(GP_archae, c("SampleType", "Soil", "Feces"), #' color_tax = "Kingdom" #' ) -#' plot_edgeR_pq(GlobalPatterns, c("SampleType", "Soil", "Feces"), +#' \dontrun{ +#' plot_edgeR_pq(GP_archae, c("SampleType", "Soil", "Feces"), #' taxolev = "Class", color_tax = "Kingdom" #' ) +#' } #' @author Adrien Taudière #' #' @return A \code{\link{ggplot}}2 plot representing edgeR results diff --git a/R/beta_div_test.R b/R/beta_div_test.R index 53357e6b..caa54fdc 100644 --- a/R/beta_div_test.R +++ b/R/beta_div_test.R @@ -230,12 +230,11 @@ adonis_pq <- function(physeq, #' @export #' @seealso [plot_LCBD_pq], [adespatial::beta.div()] #' @examples -#' data(data_fungi_sp_known) -#' res <- LCBD_pq(data_fungi_sp_known, nperm = 50) +#' res <- LCBD_pq(data_fungi_sp_known, nperm = 5) #' str(res) #' length(res$LCBD) #' length(res$SCBD) -#' LCBD_pq(data_fungi_sp_known, nperm = 50, method = "jaccard") +#' LCBD_pq(data_fungi_sp_known, nperm = 5, method = "jaccard") #' #' @author Adrien Taudière #' This function is mainly a wrapper of the work of others. @@ -288,20 +287,20 @@ LCBD_pq <- function(physeq, #' #' @examples #' data(data_fungi) -#' plot_LCBD_pq(data_fungi, +#' plot_LCBD_pq(data_fungi_mini, #' nperm = 100, only_plot_significant = FALSE, #' pval = 0.2 #' ) -#' plot_LCBD_pq(data_fungi, +#' plot_LCBD_pq(data_fungi_mini, #' nperm = 100, only_plot_significant = TRUE, #' pval = 0.2 #' ) #' library("patchwork") -#' plot_LCBD_pq(data_fungi, +#' plot_LCBD_pq(data_fungi_mini, #' nperm = 100, only_plot_significant = FALSE, #' sam_variables = c("Time", "Height") #' ) -#' plot_LCBD_pq(data_fungi, +#' plot_LCBD_pq(data_fungi_mini, #' nperm = 100, only_plot_significant = TRUE, pval = 0.2, #' sam_variables = c("Time", "Height", "Tree_name") #' ) & @@ -563,12 +562,8 @@ multipatt_pq <- function(physeq, #' @export #' #' @examples -#' data(data_fungi_sp_known) #' res_height <- ancombc_pq( -#' subset_taxa_pq( -#' data_fungi_sp_known, -#' taxa_sums(data_fungi_sp_known) > 5000 -#' ), +#' data_fungi_mini, #' fact = "Height", #' levels_fact = c("Low", "High"), #' verbose = TRUE @@ -590,10 +585,7 @@ multipatt_pq <- function(physeq, #' geom_point() #' #' res_time <- ancombc_pq( -#' subset_taxa_pq( -#' data_fungi_sp_known, -#' taxa_sums(data_fungi_sp_known) > 5000 -#' ), +#' data_fungi_mini, #' fact = "Time", #' levels_fact = c("0", "15"), #' tax_level = "Family", diff --git a/R/dada_phyloseq.R b/R/dada_phyloseq.R index 99a0d5f1..d454c999 100644 --- a/R/dada_phyloseq.R +++ b/R/dada_phyloseq.R @@ -481,7 +481,7 @@ track_wkflow_samples <- function(list_pq_obj, ...) { #' @param method (default: clusterize) #' Set the clustering method. #' - `clusterize` use the [DECIPHER::Clusterize()] fonction, -#' - `vsearch` use the vsearch software (https://github.com/torognes/vsearch/) +#' - `vsearch` use the vsearch software (https://github.com/torognes/vsearch) #' with arguments `--cluster_size` by default (see args `vsearch_cluster_method`) #' and `-strand both` (see args `vsearch_args`) #' - `swarm` use the swarm @@ -493,7 +493,7 @@ track_wkflow_samples <- function(list_pq_obj, ...) { #' set tax_adjust to 0 (default). For the moment only tax_adjust = 0 is #' robust #' @param vsearch_cluster_method (default: "--cluster_size) See other possible -#' methods in the [vsearch pdf manual](https://github.com/torognes/vsearch/releases/download/v2.23.0/vsearch_manual.pdf) (e.g. `--cluster_size` or `--cluster_smallmem`) +#' methods in the [vsearch manual](https://github.com/torognes/vsearch/) (e.g. `--cluster_size` or `--cluster_smallmem`) #' - `--cluster_fast` : Clusterize the fasta sequences in filename, automatically sort by decreasing sequence length beforehand. #' - `--cluster_size` : Clusterize the fasta sequences in filename, automatically sort by decreasing sequence abundance beforehand. #' - `--cluster_smallmem` : Clusterize the fasta sequences in filename without automatically modifying their order beforehand. Sequence are expected to be sorted by decreasing sequence length, unless *--usersort* is used. @@ -520,6 +520,15 @@ track_wkflow_samples <- function(list_pq_obj, ...) { #' @return A new object of class `physeq` or a list of cluster if dna_seq #' args was used. #' +#' @examples +#' asv2otu(data_fungi_mini) +#' asv2otu(data_fungi_mini, method_clusterize = "longest") +#' if (MiscMetabar:::is_swarm_installed()) { +#' d_swarm <- asv2otu(data_fungi_mini, method = "swarm") +#' } +#' if (MiscMetabar:::is_vsearch_installed()) { +#' d_vs <- asv2otu(data_fungi_mini, method = "vsearch") +#' } #' @references #' VSEARCH can be downloaded from #' \url{https://github.com/torognes/vsearch}. @@ -1917,8 +1926,8 @@ plot_guild_pq <- #' @examples #' library("phangorn") #' -#' df <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 9000) -#' df_tree <- build_phytree_pq(df, nb_bootstrap = 5) +#' 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") diff --git a/R/data.R b/R/data.R index 56a1188e..cafcf309 100644 --- a/R/data.R +++ b/R/data.R @@ -32,6 +32,39 @@ #' @usage data(data_fungi_sp_known) "data_fungi_sp_known" + +#' Fungal OTU in phyloseq format +#' +#' It is a subset of the data_fungi dataset including only Basidiomycota +#' with more than 5000 sequences. +#' +#' Obtain using `data_fungi_mini <- subset_taxa(data_fungi, Phylum == "Basidiomycota")` +#' and then `data_fungi_mini <- subset_taxa_pq(data_fungi_mini, colSums(data_fungi_mini@otu_table) > 5000)` +#' +#' +#' @format A physeq object containing 45 taxa with references sequences +#' described by 14 taxonomic ranks and 137 samples described by 7 sample variables: +#' - *X*: the name of the fastq-file +#' - *Sample_names*: the names of ... the samples +#' - *Treename*: the name of an tree +#' - *Sample_id*: identifier for each sample +#' - *Height*: height of the sample in the tree +#' - *Diameter*: diameter of the trunk +#' - *Time*: time since the dead of the tree +#' @usage data(data_fungi_mini) +#' @format A physeq object containing 45 taxa with references sequences +#' described by 14 taxonomic ranks and 137 samples described by 7 sample variables: +#' - *X*: the name of the fastq-file +#' - *Sample_names*: the names of ... the samples +#' - *Treename*: the name of an tree +#' - *Sample_id*: identifier for each sample +#' - *Height*: height of the sample in the tree +#' - *Diameter*: diameter of the trunk +#' - *Time*: time since the dead of the tree +#' @usage data(data_fungi_mini) +"data_fungi_mini" + + #' This tutorial explore the dataset from Tengeler et al. (2020) available in the `mia` package. #' obtain using `mia::makePhyloseqFromTreeSE(Tengeler2020)` #' diff --git a/R/miscellanous.R b/R/miscellanous.R index e4c0dcd9..3dbd29ea 100644 --- a/R/miscellanous.R +++ b/R/miscellanous.R @@ -359,3 +359,100 @@ install_pkg_needed <- function(pkg, use_pak = TRUE, bioconductor_pkg = FALSE, } } } + +################################################################################ +#' Test if cutadapt is installed. +#' +#' @description +#' `r lifecycle::badge("maturing")` +#' +#' Useful for testthat and examples compilation for R CMD CHECK and +#' test coverage +#' +#' @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 +#' @return A logical that say if cutadapt is install in +#' +#' @examples +#' 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 && ") { + writeLines(paste0(args_before_cutadapt, " cutadapt -h"), paste0(tempdir(), "/script_cutadapt.sh")) + cutadapt_error_or_not <- try(system(paste0("bash ", tempdir(), "/script_cutadapt.sh 2>&1"), intern = TRUE), silent = T) + unlink(paste0(tempdir(), "/script_cutadapt.sh")) + + return(class(cutadapt_error_or_not) != "try-error") +} + +#' Test if falco is installed. +#' +#' @description +#' `r lifecycle::badge("maturing")` +#' +#' Useful for testthat and examples compilation for R CMD CHECK and +#' test coverage +#' +#' @param path (default: falco) Path to falco +#' @keywords internal +#' @noRd +#' @return A logical that say if falco is install in +#' +#' @examples +#' MiscMetabar:::is_falco_installed() +#' @author Adrien Taudière + +is_falco_installed <- function(path = "falco") { + return(class(try(system(paste0(path, " 2>&1"), intern = TRUE), + silent = TRUE + )) != "try-error") +} + +#' Test if swarm is installed. +#' +#' @description +#' `r lifecycle::badge("maturing")` +#' +#' Useful for testthat and examples compilation for R CMD CHECK and +#' test coverage +#' +#' @param path (default: swarm) Path to falco +#' @keywords internal +#' @noRd +#' @return A logical that say if swarm is install in +#' +#' @examples +#' MiscMetabar:::is_swarm_installed() +#' @author Adrien Taudière + +is_swarm_installed <- function(path = "swarm") { + return(class(try(system(paste0(path, " -h 2>&1"), intern = TRUE), + silent = TRUE + )) != "try-error") +} + +#' Test if vsearch is installed. +#' +#' @description +#' `r lifecycle::badge("maturing")` +#' +#' Useful for testthat and examples compilation for R CMD CHECK and +#' test coverage +#' +#' @param path (default: vsearch) Path to vsearch +#' @keywords internal +#' @noRd +#' @return A logical that say if vsearch is install in +#' +#' @examples +#' MiscMetabar:::is_vsearch_installed() +#' @author Adrien Taudière + +is_vsearch_installed <- function(path = "vsearch") { + 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 dea31fae..7488bd76 100644 --- a/R/plot_functions.R +++ b/R/plot_functions.R @@ -1713,11 +1713,13 @@ summary_plot_pq <- function(physeq, #' use this function. #' @examples #' library("rotl") -#' data(data_fungi) -#' tr <- rotl_pq(data_fungi, species_colnames = "Genus_species") +#' 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) +#' \dontrun{ +#' 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") { @@ -1777,7 +1779,7 @@ rotl_pq <- function(physeq, #' #' GPsubset <- subset_taxa( #' GPsubset, -#' rowSums(GPsubset@otu_table) > 1000 +#' rowSums(GPsubset@otu_table) > 5000 #' ) #' #' GPsubset <- subset_taxa( @@ -1793,13 +1795,15 @@ rotl_pq <- function(physeq, #' 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" -#' ) +#' \dontrun{ +#' 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) @@ -2747,18 +2751,17 @@ iNEXT_pq <- function(physeq, #' @seealso [ggvenn_pq()] #' @examples #' -#' upset_pq(data_fungi, fact = "Height", width_ratio = 0.2) -#' upset_pq(data_fungi, +#' upset_pq(data_fungi_mini, #' fact = "Height", width_ratio = 0.2, #' taxa_fill = "Class" #' ) -#' upset_pq(data_fungi, fact = "Height", min_nb_seq = 1000) -#' upset_pq(data_fungi, fact = "Height", na_remove = FALSE) -#' upset_pq(data_fungi, fact = "Time", width_ratio = 0.2) -#' upset_pq(data_fungi, fact = "Time", width_ratio = 0.2, rarefy_after_merging = TRUE) +#' upset_pq(data_fungi_mini, fact = "Height", min_nb_seq = 1000) +#' upset_pq(data_fungi_mini, fact = "Height", na_remove = FALSE) +#' +#' upset_pq(data_fungi_mini, fact = "Time", width_ratio = 0.2, rarefy_after_merging = TRUE) #' #' upset_pq( -#' data_fungi, +#' data_fungi_mini, #' fact = "Time", #' width_ratio = 0.2, #' annotations = list( @@ -2787,7 +2790,7 @@ iNEXT_pq <- function(physeq, #' #' #' upset_pq( -#' data_fungi, +#' data_fungi_mini, #' fact = "Time", #' width_ratio = 0.2, #' numeric_fonction = mean, @@ -2817,7 +2820,7 @@ iNEXT_pq <- function(physeq, #' #' #' upset_pq( -#' subset_taxa(data_fungi, Phylum == "Basidiomycota"), +#' subset_taxa(data_fungi_mini, Phylum == "Basidiomycota"), #' fact = "Time", #' width_ratio = 0.2, #' base_annotations = list(), @@ -2845,7 +2848,7 @@ iNEXT_pq <- function(physeq, #' ) #' ) #' -#' data_fungi2 <- data_fungi +#' data_fungi2 <- data_fungi_mini #' data_fungi2@sam_data[["Time_0"]] <- data_fungi2@sam_data$Time == 0 #' data_fungi2@sam_data[["Height__Time_0"]] <- #' paste0(data_fungi2@sam_data[["Height"]], "__", data_fungi2@sam_data[["Time_0"]]) @@ -3183,24 +3186,18 @@ tax_bar_pq <- function(physeq, fact = "Sample", taxa = "Order", percent_bar = FA #' @author Adrien Taudière #' @examples #' -#' ridges_pq(data_fungi, "Time", alpha = 0.5, log10trans = FALSE) + xlim(c(0, 1000)) -#' ridges_pq(data_fungi, "Time", alpha = 0.5) -#' ridges_pq( -#' clean_pq(subset_taxa(data_fungi_sp_known, Phylum == "Basidiomycota")), -#' "Sample_names" -#' ) -#' ridges_pq(clean_pq(subset_taxa(data_fungi_sp_known, Phylum == "Basidiomycota")), -#' "Time", -#' alpha = 0.6, scale = 0.9 -#' ) -#' ridges_pq(clean_pq(subset_taxa(data_fungi_sp_known, Phylum == "Basidiomycota")), +#' ridges_pq(data_fungi_mini, "Time", alpha = 0.5, log10trans = FALSE) + xlim(c(0, 1000)) +#' ridges_pq(data_fungi_mini, "Time", alpha = 0.5, scale = 0.9) +#' ridges_pq(data_fungi_mini, "Sample_names", log10trans = TRUE) +#' +#' ridges_pq(data_fungi_mini, #' "Time", #' jittered_points = TRUE, #' position = ggridges::position_points_jitter(width = 0.05, height = 0), #' point_shape = "|", point_size = 3, point_alpha = 1, alpha = 0.7, #' scale = 0.8 #' ) -#' ridges_pq(data_fungi, "Height", alpha = 0.5, log10trans = TRUE) +#' ridges_pq <- function(physeq, fact, nb_seq = TRUE, diff --git a/R/speedyseq_functions.R b/R/speedyseq_functions.R index 1fefb79c..1d5a03d7 100644 --- a/R/speedyseq_functions.R +++ b/R/speedyseq_functions.R @@ -585,6 +585,7 @@ merge_groups <- function(x, group, f = unique_or_na) { #' 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 38e9b2db..ef8b9c0d 100644 --- a/R/vsearch.R +++ b/R/vsearch.R @@ -164,9 +164,7 @@ vs_search_global <- function(physeq, #' \url{https://github.com/torognes/swarm/}. #' #' @export -#' @examples -#' \dontrun{ -#' +#' @examplesIf MiscMetabar:::is_swarm_installed() #' summary_plot_pq(data_fungi) #' system2("swarm", "-h") #' @@ -188,13 +186,12 @@ vs_search_global <- function(physeq, #' sequences_ex_swarm <- swarm_clustering( #' dna_seq = sequences_ex #' ) -#' } #' @seealso [asv2otu()], [vsearch_clustering()] #' @references #' SWARM can be downloaded from #' \url{https://github.com/torognes/swarm}. #' More information in the associated publications -#' \doi{doi:10.1093/bioinformatics/btab493} and \doi{doi:10.7717/2Fpeerj.593} +#' \doi{doi:10.1093/bioinformatics/btab493} and \doi{doi:10.7717/peerj.593} #' @details #' This function is mainly a wrapper of the work of others. #' Please cite [SWARM](https://github.com/torognes/swarm). @@ -348,7 +345,7 @@ swarm_clustering <- function(physeq = NULL, #' set tax_adjust to 0 (default). For the moment only tax_adjust = 0 is #' robust #' @param vsearch_cluster_method (default: "--cluster_size) See other possible -#' methods in the [vsearch pdf manual](https://github.com/torognes/vsearch/releases/download/v2.23.0/vsearch_manual.pdf) (e.g. `--cluster_size` or `--cluster_smallmem`) +#' methods in the [vsearch manual](https://github.com/torognes/vsearch) (e.g. `--cluster_size` or `--cluster_smallmem`) #' - `--cluster_fast` : Clusterize the fasta sequences in filename, automatically sort by decreasing sequence length beforehand. #' - `--cluster_size` : Clusterize the fasta sequences in filename, automatically sort by decreasing sequence abundance beforehand. #' - `--cluster_smallmem` : Clusterize the fasta sequences in filename without automatically modifying their order beforehand. Sequence are expected to be sorted by decreasing sequence length, unless *--usersort* is used. @@ -376,8 +373,7 @@ swarm_clustering <- function(physeq = NULL, #' @export #' @author Adrien Taudière #' -#' @examples -#' +#' @examplesIf MiscMetabar:::is_vsearch_installed() #' summary_plot_pq(data_fungi) #' d_vs <- vsearch_clustering(data_fungi) #' summary_plot_pq(d_vs) @@ -503,8 +499,7 @@ vsearch_clustering <- function(physeq = NULL, #' #' @export #' -#' @examples -#' \dontrun{ +#' @examplesIf MiscMetabar:::is_vsearch_installed() #' data_fungi_nochim <- chimera_removal_vs(data_fungi) #' data_fungi_nochim_16 <- chimera_removal_vs(data_fungi, #' abskew = 16, @@ -514,7 +509,6 @@ vsearch_clustering <- function(physeq = NULL, #' chimera_removal_vs(data_fungi, type = "Select_only_non_chim") #' data_fungi_chimera <- #' chimera_removal_vs(data_fungi, type = "Select_only_chim") -#' } #' @author Adrien Taudière #' @details #' This function is mainly a wrapper of the work of others. @@ -626,13 +620,11 @@ chimera_removal_vs <- #' (`$chimera`) and bordeline taxa (`$borderline`) #' @export #' -#' @examples -#' \dontrun{ +#' @examplesIf MiscMetabar:::is_vsearch_installed() #' chimera_detection_vs( #' seq2search = data_fungi@refseq, #' nb_seq = taxa_sums(data_fungi) #' ) -#' } #' @author Adrien Taudière #' @details #' This function is mainly a wrapper of the work of others. diff --git a/_pkgdown.yml b/_pkgdown.yml index e67b30f0..d0427af8 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -50,11 +50,6 @@ reference: - tbl_sum_samdata - verify_pq -- title: Obtain phyloseq object - contents: - - chimera_removal_vs - - chimera_detection_vs - - title: Transform phyloseq object - subtitle: Taxonomy contents: @@ -74,17 +69,35 @@ reference: - funguild_assign - get_funguild_db -- subtitle: OTU table +- subtitle: Transform OTU table only contents: - as_binary_otu_table + +- subtitle: Subset/merge taxa + contents: + - subset_taxa_pq + - subset_taxa_tax_control + - select_taxa + - merge_taxa_vec + +- subtitle: Subset/merge samples + contents: + - select_one_sample + - merge_samples2 + +- subtitle: (Re)clustering OTU table + contents: - asv2otu - swarm_clustering - vsearch_clustering - lulu_pq - lulu - mumu_pq - - subset_taxa_pq - - subset_taxa_tax_control + +- subtitle: Remove chimera using vsearch + contents: + - chimera_removal_vs + - chimera_detection_vs - subtitle: Sample data contents: @@ -189,6 +202,7 @@ reference: contents: - data_fungi - data_fungi_sp_known + - data_fungi_mini - Tengeler2020_pq - title: Others utilities @@ -203,11 +217,10 @@ reference: - multiplot - perc - are_modality_even_depth - - merge_samples2 - - merge_taxa_vec - unique_or_na - physeq_or_string_to_dna - - select_one_sample + - MiscMetabar-package + diff --git a/cran-comments.md b/cran-comments.md index 24d32865..dc666e4f 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,19 +1,9 @@ ## R CMD check results -0 errors | 0 warnings | 2 note +0 errors | 0 warnings | 1 note * This is a First release. - -Notes: - -- Found the following (possibly) invalid URLs: - URL: - From: inst/doc/MiscMetabar.html - Message: Empty URL - --> Answer: I didn't find the place of this url. - - 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 sometimes the use of full data is necessary. The total examples run time is 246s on my computer which seems to be reasonable given the high number of examples in this package. +-> 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() relies 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. diff --git a/data/data_fungi_mini.rda b/data/data_fungi_mini.rda new file mode 100644 index 00000000..8c8e4c7e Binary files /dev/null and b/data/data_fungi_mini.rda differ diff --git a/man/LCBD_pq.Rd b/man/LCBD_pq.Rd index b88518be..a990bf53 100644 --- a/man/LCBD_pq.Rd +++ b/man/LCBD_pq.Rd @@ -26,12 +26,11 @@ A wrapper for the \code{\link[adespatial:beta.div]{adespatial::beta.div()}} func object. } \examples{ -data(data_fungi_sp_known) -res <- LCBD_pq(data_fungi_sp_known, nperm = 50) +res <- LCBD_pq(data_fungi_sp_known, nperm = 5) str(res) length(res$LCBD) length(res$SCBD) -LCBD_pq(data_fungi_sp_known, nperm = 50, method = "jaccard") +LCBD_pq(data_fungi_sp_known, nperm = 5, method = "jaccard") } \seealso{ diff --git a/man/ancombc_pq.Rd b/man/ancombc_pq.Rd index 8921eff0..8eb6aa53 100644 --- a/man/ancombc_pq.Rd +++ b/man/ancombc_pq.Rd @@ -35,12 +35,8 @@ Please make a reference to \code{ANCOMBC::ancombc2()} if you use this function. } \examples{ -data(data_fungi_sp_known) res_height <- ancombc_pq( - subset_taxa_pq( - data_fungi_sp_known, - taxa_sums(data_fungi_sp_known) > 5000 - ), + data_fungi_mini, fact = "Height", levels_fact = c("Low", "High"), verbose = TRUE @@ -62,10 +58,7 @@ ggplot( geom_point() res_time <- ancombc_pq( - subset_taxa_pq( - data_fungi_sp_known, - taxa_sums(data_fungi_sp_known) > 5000 - ), + data_fungi_mini, fact = "Time", levels_fact = c("0", "15"), tax_level = "Family", diff --git a/man/asv2otu.Rd b/man/asv2otu.Rd index 826aefae..fcb980aa 100644 --- a/man/asv2otu.Rd +++ b/man/asv2otu.Rd @@ -38,7 +38,7 @@ Set to number of cpus/processors to use for the clustering} Set the clustering method. \itemize{ \item \code{clusterize} use the \code{\link[DECIPHER:Clusterize]{DECIPHER::Clusterize()}} fonction, -\item \code{vsearch} use the vsearch software (https://github.com/torognes/vsearch/) +\item \code{vsearch} use the vsearch software (https://github.com/torognes/vsearch) with arguments \code{--cluster_size} by default (see args \code{vsearch_cluster_method}) and \verb{-strand both} (see args \code{vsearch_args}) \item \code{swarm} use the swarm @@ -55,7 +55,7 @@ set tax_adjust to 0 (default). For the moment only tax_adjust = 0 is robust} \item{vsearch_cluster_method}{(default: "--cluster_size) See other possible -methods in the \href{https://github.com/torognes/vsearch/releases/download/v2.23.0/vsearch_manual.pdf}{vsearch pdf manual} (e.g. \code{--cluster_size} or \code{--cluster_smallmem}) +methods in the \href{https://github.com/torognes/vsearch/}{vsearch manual} (e.g. \code{--cluster_size} or \code{--cluster_smallmem}) \itemize{ \item \code{--cluster_fast} : Clusterize the fasta sequences in filename, automatically sort by decreasing sequence length beforehand. \item \code{--cluster_size} : Clusterize the fasta sequences in filename, automatically sort by decreasing sequence abundance beforehand. @@ -99,6 +99,16 @@ This function use the \code{merge_taxa_vec} function to merge taxa into clusters. By default tax_adjust = 0. See the man page of \code{\link[=merge_taxa_vec]{merge_taxa_vec()}}. } +\examples{ +asv2otu(data_fungi_mini) +asv2otu(data_fungi_mini, method_clusterize = "longest") +if (MiscMetabar:::is_swarm_installed()) { + d_swarm <- asv2otu(data_fungi_mini, method = "swarm") +} +if (MiscMetabar:::is_vsearch_installed()) { + d_vs <- asv2otu(data_fungi_mini, method = "vsearch") +} +} \references{ VSEARCH can be downloaded from \url{https://github.com/torognes/vsearch}. diff --git a/man/build_phytree_pq.Rd b/man/build_phytree_pq.Rd index 0d2fd30c..56e6200e 100644 --- a/man/build_phytree_pq.Rd +++ b/man/build_phytree_pq.Rd @@ -75,8 +75,8 @@ use this function. \examples{ library("phangorn") -df <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 9000) -df_tree <- build_phytree_pq(df, nb_bootstrap = 5) +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") diff --git a/man/chimera_detection_vs.Rd b/man/chimera_detection_vs.Rd index c24ee93c..8c028359 100644 --- a/man/chimera_detection_vs.Rd +++ b/man/chimera_detection_vs.Rd @@ -57,12 +57,12 @@ This function is mainly a wrapper of the work of others. Please make \href{https://github.com/torognes/vsearch}{vsearch}. } \examples{ -\dontrun{ +\dontshow{if (MiscMetabar:::is_vsearch_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} chimera_detection_vs( seq2search = data_fungi@refseq, nb_seq = taxa_sums(data_fungi) ) -} +\dontshow{\}) # examplesIf} } \author{ Adrien Taudière diff --git a/man/chimera_removal_vs.Rd b/man/chimera_removal_vs.Rd index d0b1b698..18eb93f9 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{ -\dontrun{ +\dontshow{if (MiscMetabar:::is_vsearch_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} data_fungi_nochim <- chimera_removal_vs(data_fungi) data_fungi_nochim_16 <- chimera_removal_vs(data_fungi, abskew = 16, @@ -55,7 +55,7 @@ data_fungi_nochim2 <- chimera_removal_vs(data_fungi, type = "Select_only_non_chim") data_fungi_chimera <- chimera_removal_vs(data_fungi, type = "Select_only_chim") -} +\dontshow{\}) # examplesIf} } \seealso{ \code{\link[=chimera_detection_vs]{chimera_detection_vs()}} diff --git a/man/data_fungi_mini.Rd b/man/data_fungi_mini.Rd new file mode 100644 index 00000000..c0c0678a --- /dev/null +++ b/man/data_fungi_mini.Rd @@ -0,0 +1,45 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{data_fungi_mini} +\alias{data_fungi_mini} +\title{Fungal OTU in phyloseq format} +\format{ +A physeq object containing 45 taxa with references sequences +described by 14 taxonomic ranks and 137 samples described by 7 sample variables: +\itemize{ +\item \emph{X}: the name of the fastq-file +\item \emph{Sample_names}: the names of ... the samples +\item \emph{Treename}: the name of an tree +\item \emph{Sample_id}: identifier for each sample +\item \emph{Height}: height of the sample in the tree +\item \emph{Diameter}: diameter of the trunk +\item \emph{Time}: time since the dead of the tree +} + +A physeq object containing 45 taxa with references sequences +described by 14 taxonomic ranks and 137 samples described by 7 sample variables: +\itemize{ +\item \emph{X}: the name of the fastq-file +\item \emph{Sample_names}: the names of ... the samples +\item \emph{Treename}: the name of an tree +\item \emph{Sample_id}: identifier for each sample +\item \emph{Height}: height of the sample in the tree +\item \emph{Diameter}: diameter of the trunk +\item \emph{Time}: time since the dead of the tree +} +} +\usage{ +data(data_fungi_mini) + +data(data_fungi_mini) +} +\description{ +It is a subset of the data_fungi dataset including only Basidiomycota +with more than 5000 sequences. +} +\details{ +Obtain using \code{data_fungi_mini <- subset_taxa(data_fungi, Phylum == "Basidiomycota")} +and then \code{data_fungi_mini <- subset_taxa_pq(data_fungi_mini, colSums(data_fungi_mini@otu_table) > 5000)} +} +\keyword{datasets} diff --git a/man/heat_tree_pq.Rd b/man/heat_tree_pq.Rd index 08a4464e..c814156c 100644 --- a/man/heat_tree_pq.Rd +++ b/man/heat_tree_pq.Rd @@ -36,7 +36,7 @@ GPsubset <- subset_taxa( GPsubset <- subset_taxa( GPsubset, - rowSums(GPsubset@otu_table) > 1000 + rowSums(GPsubset@otu_table) > 5000 ) GPsubset <- subset_taxa( @@ -52,13 +52,15 @@ heat_tree_pq(GPsubset, 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" -) +\dontrun{ + 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{ diff --git a/man/plot_LCBD_pq.Rd b/man/plot_LCBD_pq.Rd index e2b3df05..f2df4ee4 100644 --- a/man/plot_LCBD_pq.Rd +++ b/man/plot_LCBD_pq.Rd @@ -46,20 +46,20 @@ use this function. } \examples{ data(data_fungi) -plot_LCBD_pq(data_fungi, +plot_LCBD_pq(data_fungi_mini, nperm = 100, only_plot_significant = FALSE, pval = 0.2 ) -plot_LCBD_pq(data_fungi, +plot_LCBD_pq(data_fungi_mini, nperm = 100, only_plot_significant = TRUE, pval = 0.2 ) library("patchwork") -plot_LCBD_pq(data_fungi, +plot_LCBD_pq(data_fungi_mini, nperm = 100, only_plot_significant = FALSE, sam_variables = c("Time", "Height") ) -plot_LCBD_pq(data_fungi, +plot_LCBD_pq(data_fungi_mini, nperm = 100, only_plot_significant = TRUE, pval = 0.2, sam_variables = c("Time", "Height", "Tree_name") ) & diff --git a/man/plot_edgeR_pq.Rd b/man/plot_edgeR_pq.Rd index 51e556cb..9b13edbb 100644 --- a/man/plot_edgeR_pq.Rd +++ b/man/plot_edgeR_pq.Rd @@ -45,13 +45,16 @@ A \code{\link{ggplot}}2 plot representing edgeR results } \examples{ data("GlobalPatterns", package = "phyloseq") -plot_edgeR_pq(GlobalPatterns, c("SampleType", "Soil", "Feces"), +GP_archae <- subset_taxa(GlobalPatterns, GlobalPatterns@tax_table[, 1] == "Archaea") +plot_edgeR_pq(GP_archae, c("SampleType", "Soil", "Feces"), color_tax = "Kingdom" ) -plot_edgeR_pq(GlobalPatterns, c("SampleType", "Soil", "Feces"), +\dontrun{ +plot_edgeR_pq(GP_archae, c("SampleType", "Soil", "Feces"), taxolev = "Class", color_tax = "Kingdom" ) } +} \seealso{ \code{\link[edgeR]{exactTest}} diff --git a/man/ridges_pq.Rd b/man/ridges_pq.Rd index 334f6eda..1d466c6c 100644 --- a/man/ridges_pq.Rd +++ b/man/ridges_pq.Rd @@ -32,24 +32,18 @@ taxonomic groups } \examples{ -ridges_pq(data_fungi, "Time", alpha = 0.5, log10trans = FALSE) + xlim(c(0, 1000)) -ridges_pq(data_fungi, "Time", alpha = 0.5) -ridges_pq( - clean_pq(subset_taxa(data_fungi_sp_known, Phylum == "Basidiomycota")), - "Sample_names" -) -ridges_pq(clean_pq(subset_taxa(data_fungi_sp_known, Phylum == "Basidiomycota")), - "Time", - alpha = 0.6, scale = 0.9 -) -ridges_pq(clean_pq(subset_taxa(data_fungi_sp_known, Phylum == "Basidiomycota")), +ridges_pq(data_fungi_mini, "Time", alpha = 0.5, log10trans = FALSE) + xlim(c(0, 1000)) +ridges_pq(data_fungi_mini, "Time", alpha = 0.5, scale = 0.9) +ridges_pq(data_fungi_mini, "Sample_names", log10trans = TRUE) + +ridges_pq(data_fungi_mini, "Time", jittered_points = TRUE, position = ggridges::position_points_jitter(width = 0.05, height = 0), point_shape = "|", point_size = 3, point_alpha = 1, alpha = 0.7, scale = 0.8 ) -ridges_pq(data_fungi, "Height", alpha = 0.5, log10trans = TRUE) + } \author{ Adrien Taudière diff --git a/man/rotl_pq.Rd b/man/rotl_pq.Rd index 93206e20..28b7ab7d 100644 --- a/man/rotl_pq.Rd +++ b/man/rotl_pq.Rd @@ -32,11 +32,13 @@ use this function. } \examples{ library("rotl") -data(data_fungi) -tr <- rotl_pq(data_fungi, species_colnames = "Genus_species") +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) +\dontrun{ + tr_Asco <- rotl_pq(data_fungi, species_colnames = "Genus_species", context_name = "Ascomycetes") + plot(tr_Asco) +} + } \author{ Adrien Taudière diff --git a/man/swarm_clustering.Rd b/man/swarm_clustering.Rd index 256e54c7..083ef83f 100644 --- a/man/swarm_clustering.Rd +++ b/man/swarm_clustering.Rd @@ -70,8 +70,7 @@ This function is mainly a wrapper of the work of others. Please cite \href{https://github.com/torognes/swarm}{SWARM}. } \examples{ -\dontrun{ - +\dontshow{if (MiscMetabar:::is_swarm_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} summary_plot_pq(data_fungi) system2("swarm", "-h") @@ -93,7 +92,7 @@ sequences_ex <- c( sequences_ex_swarm <- swarm_clustering( dna_seq = sequences_ex ) -} +\dontshow{\}) # examplesIf} } \references{ SWARM can be downloaded from @@ -102,7 +101,7 @@ SWARM can be downloaded from SWARM can be downloaded from \url{https://github.com/torognes/swarm}. More information in the associated publications -\doi{doi:10.1093/bioinformatics/btab493} and \doi{doi:10.7717/2Fpeerj.593} +\doi{doi:10.1093/bioinformatics/btab493} and \doi{doi:10.7717/peerj.593} } \seealso{ \code{\link[=asv2otu]{asv2otu()}}, \code{\link[=vsearch_clustering]{vsearch_clustering()}} diff --git a/man/upset_pq.Rd b/man/upset_pq.Rd index d1417464..98fc50fa 100644 --- a/man/upset_pq.Rd +++ b/man/upset_pq.Rd @@ -51,18 +51,17 @@ Alternative to venn plot. } \examples{ -upset_pq(data_fungi, fact = "Height", width_ratio = 0.2) -upset_pq(data_fungi, +upset_pq(data_fungi_mini, fact = "Height", width_ratio = 0.2, taxa_fill = "Class" ) -upset_pq(data_fungi, fact = "Height", min_nb_seq = 1000) -upset_pq(data_fungi, fact = "Height", na_remove = FALSE) -upset_pq(data_fungi, fact = "Time", width_ratio = 0.2) -upset_pq(data_fungi, fact = "Time", width_ratio = 0.2, rarefy_after_merging = TRUE) +upset_pq(data_fungi_mini, fact = "Height", min_nb_seq = 1000) +upset_pq(data_fungi_mini, fact = "Height", na_remove = FALSE) + +upset_pq(data_fungi_mini, fact = "Time", width_ratio = 0.2, rarefy_after_merging = TRUE) upset_pq( - data_fungi, + data_fungi_mini, fact = "Time", width_ratio = 0.2, annotations = list( @@ -91,7 +90,7 @@ upset_pq( upset_pq( - data_fungi, + data_fungi_mini, fact = "Time", width_ratio = 0.2, numeric_fonction = mean, @@ -121,7 +120,7 @@ upset_pq( upset_pq( - subset_taxa(data_fungi, Phylum == "Basidiomycota"), + subset_taxa(data_fungi_mini, Phylum == "Basidiomycota"), fact = "Time", width_ratio = 0.2, base_annotations = list(), @@ -149,7 +148,7 @@ upset_pq( ) ) -data_fungi2 <- data_fungi +data_fungi2 <- data_fungi_mini data_fungi2@sam_data[["Time_0"]] <- data_fungi2@sam_data$Time == 0 data_fungi2@sam_data[["Height__Time_0"]] <- paste0(data_fungi2@sam_data[["Height"]], "__", data_fungi2@sam_data[["Time_0"]]) diff --git a/man/vsearch_clustering.Rd b/man/vsearch_clustering.Rd index 0adb5e98..c1f3c8ed 100644 --- a/man/vsearch_clustering.Rd +++ b/man/vsearch_clustering.Rd @@ -39,7 +39,7 @@ set tax_adjust to 0 (default). For the moment only tax_adjust = 0 is robust} \item{vsearch_cluster_method}{(default: "--cluster_size) See other possible -methods in the \href{https://github.com/torognes/vsearch/releases/download/v2.23.0/vsearch_manual.pdf}{vsearch pdf manual} (e.g. \code{--cluster_size} or \code{--cluster_smallmem}) +methods in the \href{https://github.com/torognes/vsearch}{vsearch manual} (e.g. \code{--cluster_size} or \code{--cluster_smallmem}) \itemize{ \item \code{--cluster_fast} : Clusterize the fasta sequences in filename, automatically sort by decreasing sequence length beforehand. \item \code{--cluster_size} : Clusterize the fasta sequences in filename, automatically sort by decreasing sequence abundance beforehand. @@ -73,10 +73,11 @@ 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} summary_plot_pq(data_fungi) d_vs <- vsearch_clustering(data_fungi) summary_plot_pq(d_vs) +\dontshow{\}) # examplesIf} } \references{ VSEARCH can be downloaded from diff --git a/tests/testthat/Rplots.pdf b/tests/testthat/Rplots.pdf deleted file mode 100644 index 36f5f778..00000000 Binary files a/tests/testthat/Rplots.pdf and /dev/null differ diff --git a/tests/testthat/test_blast.R b/tests/testthat/test_blast.R index 07595efa..d85505da 100644 --- a/tests/testthat/test_blast.R +++ b/tests/testthat/test_blast.R @@ -1,7 +1,3 @@ -data("data_fungi") -df_basidio <- subset_taxa(data_fungi, Phylum == "Basidiomycota") -df_basidio <- - subset_taxa_pq(df_basidio, colSums(df_basidio@otu_table) > 1000) path_db <- system.file("extdata", "100_sp_UNITE_sh_general_release_dynamic.fasta", package = "MiscMetabar", mustWork = TRUE @@ -22,23 +18,23 @@ if (class(blast_error_or_not) == "try-error") { { expect_s3_class( blast_on_df <- - blast_to_phyloseq(df_basidio, path_db), + blast_to_phyloseq(data_fungi_mini, path_db), "data.frame" ) expect_s3_class( - blast_to_phyloseq(df_basidio, path_db, list_no_output_query = TRUE), + blast_to_phyloseq(data_fungi_mini, path_db, list_no_output_query = TRUE), "data.frame" ) expect_s3_class( blast_to_phyloseq( - df_basidio, + data_fungi_mini, path_db, unique_per_seq = TRUE, score_filter = FALSE ), "data.frame" ) - expect_error(blast_to_phyloseq(df_basidio, "inst/extdata/nil.fasta")) + expect_error(blast_to_phyloseq(data_fungi_mini, "inst/extdata/nil.fasta")) } ) @@ -46,17 +42,17 @@ if (class(blast_error_or_not) == "try-error") { "blast_pq works fine", { expect_s3_class(blast_df <- - blast_pq(df_basidio, path_db), "data.frame") + blast_pq(data_fungi_mini, path_db), "data.frame") expect_equal(ncol(blast_df), 9) expect_true(nrow(blast_df) > 0) expect_s3_class( - blast_df <- blast_pq(df_basidio, path_db, + blast_df <- blast_pq(data_fungi_mini, path_db, unique_per_seq = TRUE ), "data.frame" ) expect_s3_class( - blast_df <- blast_pq(df_basidio, path_db, + blast_df <- blast_pq(data_fungi_mini, path_db, score_filter = FALSE ), "data.frame" @@ -64,7 +60,7 @@ if (class(blast_error_or_not) == "try-error") { expect_s3_class( blast_df <- blast_pq( - df_basidio, + data_fungi_mini, path_db, unique_per_seq = FALSE, score_filter = FALSE @@ -73,14 +69,14 @@ if (class(blast_error_or_not) == "try-error") { ) expect_s3_class( blast_df <- - blast_pq(df_basidio, database = "inst/extdata/dbase"), + blast_pq(data_fungi_mini, database = "inst/extdata/dbase"), "data.frame" ) expect_error( blast_df <- - blast_pq(df_basidio, fasta_for_db = path_db, database = "inst/extdata/dbase") + blast_pq(data_fungi_mini, fasta_for_db = path_db, database = "inst/extdata/dbase") ) - expect_error(blast_df <- blast_pq(df_basidio)) + expect_error(blast_df <- blast_pq(data_fungi_mini)) } ) @@ -89,13 +85,13 @@ if (class(blast_error_or_not) == "try-error") { { expect_s4_class( df_blast <- - filter_asv_blast(df_basidio, path_db), + filter_asv_blast(data_fungi_mini, path_db), "phyloseq" ) expect_s4_class( df_blast <- filter_asv_blast( - df_basidio, + data_fungi_mini, path_db, id_filter = 50, e_value_filter = 10, @@ -107,14 +103,14 @@ if (class(blast_error_or_not) == "try-error") { expect_s4_class( df_blast <- filter_asv_blast( - df_basidio, + data_fungi_mini, path_db, add_info_to_taxtable = FALSE, nproc = 2 ), "phyloseq" ) - expect_error(filter_asv_blast(df_basidio, "inst/extdata/nil.fasta")) + expect_error(filter_asv_blast(data_fungi_mini, "inst/extdata/nil.fasta")) } ) @@ -123,10 +119,10 @@ if (class(blast_error_or_not) == "try-error") { { expect_s4_class( df_blast <- - add_blast_info(df_basidio, path_db), + add_blast_info(data_fungi_mini, path_db), "phyloseq" ) - expect_error(add_blast_info(df_basidio, "inst/extdata/nil.fasta")) + expect_error(add_blast_info(data_fungi_mini, "inst/extdata/nil.fasta")) } ) diff --git a/tests/testthat/test_cutadapt.R b/tests/testthat/test_cutadapt.R index c2ab5668..ca4c2733 100644 --- a/tests/testthat/test_cutadapt.R +++ b/tests/testthat/test_cutadapt.R @@ -1,8 +1,4 @@ -suppressWarnings(cutadapt_error_or_not <- - try(system("cutadapt 2>&1", intern = TRUE), silent = TRUE)) - -if (class(cutadapt_error_or_not) == "try-error" || - sum(grepl("ModuleNotFoundError", cutadapt_error_or_not)) != 0) { +if (!MiscMetabar:::is_cutadapt_installed()) { message( "cutadapt_remove_primers() can't be tested when cutadapt is not installed" @@ -11,8 +7,9 @@ if (class(cutadapt_error_or_not) == "try-error" || test_that("cutadapt_remove_primers works fine", { expect_silent(suppressMessages( res_cut <- cutadapt_remove_primers("inst/extdata", "TTC", "GAA", - folder_output = paste0(tempdir(), "/output_cutadapt") - ))) + folder_output = paste0(tempdir(), "/output_cutadapt") + ) + )) expect_type(res_cut, "list") expect_equal(length(res_cut), 1) expect_type(res_cut[[1]], "character") @@ -22,7 +19,7 @@ if (class(cutadapt_error_or_not) == "try-error" || expect_silent( suppressMessages(res_cut2 <- cutadapt_remove_primers( system.file("extdata", - package = "dada2" + package = "dada2" ), pattern_R1 = "F.fastq.gz", pattern_R2 = "R.fastq.gz", @@ -42,14 +39,14 @@ if (class(cutadapt_error_or_not) == "try-error" || expect_silent( suppressMessages(res_cut3 <- cutadapt_remove_primers( system.file("extdata", - package = "dada2" + package = "dada2" ), pattern_R1 = "F.fastq.gz", primer_fw = "TTC", folder_output = tempdir(), cmd_is_run = FALSE - ) - )) + )) + ) expect_type(res_cut3, "list") expect_equal(length(res_cut3), 2) @@ -59,5 +56,4 @@ if (class(cutadapt_error_or_not) == "try-error" || }) unlink(tempdir(), recursive = TRUE) - } diff --git a/tests/testthat/test_deprecated.R b/tests/testthat/test_deprecated.R index 0e02d013..6000b61e 100644 --- a/tests/testthat/test_deprecated.R +++ b/tests/testthat/test_deprecated.R @@ -1,20 +1,33 @@ -data("data_fungi") -data("data_fungi_sp_known") data("GlobalPatterns", package = "phyloseq") data("enterotype") -data_fungi_low_high <- subset_samples(data_fungi, Height %in% c("Low", "High")) +data_fungi_low_high <- subset_samples( + data_fungi_mini, + Height %in% c("Low", "High") +) data_basidio <- subset_taxa(data_fungi, Phylum == "Basidiomycota") -data_fungi_2trees <- subset_samples(data_fungi, data_fungi@sam_data$Tree_name %in% c("A10-005", "AD30-abm-X")) +data_fungi_2trees <- + subset_samples( + data_fungi, + data_fungi@sam_data$Tree_name %in% c("A10-005", "AD30-abm-X") + ) GlobalPatterns@sam_data[, "Soil_logical"] <- ifelse(GlobalPatterns@sam_data[, "SampleType"] == "Soil", "Soil", "Not Soil") -GP <- subset_samples(GlobalPatterns, GlobalPatterns@sam_data$SampleType %in% c("Soil", "Skin")) +GP_archae <- subset_taxa( + GlobalPatterns, + GlobalPatterns@tax_table[, 1] == "Archaea" +) +GP <- subset_samples_pq( + GP_archae, + GP_archae@sam_data$SampleType %in% c("Soil", "Skin") +) + res_deseq <- DESeq2::DESeq(phyloseq_to_deseq2(GP, ~SampleType), test = "Wald", fitType = "local") test_that("Test one case for each deprecated functions", { - expect_warning(physeq_graph_test(data_fungi, fact = "Tree_name"), "deprecated") - expect_s3_class(suppressWarnings(adonis_phyloseq(data_fungi, "Tree_name")), "anova") - expect_s4_class(suppressWarnings(clean_pq(data_fungi)), "phyloseq") + expect_warning(physeq_graph_test(data_fungi_mini, fact = "Tree_name"), "deprecated") + expect_s3_class(suppressWarnings(adonis_phyloseq(data_fungi_mini, "Tree_name")), "anova") + expect_s4_class(suppressWarnings(clean_pq(data_fungi_mini)), "phyloseq") expect_message(expect_warning(otu_circle(data_fungi_2trees, fact = "Tree_name", nproc = 1, add_nb_seq = FALSE), "deprecated")) expect_message(expect_warning(biplot_physeq(data_fungi_2trees, merge_sample_by = "Tree_name"), "deprecated")) @@ -23,12 +36,12 @@ test_that("Test one case for each deprecated functions", { expect_warning(write_phyloseq(enterotype, path = testFolder, silent = TRUE), "deprecated") expect_s4_class(suppressWarnings(read_phyloseq(testFolder, taxa_are_rows = TRUE)), "phyloseq") - expect_warning(sankey_phyloseq(data_fungi), "deprecated") - expect_s3_class(suppressWarnings(summary_plot_phyloseq(data_fungi)), "ggplot") + expect_warning(sankey_phyloseq(data_fungi_mini), "deprecated") + expect_s3_class(suppressWarnings(summary_plot_phyloseq(data_fungi_mini)), "ggplot") expect_message(expect_warning(plot_edgeR_phyloseq(GlobalPatterns, c("SampleType", "Soil", "Feces"), color_tax = "Kingdom"), "deprecated"), "Perform edgeR binary test") expect_warning(plot_deseq2_phyloseq(res_deseq, c("SampleType", "Soil", "Skin"), tax_table = GP@tax_table, color_tax = "Kingdom"), "deprecated") - expect_warning(venn_phyloseq(data_fungi, "Height"), "deprecated") - expect_warning(ggVenn_phyloseq(data_fungi, "Height"), "deprecated") + expect_warning(venn_phyloseq(data_fungi_mini, "Height"), "deprecated") + expect_warning(ggVenn_phyloseq(data_fungi_mini, "Height"), "deprecated") expect_warning(hill_tuckey_phyloseq(GlobalPatterns, "Soil_logical"), "deprecated") expect_message(expect_warning(hill_phyloseq(GP, "SampleType"), "deprecated")) diff --git a/tests/testthat/test_deseq2_edgeR.R b/tests/testthat/test_deseq2_edgeR.R index ccd53f9f..28ea1bcb 100644 --- a/tests/testthat/test_deseq2_edgeR.R +++ b/tests/testthat/test_deseq2_edgeR.R @@ -1,5 +1,14 @@ data("GlobalPatterns", package = "phyloseq") -GP <- subset_samples(GlobalPatterns, GlobalPatterns@sam_data$SampleType %in% c("Soil", "Skin")) + +GP_archae <- subset_taxa( + GlobalPatterns, + GlobalPatterns@tax_table[, 1] == "Archaea" +) + +GP <- subset_samples_pq( + GP_archae, + GP_archae@sam_data$SampleType %in% c("Soil", "Skin") +) fac2col <- function(x, col.pal = funky_color, na.col = "transparent", seed = NULL) { x <- factor(x) @@ -18,14 +27,15 @@ fac2col <- function(x, col.pal = funky_color, na.col = "transparent", seed = NUL return(res) } -test_that("plot_edgeR_pq works", { - expect_message(plot_edgeR_pq(GlobalPatterns, c("SampleType", "Soil", "Feces"), color_tax = "Kingdom"), "Perform edgeR binary test") # nolint: line_length_linter. - expect_message(plot_edgeR_pq(GlobalPatterns, c("SampleType", "Soil", "Feces"), color_tax = "Species"), "Perform edgeR binary test") - expect_message(plot_edgeR_pq(GlobalPatterns, c("SampleType", "Soil", "Feces"), taxolev = "Class", color_tax = "Kingdom"), "Perform edgeR binary test") - expect_error(plot_edgeR_pq(GlobalPatterns, "SampleType", taxolev = "Class", color_tax = "Kingdom"), "At least one element of given pair is not a group") - expect_error(plot_edgeR_pq(GlobalPatterns, c("SampleType", "Soil", "Feces"), color_tax = "Samples")) +test_that("plot_edgeR_pq works with GP dataset", { + expect_message(plot_edgeR_pq(GP_archae, c("SampleType", "Soil", "Feces"), color_tax = "Kingdom"), "Perform edgeR binary test") + expect_message(plot_edgeR_pq(GP_archae, c("SampleType", "Soil", "Feces"), color_tax = "Species"), "Perform edgeR binary test") + expect_message(plot_edgeR_pq(GP_archae, c("SampleType", "Soil", "Feces"), taxolev = "Class", color_tax = "Kingdom"), "Perform edgeR binary test") + expect_error(plot_edgeR_pq(GP_archae, "SampleType", taxolev = "Class", color_tax = "Kingdom"), "At least one element of given pair is not a group") + expect_error(plot_edgeR_pq(GP_archae, c("SampleType", "Soil", "Feces"), color_tax = "Samples")) }) -test_that("plot_deseq2_pq works with results", { + +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") 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"))) @@ -34,27 +44,27 @@ test_that("plot_deseq2_pq works with results", { color_tax = fac2col(as.vector(GP@tax_table[, "Order"])) ))) expect_silent(suppressWarnings(plot_deseq2_pq(res, c("SampleType", "Soil", "Skin"), tax_table = GP@tax_table, color_tax = "Kingdom", verbose = TRUE))) - 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, color_tax = "Kingdom", taxolev = "Class"))) - expect_silent(suppressWarnings(plot_deseq2_pq(res, c("SampleType", "Soil", "Skin"), tax_table = GP@tax_table, color_tax = "Class"))) expect_silent(suppressWarnings(plot_deseq2_pq(res, c("SampleType", "Soil", "Skin"), tax_table = GP@tax_table, color_tax = "Class", alpha = 0.7))) + expect_silent(suppressWarnings(plot_deseq2_pq(res, c("SampleType", "Soil", "Skin"), tax_table = GP@tax_table, color_tax = "Kingdom", taxolev = "Class"))) + expect_error(plot_deseq2_pq(res, c("SampleType", "Soil", "Skyp"), tax_table = GP@tax_table, color_tax = "Kingdom")) expect_error(plot_deseq2_pq(res, c("SampleType", "Soil", "Skin"), color_tax = "Class")) expect_message(plot_deseq2_pq(res, c("SampleType", "Soil", "Skin"), tax_table = GP@tax_table, color_tax = "Class", select_taxa = "522457")) expect_message(plot_deseq2_pq(res, c("SampleType", "Soil", "Skin"), tax_table = GP@tax_table, color_tax = "Class", select_taxa = c("522457", "271582"))) - expect_silent(suppressWarnings(plot_deseq2_pq(res, c("SampleType", "Soil", "Skin"), tax_table = GP@tax_table, select_taxa = c("522457", "200359")))) + expect_message(suppressWarnings(plot_deseq2_pq(res, c("SampleType", "Soil", "Skin"), tax_table = GP@tax_table, select_taxa = c("522457", "200359")))) }) -test_that("plot_deseq2_pq works with phyloseq object", { +test_that("plot_deseq2_pq works with GP dataset", { expect_message(suppressWarnings(plot_deseq2_pq(GP, c("SampleType", "Soil", "Skin")))) expect_message(suppressWarnings(plot_deseq2_pq(GP, c("SampleType", "Soil", "Skin"), color_tax = "Class", select_taxa = c("522457", "271582", "200359")))) expect_message(suppressWarnings(plot_deseq2_pq(GP, c("SampleType", "Soil", "Skin"), taxolev = "Class", verbose = TRUE))) expect_message(suppressWarnings(plot_deseq2_pq(GP, c("SampleType", "Soil", "Skin"), pval = 0.1))) }) -GlobalPatterns_row <- clean_pq(GP, force_taxa_as_columns = TRUE) + +GP_row <- clean_pq(GP, force_taxa_as_columns = TRUE) test_that("phyloseq_to_edgeR gives the good class", { - expect_s4_class(phyloseq_to_edgeR(GlobalPatterns, "SampleType"), "DGEList") - expect_s4_class(phyloseq_to_edgeR(GlobalPatterns_row, "SampleType"), "DGEList") + 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 4e37283b..ddb3dac6 100644 --- a/tests/testthat/test_figures_alpha_div.R +++ b/tests/testthat/test_figures_alpha_div.R @@ -15,36 +15,36 @@ GP_archae <- clean_pq(rarefy_even_depth(subset_samples_pq(GP_archae, sample_sums data_basidio <- subset_taxa(data_fungi, Phylum == "Basidiomycota") test_that("hill_pq works with data_fungi dataset", { - expect_message(expect_message(hill_pq(data_fungi, "Height"))) - expect_message(expect_message(hill_pq(data_fungi, "Height", add_points = TRUE))) + expect_message(hill_pq(data_fungi_mini, "Height")) + expect_message(hill_pq(data_fungi_mini, "Height", add_points = TRUE)) expect_silent(suppressMessages(hill_pq( clean_pq(subset_samples_pq( - data_fungi, !is.na(data_fungi@sam_data$Height) + data_fungi_mini, !is.na(data_fungi_mini@sam_data$Height) )), "Height", letters = TRUE ))) expect_silent(suppressMessages( hill_pq( - data_fungi, + data_fungi_mini, "Height", add_points = TRUE, color_fac = "Time" ) )) - expect_message(expect_message( + expect_message( hill_pq( - data_fungi, + data_fungi_mini, "Height", add_points = TRUE, color_fac = "Time", one_plot = TRUE, correction_for_sample_size = FALSE ) - )) + ) expect_silent(suppressWarnings(suppressMessages( hill_pq( clean_pq(subset_samples_pq( - data_fungi, !is.na(data_fungi@sam_data$Height) + data_fungi_mini, !is.na(data_fungi_mini@sam_data$Height) )), "Height", add_points = TRUE, @@ -54,8 +54,8 @@ test_that("hill_pq works with data_fungi dataset", { letters = TRUE ) ))) - expect_equal(length(hill_pq(data_fungi, "Height", add_points = TRUE)), 4) - expect_s3_class(hill_pq(data_fungi, "Height", add_points = TRUE)[[1]], "ggplot") + expect_equal(length(hill_pq(data_fungi_mini, "Height", add_points = TRUE)), 4) + expect_s3_class(hill_pq(data_fungi_mini, "Height", add_points = TRUE)[[1]], "ggplot") }) test_that("hill_pq works with GP dataset", { @@ -67,13 +67,13 @@ test_that("hill_pq works with GP dataset", { expect_s3_class(hill_pq(GP, "SampleType", add_points = TRUE)[[1]], "ggplot") }) -test_that("iNEXT_pq works with data_fungi dataset", { +test_that("iNEXT_pq works with data_fungi_mini dataset", { library("iNEXT") expect_s3_class( suppressWarnings(res_iNEXT <- iNEXT_pq( subset_taxa_pq( - data_fungi, - taxa_sums(data_fungi) > 5000 + data_fungi_mini, + taxa_sums(data_fungi_mini) > 5000 ), merge_sample_by = "Height", q = 1, @@ -147,11 +147,11 @@ test_that("accu_samp_threshold works with GlobalPatterns dataset", { expect_equal(length(accu_samp_threshold(p)), 5) }) -test_that("accu_samp_threshold works with data_fungi dataset", { +test_that("accu_samp_threshold works with data_fungi_mini dataset", { expect_warning(ggb <- - ggbetween_pq(data_fungi, variable = "Time")) + ggbetween_pq(data_fungi_mini, variable = "Time")) expect_equal(length(ggb), 3) - expect_s3_class(ggbetween_pq(data_fungi, variable = "Height")[[1]], "ggplot") + expect_s3_class(ggbetween_pq(data_fungi_mini, variable = "Height")[[1]], "ggplot") expect_s3_class( ggbetween_pq( data_fungi, @@ -162,4 +162,8 @@ test_that("accu_samp_threshold works with data_fungi dataset", { )[[2]], "ggplot" ) + expect_s3_class(ggbetween_pq( + data_fungi_mini, + variable = "Height" + )[[1]], "ggplot") }) diff --git a/tests/testthat/test_figures_beta_div.R b/tests/testthat/test_figures_beta_div.R index 7000b8a4..b5344e80 100644 --- a/tests/testthat/test_figures_beta_div.R +++ b/tests/testthat/test_figures_beta_div.R @@ -1,5 +1,3 @@ -data("data_fungi") -data("data_fungi_sp_known") data("GlobalPatterns", package = "phyloseq") data("enterotype", package = "phyloseq") @@ -10,7 +8,7 @@ data_basidio_2trees <- GP_archae <- subset_taxa(GlobalPatterns, GlobalPatterns@tax_table[, 1] == "Archaea") -data_fungi_woNA4time <- subset_samples(data_fungi, !is.na(Time)) +data_fungi_woNA4time <- subset_samples(data_fungi_mini, !is.na(Time)) res_mt <- mt( data_fungi_woNA4time, @@ -69,17 +67,17 @@ test_that("circle_pq works", { }) test_that("graph_test_pq works", { - expect_silent(graph_test_pq(data_fungi, fact = "Tree_name")) - expect_silent(graph_test_pq(data_fungi, fact = "Tree_name", na_remove = TRUE)) - expect_silent(graph_test_pq(data_fungi, fact = "Tree_name", return_plot = FALSE)) + expect_silent(graph_test_pq(data_fungi_mini, fact = "Tree_name")) + expect_silent(graph_test_pq(data_fungi_mini, fact = "Tree_name", na_remove = TRUE)) + expect_silent(graph_test_pq(data_fungi_mini, fact = "Tree_name", return_plot = FALSE)) expect_message(graph_test_pq( - subset_samples(data_fungi, !is.na(data_fungi@sam_data$Time)), + subset_samples(data_fungi_mini, !is.na(data_fungi_mini@sam_data$Time)), fact = "Time", merge_sample_by = "Tree_name" )) - expect_error(graph_test_pq(data_fungi, fact = "Height")) + expect_error(graph_test_pq(data_fungi_mini, fact = "Height")) expect_error(graph_test_pq(enterotype, fact = "Enterotype")) - expect_error(graph_test_pq(data_fungi, fact = "tRREE_name")) + expect_error(graph_test_pq(data_fungi_mini, fact = "tRREE_name")) }) @@ -146,26 +144,26 @@ test_that("sankey_pq works with GlobalPatterns dataset", { expect_error(sankey_pq(GP_archae@otu_table)) }) -test_that("sankey_pq works with data_fungi dataset", { - expect_silent(sankey_pq(data_fungi)) - expect_s3_class(sankey_pq(data_fungi), "htmlwidget") - expect_s3_class(sankey_pq(data_fungi), "sankeyNetwork") - expect_silent(suppressWarnings(sankey_pq(data_fungi, fact = "Height"))) +test_that("sankey_pq works with data_fungi_mini dataset", { + expect_silent(sankey_pq(data_fungi_mini)) + expect_s3_class(sankey_pq(data_fungi_mini), "htmlwidget") + expect_s3_class(sankey_pq(data_fungi_mini), "sankeyNetwork") + expect_silent(suppressWarnings(sankey_pq(data_fungi_mini, fact = "Height"))) expect_silent(sankey_pq( - data_fungi, + data_fungi_mini, taxa = 3:7, min_prop_tax = 0.01, units = "sequences" )) expect_silent(sankey_pq( - data_fungi, + data_fungi_mini, taxa = 1:4, min_prop_tax = 0.01, add_nb_seq = TRUE )) expect_silent( sankey_pq( - data_fungi, + data_fungi_mini, taxa = 1:4, min_prop_tax = 0.001, add_nb_seq = TRUE, @@ -174,7 +172,7 @@ test_that("sankey_pq works with data_fungi dataset", { ) expect_silent( sankey_pq( - data_fungi, + data_fungi_mini, taxa = 1:4, add_nb_seq = TRUE, units = "sequences", @@ -183,7 +181,7 @@ test_that("sankey_pq works with data_fungi dataset", { ) expect_warning( sankey_pq( - data_fungi, + data_fungi_mini, taxa = 1:4, min_prop_tax = 0.01, add_nb_seq = TRUE, @@ -191,60 +189,60 @@ test_that("sankey_pq works with data_fungi dataset", { symbol2sub = NA ) ) - expect_error(sankey_pq(data_fungi, "HEIGHT")) + expect_error(sankey_pq(data_fungi_mini, "HEIGHT")) }) -test_that("venn_pq works with data_fungi dataset", { +test_that("venn_pq works with data_fungi_mini dataset", { library("grid") - expect_silent(venn_pq(data_fungi, "Height")) + expect_silent(venn_pq(data_fungi_mini, "Height")) expect_silent(suppressMessages(venn_pq( clean_pq( - data_fungi, + data_fungi_mini, force_taxa_as_rows = TRUE, silent = TRUE ), "Height" ))) - expect_silent(venn_pq(data_fungi, "Height", min_nb_seq = 10)) - expect_silent(venn_pq(data_fungi, "Height", print_values = FALSE)) - expect_silent(venn_pq(data_fungi, "Height", print_values = FALSE) + + expect_silent(venn_pq(data_fungi_mini, "Height", min_nb_seq = 10)) + expect_silent(venn_pq(data_fungi_mini, "Height", print_values = FALSE)) + expect_silent(venn_pq(data_fungi_mini, "Height", print_values = FALSE) + scale_fill_hue()) - expect_silent(venn_pq(data_fungi, "Height", print_values = TRUE) + + expect_silent(venn_pq(data_fungi_mini, "Height", print_values = TRUE) + scale_fill_hue()) - expect_error(venn_pq(data_fungi)) - expect_error(venn_pq(data_fungi@otu_table, "Height")) + expect_error(venn_pq(data_fungi_mini)) + expect_error(venn_pq(data_fungi_mini@otu_table, "Height")) expect_type( - venn_pq(data_fungi, "Height", print_values = TRUE) + scale_fill_hue(), + venn_pq(data_fungi_mini, "Height", print_values = TRUE) + scale_fill_hue(), "NULL" ) expect_s3_class( - venn_pq(data_fungi, "Height", print_values = FALSE) + scale_fill_hue(), + venn_pq(data_fungi_mini, "Height", print_values = FALSE) + scale_fill_hue(), "ggplot" ) }) -test_that("ggvenn_pq works with data_fungi dataset", { - expect_silent(ggvenn_pq(data_fungi, "Height")) - expect_message(ggvenn_pq(data_fungi, "Height", rarefy_before_merging = TRUE)) - expect_message(suppressWarnings(ggvenn_pq(data_fungi, "Height", rarefy_after_merging = TRUE))) - expect_silent(ggvenn_pq(data_fungi, "Height", add_nb_seq = TRUE)) - expect_silent(suppressMessages(ggvenn_pq(data_fungi, "Height", rarefy_nb_seqs = TRUE))) - expect_silent(ggvenn_pq(data_fungi, "Height", min_nb_seq = 2)) - expect_silent(ggvenn_pq(data_fungi, "Height", taxonomic_rank = 4)) - expect_silent(suppressMessages(ggvenn_pq(data_fungi, "Height", split_by = "Time"))) - expect_error(ggvenn_pq(data_fungi)) - expect_s3_class(ggvenn_pq(data_fungi, "Height"), "ggplot") - expect_error(ggvenn_pq(data_fungi@otu_table, "Height")) +test_that("ggvenn_pq works with data_fungi_mini dataset", { + expect_message(ggvenn_pq(data_fungi_mini, "Height")) + expect_message(ggvenn_pq(data_fungi_mini, "Height", rarefy_before_merging = TRUE)) + expect_message(suppressWarnings(ggvenn_pq(data_fungi_mini, "Height", rarefy_after_merging = TRUE))) + expect_message(ggvenn_pq(data_fungi_mini, "Height", add_nb_seq = TRUE)) + expect_silent(suppressMessages(ggvenn_pq(data_fungi_mini, "Height", rarefy_nb_seqs = TRUE))) + expect_message(ggvenn_pq(data_fungi_mini, "Height", min_nb_seq = 2)) + expect_message(ggvenn_pq(data_fungi_mini, "Height", taxonomic_rank = 4)) + expect_silent(suppressMessages(ggvenn_pq(data_fungi_mini, "Height", split_by = "Time"))) + expect_error(ggvenn_pq(data_fungi_mini)) + expect_s3_class(suppressMessages(ggvenn_pq(data_fungi_mini, "Height")), "ggplot") + expect_error(ggvenn_pq(data_fungi_mini@otu_table, "Height")) }) test_that("upset_pq works with data_fungi dataset", { - expect_silent(suppressMessages(upset_pq(data_fungi, "Height"))) - expect_s3_class(upset_pq(data_fungi, "Height", taxa_fill = "Class"), "ggplot") - expect_s3_class(upset_pq(data_fungi, "Height"), "ggplot") + expect_silent(suppressMessages(upset_pq(data_fungi_mini, "Height"))) + expect_s3_class(upset_pq(data_fungi_mini, "Height", taxa_fill = "Class"), "ggplot") + expect_s3_class(upset_pq(data_fungi_mini, "Height"), "ggplot") expect_s3_class( upset_pq( - data_fungi, + data_fungi_mini, "Height", na_remove = TRUE, rarefy_after_merging = TRUE @@ -252,44 +250,44 @@ test_that("upset_pq works with data_fungi dataset", { "ggplot" ) - expect_s3_class(upset_pq(data_fungi, "Time"), "ggplot") - expect_s3_class(upset_pq(data_fungi, "Time", min_nb_seq = 10), "ggplot") + expect_s3_class(upset_pq(data_fungi_mini, "Time"), "ggplot") + expect_s3_class(upset_pq(data_fungi_mini, "Time", min_nb_seq = 10), "ggplot") expect_s3_class( - upset_pq(data_fungi, "Time", numeric_fonction = mean), + upset_pq(data_fungi_mini, "Time", numeric_fonction = mean), "ggplot" ) - expect_error(upset_pq(data_fungi)) + expect_error(upset_pq(data_fungi_mini)) }) -test_that("upset_test_pq works with data_fungi dataset", { - expect_s3_class(upset_test_pq(data_fungi, "Height"), "data.frame") - expect_s3_class(upset_test_pq(data_fungi, "Time"), "data.frame") +test_that("upset_test_pq works with data_fungi_mini dataset", { + expect_s3_class(upset_test_pq(data_fungi_mini, "Height"), "data.frame") + expect_s3_class(upset_test_pq(data_fungi_mini, "Time"), "data.frame") expect_s3_class( - upset_test_pq(data_fungi, "Time", min_nb_seq = 10), + upset_test_pq(data_fungi_mini, "Time", min_nb_seq = 10), "data.frame" ) expect_s3_class( - upset_test_pq(data_fungi, "Time", numeric_fonction = mean), + upset_test_pq(data_fungi_mini, "Time", numeric_fonction = mean), "data.frame" ) expect_s3_class( upset_test_pq( - data_fungi, + data_fungi_mini, "Time", numeric_fonction = mean, var_to_test = c("OTU", "Guild", "Genus") ), "data.frame" ) - expect_error(upset_test_pq(data_fungi, "Height", var_to_test = "GUILDDDS")) - expect_error(upset_test_pq(data_fungi)) + expect_error(upset_test_pq(data_fungi_mini, "Height", var_to_test = "GUILDDDS")) + expect_error(upset_test_pq(data_fungi_mini)) }) test_that("plot_LCBD_pq works with data_fungi dataset", { expect_s3_class( plot_LCBD_pq( - data_fungi, + data_fungi_mini, nperm = 100, only_plot_significant = FALSE ), @@ -297,7 +295,7 @@ test_that("plot_LCBD_pq works with data_fungi dataset", { ) expect_s3_class( plot_LCBD_pq( - data_fungi, + data_fungi_mini, nperm = 100, only_plot_significant = TRUE, pval = 0.2 @@ -306,7 +304,7 @@ test_that("plot_LCBD_pq works with data_fungi dataset", { ) expect_s3_class( plot_LCBD_pq( - data_fungi, + data_fungi_mini, nperm = 100, only_plot_significant = TRUE, p_adjust_method = "holm", @@ -317,18 +315,18 @@ test_that("plot_LCBD_pq works with data_fungi dataset", { }) -test_that("LCBD_pq works with data_fungi dataset", { - expect_s3_class(LCBD_pq(data_fungi, nperm = 100), "beta.div") +test_that("LCBD_pq works with data_fungi_mini dataset", { + expect_s3_class(LCBD_pq(data_fungi_mini, nperm = 100), "beta.div") expect_s3_class( - LCBD_pq(data_fungi, nperm = 100, method = "jaccard"), + LCBD_pq(data_fungi_mini, nperm = 100, method = "jaccard"), "beta.div" ) }) -test_that("plot_LCBD_pq works with data_fungi dataset", { +test_that("plot_LCBD_pq works with data_fungi_mini dataset", { expect_s3_class( plot_LCBD_pq( - data_fungi, + data_fungi_mini, nperm = 100, only_plot_significant = FALSE ), @@ -336,7 +334,7 @@ test_that("plot_LCBD_pq works with data_fungi dataset", { ) expect_s3_class( plot_LCBD_pq( - data_fungi, + data_fungi_mini, nperm = 100, only_plot_significant = TRUE, pval = 0.2 @@ -345,7 +343,7 @@ test_that("plot_LCBD_pq works with data_fungi dataset", { ) expect_s3_class( plot_LCBD_pq( - data_fungi, + data_fungi_mini, nperm = 100, only_plot_significant = TRUE, p_adjust_method = "holm", @@ -356,11 +354,11 @@ test_that("plot_LCBD_pq works with data_fungi dataset", { }) -test_that("plot_SCBD_pq works with data_fungi dataset", { - expect_s3_class(plot_SCBD_pq(data_fungi), "ggplot") +test_that("plot_SCBD_pq works with data_fungi_mini dataset", { + expect_s3_class(plot_SCBD_pq(data_fungi_mini), "ggplot") expect_s3_class( plot_SCBD_pq( - data_fungi, + data_fungi_mini, tax_level = "Class", tax_col = "Phylum", min_SCBD = 0 @@ -369,17 +367,17 @@ test_that("plot_SCBD_pq works with data_fungi dataset", { ) }) -test_that("multipatt_pq works with data_fungi dataset", { +test_that("multipatt_pq works with data_fungi_mini dataset", { expect_s3_class( - multipatt_pq(subset_samples(data_fungi, !is.na(Time)), + multipatt_pq(subset_samples(data_fungi_mini, !is.na(Time)), fact = "Time" ), "ggplot" ) - expect_error(multipatt_pq(data_fungi, fact = "Time")) + expect_error(multipatt_pq(data_fungi_mini, fact = "Time")) }) -test_that("multipatt_pq works with data_fungi dataset", { +test_that("multipatt_pq works with data_fungi_mini dataset", { expect_type(suppressMessages(suppressWarnings(res_height <- ancombc_pq( subset_taxa_pq( data_fungi_sp_known, diff --git a/tests/testthat/test_figures_misc.R b/tests/testthat/test_figures_misc.R index c330a634..ec478fd8 100644 --- a/tests/testthat/test_figures_misc.R +++ b/tests/testthat/test_figures_misc.R @@ -1,5 +1,3 @@ -data("data_fungi") -data("data_fungi_sp_known") data("GlobalPatterns", package = "phyloseq") data("enterotype", package = "phyloseq") @@ -8,29 +6,29 @@ data_fungi_2trees <- subset_samples(data_fungi, data_fungi@sam_data$Tree_name %i GP_archae <- subset_taxa(GlobalPatterns, GlobalPatterns@tax_table[, 1] == "Archaea") data_basidio <- subset_taxa(data_fungi, Phylum == "Basidiomycota") -test_that("tsne_pq works with data_fungi dataset", { - expect_silent(suppressMessages(res_tsne <- tsne_pq(data_fungi))) +test_that("tsne_pq works with data_fungi_mini dataset", { + expect_silent(suppressMessages(res_tsne <- tsne_pq(data_fungi_mini))) expect_s3_class(res_tsne, "Rtsne") - expect_silent(suppressMessages(res_tsne <- tsne_pq(data_fungi, dims = 3, perplexity = 25))) + expect_silent(suppressMessages(res_tsne <- tsne_pq(data_fungi_mini, dims = 3, perplexity = 25))) }) -test_that("plot_tsne_pq works with data_fungi dataset", { - expect_silent(suppressMessages(pt <- plot_tsne_pq(data_fungi, fact = "Height", perplexity = 15))) +test_that("plot_tsne_pq works with data_fungi_mini dataset", { + expect_silent(suppressMessages(pt <- plot_tsne_pq(data_fungi_mini, fact = "Height", perplexity = 15))) expect_s3_class(pt, "ggplot") - expect_message(plot_tsne_pq(data_fungi)) + expect_error(plot_tsne_pq(data_fungi_mini, fact = "HEIgTHT")) }) -test_that("SRS_curve_pq works with data_fungi dataset", { - expect_silent(suppressMessages(sc <- SRS_curve_pq(data_basidio))) - expect_silent(suppressMessages(sc <- SRS_curve_pq(data_basidio, clean_pq = TRUE))) +test_that("SRS_curve_pq works with data_fungi_mini dataset", { + 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_basidio, metric = "shannon"))) - expect_silent(suppressMessages(sc <- SRS_curve_pq(data_basidio, step = 20, rarefy.repeats = 15))) + expect_silent(suppressMessages(sc <- SRS_curve_pq(data_fungi_mini, metric = "shannon"))) + expect_silent(suppressMessages(sc <- SRS_curve_pq(data_fungi_mini, step = 20, rarefy.repeats = 15))) }) test_that("multiplot works fine", { - res_venn1 <- ggvenn_pq(data_fungi, "Height") - res_venn2 <- ggvenn_pq(data_fungi, "Time") + res_venn1 <- ggvenn_pq(data_fungi_mini, "Height") + res_venn2 <- ggvenn_pq(data_fungi_mini, "Time") expect_silent(multiplot(res_venn1, res_venn2)) expect_message(multiplot(res_venn1)) expect_type(multiplot(res_venn1, res_venn2), "NULL") diff --git a/tests/testthat/test_figures_taxo.R b/tests/testthat/test_figures_taxo.R index b739c4c6..fcff77a2 100644 --- a/tests/testthat/test_figures_taxo.R +++ b/tests/testthat/test_figures_taxo.R @@ -26,13 +26,12 @@ test_that("rotl_pq works with data_fungi dataset", { expect_silent(plot(tr)) }) -data_basidio <- subset_taxa(data_fungi, Phylum == "Basidiomycota") test_that("heat_tree_pq works with data_fungi dataset", { library(metacoder) - expect_silent(suppressMessages(ht <- heat_tree_pq(data_basidio))) + expect_silent(suppressMessages(ht <- heat_tree_pq(data_fungi_mini))) expect_s3_class(ht, "ggplot") expect_s3_class( - heat_tree_pq(data_basidio, taxonomic_level = 1:4), + heat_tree_pq(data_fungi_mini, taxonomic_level = 1:4), "ggplot" ) }) @@ -63,7 +62,7 @@ test_that("plot_tax_pq works with data_fungi dataset", { expect_silent(suppressMessages( pt <- plot_tax_pq( - data_fungi_sp_known, + data_fungi_mini, "Time", merge_sample_by = "Time", taxa_fill = "Class", @@ -73,7 +72,7 @@ test_that("plot_tax_pq works with data_fungi dataset", { expect_silent(suppressMessages( pt <- plot_tax_pq( - data_fungi_sp_known, + data_fungi_mini, "Time", merge_sample_by = "Time", taxa_fill = "Class" @@ -82,13 +81,13 @@ test_that("plot_tax_pq works with data_fungi dataset", { expect_s3_class(pt, "ggplot") expect_silent(suppressMessages( pt <- - plot_tax_pq(data_fungi_sp_known, "Time", taxa_fill = "Class") + plot_tax_pq(data_fungi_mini, "Time", taxa_fill = "Class") )) expect_s3_class(pt, "ggplot") expect_silent(suppressMessages( pt <- plot_tax_pq( - data_fungi_sp_known, + data_fungi_mini, "Time", merge_sample_by = "Time", taxa_fill = "Class", @@ -99,7 +98,7 @@ test_that("plot_tax_pq works with data_fungi dataset", { expect_silent(suppressMessages( pt <- plot_tax_pq( - data_fungi_sp_known, + data_fungi_mini, "Time", merge_sample_by = "Time", taxa_fill = "Class", @@ -110,7 +109,7 @@ test_that("plot_tax_pq works with data_fungi dataset", { expect_silent(suppressMessages( pt <- plot_tax_pq( - data_fungi_sp_known, + data_fungi_mini, "Time", merge_sample_by = "Time", taxa_fill = "Class", @@ -121,7 +120,7 @@ test_that("plot_tax_pq works with data_fungi dataset", { expect_silent(suppressMessages( pt <- plot_tax_pq( - data_fungi_sp_known, + data_fungi_mini, "Time", merge_sample_by = "Time", taxa_fill = "Class", @@ -131,7 +130,7 @@ test_that("plot_tax_pq works with data_fungi dataset", { expect_s3_class(pt[[1]], "ggplot") expect_silent(suppressMessages( plot_tax_pq( - data_fungi_sp_known, + data_fungi_mini, "Time", merge_sample_by = "Time", taxa_fill = "Class", @@ -140,7 +139,7 @@ test_that("plot_tax_pq works with data_fungi dataset", { )) expect_silent(suppressMessages( plot_tax_pq( - data_fungi_sp_known, + data_fungi_mini, "Time", merge_sample_by = "Time", taxa_fill = "Order", @@ -149,7 +148,7 @@ test_that("plot_tax_pq works with data_fungi dataset", { )) expect_silent(suppressMessages( plot_tax_pq( - data_fungi_sp_known, + data_fungi_mini, "Height", merge_sample_by = "Height", taxa_fill = "Order" @@ -160,16 +159,16 @@ test_that("plot_tax_pq works with data_fungi dataset", { test_that("multitax_bar_pq works with data_fungi_sp_known dataset", { expect_s3_class( - multitax_bar_pq(data_fungi_sp_known, "Phylum", "Class", "Order", "Time"), + multitax_bar_pq(data_fungi_mini, "Phylum", "Class", "Order", "Time"), "ggplot" ) expect_s3_class( - multitax_bar_pq(data_fungi_sp_known, "Phylum", "Class", "Order"), + multitax_bar_pq(data_fungi_mini, "Phylum", "Class", "Order"), "ggplot" ) expect_s3_class( multitax_bar_pq( - data_fungi_sp_known, + data_fungi_mini, "Phylum", "Class", "Order", @@ -179,7 +178,7 @@ test_that("multitax_bar_pq works with data_fungi_sp_known dataset", { "ggplot" ) expect_s3_class( - multitax_bar_pq(data_fungi_sp_known, + multitax_bar_pq(data_fungi_mini, "Phylum", "Class", "Order", @@ -188,10 +187,10 @@ test_that("multitax_bar_pq works with data_fungi_sp_known dataset", { "ggplot" ) expect_error(print( - multitax_bar_pq(data_fungi_sp_known, "Class", "Genus", "Order") + multitax_bar_pq(data_fungi_mini, "Class", "Genus", "Order") )) expect_error(print( - multitax_bar_pq(data_fungi_sp_known, "Phylum", "Class", "Order", "TIMESS") + multitax_bar_pq(data_fungi_mini, "Phylum", "Class", "Order", "TIMESS") )) }) @@ -234,7 +233,7 @@ test_that("multitax_bar_pq works with GlobalPatterns dataset", { test_that("rigdes_pq work with data_fungi dataset", { expect_s3_class( - ridges_pq(data_fungi, + ridges_pq(data_fungi_mini, "Time", alpha = 0.5, log10trans = FALSE @@ -242,12 +241,12 @@ test_that("rigdes_pq work with data_fungi dataset", { "ggplot" ) expect_s3_class( - ridges_pq(data_fungi, "Time", alpha = 0.5), + ridges_pq(data_fungi_mini, "Time", alpha = 0.5), "ggplot" ) expect_s3_class( ridges_pq( - data_fungi, + data_fungi_mini, "Time", nb_seq = FALSE, log10trans = FALSE @@ -298,10 +297,7 @@ test_that("treemap_pq work with data_fungi_sp_known dataset", { expect_s3_class( treemap_pq( clean_pq( - subset_taxa( - data_fungi_sp_known, - Phylum == "Basidiomycota" - ) + data_fungi_mini ), "Order", "Class", plot_legend = TRUE @@ -311,10 +307,7 @@ test_that("treemap_pq work with data_fungi_sp_known dataset", { expect_s3_class( treemap_pq( clean_pq( - subset_taxa( - data_fungi_sp_known, - Phylum == "Basidiomycota" - ) + data_fungi_mini ), "Order", "Class", log10trans = FALSE @@ -323,10 +316,7 @@ test_that("treemap_pq work with data_fungi_sp_known dataset", { ) expect_s3_class( treemap_pq( - clean_pq(subset_taxa( - data_fungi_sp_known, - Phylum == "Basidiomycota" - )), + data_fungi_mini, "Order", "Class", nb_seq = FALSE, @@ -337,11 +327,11 @@ 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, taxa = "Class"), "ggplot") - expect_s3_class(tax_bar_pq(data_fungi, taxa = "Class", fact = "Time"), "ggplot") + 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( - data_fungi, + data_fungi_mini, taxa = "Class", fact = "Time", nb_seq = FALSE @@ -350,7 +340,7 @@ test_that("tax_bar_pq work with data_fungi dataset", { ) expect_s3_class( tax_bar_pq( - data_fungi, + data_fungi_mini, taxa = "Class", fact = "Time", nb_seq = FALSE, @@ -360,11 +350,12 @@ test_that("tax_bar_pq work with data_fungi dataset", { ) }) -test_that("add_funguild_info and plot_guild_pq work with data_fungi dataset", { +test_that("add_funguild_info and plot_guild_pq work with data_fungi_mini dataset", { + skip_on_cran() expect_s4_class( df <- add_funguild_info( - subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 5000), + subset_taxa_pq(data_fungi_mini, taxa_sums(data_fungi_mini) > 5000), taxLevels = c( "Domain", "Phylum", @@ -379,7 +370,7 @@ test_that("add_funguild_info and plot_guild_pq work with data_fungi dataset", { ) expect_error(df <- add_funguild_info( - subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 5000), + subset_taxa_pq(data_fungi_mini, taxa_sums(data_fungi_mini) > 5000), taxLevels = c( "PHYLLUUM", "Phylum", diff --git a/tests/testthat/test_misc.R b/tests/testthat/test_misc.R index 2f32d594..75badde4 100644 --- a/tests/testthat/test_misc.R +++ b/tests/testthat/test_misc.R @@ -100,6 +100,7 @@ test_that("install_pkg_needed works fine", { }) test_that("add_funguild_info works fine", { + skip_on_cran() data_f <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 5000) expect_silent(data_f <- add_funguild_info(data_f, taxLevels = c( @@ -109,6 +110,7 @@ test_that("add_funguild_info works fine", { expect_equal(dim(data_f@tax_table)[2], 24) }) + test_that("are_modality_even_depth works fine", { expect_equal(are_modality_even_depth(data_fungi, "Time")$statistic[[1]], 62.143) expect_equal(are_modality_even_depth(rarefy_even_depth(data_fungi), "Time")$p.value, 1) diff --git a/tests/testthat/test_phyloseq_class.R b/tests/testthat/test_phyloseq_class.R index 0c07e2c0..f8793ca5 100644 --- a/tests/testthat/test_phyloseq_class.R +++ b/tests/testthat/test_phyloseq_class.R @@ -1,5 +1,4 @@ data(enterotype) -data("data_fungi_sp_known") sequences_ex <- c( "TACCTATGTTGCCTTGGCGGCTAAACCTACCCGGGATTTGATGGGGCGAATTACCTGGTATTTTAGCCCACTTACCCGGTACCAACCTACCCTGTACACCGCGCCTGGGTCTACCCTCCGGATGACATTTTTAAGACTCTTGTTTTATAGTGAAATTCTGAGTTTTTATACTTAATAAGTTAAAACTTTCAATCTCGGATCTCTTGGCTCTGGCATCGATGAAGAACGCTACGAAATGCTGATAAATAATGTGAATTGCCGAATTCATTGAATCATCGAATCTTTGAACGCACATTGCACCCATTAGTATTCTAGAGTGCATGCCTGTTCCAGCGTCATTTTCAATCCTCAAGCCCCTTATTGCTTGGTGTTGGCAGTTTAGCTGGCTTTATAGTGCTTAACTCCCTAAATATACTGCCTGATTCGCGGTGACCCCAAGCGTAATAATTATTTTCTCGCTTGAGGTG", @@ -7,9 +6,9 @@ sequences_ex <- c( "TACCTATGTTGCCTTGGCGGCTAAACCTACCCGGGATTTGATGGCGAATTACCTGGTATTTTAGCCCACTTACCCGGTACCAACCTACCCTGTACACCGCGCCTGGGTCTACCCTCCGGATGACATTTTTAAGACTCTTGTTTTATAGTGAAATTCTGAGTTTTTATACTTAATAAGTTAAAACTTTCAATCTCGGATCTCTTGGCTCTGGCATCGATGAAGAACGCTACGAAATGCTGATAAATAATGTGAATTGCCGAATTCATTGAATCATCGAATCTTTGAACGCACATTGCACCCATTAGTATTCTAGAGTGCATGCCTGTTCCAGCGTCATTTTCAATCCTCAAGCCCCTTATTGCTTGGTGTTGGCAGTTTAGCTGGCTTTATAGTGCTTAACTCCCTAAATATACTGCCTGATTCGCGGTGACCCCAAGCGTAATAATTATTTTCTCGCTTGAGGTG" ) test_that("asv2otu works fine with Clusterize method", { - expect_s4_class(data_fungi_sp_known, "phyloseq") - expect_s4_class(suppressWarnings(asv2otu(data_fungi_sp_known)), "phyloseq") - expect_s4_class(suppressWarnings(asv2otu(data_fungi_sp_known, + expect_s4_class(data_fungi_mini, "phyloseq") + expect_s4_class(suppressWarnings(asv2otu(data_fungi_mini)), "phyloseq") + expect_s4_class(suppressWarnings(asv2otu(data_fungi_mini, method_clusterize = "longest" )), "phyloseq") @@ -17,8 +16,8 @@ test_that("asv2otu works fine with Clusterize method", { expect_error(asv2otu(enterotype, method = "vsearch")) expect_error(asv2otu(enterotype)) expect_error(asv2otu()) - expect_error(asv2otu(data_fungi_sp_known, method = "VsaerCh")) - expect_error(asv2otu(data_fungi_sp_known, dna_seq = sequences_ex)) + expect_error(asv2otu(data_fungi_mini, method = "VsaerCh")) + expect_error(asv2otu(data_fungi_mini, dna_seq = sequences_ex)) }) @@ -30,8 +29,8 @@ if (class(vsearch_error_or_not) == "try-error") { message("lulu_pq() can't be tested when vsearch is not installed") } else { test_that("lulu_pq works fine", { - expect_s4_class(lulu_pq(data_fungi_sp_known)$new_physeq, "phyloseq") - expect_error(lulu_pq(enterotype)$new_physeq, "phyloseq") + 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") }) } @@ -42,19 +41,19 @@ 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", { - expect_s4_class(mumu_pq(data_fungi_sp_known)$new_physeq, "phyloseq") + 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_sp_known, clean_pq = TRUE, verbose = TRUE)$new_physeq, "phyloseq") + expect_s4_class(mumu_pq(data_fungi_mini, clean_pq = TRUE, verbose = TRUE)$new_physeq, "phyloseq") }) } test_that("as_binary_otu_table works fine", { - expect_s4_class(as_binary_otu_table(data_fungi_sp_known), "phyloseq") + expect_s4_class(as_binary_otu_table(data_fungi_mini), "phyloseq") expect_s4_class(as_binary_otu_table(enterotype), "phyloseq") }) -data_fungi_taxaSeq <- data_fungi +data_fungi_taxaSeq <- data_fungi_mini taxa_names(data_fungi_taxaSeq) <- as.character(data_fungi_taxaSeq@refseq) data_fungi_taxaSeq@refseq <- NULL test_that("add_dna_to_phyloseq works fine", { @@ -63,17 +62,17 @@ test_that("add_dna_to_phyloseq works fine", { }) -df <- data_fungi -df <- unclass(data_fungi) +df <- data_fungi_mini +df <- unclass(data_fungi_mini) test_that("verify_pq works fine", { expect_error(verify_pq(df), "The physeq argument is not a valid phyloseq object.") }) -data_fungi_with__P <- data_fungi +data_fungi_with__P <- data_fungi_mini data_fungi_with__P@tax_table[, "Phylum"] <- paste0("P__", data_fungi_with__P@tax_table[, "Phylum"]) test_that("simplify_taxo works fine", { - expect_equal(sum(data_fungi_with__P@tax_table[, "Phylum"] == data_fungi@tax_table[, "Phylum"]), 0) - expect_equal(simplify_taxo(data_fungi_with__P)@tax_table[, "Phylum"], data_fungi@tax_table[, "Phylum"]) + expect_equal(sum(data_fungi_with__P@tax_table[, "Phylum"] == data_fungi_mini@tax_table[, "Phylum"]), 0) + expect_equal(simplify_taxo(data_fungi_with__P)@tax_table[, "Phylum"], data_fungi_mini@tax_table[, "Phylum"]) }) diff --git a/tests/testthat/test_swarm.R b/tests/testthat/test_swarm.R index 0cbc8590..a96f4fa9 100644 --- a/tests/testthat/test_swarm.R +++ b/tests/testthat/test_swarm.R @@ -1,7 +1,4 @@ -suppressWarnings(swarm_error_or_not <- - try(system("swarm -h 2>&1", intern = TRUE), silent = TRUE)) - -if (class(swarm_error_or_not) == "try-error") { +if (!MiscMetabar:::is_swarm_installed()) { message( "swarm_clustering() and asv2otu(..., method=swarm) can't be tested when swarm is not installed" diff --git a/tests/testthat/test_vsearch.R b/tests/testthat/test_vsearch.R index 4a6a1f64..56fd60ed 100644 --- a/tests/testthat/test_vsearch.R +++ b/tests/testthat/test_vsearch.R @@ -10,10 +10,7 @@ df_basidio <- subset_taxa_pq(df_basidio, colSums(df_basidio@otu_table) > 1000) # path_db <- "inst/extdata/100_sp_UNITE_sh_general_release_dynamic.fasta" -suppressWarnings(vsearch_error_or_not <- - try(system("vsearch 2>&1", intern = TRUE), silent = TRUE)) - -if (class(vsearch_error_or_not) == "try-error") { +if (!MiscMetabar:::is_vsearch_installed()) { message( "vs_search_global() and asv2otu(..., method=vsearch) can't be tested when vsearch is not installed" ) diff --git a/vignettes/MiscMetabar.Rmd b/vignettes/MiscMetabar.Rmd index 79a712d2..042e390b 100644 --- a/vignettes/MiscMetabar.Rmd +++ b/vignettes/MiscMetabar.Rmd @@ -71,10 +71,10 @@ circle_pq(gp, "SampleType", taxa = "Class") # References -Tengeler, A.C., Dam, S.A., Wiesmann, M. et al. Gut microbiota from persons with attention-deficit/hyperactivity disorder affects the brain in mice. Microbiome 8, 44 (2020). https://doi.org/10.1186/s40168-020-00816-x +Tengeler, A.C., Dam, S.A., Wiesmann, M. et al. Gut microbiota from persons with attention-deficit/hyperactivity disorder affects the brain in mice. Microbiome 8, 44 (2020). -# Session information +# Session inform ```{r} sessionInfo()