Skip to content

Commit

Permalink
Merge pull request #98 from adrientaudiere/dev
Browse files Browse the repository at this point in the history
 Minor fix for CRAN resubmission
  • Loading branch information
adrientaudiere authored Sep 4, 2024
2 parents 9d4ea63 + 8696286 commit 354461f
Show file tree
Hide file tree
Showing 402 changed files with 28,898 additions and 13,248 deletions.
24 changes: 20 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
{
"workbench.colorCustomizations": {
"activityBar.background": "#253202",
"titleBar.activeBackground": "#344602",
"titleBar.activeForeground": "#F4FEDC"
}
"activityBar.activeBackground": "#ab307e",
"activityBar.background": "#ab307e",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#25320e",
"activityBarBadge.foreground": "#e7e7e7",
"commandCenter.border": "#e7e7e799",
"sash.hoverBorder": "#ab307e",
"statusBar.background": "#832561",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#ab307e",
"statusBarItem.remoteBackground": "#832561",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#832561",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#83256199",
"titleBar.inactiveForeground": "#e7e7e799",
"tab.activeBorder": "#ab307e"
},
"peacock.color": "#832561"
}
4 changes: 2 additions & 2 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.9.2
Version: 0.9.3
Authors@R: person("Adrien", "Taudière", email = "[email protected]",
role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0003-1088-1182"))
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>.
Expand Down Expand Up @@ -79,7 +79,7 @@ Suggests:
vctrs,
viridis,
withr
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
URL: https://github.com/adrientaudiere/MiscMetabar,
https://adrientaudiere.github.io/MiscMetabar/
biocViews: Sequencing, Microbiome, Metagenomics,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export(dist_pos_control)
export(distri_1_taxa)
export(fac2col)
export(filter_asv_blast)
export(filter_taxa_blast)
export(filter_trim)
export(formattable_pq)
export(funguild_assign)
Expand Down Expand Up @@ -98,6 +99,7 @@ export(plot_mt)
export(plot_tax_pq)
export(plot_tsne_pq)
export(plot_var_part_pq)
export(postcluster_pq)
export(psmelt_samples_pq)
export(rarefy_sample_count_by_modality)
export(read_phyloseq)
Expand Down
19 changes: 18 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
# MiscMetabar 0.9.2 (in development)

# MiscMetabar 0.9.3 (in development)

- Homogenize terminology replacing ASV by taxa/taxon in documentation and code
- Build an alias function `filter_taxa_blast()` for
`filter_asv_blast()`
- Build an alias function `postcluster_pq()` for
`asv2otu()`


## BREAKING CHANGES

- Replacing misnamed param `rename_asv` by `rename_taxons` in `clean_pq()`
- Replacing misnamed param `reorder_asv` by `reorder_taxons` in `clean_pq()`



# MiscMetabar 0.9.2

- Add param `default_fun` in function `merge_samples2()` in order to replace the default function that change the sample data in case of merging. A useful parameter is `default_fun=diff_fct_diff_class`.
- Add param `kruskal_test` to `hill_pq()` function to prevent user to mis-interpret Tuckey HSD result (and letters) if the global effect of the tested factor on Hill diversity is non significant.
Expand Down
10 changes: 5 additions & 5 deletions R/Deseq2_edgeR.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
################################################################################
#' Plot edgeR results for a phyloseq or a edgeR object.
#'
#' @description
#'
#' @description
#'
#' <a href="https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html#lifecycle">
#' <img src="https://img.shields.io/badge/lifecycle-maturing-blue" alt="lifecycle-maturing"></a>
#'
#' Graphical representation of edgeR result.
#'
#'
#' @inheritParams clean_pq
#' @param contrast (required):This argument specifies what comparison
#' to extract from the object to build a results table.
Expand Down Expand Up @@ -125,12 +125,12 @@ plot_edgeR_pq <-
# Plot the result of a DESeq2 test
################################################################################
#' Plot DESeq2 results for a phyloseq or a DESeq2 object.
#'
#'
#' @description
#'
#' <a href="https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html#lifecycle">
#' <img src="https://img.shields.io/badge/lifecycle-experimental-orange" alt="lifecycle-experimental"></a>
#'
#'
#' Graphical representation of DESeq2 analysis.
#'
#' @param data (required) a \code{\link{phyloseq-class}} or a
Expand Down
4 changes: 2 additions & 2 deletions R/MiscMetabar-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ NULL

if (getRversion() >= "2.15.1") {
utils::globalVariables(c(
".id", "%>%", "Ab", "Abundance", "ASV_names", "beta.div", "calc_taxon_abund",
".id", "%>%", "Ab", "Abundance", "taxon_names", "beta.div", "calc_taxon_abund",
"character_method", "Class", "col_tax", "colors", "combn", "complement",
"e-value", "Family", "Genus", "grid.draw", "grid.layout",
"group_by", "Guild", "heat_tree", "hill_0", "Hill_0", "hill_1",
"Hill_1", "hill_2", "Hill_2", "how name", "install_github", "install.packages",
"LCBD", "log2FoldChange", "logFC", "LVL1", "LVL3", "lwr", "max_Hill",
"modality", "multcompLetters", "name", "nb_asv", "nb_seq", "nb_values",
"modality", "multcompLetters", "name", "nb_taxa", "nb_seq", "nb_values",
"ott_id", "OTU", "p.adj", "p.adjust", "plot_layout",
"plot_layout value", "Proportion", "pushViewport", "Query name",
"rarefy", "read.delim", "reverse", "reverseComplement", "rgb",
Expand Down
10 changes: 5 additions & 5 deletions R/alpha_div_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ hill_tuckey_pq <- function(
#' Test multiple times effect of factor on Hill diversity
#' with different rarefaction even depth
#'
#' @description
#' @description
#' <a href="https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html#lifecycle">
#' <img src="https://img.shields.io/badge/lifecycle-experimental-orange" alt="lifecycle-experimental"></a>
#'
#' This reduce the risk of a random drawing of a exceptional situation of an unique rarefaction.
#'
#' This reduce the risk of a random drawing of a exceptional situation of an unique rarefaction.
#' @inheritParams clean_pq
#' @param fact (required) Name of the factor in `physeq@sam_data` used to plot
#' different lines
Expand Down Expand Up @@ -272,12 +272,12 @@ hill_test_rarperm_pq <- function(physeq,
################################################################################
#' Automated model selection and multimodel inference with (G)LMs for phyloseq
#'
#' @description
#' @description
#' <a href="https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html#lifecycle">
#' <img src="https://img.shields.io/badge/lifecycle-experimental-orange" alt="lifecycle-experimental"></a>
#'
#' See [glmulti::glmulti()] for more information.
#'
#'
#' @inheritParams clean_pq
#' @param formula (required) a formula for [glmulti::glmulti()]
#' Variables must be present in the `physeq@sam_data` slot or be one
Expand Down
38 changes: 19 additions & 19 deletions R/beta_div_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@ adonis_pq <- function(physeq,
################################################################################
#' Permanova (adonis) on permutations of rarefaction even depth
#'
#' @description
#'
#' @description
#'
#' <a href="https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html#lifecycle">
#' <img src="https://img.shields.io/badge/lifecycle-experimental-orange" alt="lifecycle-experimental"></a>
#'
#' Permanova are computed on a given number of rarefaction with different
#' seed.number. This reduce the risk of a random drawing of a exceptional
#' situation of an unique rarefaction.
#'
#' Permanova are computed on a given number of rarefaction with different
#' seed.number. This reduce the risk of a random drawing of a exceptional
#' situation of an unique rarefaction.
#'
#' @inheritParams adonis_pq
#' @param nperm (int, default = 99) The number of permutations to perform.
#' @param progress_bar (logical, default TRUE) Do we print progress during
Expand Down Expand Up @@ -578,7 +578,7 @@ plot_LCBD_pq <- function(physeq,
#' Please make a reference to `vegan::beta.div()` if you
#' use this function.
plot_SCBD_pq <- function(physeq,
tax_level = "ASV",
tax_level = "Taxa",
tax_col = "Order",
min_SCBD = 0.01,
...) {
Expand All @@ -587,7 +587,7 @@ plot_SCBD_pq <- function(physeq,
tax_tab <- data.frame(physeq@tax_table)

resSCBD <- tibble(
"ASV" = taxa_names(physeq),
"Taxa" = taxa_names(physeq),
"SCBD" = resBeta$SCBD,
tax_tab
)
Expand Down Expand Up @@ -663,7 +663,7 @@ multipatt_pq <- function(physeq,

res_df <- res$sign
res_df$p.adj <- p.adjust(res_df$p.value, method = p_adjust_method)
res_df$ASV_names <- rownames(res_df)
res_df$taxon_names <- rownames(res_df)
res_df_signif <-
res_df %>%
filter(p.adj < pval) %>%
Expand All @@ -672,7 +672,7 @@ multipatt_pq <- function(physeq,
p <- ggplot(
res_df_signif,
aes(
x = ASV_names,
x = taxon_names,
y = name,
size = 2 * value,
color = stat
Expand Down Expand Up @@ -775,12 +775,12 @@ ancombc_pq <- function(physeq, fact, levels_fact = NULL, tax_level = "Class", ..
################################################################################
#' Filter ancombc_pq results
#'
#' @description
#' @description
#' <a href="https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html#lifecycle">
#' <img src="https://img.shields.io/badge/lifecycle-experimental-orange" alt="lifecycle-experimental"></a>
#'
#' Internally used in [plot_ancombc_pq()].
#'
#'
#' @param ancombc_res (required) the result of the ancombc_pq function
#' For the moment only bimodal factors are possible.
#' @param filter_passed (logical, default TRUE) Do we filter using the column
Expand Down Expand Up @@ -857,12 +857,12 @@ signif_ancombc <- function(ancombc_res,
################################################################################
#' Plot ANCOMBC2 result for phyloseq object
#'
#' @description
#' @description
#' <a href="https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html#lifecycle">
#' <img src="https://img.shields.io/badge/lifecycle-experimental-orange" alt="lifecycle-experimental"></a>
#'
#' Graphical representation of ANCOMBC2 result.
#'
#'
#' @inheritParams clean_pq
#' @param ancombc_res (required) the result of the ancombc_pq function
#' For the moment only bimodal factors are possible.
Expand Down Expand Up @@ -961,7 +961,7 @@ plot_ancombc_pq <-
)

taxtable <- data.frame(physeq@tax_table)
taxtable$taxon <- taxa_names(physeq)
taxtable$taxa <- taxa_names(physeq)

df <-
left_join(signif_ancombc_res, taxtable, by = join_by("taxon" == "taxon"))
Expand Down Expand Up @@ -1080,13 +1080,13 @@ taxa_only_in_one_level <- function(physeq,
################################################################################
#' Distribution of sequences across a factor for one taxon
#'
#' @description
#'
#' @description
#'
#' <a href="https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html#lifecycle">
#' <img src="https://img.shields.io/badge/lifecycle-experimental-orange" alt="lifecycle-experimental"></a>
#'
#' Focus on one taxon and one factor.
#'
#' Focus on one taxon and one factor.
#'
#' @inheritParams clean_pq
#' @param fact (required) Name of the factor in `physeq@sam_data` used to plot
#' different lines
Expand Down
39 changes: 22 additions & 17 deletions R/blast.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
#' Blast some sequence against `refseq` slot of a \code{\link{phyloseq-class}}
#' object.
#'
#' @description
#'
#' @description
#'
#' <a href="https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html#lifecycle">
#' <img src="https://img.shields.io/badge/lifecycle-maturing-blue" alt="lifecycle-maturing"></a>
#'
#'
#' Use the blast software.
#'
#'
#' @param physeq (required): a \code{\link{phyloseq-class}} object obtained
#' using the `phyloseq` package.
#' @param seq2search (required) path to a fasta file defining the sequences
#' you want to blast against the ASV sequences from the physeq object.
#' you want to blast against the taxa (ASV, OTU) sequences from the physeq object.
#' @param blastpath path to blast program
#' @param id_cut (default: 90) cut of in identity percent to keep result
#' @param bit_score_cut (default: 50) cut of in bit score to keep result
Expand Down Expand Up @@ -184,13 +184,13 @@ blast_to_phyloseq <- function(physeq,
#' Blast all sequence of `refseq` slot of a \code{\link{phyloseq-class}}
#' object against a custom database.
#'
#' @description
#'
#' @description
#'
#' <a href="https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html#lifecycle">
#' <img src="https://img.shields.io/badge/lifecycle-experimental-orange" alt="lifecycle-experimental"></a>
#'
#' Use the blast software.
#'
#'
#' @inheritParams blast_to_phyloseq
#' @param fasta_for_db path to a fasta file to make the blast database
#' @param database path to a blast database
Expand Down Expand Up @@ -338,23 +338,21 @@ blast_pq <- function(physeq,
return(blast_tab)
}



################################################################################
#' Filter undesirable taxa using blast against a custom database.
#'
#' @description
#'
#' @description
#'
#' <a href="https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html#lifecycle">
#' <img src="https://img.shields.io/badge/lifecycle-experimental-orange" alt="lifecycle-experimental"></a>
#'
#' Use the blast software.
#'
#'
#' @inheritParams blast_to_phyloseq
#' @param fasta_for_db path to a fasta file to make the blast database
#' @param database path to a blast database
#' @param clean_pq (logical)
#' If set to TRUE, empty samples and empty ASV are discarded
#' If set to TRUE, empty samples and empty taxa (ASV, OTU) are discarded
#' after filtering.
#' @param id_filter (default: 90) cut of in identity percent to keep result
#' @param bit_score_filter (default: 50) cut of in bit score to keep result
Expand Down Expand Up @@ -432,20 +430,27 @@ filter_asv_blast <- function(physeq,
}


################################################################################
#' @rdname filter_asv_blast
#' @export
filter_taxa_blast <- filter_asv_blast
################################################################################


#' Blast some sequence against sequences from of a \code{\link{derep-class}}
#' object.
#'
#' @description
#' @description
#' <a href="https://adrientaudiere.github.io/MiscMetabar/articles/Rules.html#lifecycle">
#' <img src="https://img.shields.io/badge/lifecycle-experimental-orange" alt="lifecycle-experimental"></a>
#'
#' Use the blast software.
#'
#'
#' @inheritParams blast_to_phyloseq
#' @param derep The result of `dada2::derepFastq()`. A list of `derep-class`
#' object.
#' @param seq2search (required) path to a fasta file defining the sequences
#' you want to blast against the ASV sequences from the physeq object.
#' you want to blast against the taxa (ASV, OTU) sequences from the physeq object.
#' @param min_length_seq (default: 200) Removed sequences with less than
#' `min_length_seq` from derep before blast. Set to 0 to discard filtering
#' sequences by length.
Expand Down
Loading

0 comments on commit 354461f

Please sign in to comment.