Skip to content

Commit

Permalink
Pave the way for cran Submission
Browse files Browse the repository at this point in the history
  • Loading branch information
adrientaudiere committed Feb 6, 2024
1 parent d81b9b5 commit 7e1da5e
Show file tree
Hide file tree
Showing 70 changed files with 961 additions and 169 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
^paper$
^.vscode$
^citation.cff$
^vignettes/articles$
10 changes: 10 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ jobs:
&& make check \
&& sudo make install
- name: Install swarm
run: |
git clone https://github.com/torognes/swarm.git \
&& cd swarm/ \
&& make

- name: Install cutadapt
run: |
sudo python3 -m pip install cutadapt

- name: Test coverage
run: |
covr::codecov(
Expand Down
28 changes: 15 additions & 13 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Package: MiscMetabar
Type: Package
Title: Miscellaneous Functions for Metabarcoding Analysis
Version: 0.7.0
Version: 0.7.1
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 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.
License: AGPL-3
Encoding: UTF-8
LazyData: false
LazyData: true
Depends:
R (>= 3.5.0),
phyloseq,
Expand All @@ -21,17 +21,14 @@ Suggests:
Biostrings,
circlize,
ComplexUpset,
data.table,
DECIPHER,
DESeq2,
devtools,
DT,
edgeR,
formattable,
gghalves,
ggh4x,
ggstatsplot,
ggtree,
ggridges,
ggVennDiagram,
gtsummary,
Expand All @@ -48,7 +45,6 @@ Suggests:
metacoder,
methods,
mia,
MicrobiotaProcess,
mixtools,
multcompView,
networkD3,
Expand All @@ -73,14 +69,24 @@ Suggests:
testthat (>= 3.0.0),
tibble,
tidyr,
tidytree,
treeio,
treemapify,
vegan,
venneuler,
vctrs,
viridis,
withr
withr,
datawizard,
formattable,
ggforce,
ggtree,
gtExtras,
MicrobiotaProcess,
pillar,
pointblank,
summarytools,
svglite,
tidytree,
treeio
RoxygenNote: 7.3.1
URL: https://github.com/adrientaudiere/MiscMetabar,
https://adrientaudiere.github.io/MiscMetabar/
Expand All @@ -93,10 +99,6 @@ Imports:
lifecycle,
rlang,
stats
Remotes:
bioc::phyloseq,
bioc::dada2,
bioc::ANCOMBC
Config/testthat/edition: 3
Config/testthat/parallel: true
VignetteBuilder: knitr
Expand Down
3 changes: 2 additions & 1 deletion R/MiscMetabar-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ if (getRversion() >= "2.15.1") {
"tax", "tax_col", "teststat", "Time", "tnrs_match_names", "tol_induced_subtree",
"update", "upr", "upViewport", "val", "value", "vegdist", "viewport",
"write.table", "x", "x1", "X1", "x2", "y", "y1", "y2", "ymax",
"ymin", ".group", "archetype", "nOTUid", "taxon", "total"
"ymin", ".group", "archetype", "nOTUid", "taxon", "total",
"chim_rm", "condition", "physeq", "seq_tab_Pairs"
))
}

Expand Down
2 changes: 1 addition & 1 deletion R/blast.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#'
#' @examples
#' \dontrun{
#' data(data_fungi)
#' # data(data_fungi)
#' blastpath <- "...YOUR_PATH_TO_BLAST..."
#' blast_to_phyloseq(data_fungi,
#' seq2search = system.file("extdata", "ex.fasta",
Expand Down
2 changes: 1 addition & 1 deletion R/controls.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ dist_pos_control <- function(physeq, samples_names, method = "bray") {
#' @export
#'
#' @examples
#' data(data_fungi)
#' # data(data_fungi)
#'
#' subset_taxa_tax_control(data_fungi,
#' as.numeric(data_fungi@otu_table[, 300]),
Expand Down
64 changes: 42 additions & 22 deletions R/dada_phyloseq.R
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ track_wkflow <- function(list_of_objects,
#' @author Adrien Taudière
#'
#' @examples
#' data(data_fungi)
#' # data(data_fungi)
#' 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 Expand Up @@ -619,7 +619,7 @@ asv2otu <- function(physeq = NULL,
#' ACCCTCAAGCCCCTTATTGCTTGGTGTTGGGAGTTTAGCTGGCTTTATAGCGGTTAACTCCCTAAATATACTGGCG",
#' file = file_dna, names = "seq1"
#' )
#' data(data_fungi)
#' # data(data_fungi)
#' res <- vs_search_global(data_fungi, file_dna)
#' unlink(file_dna)
#'
Expand Down Expand Up @@ -753,7 +753,7 @@ vs_search_global <- function(physeq,
#' @export
#' @author Adrien Taudière
#' @examples
#' data(data_fungi)
#' # data(data_fungi)
#' # write_pq(data_fungi, path = "phyloseq")
#' # write_pq(data_fungi, path = "phyloseq", one_file = TRUE)
#' @seealso [MiscMetabar::save_pq()]
Expand Down Expand Up @@ -960,7 +960,7 @@ write_pq <- function(physeq,
#' @author Adrien Taudière
#' @examples
#' \dontrun{
#' data(data_fungi)
#' # data(data_fungi)
#' save_pq(data_fungi, path = "phyloseq")
#' }
#' @seealso [MiscMetabar::write_pq()]
Expand Down Expand Up @@ -1478,7 +1478,7 @@ verify_pq <- function(
#' the number of samples
#'
#' @examples
#' data(data_fungi)
#' # data(data_fungi)
#' cond_samp <- grepl("A1", data_fungi@sam_data[["Sample_names"]])
#' subset_samples_pq(data_fungi, cond_samp)
#'
Expand Down Expand Up @@ -1532,7 +1532,7 @@ subset_samples_pq <- function(physeq, condition) {
#' of this function if you use this parameter. No effect if the condition
#' is of class `tax_table`.
#' @examples
#' data(data_fungi)
#' # data(data_fungi)
#' subset_taxa_pq(data_fungi, data_fungi@tax_table[, "Phylum"] == "Ascomycota")
#'
#' cond_taxa <- grepl("Endophyte", data_fungi@tax_table[, "Guild"])
Expand Down Expand Up @@ -1637,7 +1637,7 @@ subset_taxa_pq <- function(physeq,
#' @author Adrien Taudière
#'
#' @examples
#' data(data_fungi)
#' # data(data_fungi)
#' A8_005 <- select_one_sample(data_fungi, "A8-005_S4_MERGED.fastq.gz")
#' A8_005
select_one_sample <- function(physeq, sam_name, silent = FALSE) {
Expand Down Expand Up @@ -1784,7 +1784,7 @@ tbl_sum_samdata <- function(physeq, remove_col_unique_value = TRUE, ...) {
#' @export
#' @author Adrien Taudière
#' @examples
#' data(data_fungi)
#' # data(data_fungi)
#' df <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 5000)
#' \dontrun{
#' df <- add_funguild_info(df,
Expand Down Expand Up @@ -1853,7 +1853,7 @@ add_funguild_info <- function(physeq,
#' @author Adrien Taudière
#' @examples
#' \dontrun{
#' data(data_fungi)
#' # data(data_fungi)
#' df <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 5000)
#' df <- add_funguild_info(df,
#' taxLevels = c(
Expand Down Expand Up @@ -2016,7 +2016,7 @@ plot_guild_pq <-
#' use this function.
#' @examples
#' library("phangorn")
#' data(data_fungi)
#' # data(data_fungi)
#' df <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 9000)
#' df_tree <- build_phytree_pq(df, nb_bootstrap = 5)
#' plot(df_tree$UPGMA)
Expand Down Expand Up @@ -2153,7 +2153,7 @@ build_phytree_pq <- function(physeq,
#' @author Adrien Taudière
#' @importFrom stats kruskal.test
#' @examples
#' data(data_fungi)
#' # data(data_fungi)
#' are_modality_even_depth(data_fungi, "Time")$p.value
#' are_modality_even_depth(rarefy_even_depth(data_fungi), "Time")$p.value
#' are_modality_even_depth(data_fungi, "Height", boxplot = TRUE)
Expand Down Expand Up @@ -2191,7 +2191,7 @@ are_modality_even_depth <- function(physeq, fact, boxplot = FALSE) {
#' @export
#' @author Adrien Taudière
#' @examples
#' data(data_fungi)
#' # data(data_fungi)
#' data_fungi_ordered_by_genus <- reorder_taxa_pq(
#' data_fungi,
#' taxa_names(data_fungi)[order(as.vector(data_fungi@tax_table[, "Genus"]))]
Expand Down Expand Up @@ -2263,7 +2263,7 @@ reorder_taxa_pq <- function(physeq, names_ordered, remove_phy_tree = FALSE) {
#' @export
#'
#' @examples
#' data(data_fungi)
#' # data(data_fungi)
#' data_fungi <- add_info_to_sam_data(data_fungi)
#' boxplot(data_fungi@sam_data$nb_otu ~ data_fungi@sam_data$Time)
#'
Expand Down Expand Up @@ -2293,7 +2293,7 @@ add_info_to_sam_data <- function(physeq,
df_info <-
df_info[match(sample_names(physeq), rownames(df_info)), ]
physeq@sam_data <- sample_data(cbind(
as_tibble(physeq@sam_data),
as.data.frame(physeq@sam_data),
df_info
))
}
Expand Down Expand Up @@ -2347,15 +2347,25 @@ add_info_to_sam_data <- function(physeq,
#' @export
#' @examples
#' \dontrun{
#' data(data_fungi)
#' # data(data_fungi)
#' summary_plot_pq(data_fungi)
#' # Change with your PATH
#' path_to_swarm <- "/home/adrien/miniconda3/bin/swarm"
#'
#' data_fungi_swarm <- swarm_clustering(data_fungi, swarmpath = path_to_swarm)
#' summary_plot_pq(data_fungi_swarm)
#'
#' sequences_ex <- c("TACCTATGTTGCCTTGGCGGCTAAACCTACCCGGGATTTGATGGGGCGAATTACCTGGTATTTTAGCCCACTTACCCGGTACCAACCTACCCTGTACACCGCGCCTGGGTCTACCCTCCGGATGACATTTTTAAGACTCTTGTTTTATAGTGAAATTCTGAGTTTTTATACTTAATAAGTTAAAACTTTCAATCTCGGATCTCTTGGCTCTGGCATCGATGAAGAACGCTACGAAATGCTGATAAATAATGTGAATTGCCGAATTCATTGAATCATCGAATCTTTGAACGCACATTGCACCCATTAGTATTCTAGAGTGCATGCCTGTTCCAGCGTCATTTTCAATCCTCAAGCCCCTTATTGCTTGGTGTTGGCAGTTTAGCTGGCTTTATAGTGCTTAACTCCCTAAATATACTGCCTGATTCGCGGTGACCCCAAGCGTAATAATTATTTTCTCGCTTGAGGTG", "TACCTATGTTGCCTTGGCGGCTAAACCTACCCGGGATTTGATGGGGCGAATTACCTGGTAAGGCCCACTTACCCGGTACCAACCTACCCTGTACACCGCGCCTGGGTCTACCCTCCGGATGACATTTTTAAGACTCTTGTTTTATAGTGAAATTCTGAGTTTTTATACTTAATAAGTTAAAACTTTCAATCTCGGATCTCTTGGCTCTGGCATCGATGAAGAACGCTACGAAATGCTGATAAATAATGTGAATTGCCGAATTCATTGAATCATCGAATCTTTGAACGCACATTGCACCCATTAGTATTCTAGAGTGCATGCCTGTTCCAGCGTCATTTTCAATCCTCAAGCCCCTTATTGCTTGGTGTTGGCAGTTTAGCTGGCTTTATAGTGCTTAACTCCCTAAATATACTGCCTGATTCGCGGTGACCCCAAGCGTAATAATTATTTTCTCGCTTGAGGTG", "TACCTATGTTGCCTTGGCGGCTAAACCTACCCGGGATTTGATGGGGCGAATTACCTGGTAAGGCCCACTTACCCGGTACCAACCTACCCTGTACACCGCGCCTGGGTCTACCCTCCGGATGACATTTTTAAGACTCTTGTTTTATAGTGAAATTCTGAGTTTTTATACTTAATAAGTTAAAACTTTCAATCTCGGATCTCTTGGCTCTGGCATCGATGAAGAACGCTACGAAATGCTGATAAATAATGTGAATTGCCGAATTCATTGAATCATCGAATCTTTGAACGCACATTGCACCCATTAGTATTCTAGAGTGCATGCCTGTTCCAGCGTCATTTTCAATCCTCAAGCCCCTTATTGCTTGGTGTTGGCAGTTTAGCTGGCTTTATAGTGCTTAACTCCCTAAATATACTGCCTGATTCGCGGTGACCCCAAGCGTAATAATTATTTTCTCGCTTGAGGTG", "TACCTATGTTGCCTTGGCGGCTAAACCTACCCGGGATTTGATGGCGAATTACCTGGTATTTTAGCCCACTTACCCGGTACCAACCTACCCTGTACACCGCGCCTGGGTCTACCCTCCGGATGACATTTTTAAGACTCTTGTTTTATAGTGAAATTCTGAGTTTTTATACTTAATAAGTTAAAACTTTCAATCTCGGATCTCTTGGCTCTGGCATCGATGAAGAACGCTACGAAATGCTGATAAATAATGTGAATTGCCGAATTCATTGAATCATCGAATCTTTGAACGCACATTGCACCCATTAGTATTCTAGAGTGCATGCCTGTTCCAGCGTCATTTTCAATCCTCAAGCCCCTTATTGCTTGGTGTTGGCAGTTTAGCTGGCTTTATAGTGCTTAACTCCCTAAATATACTGCCTGATTCGCGGTGACCCCAAGCGTAATAATTATTTTCTCGCTTGAGGTG", "GCGGCTAAACCTACCCGGGATTTGATGGCGAATTACCTGG", "GCGGCTAAACCTACCCGGGATTTGATGGCGAATTACAAAG", "GCGGCTAAACCTACCCGGGATTTGATGGCGAATTACAAAG", "GCGGCTAAACCTACCCGGGATTTGATGGCGAATTACAAAG")
#' sequences_ex <- c(
#' "TACCTATGTTGCCTTGGCGGCTAAACCTACCCGGGATTTGATGGGGCGAATTAATAACGAATTCATTGAATCA",
#' "TACCTATGTTGCCTTGGCGGCTAAACCTACCCGGGATTTGATGGGGCGAATTACCTGGTAAGGCCCACTT",
#' "TACCTATGTTGCCTTGGCGGCTAAACCTACCCGGGATTTGATGGGGCGAATTACCTGGTAGAGGTG",
#' "TACCTATGTTGCCTTGGCGGCTAAACCTACC",
#' "CGGGATTTGATGGCGAATTACCTGGTATTTTAGCCCACTTACCCGGTACCATGAGGTG",
#' "GCGGCTAAACCTACCCGGGATTTGATGGCGAATTACCTGG",
#' "GCGGCTAAACCTACCCGGGATTTGATGGCGAATTACAAAG",
#' "GCGGCTAAACCTACCCGGGATTTGATGGCGAATTACAAAG",
#' "GCGGCTAAACCTACCCGGGATTTGATGGCGAATTACAAAG"
#' )
#'
#' sequences_ex_swarm <- swarm_clustering(
#' dna_seq = sequences_ex,
Expand Down Expand Up @@ -2520,11 +2530,21 @@ swarm_clustering <- function(physeq = NULL,
#' @export
#'
#' @examples
#' data(data_fungi)
#' # data(data_fungi)
#' dna <- physeq_or_string_to_dna(data_fungi)
#' dna
#'
#' sequences_ex <- c("TACCTATGTTGCCTTGGCGGCTAAACCTACCCGGGATTTGATGGGGCGAATTACCTGGTATTTTAGCCCACTTACCCGGTACCAACCTACCCTGTACACCGCGCCTGGGTCTACCCTCCGGATGACATTTTTAAGACTCTTGTTTTATAGTGAAATTCTGAGTTTTTATACTTAATAAGTTAAAACTTTCAATCTCGGATCTCTTGGCTCTGGCATCGATGAAGAACGCTACGAAATGCTGATAAATAATGTGAATTGCCGAATTCATTGAATCATCGAATCTTTGAACGCACATTGCACCCATTAGTATTCTAGAGTGCATGCCTGTTCCAGCGTCATTTTCAATCCTCAAGCCCCTTATTGCTTGGTGTTGGCAGTTTAGCTGGCTTTATAGTGCTTAACTCCCTAAATATACTGCCTGATTCGCGGTGACCCCAAGCGTAATAATTATTTTCTCGCTTGAGGTG", "TACCTATGTTGCCTTGGCGGCTAAACCTACCCGGGATTTGATGGGGCGAATTACCTGGTAAGGCCCACTTACCCGGTACCAACCTACCCTGTACACCGCGCCTGGGTCTACCCTCCGGATGACATTTTTAAGACTCTTGTTTTATAGTGAAATTCTGAGTTTTTATACTTAATAAGTTAAAACTTTCAATCTCGGATCTCTTGGCTCTGGCATCGATGAAGAACGCTACGAAATGCTGATAAATAATGTGAATTGCCGAATTCATTGAATCATCGAATCTTTGAACGCACATTGCACCCATTAGTATTCTAGAGTGCATGCCTGTTCCAGCGTCATTTTCAATCCTCAAGCCCCTTATTGCTTGGTGTTGGCAGTTTAGCTGGCTTTATAGTGCTTAACTCCCTAAATATACTGCCTGATTCGCGGTGACCCCAAGCGTAATAATTATTTTCTCGCTTGAGGTG", "TACCTATGTTGCCTTGGCGGCTAAACCTACCCGGGATTTGATGGCGAATTACCTGGTATTTTAGCCCACTTACCCGGTACCAACCTACCCTGTACACCGCGCCTGGGTCTACCCTCCGGATGACATTTTTAAGACTCTTGTTTTATAGTGAAATTCTGAGTTTTTATACTTAATAAGTTAAAACTTTCAATCTCGGATCTCTTGGCTCTGGCATCGATGAAGAACGCTACGAAATGCTGATAAATAATGTGAATTGCCGAATTCATTGAATCATCGAATCTTTGAACGCACATTGCACCCATTAGTATTCTAGAGTGCATGCCTGTTCCAGCGTCATTTTCAATCCTCAAGCCCCTTATTGCTTGGTGTTGGCAGTTTAGCTGGCTTTATAGTGCTTAACTCCCTAAATATACTGCCTGATTCGCGGTGACCCCAAGCGTAATAATTATTTTCTCGCTTGAGGTG")
#' sequences_ex <- c(
#' "TACCTATGTTGCCTTGGCGGCTAAACCTACCCGGGATTTGATGGGGCGAATTAATAACGAATTCATTGAATCA",
#' "TACCTATGTTGCCTTGGCGGCTAAACCTACCCGGGATTTGATGGGGCGAATTACCTGGTAAGGCCCACTT",
#' "TACCTATGTTGCCTTGGCGGCTAAACCTACCCGGGATTTGATGGGGCGAATTACCTGGTAGAGGTG",
#' "TACCTATGTTGCCTTGGCGGCTAAACCTACC",
#' "CGGGATTTGATGGCGAATTACCTGGTATTTTAGCCCACTTACCCGGTACCATGAGGTG",
#' "GCGGCTAAACCTACCCGGGATTTGATGGCGAATTACCTGG",
#' "GCGGCTAAACCTACCCGGGATTTGATGGCGAATTACAAAG",
#' "GCGGCTAAACCTACCCGGGATTTGATGGCGAATTACAAAG",
#' "GCGGCTAAACCTACCCGGGATTTGATGGCGAATTACAAAG"
#' )
#' dna2 <- physeq_or_string_to_dna(dna_seq = sequences_ex)
#' dna2
#'
Expand Down Expand Up @@ -2602,7 +2622,7 @@ physeq_or_string_to_dna <- function(physeq = NULL,
#' @author Adrien Taudière
#'
#' @examples
#' data(data_fungi)
#' # data(data_fungi)
#' summary_plot_pq(data_fungi)
#' d_vs <- vsearch_clustering(data_fungi)
#' summary_plot_pq(d_vs)
Expand Down Expand Up @@ -2776,7 +2796,7 @@ cutadapt_remove_primers <- function(path_to_fastq,
args_before_cutadapt = "source ~/miniconda3/etc/profile.d/conda.sh && conda activate cutadaptenv && ") {
cmd <- list()
if (!dir.exists(folder_output)) {
dir.create(folder_output)
dir.create(folder_output)
}

if (is.null(primer_rev)) {
Expand Down Expand Up @@ -2813,8 +2833,8 @@ cutadapt_remove_primers <- function(path_to_fastq,
nb_files = nb_files
)

primer_fw_RC <- dada2:::rc(primer_fw)
primer_rev_RC <- dada2:::rc(primer_rev)
primer_fw_RC <- dada2::rc(primer_fw)
primer_rev_RC <- dada2::rc(primer_rev)
for (f in lff$fnfs) {
cmd[[f]] <-
paste0(
Expand Down
7 changes: 4 additions & 3 deletions R/funguild.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#' to the `db` argument of [funguild_assign()]
#' @export
#'
#' @examples
#' get_funguild_db()
#' @references Nguyen NH, Song Z, Bates ST, Branco S, Tedersoo L, Menke J,
#' Schilling JS, Kennedy PG. 2016. *FUNGuild: An open annotation tool for
#' parsing fungal community datasets by ecological guild*. Fungal Ecology
Expand Down Expand Up @@ -135,6 +133,9 @@ funguild_assign <- function(otu_table, db_funguild = get_funguild_db(),
dplyr::ungroup() %>%
dplyr::mutate_all(as.character) %>%
dplyr::left_join(otu_table, ., by = "taxkey") %>%
dplyr::left_join(db_funguild, by = "searchkey", suffix = c("", ".funguild")) %>%
dplyr::left_join(db_funguild,
by = "searchkey",
suffix = c("", ".funguild")
) %>%
dplyr::select(-taxkey, -searchkey)
}
Loading

0 comments on commit 7e1da5e

Please sign in to comment.