Skip to content

Commit

Permalink
Merge pull request #86 from adrientaudiere/dev
Browse files Browse the repository at this point in the history
v0.7.8
  • Loading branch information
adrientaudiere committed Feb 13, 2024
2 parents 295ebee + cf89fdd commit df14c70
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 26 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: MiscMetabar
Type: Package
Title: Miscellaneous Functions for Metabarcoding Analysis
Version: 0.7.7
Version: 0.7.8
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.
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
- 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)
- Submit to CRAN and change code to comply with their rules (patch 0.7.1 to 0.7.8)
- 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.


## BREAKING CHANGES
Expand Down
6 changes: 4 additions & 2 deletions R/dada_phyloseq.R
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ read_pq <- function(path = NULL,
#' @param clean_pq (logical) if true, empty samples and empty ASV are discarded
#' before clustering.
#' @param keep_temporary_files (logical, default: FALSE) Do we keep temporary files
#' @param ... Others args for function [lulu()]
#' @return a list of for object
#' - "new_physeq": The new phyloseq object (class physeq)
#' - "discrepancy_vector": A vector of discrepancy showing for each taxonomic
Expand Down Expand Up @@ -1037,7 +1038,8 @@ lulu_pq <- function(physeq,
vsearchpath = "vsearch",
verbose = FALSE,
clean_pq = FALSE,
keep_temporary_files = FALSE) {
keep_temporary_files = FALSE,
...) {
verify_pq(physeq)
if (is.null(physeq@refseq)) {
stop("The phyloseq object do not contain a @refseq slot")
Expand Down Expand Up @@ -1067,7 +1069,7 @@ lulu_pq <- function(physeq,

message("Lulu algorithm")
res_lulu <-
lulu(data.frame(t(physeq@otu_table)), match_list)
lulu(data.frame(t(physeq@otu_table), ...), match_list)

if (!keep_temporary_files) {
if (file.exists("temp.fasta")) {
Expand Down
7 changes: 3 additions & 4 deletions R/vsearch.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
#' @examplesIf MiscMetabar:::is_vsearch_installed()
#' \donttest{
#' file_dna <- tempfile("dna.fa")
#' seqinr::write.fasta("GCCCATTAGTATTCTAGTGGGCATGCCTGTTCGAGCGTCATTTTCAACCCTCAAGCCCCTTATTGCTTGGTGTTGGGAGTTTAGCTGGCTTTATAGCGGTTAACTCCCTAAATATACTGGCG",
#' nbchar = 200,
#' seqinr::write.fasta("GCCCATTAGTATTCTAGTGGGCATGCCTGTTCGAGCGTCATTTTCAACC",
#' file = file_dna, names = "seq1"
#' )
#'
#' res <- vs_search_global(data_fungi, file_dna)
#' res <- vs_search_global(data_fungi, path_to_fasta = file_dna)
#' unlink(file_dna)
#'
#' res[res$identity != "*", ]
Expand Down Expand Up @@ -58,7 +57,7 @@ vs_search_global <- function(physeq,
}
if (!is.null(seq2search)) {
if (inherits(seq2search, "character")) {
seq2search <- Biostrings::readDNAStringSet(seq2search)
seq2search <- Biostrings::DNAStringSet(seq2search)
}
Biostrings::writeXStringSet(seq2search, paste0(tempdir(), "seq2search.fasta"))
seq2search <- paste0(tempdir(), "seq2search.fasta")
Expand Down
5 changes: 4 additions & 1 deletion man/lulu_pq.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions man/vs_search_global.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tests/testthat/test_deseq2_edgeR.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ test_that("plot_deseq2_pq works with results on GP dataset", {

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_error(plot_deseq2_pq(data_fungi_mini@otu_table, c("SampleType", "Soil", "Skyp"), tax_table = GP@tax_table, color_tax = "Kingdom"))
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_message(suppressWarnings(plot_deseq2_pq(res, c("SampleType", "Soil", "Skin"), tax_table = GP@tax_table, select_taxa = c("522457", "200359"))))
Expand All @@ -61,7 +62,7 @@ test_that("plot_deseq2_pq works with GP dataset", {
skip_on_cran()
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)))
expect_message(suppressWarnings(plot_deseq2_pq(GP, c("SampleType", "Soil", "Skin"), pval = 0.1, tax_depth = "Family")))
})


Expand Down
7 changes: 5 additions & 2 deletions tests/testthat/test_figures_beta_div.R
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ test_that("upset_pq works with data_fungi dataset", {
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_mini, "Time", numeric_fonction = mean),
upset_pq(data_fungi_mini, "Time",
numeric_fonction = mean,
na_remove = FALSE
),
"ggplot"
)

Expand Down Expand Up @@ -422,4 +425,4 @@ test_that("multipatt_pq works with data_fungi_mini dataset", {

expect_s3_class(res_time$ss_tab, "data.frame")
expect_equal(dim(res_time$res), c(12, 15))
})
})
15 changes: 13 additions & 2 deletions tests/testthat/test_figures_taxo.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ test_that("plot_tax_pq works with data_fungi dataset", {
data_fungi_mini,
"Time",
merge_sample_by = "Time",
taxa_fill = "Class"
taxa_fill = "Class",
nb_print_value = 2
)
))
expect_s3_class(pt, "ggplot")
Expand Down Expand Up @@ -206,7 +207,7 @@ test_that("multitax_bar_pq works with GlobalPatterns dataset", {
)
skip_on_cran()
expect_s3_class(
multitax_bar_pq(GP_archae, "Phylum", "Class", "Order"),
multitax_bar_pq(GP_archae, "Phylum", "Class", "Order", nb_seq = FALSE),
"ggplot"
)
expect_s3_class(
Expand Down Expand Up @@ -331,6 +332,16 @@ test_that("treemap_pq work with data_fungi_sp_known dataset", {
),
"ggplot"
)
expect_s3_class(
treemap_pq(
data_fungi_mini,
"Order",
"Class",
nb_seq = FALSE,
log10trans = TRUE
),
"ggplot"
)
})

test_that("tax_bar_pq work with data_fungi dataset", {
Expand Down
8 changes: 2 additions & 6 deletions tests/testthat/test_phyloseq_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,14 @@ test_that("asv2otu works fine with Clusterize method", {
expect_error(asv2otu(data_fungi_mini, dna_seq = sequences_ex))
})




suppressWarnings(vsearch_error_or_not <- try(system("vsearch 2>&1", intern = TRUE), silent = TRUE))

if (class(vsearch_error_or_not) == "try-error") {
if (!is_vsearch_installed()) {
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)$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")
expect_error(lulu_pq(data_fungi_sp_known, minimum_ratio_type = "avg")$new_physeq)
})
}

Expand Down
5 changes: 3 additions & 2 deletions tests/testthat/test_targets.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ test_that("sample_data_with_new_names function works fine", {
)
expect_silent(filt_fastq_fw <- filter_trim(testFastqs_fw, output_fw = tempdir()))
expect_equal(length(derepFastq(filt_fastq_fw[1])), 2)
expect_silent(filt_fastq_pe <- filter_trim(testFastqs_fw,
testFastqs_rev,
expect_silent(filt_fastq_pe <- filter_trim(
fw = testFastqs_fw,
rev = testFastqs_rev,
output_fw = tempdir("fw"),
output_rev = tempdir("rev")
))
Expand Down
27 changes: 27 additions & 0 deletions vignettes/articles/Rules.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,34 @@ vignette: >
- **Maturing**: Some tests and/or analyses make stronger these functions
- **Stable**: Good level of confidence

## Tests and examples

### Special cases of external softwares

Some examples and test required the installation of external softwares. I used MiscMetabar internal functions (such as [is_vsearch_installed()]) to conditionnaly test (`if(is_vsearch_installed()){...test...}`) and run examples `#' @examplesIf is_vsearch_installed()`.

### Special case of CRAN

I use `\donttest{}` for some long examples (in roxygen documentation) and `testthat::skip_on_cran()` in long test.

### Special case of windows

Some tests and examples are not tested on windows. I used `testthat::skip_on_os("windows")` inside test and `#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows"` in examples (roxygen documentation). Here is a list of functions with some limitations or not working at all on windows OS:

- [build_phytree_pq()]
- [count_seq()]
- [cutadapt_remove_primers()]
- [krona()]
- [merge_krona()]
- [multipatt_pq()]
- [plot_tsne_pq()]
- [rotl_pq()]
- [save_pq()]
- [tax_datatable()]
- [track_wkflow()]
- [track_wkflow_samples()]
- [tsne_pq()]
- [venn_pq()]

# Session information

Expand Down

0 comments on commit df14c70

Please sign in to comment.