Skip to content

Commit

Permalink
Merge pull request #87 from adrientaudiere/dev
Browse files Browse the repository at this point in the history
Second release on CRAN
  • Loading branch information
adrientaudiere authored Mar 8, 2024
2 parents df14c70 + 29e9db8 commit e08aa46
Show file tree
Hide file tree
Showing 76 changed files with 726 additions and 479 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Package: MiscMetabar
Type: Package
Title: Miscellaneous Functions for Metabarcoding Analysis
Version: 0.7.8
Version: 0.7.10
Authors@R: person("Adrien", "Taudière", email = "[email protected]",
role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0003-1088-1182"))
Description: The MiscMetabar package aims to facilitate the description, transformation, exploration, and reproducibility of metabarcoding analysis. Mainly build on the top of phyloseq, dada2 R packages. MiscMetabar help to build reproducible and robust bioinformatics pipelines in R. MiscMetabar make ecological analysis of alpha and beta-diversity simple and powerful by integrating a large number of analysis, some of them from other R packages.
Description: Facilitate the description, transformation, exploration, and reproducibility of metabarcoding analyses. 'MiscMetabar' is mainly built on top of the 'phyloseq', 'dada2' and 'targets' R packages. It helps to build reproducible and robust bioinformatics pipelines in R. 'MiscMetabar' makes ecological analysis of alpha and beta-diversity easier, more reproducible and more powerful by integrating a large number of tools. Important features are described in Taudière A. (2023) <doi:10.21105/joss.06038>.
License: AGPL-3
Encoding: UTF-8
LazyData: true
Depends:
R (>= 3.5.0),
phyloseq,
ggplot2,
ggplot2 (>= 3.5.0),
dada2,
dplyr
Suggests:
Expand Down
7 changes: 6 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ export(hill_pq)
export(hill_tuckey_phyloseq)
export(hill_tuckey_pq)
export(iNEXT_pq)
export(install_pkg_needed)
export(is_cutadapt_installed)
export(is_falco_installed)
export(is_krona_installed)
export(is_mumu_installed)
export(is_swarm_installed)
export(is_vsearch_installed)
export(krona)
export(list_fastq_files)
export(lulu)
Expand Down
9 changes: 8 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# MiscMetabar 0.8 (in development)

- Add param `plot_with_tuckey` to `hill_pq()`.



# MiscMetabar 0.7 (in development)

- Add functions `chimera_detection_vs()` and `chimera_removal_vs()` to process chimera detection and removal using [vsearch](https://github.com/torognes/vsearch) software
Expand All @@ -8,7 +14,7 @@
- Add function `cutadapt_remove_primers()` to remove primers using [cutadapt](https://github.com/marcelm/cutadapt/)
- Add internal functions `is_swarm_installed()`, `is_cutadapt_installed()`, `is_vsearch_installed()` and `is_falco_installed()` to test for the availability of external software in order to run examples and test from testthat.

- Submit to CRAN and change code to comply with their rules (patch 0.7.1 to 0.7.8)
- Submit to CRAN and change code to comply with their rules (patch 0.7.1 to 0.7.9)
- Numerous examples and tests are skipped on CRAN because it spends to much time to run. Rules vignettes is updated to details the strategy for this.


Expand All @@ -25,6 +31,7 @@
- `sequences` -> `seq2search` in function `search_exact_seq_pq()`
- `seq_names` -> `dna_seq` in function `asv2otu`

- Removing the function `install_pkg_needed()` which do not comply with CRAN policies

# MiscMetabar 0.6.0

Expand Down
37 changes: 20 additions & 17 deletions R/beta_div_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#' [phyloseqGraphTest::graph_perm_test()] function
#'
#' @examples
#' \donttest{
#' data(enterotype)
#' graph_test_pq(enterotype, fact = "SeqTech")
#' \donttest{
#' graph_test_pq(enterotype, fact = "Enterotype", na_remove = TRUE)
#' }
#' @author Adrien Taudière
Expand Down Expand Up @@ -119,6 +119,7 @@ graph_test_pq <- function(physeq,
#' `phyloseq::rarefy_even_depth()`.
#' if `correction_for_sample_size` is TRUE, rarefy_nb_seqs will have no
#' effect.
#' @param verbose (logical, default TRUE) If TRUE, prompt some messages.
#' @param ... Other arguments passed on to [vegan::adonis2()] function.
#' @return The function returns an anova.cca result object with a
#' new column for partial R^2. See help of [vegan::adonis2()] for
Expand All @@ -144,6 +145,7 @@ adonis_pq <- function(physeq,
na_remove = FALSE,
correction_for_sample_size = FALSE,
rarefy_nb_seqs = FALSE,
verbose = TRUE,
...) {
physeq <- clean_pq(
physeq,
Expand Down Expand Up @@ -175,7 +177,9 @@ adonis_pq <- function(physeq,
if (na_remove) {
new_physeq <- physeq
for (tl in term_lab) {
print(tl)
if (verbose) {
message(tl)
}
new_physeq <-
subset_samples_pq(new_physeq, !is.na(physeq@sam_data[[tl]]))
}
Expand Down Expand Up @@ -257,8 +261,6 @@ LCBD_pq <- function(physeq,
silent = TRUE
)

install_pkg_needed("adespatial")

mat <- as.matrix(unclass(physeq@otu_table))
resBeta <- adespatial::beta.div(mat, adj = FALSE, ...)

Expand Down Expand Up @@ -301,20 +303,21 @@ LCBD_pq <- function(physeq,
#' nperm = 100, only_plot_significant = TRUE,
#' pval = 0.2
#' )
#' library("patchwork")
#' plot_LCBD_pq(data_fungi_mini,
#' nperm = 100, only_plot_significant = FALSE,
#' sam_variables = c("Time", "Height")
#' )
#' plot_LCBD_pq(data_fungi_mini,
#' nperm = 100, only_plot_significant = TRUE, pval = 0.2,
#' sam_variables = c("Time", "Height", "Tree_name")
#' ) &
#' theme(
#' legend.key.size = unit(0.4, "cm"),
#' legend.text = element_text(size = 10),
#' axis.title.x = element_text(size = 6)
#' if (!requireNamespace("patchwork")) {
#' plot_LCBD_pq(data_fungi_mini,
#' nperm = 100, only_plot_significant = FALSE,
#' sam_variables = c("Time", "Height")
#' )
#' plot_LCBD_pq(data_fungi_mini,
#' nperm = 100, only_plot_significant = TRUE, pval = 0.2,
#' sam_variables = c("Time", "Height", "Tree_name")
#' ) &
#' theme(
#' legend.key.size = unit(0.4, "cm"),
#' legend.text = element_text(size = 10),
#' axis.title.x = element_text(size = 6)
#' )
#' }
#' }
#' @author Adrien Taudière
#' @details
Expand Down
14 changes: 7 additions & 7 deletions R/blast.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@
#' @examples
#' \dontrun{
#'
#' # blastpath <- "...YOUR_PATH_TO_BLAST..."
#' # blast_to_phyloseq(data_fungi,
#' # seq2search = system.file("extdata", "ex.fasta",
#' # package = "MiscMetabar", mustWork = TRUE
#' # ),
#' # blastpath = blastpath
#' # )
#' blastpath <- "...YOUR_PATH_TO_BLAST..."
#' blast_to_phyloseq(data_fungi,
#' seq2search = system.file("extdata", "ex.fasta",
#' package = "MiscMetabar", mustWork = TRUE
#' ),
#' blastpath = blastpath
#' )
#' }
blast_to_phyloseq <- function(physeq,
seq2search,
Expand Down
126 changes: 66 additions & 60 deletions R/dada_phyloseq.R
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,10 @@ track_wkflow_samples <- function(list_pq_obj, ...) {
#' \donttest{
#' asv2otu(data_fungi_mini, method_clusterize = "longest")
#'
#' if (MiscMetabar:::is_swarm_installed()) {
#' if (MiscMetabar::is_swarm_installed()) {
#' d_swarm <- asv2otu(data_fungi_mini, method = "swarm")
#' }
#' if (MiscMetabar:::is_vsearch_installed()) {
#' if (MiscMetabar::is_vsearch_installed()) {
#' d_vs <- asv2otu(data_fungi_mini, method = "vsearch")
#' }
#' }
Expand Down Expand Up @@ -667,11 +667,9 @@ asv2otu <- function(physeq = NULL,
#' @export
#' @author Adrien Taudière
#' @examples
#' \dontrun{
#' write_pq(data_fungi, path = "phyloseq")
#' write_pq(data_fungi, path = "phyloseq", one_file = TRUE)
#' }

#' write_pq(data_fungi, path = paste0(tempdir(), "/phyloseq"))
#' write_pq(data_fungi, path = paste0(tempdir(), "/phyloseq"), one_file = TRUE)
#' unlink(paste0(tempdir(), "/phyloseq"), recursive = TRUE)
#' @seealso [MiscMetabar::save_pq()]

write_pq <- function(physeq,
Expand Down Expand Up @@ -875,9 +873,8 @@ write_pq <- function(physeq,
#' @export
#' @author Adrien Taudière
#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows"
#' \dontrun{
#' save_pq(data_fungi, path = "phyloseq")
#' }
#' save_pq(data_fungi, path = paste0(tempdir(), "/phyloseq"))
#' unlink(paste0(tempdir(), "/phyloseq"), recursive = TRUE)
#' @seealso [MiscMetabar::write_pq()]
save_pq <- function(physeq, path = NULL, ...) {
write_pq(physeq,
Expand Down Expand Up @@ -913,9 +910,9 @@ save_pq <- function(physeq, path = NULL, ...) {
#' @export
#'
#' @examples
#' # read_pq(path = "phyloseq_folder")
#' # read_pq(path = "phyloseq_folder", taxa_are_rows = TRUE)
#'
#' write_pq(data_fungi, path = paste0(tempdir(), "/phyloseq"))
#' read_pq(path = paste0(tempdir(), "/phyloseq"))
#' unlink(paste0(tempdir(), "/phyloseq"), recursive = TRUE)
read_pq <- function(path = NULL,
taxa_are_rows = FALSE,
sam_names = NULL,
Expand Down Expand Up @@ -1016,9 +1013,8 @@ read_pq <- function(path = NULL,
#' - "merged_ASV": the data.frame used to merged ASV
#'
#' @export
#' @examples
#' \dontrun{
#' data(data_fungi_sp_known)
#' @examplesIf MiscMetabar::is_vsearch_installed()
#' \donttest{
#' lulu_pq(data_fungi_sp_known)
#' }
#' @author Tobias Guldberg Frøslev \email{[email protected]}
Expand Down Expand Up @@ -1163,7 +1159,7 @@ lulu_pq <- function(physeq,
#' bash to obtain details about columns' signification.
#'
#' @export
#' @examples
#' @examplesIf MiscMetabar::is_mumu_installed()
#' \dontrun{
#' mumu_pq(data_fungi_sp_known)
#' }
Expand Down Expand Up @@ -1327,7 +1323,7 @@ mumu_pq <- function(physeq,
#' Mostly for internal use in MiscMetabar functions.
#'
#' @inheritParams clean_pq
#' @param verbose (logical, default FALSE) If true, prompt some warnings.
#' @param verbose (logical, default FALSE) If TRUE, prompt some warnings.
#' @param min_nb_seq_sample (numeric) Only used if verbose = TRUE.
#' Minimum number of sequences per samples to not show warning.
#' @param min_nb_seq_taxa (numeric) Only used if verbose = TRUE.
Expand Down Expand Up @@ -1652,7 +1648,6 @@ add_new_taxonomy_pq <- function(physeq, ref_fasta, suffix = NULL, ...) {
#' @export
#' @author Adrien Taudière
#' @examples
#' data(data_fungi)
#' tbl_sum_samdata(data_fungi) %>%
#' gtsummary::as_kable()
#'
Expand All @@ -1661,11 +1656,12 @@ add_new_taxonomy_pq <- function(physeq, ref_fasta, suffix = NULL, ...) {
#' type = list(Time ~ "continuous2", Height ~ "categorical"),
#' statistic = list(Time ~ c("{median} ({p25}, {p75})", "{min}, {max}"))
#' )
#'
#' \donttest{
#' data(enterotype)
#'
#' summary_samdata <- tbl_sum_samdata(enterotype)
#' summary_samdata <- tbl_sum_samdata(enterotype, include = !contains("SampleId"))
#' }
#' @details
#' This function is mainly a wrapper of the work of others.
#' Please make a reference to `gtsummary::tbl_summary()` if you
Expand Down Expand Up @@ -1698,16 +1694,19 @@ tbl_sum_samdata <- function(physeq, remove_col_unique_value = TRUE, ...) {
#' @export
#' @author Adrien Taudière
#' @examples
#'
#' df <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 5000)
#' \dontrun{
#' df <- add_funguild_info(df,
#' \donttest{
#' d_fung_mini <- add_funguild_info(data_fungi_mini,
#' taxLevels = c(
#' "Domain", "Phylum", "Class", "Order",
#' "Family", "Genus", "Species"
#' "Domain",
#' "Phylum",
#' "Class",
#' "Order",
#' "Family",
#' "Genus",
#' "Species"
#' )
#' )
#' sort(table(df@tax_table[, "guild"]), decreasing = TRUE)
#' sort(table(d_fung_mini@tax_table[, "guild"]), decreasing = TRUE)
#' }
#' @details
#' This function is mainly a wrapper of the work of others.
Expand Down Expand Up @@ -1766,23 +1765,29 @@ add_funguild_info <- function(physeq,
#' @export
#' @author Adrien Taudière
#' @examples
#' \dontrun{
#'
#' df <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 5000)
#' df <- add_funguild_info(df,
#' \donttest{
#' d_fung_mini <- add_funguild_info(data_fungi_mini,
#' taxLevels = c(
#' "Domain", "Phylum", "Class", "Order",
#' "Family", "Genus", "Species"
#' "Domain",
#' "Phylum",
#' "Class",
#' "Order",
#' "Family",
#' "Genus",
#' "Species"
#' )
#' )
#' p <- plot_guild_pq(df)
#' library("patchwork")
#' (plot_guild_pq(subset_samples(df, Height == "Low"),
#' levels_order = p$data$Guild[order(p$data$nb_seq)]
#' ) + theme(legend.position = "none")) +
#' (plot_guild_pq(subset_samples(df, Height == "High"),
#' sort(table(d_fung_mini@tax_table[, "guild"]), decreasing = TRUE)
#'
#' p <- plot_guild_pq(d_fung_mini)
#' if (!requireNamespace("patchwork")) {
#' (plot_guild_pq(subset_samples(d_fung_mini, Height == "Low"),
#' levels_order = p$data$Guild[order(p$data$nb_seq)]
#' ) + ylab("") + theme(axis.text.y = element_blank()))
#' ) + theme(legend.position = "none")) +
#' (plot_guild_pq(subset_samples(d_fung_mini, Height == "High"),
#' levels_order = p$data$Guild[order(p$data$nb_seq)]
#' ) + ylab("") + theme(axis.text.y = element_blank()))
#' }
#' }
#' @seealso [add_funguild_info()]

Expand Down Expand Up @@ -1930,25 +1935,26 @@ plot_guild_pq <-
#' use this function.
#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows"
#' \donttest{
#' library("phangorn")
#' df <- subset_taxa_pq(data_fungi_mini, taxa_sums(data_fungi_mini) > 9000)
#' df_tree <- build_phytree_pq(df, nb_bootstrap = 2)
#' plot(df_tree$UPGMA)
#' plotBS(df_tree$UPGMA, df_tree$UPGMA_bs, main = "UPGMA")
#' plot(df_tree$NJ, "unrooted")
#' plot(df_tree$ML)
#' # plotBS(df_tree$ML_bs)
#' plotBS(df_tree$ML$tree, df_tree$ML_bs, p = 20, frame = "circle")
#' plotBS(
#' df_tree$ML$tree,
#' df_tree$ML_bs,
#' p = 20,
#' frame = "circle",
#' method = "TBE"
#' )
#' plot(consensusNet(df_tree$ML_bs))
#' plot(consensusNet(df_tree$NJ_bs))
#' ps_tree <- merge_phyloseq(df, df_tree$ML$tree)
#' if (!requireNamespace("phangorn")) {
#' df <- subset_taxa_pq(data_fungi_mini, taxa_sums(data_fungi_mini) > 9000)
#' df_tree <- build_phytree_pq(df, nb_bootstrap = 2)
#' plot(df_tree$UPGMA)
#' phangorn::plotBS(df_tree$UPGMA, df_tree$UPGMA_bs, main = "UPGMA")
#' plot(df_tree$NJ, "unrooted")
#' plot(df_tree$ML)
#'
#' phangorn::plotBS(df_tree$ML$tree, df_tree$ML_bs, p = 20, frame = "circle")
#' phangorn::plotBS(
#' df_tree$ML$tree,
#' df_tree$ML_bs,
#' p = 20,
#' frame = "circle",
#' method = "TBE"
#' )
#' plot(phangorn::consensusNet(df_tree$ML_bs))
#' plot(phangorn::consensusNet(df_tree$NJ_bs))
#' ps_tree <- merge_phyloseq(df, df_tree$ML$tree)
#' }
#' }
build_phytree_pq <- function(physeq,
nb_bootstrap = 0,
Expand Down Expand Up @@ -2341,7 +2347,7 @@ physeq_or_string_to_dna <- function(physeq = NULL,
#' )
#'
#'
#' # unlink(tempdir(), recursive = TRUE)
#' unlink(tempdir(), recursive = TRUE)
#' }
#' @details
#' This function is mainly a wrapper of the work of others.
Expand Down
Loading

0 comments on commit e08aa46

Please sign in to comment.