Skip to content

Commit

Permalink
Merge pull request #81 from adrientaudiere/dev
Browse files Browse the repository at this point in the history
Improve test and examples for CRAN submission - mainly for windows build
  • Loading branch information
adrientaudiere committed Feb 10, 2024
2 parents 14da7e5 + b7f917f commit e862ec5
Show file tree
Hide file tree
Showing 22 changed files with 75 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
- name: Install blastn
run: sudo apt-get install ncbi-blast+

- name: Install R packages not in DESCRIPTION
run: Rscript -e 'pak::pkg_install(c(datawizard, formattable, ggforce, ggtree, gtExtras, MicrobiotaProcess, pillar, pointblank, summarytools, svglite, tidytree, treeio))'

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE, clean = TRUE)
shell: Rscript {0}
Expand Down
16 changes: 2 additions & 14 deletions 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.4
Version: 0.7.5
Authors@R: person("Adrien", "Taudière", email = "adrien.taudiere@zaclys.net",
role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0003-1088-1182"))
Description: The MiscMetabar package aims to facilitate the description, transformation, exploration, and reproducibility of metabarcoding analysis. Mainly build on the top of phyloseq, dada2 R packages. MiscMetabar help to build reproducible and robust bioinformatic pipeline in R. MiscMetabar make ecological analysis of alpha and beta-diversity simple and powerful by integrating a large number of analysis, some of them from other R packages.
Expand Down Expand Up @@ -74,19 +74,7 @@ Suggests:
venneuler,
vctrs,
viridis,
withr,
datawizard,
formattable,
ggforce,
ggtree,
gtExtras,
MicrobiotaProcess,
pillar,
pointblank,
summarytools,
svglite,
tidytree,
treeio
withr
RoxygenNote: 7.3.1
URL: https://github.com/adrientaudiere/MiscMetabar,
https://adrientaudiere.github.io/MiscMetabar/
Expand Down
2 changes: 1 addition & 1 deletion R/Deseq2_edgeR.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' or \code{\link[ggplot2]{ggplot}}
#'
#' @export
#' @examples
#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows"
#' data("GlobalPatterns", package = "phyloseq")
#' GP_archae <- subset_taxa(GlobalPatterns, GlobalPatterns@tax_table[, 1] == "Archaea")
#' plot_edgeR_pq(GP_archae, c("SampleType", "Soil", "Feces"),
Expand Down
7 changes: 5 additions & 2 deletions R/dada_phyloseq.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ clean_pq <- function(physeq,
#' @return The number of sequences, clusters (e.g. OTUs, ASVs) and samples for
#' each object.
#' @export
#' @seealso [track_wkflow_samples()]
#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows"
#' data(enterotype)
#' track_wkflow(list(data_fungi, enterotype), taxonomy_rank = c(3, 5))

track_wkflow <- function(list_of_objects,
obj_names = NULL,
Expand Down Expand Up @@ -436,8 +440,7 @@ track_wkflow <- function(list_of_objects,
#' @export
#' @author Adrien Taudière
#'
#' @examples
#'
#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows"
#' tree_A10_005 <- subset_samples(data_fungi, Tree_name == "A10-005")
#' track_wkflow_samples(tree_A10_005)
track_wkflow_samples <- function(list_pq_obj, ...) {
Expand Down
12 changes: 7 additions & 5 deletions R/krona.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
#' your krona result files before merging using [merge_krona()]
#'
#' @examples
#'
#' data("GlobalPatterns", package = "phyloseq")
#' GA <- subset_taxa(GlobalPatterns, Phylum == "Acidobacteria")
#' # krona(GA, "Number.of.sequences.html")
#' # krona(GA, "Number.of.ASVs.html", nb_seq = FALSE)
#' # merge_krona(c("Number.of.sequences.html", "Number.of.ASVs.html"))
#' \dontrun{
#' krona(GA, "Number.of.sequences.html")
#' krona(GA, "Number.of.ASVs.html", nb_seq = FALSE)
#' merge_krona(c("Number.of.sequences.html", "Number.of.ASVs.html"))
#' }
#' @return A html file
#' @export
#' @seealso \code{\link{merge_krona}}
Expand Down Expand Up @@ -107,8 +110,7 @@ krona <-
#' @param output path to the output file
#'
#' @examples
#' krona_error_or_not <- try(system("ktImportText 2>&1", intern = TRUE))
#' if (class(krona_error_or_not) != "try-error") {
#' \dontrun{
#' data("GlobalPatterns", package = "phyloseq")
#' GA <- subset_taxa(GlobalPatterns, Phylum == "Acidobacteria")
#' krona(GA, "Number.of.sequences.html", name = "Nb_seq_GP_acidobacteria")
Expand Down
2 changes: 1 addition & 1 deletion R/miscellanous.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ perc <- function(x, y = NULL, accuracy = 0, add_symbol = FALSE) {
#' @return the number of sequences
#' @author Adrien Taudière
#' @export
#' @examples
#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows"
#' count_seq(file_path = system.file(
#' "extdata",
#' "ex.fasta",
Expand Down
9 changes: 7 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ The article [filter taxa and samples](https://adrientaudiere.github.io/MiscMetab

For developers, I also wrote a article describing som [rules of codes](https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html).


### Summarize a physeq object

```{r example}
Expand Down Expand Up @@ -109,11 +108,17 @@ ggvenn_pq(data_fungi, fact = "Height") +
labs(title = "Share number of ASV among Height in tree")
```

### Note for non-linux users

Some functions may not work on windows (*e.g.* [track_wflow()], [cutadapt_remove_primers()], [krona()], [vsearch_clustering()], ...). A solution is to exploit docker container, for example the using the great [rocker project](https://rocker-project.org/).

MiscMetabar is developed under Linux and the vast majority of functions may works on Unix system, but its functionning is not test under iOS.

### Installation of other softwares for debian Linux distributions

If you encounter any errors or have any questions about the installation of these softwares, please visit their dedicated websites.

#### [blast@](https://blast.ncbi.nlm.nih.gov/doc/blast-help/downloadblastdata.html#downloadblastdata)
#### [blast+](https://blast.ncbi.nlm.nih.gov/doc/blast-help/downloadblastdata.html#downloadblastdata)

```sh
sudo apt-get install ncbi-blast+
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,22 @@ ggvenn_pq(data_fungi, fact = "Height") +

<img src="man/figures/README-unnamed-chunk-6-1.png" width="100%" />

### Note for non-linux users

Some functions may not work on windows (*e.g.* \[track_wflow()\],
\[cutadapt_remove_primers()\], \[krona()\], \[vsearch_clustering()\],
…). A solution is to exploit docker container, for example the using the
great [rocker project](https://rocker-project.org/).

MiscMetabar is developed under Linux and the vast majority of functions
may works on Unix system, but its functionning is not test under iOS.

### Installation of other softwares for debian Linux distributions

If you encounter any errors or have any questions about the installation
of these softwares, please visit their dedicated websites.

#### [blast@](https://blast.ncbi.nlm.nih.gov/doc/blast-help/downloadblastdata.html#downloadblastdata)
#### [blast+](https://blast.ncbi.nlm.nih.gov/doc/blast-help/downloadblastdata.html#downloadblastdata)

``` sh
sudo apt-get install ncbi-blast+
Expand Down
2 changes: 2 additions & 0 deletions man/count_seq.Rd

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

9 changes: 6 additions & 3 deletions man/krona.Rd

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

3 changes: 1 addition & 2 deletions man/merge_krona.Rd

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

2 changes: 2 additions & 0 deletions man/plot_edgeR_pq.Rd

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

9 changes: 9 additions & 0 deletions man/track_wkflow.Rd

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

3 changes: 2 additions & 1 deletion man/track_wkflow_samples.Rd

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

2 changes: 2 additions & 0 deletions tests/testthat/test_cutadapt.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ if (!MiscMetabar:::is_cutadapt_installed()) {
)
} else {
test_that("cutadapt_remove_primers works fine", {
skip_on_cran()
skip_on_os("windows")
expect_silent(suppressMessages(
res_cut <- cutadapt_remove_primers("inst/extdata", "TTC", "GAA",
folder_output = paste0(tempdir(), "/output_cutadapt")
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test_figures_beta_div.R
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ test_that("plot_SCBD_pq works with data_fungi_mini dataset", {
})

test_that("multipatt_pq works with data_fungi_mini dataset", {
skip_on_os("windows")
expect_s3_class(
multipatt_pq(subset_samples(data_fungi_mini, !is.na(Time)),
fact = "Time"
Expand All @@ -378,6 +379,7 @@ test_that("multipatt_pq works with data_fungi_mini dataset", {
})

test_that("multipatt_pq works with data_fungi_mini dataset", {
skip_on_os("windows")
expect_type(suppressMessages(suppressWarnings(res_height <- ancombc_pq(
subset_taxa_pq(
data_fungi_sp_known,
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test_figures_taxo.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ GP_archae <-
subset_taxa(GlobalPatterns, GlobalPatterns@tax_table[, 1] == "Archaea")

test_that("rotl_pq works with data_fungi dataset", {
skip_on_os("windows")
library("rotl")
expect_s3_class(suppressWarnings(tr <-
rotl_pq(data_fungi, species_colnames = "Genus_species")), "phylo")
Expand Down Expand Up @@ -385,7 +386,7 @@ test_that("add_funguild_info and plot_guild_pq work with data_fungi_mini dataset


test_that("build_phytree_pq work with data_fungi dataset", {
library("phangorn")
skip_on_os("windows")
df <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 19000)
expect_type(df_tree <- build_phytree_pq(df, nb_bootstrap = 2, rearrangement = "stochastic"), "list")
expect_type(df_tree <- build_phytree_pq(df, nb_bootstrap = 2, rearrangement = "ratchet"), "list")
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test_krona.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ GA <- subset_taxa(GlobalPatterns, Phylum == "Acidobacteria")
krona_error_or_not <- try(system("ktImportText 2>&1", intern = TRUE))

if (class(krona_error_or_not) == "try-error") {
skip_on_cran()
skip_on_os("windows")
test_that("krona send an error when krona is not installed", {
expect_warning(krona(GA, "Number.of.sequences.html"))
expect_warning(krona(GA, "Number.of.ASVs.html", nb_seq = FALSE))
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test_phyloseq_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ test_that("perc works fine", {
})

test_that("count_seq works fine", {
skip_on_os("windows")
expect_equal(count_seq("inst/extdata/ex_R1_001.fastq.gz"), 2500)
expect_equal(count_seq("inst/extdata/ex_R2_001.fastq.gz"), 2500)
expect_equal(count_seq("inst/extdata/ex.fasta"), 3)
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test_table_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ data(data_fungi)
data(enterotype)

test_that("tax_datatable function works fine with data_fungi dataset", {
skip_on_os("windows")
expect_silent(taxdt <- tax_datatable(data_fungi))
expect_s3_class(taxdt, "datatables")
expect_silent(taxdt <- tax_datatable(data_fungi, taxonomic_level = 1:2))
Expand All @@ -12,6 +13,7 @@ test_that("tax_datatable function works fine with data_fungi dataset", {


test_that("tax_datatable function works fine with enterotype dataset", {
skip_on_os("windows")
expect_silent(tax_datatable(enterotype))
expect_s3_class(tax_datatable(enterotype), "datatables")
expect_silent(tax_datatable(enterotype, modality = enterotype@sam_data$SeqTech))
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test_targets.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ data_fungi_test@otu_table[10, ] <-
rep(0, ncol(data_fungi_test@otu_table))

test_that("track_wkflow function works fine", {
skip_on_os("windows")
expect_message(track_wkflow(list(
unlist(list_fastq_files("inst/extdata/")), data_fungi, enterotype
)))
Expand Down Expand Up @@ -119,6 +120,7 @@ derep_R_001 <-
"inst/extdata/ex_R2_001.fastq.gz"
))
test_that("track_wkflow_samples function works fine with object of class matrix, dada and derep", {
skip_on_os("windows")
expect_s3_class(track_wkflow(
list(
data_fungi@otu_table,
Expand Down
6 changes: 3 additions & 3 deletions vignettes/MiscMetabar.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ knitr::opts_chunk$set(
For an introduction to metabarcoding in R, Please visite the [state of the field](https://adrientaudiere.github.io/MiscMetabar/articles/states_of_fields_in_R.html) vignettes. The [import, export and track](https://adrientaudiere.github.io/MiscMetabar/articles/import_export_track.html) vignette explains how import and export `phyloseq` object. Its also show how to summarize useful information (number of sequences, samples and clusters) accross bioinformatic pipelines.

If you are interested in ecological metrics, see the vignettes describing [alpha-diversity](https://adrientaudiere.github.io/MiscMetabar/articles/alpha-div.html) and [beta-diversity](https://adrientaudiere.github.io/MiscMetabar/articles/beta-div.html) analysis.
The vignette [filter taxa and samples](https://adrientaudiere.github.io/MiscMetabar/articles/filter.html) describes some data-filtering processes using MiscMetabar and the [reclustering](https://adrientaudiere.github.io/MiscMetabar/articles/Reclustering.html) tutorial introduces the different way of clustering already-clustered OTU/ASV. The vignette [tengeler]() explore the dataset from Tengeler et al. (2020) using some MiscMetabar functions.
The vignette [filter taxa and samples](https://adrientaudiere.github.io/MiscMetabar/articles/filter.html) describes some data-filtering processes using MiscMetabar and the [reclustering](https://adrientaudiere.github.io/MiscMetabar/articles/Reclustering.html) tutorial introduces the different way of clustering already-clustered OTU/ASV. The vignette [tengeler](https://adrientaudiere.github.io/MiscMetabar/articles/tengeler.html) explore the dataset from Tengeler et al. (2020) using some MiscMetabar functions.

For developers, I also wrote a vignette describing som [rules of codes](https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html).

Expand Down Expand Up @@ -62,10 +62,10 @@ sankey_pq(gp, taxa = c(1:5))
```


### Circle for visualize distribution of taxa in function of samples variables
### Upset plot for visualize distribution of taxa in function of samples variables

```{r}
circle_pq(gp, "SampleType", taxa = "Class")
upset_pq(gp, "SampleType", taxa = "Class")
```


Expand Down

0 comments on commit e862ec5

Please sign in to comment.