From ce50c947b1835ff6aa6f70f13bdb73793598352f Mon Sep 17 00:00:00 2001 From: Adrien Taudiere <6680165+adrientaudiere@users.noreply.github.com> Date: Tue, 26 Dec 2023 14:48:10 +0100 Subject: [PATCH 1/6] Update plot_functions.R --- R/plot_functions.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/plot_functions.R b/R/plot_functions.R index d563635c..dea047a5 100644 --- a/R/plot_functions.R +++ b/R/plot_functions.R @@ -2666,7 +2666,7 @@ SRS_curve_pq <- function(physeq, clean_pq = FALSE, ...) { #' c("Skin", "Feces", "Tong") #' res_iNEXT <- iNEXT_pq( #' GPsubset, -#' merge_sample_by = human, +#' merge_sample_by = "human", #' q = 1, #' datatype = "abundance", #' nboot = 2 From 1afa1b1cab67ed0e582d628a244be46a6c843cb4 Mon Sep 17 00:00:00 2001 From: Adrien Taudiere <6680165+adrientaudiere@users.noreply.github.com> Date: Tue, 26 Dec 2023 14:48:48 +0100 Subject: [PATCH 2/6] Update iNEXT_pq.Rd --- man/iNEXT_pq.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/iNEXT_pq.Rd b/man/iNEXT_pq.Rd index f4fc5908..96678471 100644 --- a/man/iNEXT_pq.Rd +++ b/man/iNEXT_pq.Rd @@ -42,7 +42,7 @@ GPsubset@sam_data$human <- GPsubset@sam_data$SampleType \%in\% c("Skin", "Feces", "Tong") res_iNEXT <- iNEXT_pq( GPsubset, - merge_sample_by = human, + merge_sample_by = "human", q = 1, datatype = "abundance", nboot = 2 From 74b4dd2aece8913c1aedebf9e2b2521d2f75add4 Mon Sep 17 00:00:00 2001 From: Adrien Taudiere <6680165+adrientaudiere@users.noreply.github.com> Date: Tue, 26 Dec 2023 14:51:59 +0100 Subject: [PATCH 3/6] Update pkgdown.yaml --- .github/workflows/pkgdown.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index c57f8fce..8c6d2b6d 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -40,9 +40,9 @@ jobs: shell: Rscript {0} - name: Deploy to GitHub pages 🚀 - if: github.event_name != 'pull_request' + # if: github.event_name != 'pull_request' uses: JamesIves/github-pages-deploy-action@v4.4.1 with: clean: false branch: gh-pages - folder: docs \ No newline at end of file + folder: docs From 0f33b110ae317bc5cda0c4be7a692186793316dc Mon Sep 17 00:00:00 2001 From: adrientaudiere Date: Thu, 28 Dec 2023 14:29:47 +0100 Subject: [PATCH 4/6] Minor bugs fix to pass R CMD CHECK --- .github/workflows/R-CMD-check.yaml | 1 - DESCRIPTION | 2 +- NEWS.md | 6 +- R/beta_div_test.R | 81 ++++--- R/blast.R | 110 +++++---- R/controls.R | 9 +- R/dada_phyloseq.R | 206 ++++++++--------- R/funguild.R | 5 +- R/krona.R | 13 +- R/lulu.R | 10 +- R/miscellanous.R | 23 +- R/plot_functions.R | 357 ++++++++++++++--------------- R/speedyseq_functions.R | 22 +- R/table_functions.R | 26 +-- R/targets_misc.R | 13 +- R/tuckeyTest.R | 3 +- man/add_new_taxonomy_pq.Rd | 4 - man/iNEXT_pq.Rd | 2 +- man/multipatt_pq.Rd | 1 + man/multitax_bar_pq.Rd | 1 + man/plot_LCBD_pq.Rd | 1 + man/plot_SCBD_pq.Rd | 1 + man/plot_tsne_pq.Rd | 1 + man/ridges_pq.Rd | 1 + man/rotl_pq.Rd | 1 + man/sample_data_stable.Rd | 2 + man/tbl_sum_samdata.Rd | 1 + man/upset_test_pq.Rd | 1 + 28 files changed, 440 insertions(+), 464 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 7354e3bc..73f5446e 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -20,7 +20,6 @@ jobs: - {os: windows-latest, r: 'release'} - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} - {os: ubuntu-latest, r: 'release'} - - {os: ubuntu-latest, r: 'oldrel-1'} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} diff --git a/DESCRIPTION b/DESCRIPTION index 131a95cc..11fbb72b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: MiscMetabar Type: Package Title: Miscellaneous Functions for Metabarcoding Analysis -Version: 0.6.0 +Version: 0.6.1 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 powerfull by integrating a large number of analysis, some of them from other R packages. diff --git a/NEWS.md b/NEWS.md index b44f983c..8c188f22 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,8 @@ -# MiscMetabar 0.6.0 (in development) +# MiscMetabar 0.6.1 (in development) + +- Minor bugs fix to pass R CMD CHECK + +# MiscMetabar 0.6.0 - Add function `ancombc_pq()` to simplify the call to `ANCOMBC::ancombc2()` : ANalysis of COmpositions of Microbiomes with Bias Correction 2 - Add param `taxa_names_from_physeq` (default FALSE) to `subset_taxa_pq()` diff --git a/R/beta_div_test.R b/R/beta_div_test.R index 19ed8569..0301cc7a 100644 --- a/R/beta_div_test.R +++ b/R/beta_div_test.R @@ -35,15 +35,14 @@ #' Please cite `phyloseqGraphTest` package. #' @export -graph_test_pq <- function( - physeq, - fact, - merge_sample_by = NULL, - nperm = 999, - return_plot = TRUE, - title = "Graph Test", - na_remove = FALSE, - ...) { +graph_test_pq <- function(physeq, + fact, + merge_sample_by = NULL, + nperm = 999, + return_plot = TRUE, + title = "Graph Test", + na_remove = FALSE, + ...) { verify_pq(physeq) if (!is.null(merge_sample_by)) { @@ -135,15 +134,14 @@ graph_test_pq <- function( #' Please make a reference to `vegan::adonis2()` if you #' use this function. -adonis_pq <- function( - physeq, - formula, - dist_method = "bray", - merge_sample_by = NULL, - na_remove = FALSE, - correction_for_sample_size = FALSE, - rarefy_nb_seqs = FALSE, - ...) { +adonis_pq <- function(physeq, + formula, + dist_method = "bray", + merge_sample_by = NULL, + na_remove = FALSE, + correction_for_sample_size = FALSE, + rarefy_nb_seqs = FALSE, + ...) { physeq <- clean_pq( physeq, force_taxa_as_columns = TRUE, @@ -243,10 +241,9 @@ adonis_pq <- function( #' This function is mainly a wrapper of the work of others. #' Please make a reference to `adespatial::beta.div()` if you #' use this function. -LCBD_pq <- function( - physeq, - p_adjust_method = "BH", - ...) { +LCBD_pq <- function(physeq, + p_adjust_method = "BH", + ...) { physeq <- clean_pq( physeq, force_taxa_as_columns = TRUE, @@ -290,6 +287,7 @@ LCBD_pq <- function( #' @seealso [LCBD_pq], [adespatial::beta.div()] #' #' @examples +#' data(data_fungi) #' plot_LCBD_pq(data_fungi, #' nperm = 100, only_plot_significant = FALSE, #' pval = 0.2 @@ -317,13 +315,12 @@ LCBD_pq <- function( #' This function is mainly a wrapper of the work of others. #' Please make a reference to `vegan::beta.div()` if you #' use this function. -plot_LCBD_pq <- function( - physeq, - p_adjust_method = "BH", - pval = 0.05, - sam_variables = NULL, - only_plot_significant = TRUE, - ...) { +plot_LCBD_pq <- function(physeq, + p_adjust_method = "BH", + pval = 0.05, + sam_variables = NULL, + only_plot_significant = TRUE, + ...) { resBeta <- LCBD_pq(physeq, p_adjust_method = p_adjust_method, ... @@ -430,6 +427,7 @@ plot_LCBD_pq <- function( #' @seealso [LCBD_pq], [adespatial::beta.div()] #' #' @examples +#' data(data_fungi) #' plot_SCBD_pq(data_fungi) + #' geom_text(aes(label = paste(Genus, Species)), hjust = 1, vjust = 2) + #' xlim(c(0, NA)) @@ -441,12 +439,11 @@ plot_LCBD_pq <- function( #' This function is mainly a wrapper of the work of others. #' Please make a reference to `vegan::beta.div()` if you #' use this function. -plot_SCBD_pq <- function( - physeq, - tax_level = "ASV", - tax_col = "Order", - min_SCBD = 0.01, - ...) { +plot_SCBD_pq <- function(physeq, + tax_level = "ASV", + tax_col = "Order", + min_SCBD = 0.01, + ...) { resBeta <- LCBD_pq(physeq, nperm = 0, ...) tax_tab <- data.frame(physeq@tax_table) @@ -489,6 +486,7 @@ plot_SCBD_pq <- function( #' @return A ggplot object #' @export #' @examples +#' data(data_fungi) #' data_fungi_ab <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 10000) #' multipatt_pq(subset_samples(data_fungi_ab, !is.na(Time)), fact = "Time") #' multipatt_pq(subset_samples(data_fungi_ab, !is.na(Time)), @@ -501,13 +499,12 @@ plot_SCBD_pq <- function( #' Please make a reference to `indicspecies::multipatt()` if you #' use this function. -multipatt_pq <- function( - physeq, - fact, - p_adjust_method = "BH", - pval = 0.05, - control = permute::how(nperm = 999), - ...) { +multipatt_pq <- function(physeq, + fact, + p_adjust_method = "BH", + pval = 0.05, + control = permute::how(nperm = 999), + ...) { physeq <- clean_pq(physeq, clean_samples_names = FALSE, force_taxa_as_columns = TRUE diff --git a/R/blast.R b/R/blast.R index 0102a327..eb66a75e 100644 --- a/R/blast.R +++ b/R/blast.R @@ -54,21 +54,20 @@ #' blastpath = blastpath #' ) #' } -blast_to_phyloseq <- function( - physeq, - seq2search, - blastpath = NULL, - id_cut = 90, - bit_score_cut = 50, - min_cover_cut = 50, - e_value_cut = 1e-30, - unique_per_seq = FALSE, - score_filter = TRUE, - list_no_output_query = FALSE, - args_makedb = NULL, - args_blastn = NULL, - nproc = 1, - keep_temporary_files = FALSE) { +blast_to_phyloseq <- function(physeq, + seq2search, + blastpath = NULL, + id_cut = 90, + bit_score_cut = 50, + min_cover_cut = 50, + e_value_cut = 1e-30, + unique_per_seq = FALSE, + score_filter = TRUE, + list_no_output_query = FALSE, + args_makedb = NULL, + args_blastn = NULL, + nproc = 1, + keep_temporary_files = FALSE) { verify_pq(physeq) dna <- Biostrings::DNAStringSet(physeq@refseq) Biostrings::writeXStringSet(dna, paste0(tempdir(), "/", "db.fasta")) @@ -196,21 +195,20 @@ blast_to_phyloseq <- function( #' @return a blast table #' @export #' -blast_pq <- function( - physeq, - fasta_for_db = NULL, - database = NULL, - blastpath = NULL, - id_cut = 90, - bit_score_cut = 50, - min_cover_cut = 50, - e_value_cut = 1e-30, - unique_per_seq = FALSE, - score_filter = TRUE, - nproc = 1, - args_makedb = NULL, - args_blastn = NULL, - keep_temporary_files = FALSE) { +blast_pq <- function(physeq, + fasta_for_db = NULL, + database = NULL, + blastpath = NULL, + id_cut = 90, + bit_score_cut = 50, + min_cover_cut = 50, + e_value_cut = 1e-30, + unique_per_seq = FALSE, + score_filter = TRUE, + nproc = 1, + args_makedb = NULL, + args_blastn = NULL, + keep_temporary_files = FALSE) { verify_pq(physeq) dna <- Biostrings::DNAStringSet(physeq@refseq) Biostrings::writeXStringSet( @@ -363,17 +361,16 @@ blast_pq <- function( #' @return A new \code{\link{phyloseq-class}} object. -filter_asv_blast <- function( - physeq, - fasta_for_db = NULL, - database = NULL, - clean_pq = TRUE, - add_info_to_taxtable = TRUE, - id_filter = 90, - bit_score_filter = 50, - min_cover_filter = 50, - e_value_filter = 1e-30, - ...) { +filter_asv_blast <- function(physeq, + fasta_for_db = NULL, + database = NULL, + clean_pq = TRUE, + add_info_to_taxtable = TRUE, + id_filter = 90, + bit_score_filter = 50, + min_cover_filter = 50, + e_value_filter = 1e-30, + ...) { blast_tab <- blast_pq( physeq = physeq, fasta_for_db = fasta_for_db, @@ -446,22 +443,21 @@ filter_asv_blast <- function( #' against un custom database and [MiscMetabar::blast_to_phyloseq()] to use #' `refseq` slot as a database #' @author Adrien Taudière -blast_to_derep <- function( - derep, - seq2search, - blastpath = NULL, - id_cut = 90, - bit_score_cut = 50, - min_cover_cut = 50, - e_value_cut = 1e-30, - unique_per_seq = FALSE, - score_filter = FALSE, - list_no_output_query = FALSE, - min_length_seq = 200, - args_makedb = NULL, - args_blastn = NULL, - nproc = 1, - keep_temporary_files = FALSE) { +blast_to_derep <- function(derep, + seq2search, + blastpath = NULL, + id_cut = 90, + bit_score_cut = 50, + min_cover_cut = 50, + e_value_cut = 1e-30, + unique_per_seq = FALSE, + score_filter = FALSE, + list_no_output_query = FALSE, + min_length_seq = 200, + args_makedb = NULL, + args_blastn = NULL, + nproc = 1, + keep_temporary_files = FALSE) { if (!inherits(derep[[1]], "derep")) { stop("derep must be an object of class derep-class") } diff --git a/R/controls.R b/R/controls.R index 809f5eb2..1c13b502 100644 --- a/R/controls.R +++ b/R/controls.R @@ -153,11 +153,10 @@ dist_pos_control <- function(physeq, samples_names, method = "bray") { #' #' @author Adrien Taudière subset_taxa_tax_control <- - function( - physeq, - taxa_distri, - method = "mean", - min_diff_for_cutoff = NULL) { + function(physeq, + taxa_distri, + method = "mean", + min_diff_for_cutoff = NULL) { verify_pq(physeq) cutoff_seq <- vector(mode = "numeric", length = nsamples(physeq)) diff --git a/R/dada_phyloseq.R b/R/dada_phyloseq.R index 53cc9d96..cfc353e4 100644 --- a/R/dada_phyloseq.R +++ b/R/dada_phyloseq.R @@ -60,18 +60,17 @@ add_dna_to_phyloseq <- function(physeq) { #' `MiscMetabar::simplify_taxo()` function #' @return A new \code{\link{phyloseq-class}} object #' @export -clean_pq <- function( - physeq, - remove_empty_samples = TRUE, - remove_empty_taxa = TRUE, - clean_samples_names = TRUE, - silent = FALSE, - verbose = FALSE, - force_taxa_as_columns = FALSE, - force_taxa_as_rows = FALSE, - reorder_asv = FALSE, - rename_asv = FALSE, - simplify_taxo = FALSE) { +clean_pq <- function(physeq, + remove_empty_samples = TRUE, + remove_empty_taxa = TRUE, + clean_samples_names = TRUE, + silent = FALSE, + verbose = FALSE, + force_taxa_as_columns = FALSE, + force_taxa_as_rows = FALSE, + reorder_asv = FALSE, + rename_asv = FALSE, + simplify_taxo = FALSE) { if (clean_samples_names) { if (!is.null(physeq@refseq)) { if (sum(!names(physeq@refseq) %in% taxa_names(physeq)) > 0) { @@ -229,12 +228,11 @@ clean_pq <- function( #' each object. #' @export -track_wkflow <- function( - list_of_objects, - obj_names = NULL, - clean_pq = FALSE, - taxonomy_rank = NULL, - ...) { +track_wkflow <- function(list_of_objects, + obj_names = NULL, + clean_pq = FALSE, + taxonomy_rank = NULL, + ...) { message("Compute the number of sequences") if (!is.null(obj_names)) { names(list_of_objects) <- obj_names @@ -519,18 +517,17 @@ track_wkflow_samples <- function(list_pq_obj, ...) { #' #' @export -asv2otu <- function( - physeq = NULL, - seq_names = NULL, - nproc = 1, - method = "clusterize", - id = 0.97, - vsearchpath = "vsearch", - tax_adjust = 0, - vsearch_cluster_method = "--cluster_size", - vsearch_args = "--strand both", - keep_temporary_files = FALSE, - ...) { +asv2otu <- function(physeq = NULL, + seq_names = NULL, + nproc = 1, + method = "clusterize", + id = 0.97, + vsearchpath = "vsearch", + tax_adjust = 0, + vsearch_cluster_method = "--cluster_size", + vsearch_args = "--strand both", + keep_temporary_files = FALSE, + ...) { if (inherits(physeq, "phyloseq")) { verify_pq(physeq) if (is.null(physeq@refseq)) { @@ -691,14 +688,13 @@ asv2otu <- function( #' This function is mainly a wrapper of the work of others. #' Please make [vsearch](https://github.com/torognes/vsearch). -vs_search_global <- function( - physeq, - seq2search = NULL, - path_to_fasta = NULL, - vsearchpath = "vsearch", - id = 0.8, - iddef = 0, - keep_temporary_files = FALSE) { +vs_search_global <- function(physeq, + seq2search = NULL, + path_to_fasta = NULL, + vsearchpath = "vsearch", + id = 0.8, + iddef = 0, + keep_temporary_files = FALSE) { verify_pq(physeq) dna <- Biostrings::DNAStringSet(physeq@refseq) Biostrings::writeXStringSet(dna, paste0(tempdir(), "/", "temp.fasta")) @@ -757,13 +753,13 @@ vs_search_global <- function( ) if (!keep_temporary_files) { - if(file.exists(paste0(tempdir(), "temp.fasta"))){ + if (file.exists(paste0(tempdir(), "temp.fasta"))) { unlink(paste0(tempdir(), "temp.fasta")) } - if(file.exists(paste0(tempdir(), "temp.uc"))){ + if (file.exists(paste0(tempdir(), "temp.uc"))) { unlink(paste0(tempdir(), "temp.uc")) } - if(file.exists(paste0(tempdir(), "seq2search.fasta"))){ + if (file.exists(paste0(tempdir(), "seq2search.fasta"))) { unlink(paste0(tempdir(), "seq2search.fasta")) } } else { @@ -816,24 +812,23 @@ vs_search_global <- function( #' # write_pq(data_fungi, path = "phyloseq", one_file = TRUE) #' @seealso [MiscMetabar::save_pq()] -write_pq <- function( - physeq, - path = NULL, - rdata = FALSE, - one_file = FALSE, - write_sam_data = TRUE, - sam_data_first = FALSE, - clean_pq = TRUE, - reorder_asv = FALSE, - rename_asv = FALSE, - remove_empty_samples = TRUE, - remove_empty_taxa = TRUE, - clean_samples_names = TRUE, - silent = FALSE, - verbose = FALSE, - quote = FALSE, - sep_csv = "\t", - ...) { +write_pq <- function(physeq, + path = NULL, + rdata = FALSE, + one_file = FALSE, + write_sam_data = TRUE, + sam_data_first = FALSE, + clean_pq = TRUE, + reorder_asv = FALSE, + rename_asv = FALSE, + remove_empty_samples = TRUE, + remove_empty_taxa = TRUE, + clean_samples_names = TRUE, + silent = FALSE, + verbose = FALSE, + quote = FALSE, + sep_csv = "\t", + ...) { verify_pq(physeq) physeq <- clean_pq( @@ -1062,12 +1057,11 @@ save_pq <- function(physeq, path = NULL, ...) { #' read_pq(path = "phyloseq_data", taxa_are_rows = TRUE) #' } #' -read_pq <- function( - path = NULL, - taxa_are_rows = FALSE, - sam_names = NULL, - sep_csv = "\t", - ...) { +read_pq <- function(path = NULL, + taxa_are_rows = FALSE, + sam_names = NULL, + sep_csv = "\t", + ...) { if (file.exists(paste0(path, "/otu_table.csv"))) { if (taxa_are_rows) { otu_table_csv <- @@ -1325,15 +1319,14 @@ lulu_pq <- function(physeq, #' [lulu](https://www.nature.com/articles/s41467-017-01312-x) if you use this function #' for your work. #' -mumu_pq <- function( - physeq, - nproc = 1, - id = 0.84, - vsearchpath = "vsearch", - mumupath = "mumu", - verbose = FALSE, - clean_pq = TRUE, - keep_temporary_files = FALSE) { +mumu_pq <- function(physeq, + nproc = 1, + id = 0.84, + vsearchpath = "vsearch", + mumupath = "mumu", + verbose = FALSE, + clean_pq = TRUE, + keep_temporary_files = FALSE) { verify_pq(physeq) if (is.null(physeq@refseq)) { stop("The phyloseq object do not contain a @refseq slot") @@ -1607,12 +1600,11 @@ subset_samples_pq <- function(physeq, condition) { #' @return a new phyloseq object #' @export #' -subset_taxa_pq <- function( - physeq, - condition, - verbose = TRUE, - clean_pq = TRUE, - taxa_names_from_physeq = FALSE) { +subset_taxa_pq <- function(physeq, + condition, + verbose = TRUE, + clean_pq = TRUE, + taxa_names_from_physeq = FALSE) { if (inherits(condition, "taxonomyTable")) { condition_temp <- as.vector(condition) names(condition_temp) <- rownames(condition) @@ -1762,8 +1754,6 @@ select_one_sample <- function(physeq, sam_name, silent = FALSE) { #' @return a physeq object with a larger slot tax_table #' #' @export -#' @examples -#' # example code #' #' @author Adrien Taudière #' @@ -1802,6 +1792,7 @@ 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() #' @@ -1864,17 +1855,16 @@ tbl_sum_samdata <- function(physeq, remove_col_unique_value = TRUE, ...) { #' use this function. #' @seealso [plot_guild_pq()] -add_funguild_info <- function( - physeq, - taxLevels = c( - "Kingdom", - "Phylum", - "Class", - "Order", - "Family", - "Genus", - "Species" - )) { +add_funguild_info <- function(physeq, + taxLevels = c( + "Kingdom", + "Phylum", + "Class", + "Order", + "Family", + "Genus", + "Species" + )) { tax_tab <- physeq@tax_table FUNGuild_assign <- funguild_assign(data.frame( @@ -1936,11 +1926,10 @@ add_funguild_info <- function( #' @seealso [add_funguild_info()] plot_guild_pq <- - function( - physeq, - levels_order = NULL, - clean_pq = TRUE, - ...) { + function(physeq, + levels_order = NULL, + clean_pq = TRUE, + ...) { if (clean_pq) { physeq <- clean_pq(physeq, ...) } @@ -2099,17 +2088,16 @@ plot_guild_pq <- #' plot(consensusNet(df_tree$ML_bs)) #' plot(consensusNet(df_tree$NJ_bs)) #' ps_tree <- merge_phyloseq(df, df_tree$ML$tree) -build_phytree_pq <- function( - physeq, - nb_bootstrap = 0, - model = "GTR", - optInv = TRUE, - optGamma = TRUE, - rearrangement = "NNI", - control = phangorn::pml.control(trace = 0), - optNni = TRUE, - multicore = FALSE, - ...) { +build_phytree_pq <- function(physeq, + nb_bootstrap = 0, + model = "GTR", + optInv = TRUE, + optGamma = TRUE, + rearrangement = "NNI", + control = phangorn::pml.control(trace = 0), + optNni = TRUE, + multicore = FALSE, + ...) { seqs <- physeq@refseq alignment <- DECIPHER::AlignSeqs(Biostrings::DNAStringSet(seqs), anchor = NA) diff --git a/R/funguild.R b/R/funguild.R index 2cb5efb8..83cc515b 100644 --- a/R/funguild.R +++ b/R/funguild.R @@ -97,9 +97,8 @@ get_funguild_db <- function(db = "http://www.stbates.org/funguild_db_2.php") { #' 20:241-248. #' @author Brendan Furneaux (orcid: [0000-0003-3522-7363](https://orcid.org/0000-0003-3522-7363)), #' modified by Adrien Taudière -funguild_assign <- function( - otu_table, db = get_funguild_db(), - tax_col = "Taxonomy") { +funguild_assign <- function(otu_table, db = get_funguild_db(), + tax_col = "Taxonomy") { if (is.character(otu_table)) { otu_table <- tibble::tibble(otu_table) names(otu_table) <- tax_col diff --git a/R/krona.R b/R/krona.R index a7aaad7d..af1c7ac1 100644 --- a/R/krona.R +++ b/R/krona.R @@ -33,13 +33,12 @@ #' Please cite [Krona](https://github.com/marbl/Krona) if #' you use this function. krona <- - function( - physeq, - file = "krona.html", - nb_seq = TRUE, - ranks = "All", - add_unassigned_rank = 0, - name = NULL) { + function(physeq, + file = "krona.html", + nb_seq = TRUE, + ranks = "All", + add_unassigned_rank = 0, + name = NULL) { if (ranks[1] == "All") { ranks <- seq_along(physeq@tax_table[1, ]) } diff --git a/R/lulu.R b/R/lulu.R index b408c363..af7347dd 100644 --- a/R/lulu.R +++ b/R/lulu.R @@ -75,7 +75,15 @@ #' @author Tobias Guldberg Frøslev (orcid: [0000-0002-3530-013X](https://orcid.org/0000-0002-3530-013X)), #' modified by Adrien Taudière #' @export -lulu <- function(otutable, matchlist, minimum_ratio_type = "min", minimum_ratio = 1, minimum_match = 84, minimum_relative_cooccurence = 0.95, progress_bar = TRUE, log_conserved = FALSE) { +lulu <- function( + otutable, + matchlist, + minimum_ratio_type = "min", + minimum_ratio = 1, + minimum_match = 84, + minimum_relative_cooccurence = 0.95, + progress_bar = TRUE, + log_conserved = FALSE) { start.time <- Sys.time() colnames(matchlist) <- c("OTUid", "hit", "match") # remove no hits (vsearch) diff --git a/R/miscellanous.R b/R/miscellanous.R index 420be7e4..86e5b096 100644 --- a/R/miscellanous.R +++ b/R/miscellanous.R @@ -52,12 +52,11 @@ as_binary_otu_table <- function(physeq, min_number = 1) { #' @export #' @seealso \code{\link[vegan]{vegdist}} -dist_bycol <- function( - x, - y, - method = "bray", - nperm = 99, - ...) { +dist_bycol <- function(x, + y, + method = "bray", + nperm = 99, + ...) { x <- as.matrix(unclass(x)) y <- as.matrix(unclass(y)) @@ -294,10 +293,9 @@ funky_color <- #' subsample_fastq(ex_file, "your_path_to_output") #' subsample_fastq(list_fastq_files("extdata"), "your_path_to_output", n = 10) #' } -subsample_fastq <- function( - fastq_files, - folder_output = "subsample", - n_seq = 1000) { +subsample_fastq <- function(fastq_files, + folder_output = "subsample", + n_seq = 1000) { for (f in unlist(fastq_files)) { if (!dir.exists(folder_output)) { dir.create(folder_output) @@ -329,9 +327,8 @@ subsample_fastq <- function( #' @return Nothing #' @author Adrien Taudière #' @export -install_pkg_needed <- function( - pkg, use_pak = TRUE, bioconductor_pkg = FALSE, - github_pkg = FALSE, verbose = FALSE) { +install_pkg_needed <- function(pkg, use_pak = TRUE, bioconductor_pkg = FALSE, + github_pkg = FALSE, verbose = FALSE) { if (!requireNamespace(pkg, quietly = TRUE)) { if (verbose) { message(paste0("Installation of the package : ", pkg)) diff --git a/R/plot_functions.R b/R/plot_functions.R index dea047a5..1298f580 100644 --- a/R/plot_functions.R +++ b/R/plot_functions.R @@ -21,11 +21,10 @@ #' @seealso [phyloseq::mt()] plot_mt <- - function( - mt = NULL, - alpha = 0.05, - color_tax = "Class", - taxa = "Species") { + function(mt = NULL, + alpha = 0.05, + color_tax = "Class", + taxa = "Species") { d <- mt[mt$plower < alpha, ] d$tax_col <- factor(as.character(d[, color_tax])) d$tax_col[is.na(d$tax_col)] <- "unidentified" @@ -99,19 +98,18 @@ plot_mt <- #' @author Adrien Taudière #' @seealso \code{\link[vegan]{specaccum}} [accu_samp_threshold()] accu_plot <- - function( - physeq, - fact = NULL, - add_nb_seq = TRUE, - step = NULL, - by.fact = FALSE, - ci_col = NULL, - col = NULL, - lwd = 3, - leg = TRUE, - print_sam_names = FALSE, - ci = 2, - ...) { + function(physeq, + fact = NULL, + add_nb_seq = TRUE, + step = NULL, + by.fact = FALSE, + ci_col = NULL, + col = NULL, + lwd = 3, + leg = TRUE, + print_sam_names = FALSE, + ci = 2, + ...) { if (!inherits(physeq, "phyloseq")) { stop("physeq must be a phyloseq object") } @@ -374,21 +372,20 @@ accu_samp_threshold <- function(res_accuplot, threshold = 0.95) { #' @seealso \code{\link[circlize]{circos.par}} circle_pq <- - function( - physeq = NULL, - fact = NULL, - taxa = "Order", - nproc = 1, - add_nb_seq = TRUE, - rarefy = FALSE, - min_prop_tax = 0.01, - min_prop_mod = 0.1, - gap_degree = NULL, - start_degree = NULL, - row_col = NULL, - grid_col = NULL, - log10trans = FALSE, - ...) { + function(physeq = NULL, + fact = NULL, + taxa = "Order", + nproc = 1, + add_nb_seq = TRUE, + rarefy = FALSE, + min_prop_tax = 0.01, + min_prop_mod = 0.1, + gap_degree = NULL, + start_degree = NULL, + row_col = NULL, + grid_col = NULL, + log10trans = FALSE, + ...) { if (!inherits(physeq, "phyloseq")) { stop("physeq must be an object of class 'phyloseq'") } @@ -573,16 +570,15 @@ circle_pq <- #' @seealso \code{\link[networkD3]{sankeyNetwork}} sankey_pq <- - function( - physeq = NULL, - fact = NULL, - taxa = 1:4, - add_nb_seq = FALSE, - min_prop_tax = 0, - tax2remove = NULL, - units = NULL, - symbol2sub = c("\\.", "-"), - ...) { + function(physeq = NULL, + fact = NULL, + taxa = 1:4, + add_nb_seq = FALSE, + min_prop_tax = 0, + tax2remove = NULL, + units = NULL, + symbol2sub = c("\\.", "-"), + ...) { if (!inherits(physeq, "phyloseq")) { stop("physeq must be an object of class 'phyloseq'") } @@ -1003,17 +999,16 @@ venn_pq <- #' @author Adrien Taudière -ggvenn_pq <- function( - physeq = NULL, - fact = NULL, - min_nb_seq = 0, - taxonomic_rank = NULL, - split_by = NULL, - add_nb_samples = TRUE, - add_nb_sequences = FALSE, - rarefy_before_merging = FALSE, - rarefy_after_merging = FALSE, - ...) { +ggvenn_pq <- function(physeq = NULL, + fact = NULL, + min_nb_seq = 0, + taxonomic_rank = NULL, + split_by = NULL, + add_nb_samples = TRUE, + add_nb_sequences = FALSE, + rarefy_before_merging = FALSE, + rarefy_after_merging = FALSE, + ...) { if (!is.factor(physeq@sam_data[[fact]])) { physeq@sam_data[[fact]] <- as.factor(physeq@sam_data[[fact]]) } @@ -1128,11 +1123,10 @@ ggvenn_pq <- function( #' @export multiplot <- - function( - ..., - plotlist = NULL, - cols = 1, - layout = NULL) { + function(..., + plotlist = NULL, + cols = 1, + layout = NULL) { # Make a list from the ... arguments and plotlist plots <- c(list(...), plotlist) @@ -1230,15 +1224,14 @@ multiplot <- #' p2 <- hill_pq(data_fungi_modif, "Height", letters = TRUE) #' hill_pq <- - function( - physeq, - variable, - color_fac = NA, - letters = FALSE, - add_points = FALSE, - add_info = TRUE, - one_plot = FALSE, - correction_for_sample_size = TRUE) { + function(physeq, + variable, + color_fac = NA, + letters = FALSE, + add_points = FALSE, + add_info = TRUE, + one_plot = FALSE, + correction_for_sample_size = TRUE) { var <- sym(variable) if (is.na(color_fac)) { color_fac <- sym(variable) @@ -1521,11 +1514,10 @@ ggbetween_pq <- function(physeq, variable, one_plot = FALSE, rarefy_by_sample = #' summary_plot_pq(data_fungi, add_info = FALSE) + scale_fill_viridis_d() #' @return A ggplot2 object #' @export -summary_plot_pq <- function( - physeq, - add_info = TRUE, - min_seq_samples = 500, - clean_pq = TRUE) { +summary_plot_pq <- function(physeq, + add_info = TRUE, + min_seq_samples = 500, + clean_pq = TRUE) { if (clean_pq) { physeq <- clean_pq(physeq) } @@ -1718,14 +1710,14 @@ summary_plot_pq <- function( #' use this function. #' @examples #' library("rotl") +#' data(data_fungi) #' tr <- rotl_pq(data_fungi, species_colnames = "Genus_species") #' plot(tr) #' tr_Asco <- rotl_pq(data_fungi, species_colnames = "Genus_species", context_name = "Ascomycetes") #' plot(tr_Asco) -rotl_pq <- function( - physeq, - species_colnames = "Genus_species", - context_name = "All life") { +rotl_pq <- function(physeq, + species_colnames = "Genus_species", + context_name = "All life") { if (length(species_colnames) == 2) { physeq@tax_table <- tax_table(cbind( physeq@tax_table, @@ -1868,30 +1860,29 @@ heat_tree_pq <- function(physeq, taxonomic_level = NULL, ...) { #' @export #' @author Adrien Taudière #' -biplot_pq <- function( - physeq, - fact = NULL, - merge_sample_by = NULL, - rarefy_after_merging = FALSE, - inverse_side = FALSE, - left_name = NULL, - left_name_col = "#4B3E1E", - left_fill = "#4B3E1E", - left_col = "#f3f2d9", - right_name = NULL, - right_name_col = "#1d2949", - right_fill = "#1d2949", - right_col = "#1d2949", - log10trans = TRUE, - nudge_y = c(0.3, 0.3), - geom_label = FALSE, - text_size = 3, - size_names = 5, - y_names = NA, - ylim_modif = c(1, 1), - nb_samples_info = TRUE, - plotly_version = FALSE, - ...) { +biplot_pq <- function(physeq, + fact = NULL, + merge_sample_by = NULL, + rarefy_after_merging = FALSE, + inverse_side = FALSE, + left_name = NULL, + left_name_col = "#4B3E1E", + left_fill = "#4B3E1E", + left_col = "#f3f2d9", + right_name = NULL, + right_name_col = "#1d2949", + right_fill = "#1d2949", + right_col = "#1d2949", + log10trans = TRUE, + nudge_y = c(0.3, 0.3), + geom_label = FALSE, + text_size = 3, + size_names = 5, + y_names = NA, + ylim_modif = c(1, 1), + nb_samples_info = TRUE, + plotly_version = FALSE, + ...) { if (!is.null(merge_sample_by)) { if (nb_samples_info) { modality_1_nb <- table(physeq@sam_data[, merge_sample_by])[1] @@ -2121,12 +2112,11 @@ biplot_pq <- function( #' lapply(p, print) #' #' @author Adrien Taudière -multi_biplot_pq <- function( - physeq, - split_by = NULL, - pairs = NULL, - na_remove = TRUE, - ...) { +multi_biplot_pq <- function(physeq, + split_by = NULL, + pairs = NULL, + na_remove = TRUE, + ...) { if (is.null(pairs) && is.null(split_by)) { stop("You must set one of split_by or pairs.") } else if (!is.null(pairs) && !is.null(split_by)) { @@ -2235,20 +2225,19 @@ multi_biplot_pq <- function( #' clean_pq = FALSE #' ) plot_tax_pq <- - function( - physeq, - fact = NULL, - merge_sample_by = NULL, - type = "nb_seq", - taxa_fill = "Order", - print_values = TRUE, - color_border = "lightgrey", - linewidth = 0.1, - prop_print_value = 0.01, - nb_print_value = NULL, - add_info = TRUE, - na_remove = TRUE, - clean_pq = TRUE) { + function(physeq, + fact = NULL, + merge_sample_by = NULL, + type = "nb_seq", + taxa_fill = "Order", + print_values = TRUE, + color_border = "lightgrey", + linewidth = 0.1, + prop_print_value = 0.01, + nb_print_value = NULL, + add_info = TRUE, + na_remove = TRUE, + clean_pq = TRUE) { if (na_remove) { new_physeq <- subset_samples_pq(physeq, !is.na(physeq@sam_data[[fact]])) if (nsamples(physeq) - nsamples(new_physeq) > 0) { @@ -2389,19 +2378,19 @@ plot_tax_pq <- #' #' @author Adrien Taudière #' @examples +#' data(data_fungi_sp_known) #' multitax_bar_pq(data_fungi_sp_known, "Phylum", "Class", "Order", "Time") #' multitax_bar_pq(data_fungi_sp_known, "Phylum", "Class", "Order") #' multitax_bar_pq(data_fungi_sp_known, "Phylum", "Class", "Order", #' nb_seq = FALSE, log10trans = FALSE #' ) -multitax_bar_pq <- function( - physeq, - lvl1, - lvl2, - lvl3, - fact = NULL, - nb_seq = TRUE, - log10trans = TRUE) { +multitax_bar_pq <- function(physeq, + lvl1, + lvl2, + lvl3, + fact = NULL, + nb_seq = TRUE, + log10trans = TRUE) { if (!nb_seq) { physeq <- as_binary_otu_table(physeq) } @@ -2477,13 +2466,12 @@ multitax_bar_pq <- function( #' data(data_fungi) #' res_tsne <- tsne_pq(data_fungi) tsne_pq <- - function( - physeq, - method = "bray", - dims = 2, - theta = 0.0, - perplexity = 30, - ...) { + function(physeq, + method = "bray", + dims = 2, + theta = 0.0, + perplexity = 30, + ...) { physeq <- clean_pq( physeq, force_taxa_as_rows = TRUE, @@ -2534,21 +2522,21 @@ tsne_pq <- #' @author Adrien Taudière #' #' @examples +#' data(data_fungi) #' plot_tsne_pq(data_fungi, fact = "Height", perplexity = 15) #' plot_tsne_pq(data_fungi, fact = "Time") + geom_label(aes(label = Sample_id, fill = Time)) #' plot_tsne_pq(data_fungi, fact = "Time", na_remove = FALSE, force_factor = FALSE) -plot_tsne_pq <- function( - physeq, - method = "bray", - dims = 2, - theta = 0.0, - perplexity = 30, - fact = NA, - ellipse_level = 0.95, - plot_dims = c(1, 2), - na_remove = TRUE, - force_factor = TRUE, - ...) { +plot_tsne_pq <- function(physeq, + method = "bray", + dims = 2, + theta = 0.0, + perplexity = 30, + fact = NA, + ellipse_level = 0.95, + plot_dims = c(1, 2), + na_remove = TRUE, + force_factor = TRUE, + ...) { if (!is.factor(physeq@sam_data[[fact]]) && !is.na(fact) && force_factor) { physeq@sam_data[[fact]] <- as.factor(physeq@sam_data[[fact]]) @@ -2663,7 +2651,7 @@ SRS_curve_pq <- function(physeq, clean_pq = FALSE, ...) { #' rowSums(is.na(GPsubset@tax_table)) == 0 #' ) #' GPsubset@sam_data$human <- GPsubset@sam_data$SampleType %in% -#' c("Skin", "Feces", "Tong") +#' c("Skin", "Feces", "Tong") #' res_iNEXT <- iNEXT_pq( #' GPsubset, #' merge_sample_by = "human", @@ -2825,15 +2813,14 @@ iNEXT_pq <- function(physeq, merge_sample_by = NULL, ...) { #' data_fungi2@sam_data[["Height__Time_0"]][grepl("NA", data_fungi2@sam_data[["Height__Time_0"]])] <- #' NA #' upset_pq(data_fungi2, fact = "Height__Time_0", width_ratio = 0.2, min_size = 2) -upset_pq <- function( - physeq, - fact, - taxa_fill = NULL, - min_nb_seq = 0, - na_remove = TRUE, - numeric_fonction = sum, - rarefy_after_merging = FALSE, - ...) { +upset_pq <- function(physeq, + fact, + taxa_fill = NULL, + min_nb_seq = 0, + na_remove = TRUE, + numeric_fonction = sum, + rarefy_after_merging = FALSE, + ...) { if (!is.null(min_nb_seq)) { physeq <- subset_taxa_pq(physeq, taxa_sums(physeq) >= min_nb_seq) } @@ -2909,18 +2896,18 @@ upset_pq <- function( #' #' @seealso [upset_pq()] #' @examples +#' data(data_fungi) #' upset_test_pq(data_fungi, "Height", var_to_test = c("OTU", "Class", "Guild")) #' upset_test_pq(data_fungi, "Time") #' upset_test_pq <- - function( - physeq, - fact, - var_to_test = "OTU", - min_nb_seq = 0, - na_remove = TRUE, - numeric_fonction = sum, - ...) { + function(physeq, + fact, + var_to_test = "OTU", + min_nb_seq = 0, + na_remove = TRUE, + numeric_fonction = sum, + ...) { if (!is.null(min_nb_seq)) { physeq <- subset_taxa_pq(physeq, taxa_sums(physeq) >= min_nb_seq) } @@ -3027,12 +3014,11 @@ upset_test_pq <- #' ) #' @author Adrien Taudière diff_fct_diff_class <- - function( - x, - numeric_fonction = mean, - logical_method = "TRUE_if_one", - character_method = "unique_or_na", - ...) { + function(x, + numeric_fonction = mean, + logical_method = "TRUE_if_one", + character_method = "unique_or_na", + ...) { if (is.character(x) || is.factor(x)) { if (length(unique(x)) == 1) { return(unique(x)) @@ -3155,6 +3141,7 @@ tax_bar_pq <- function(physeq, fact = "Sample", taxa = "Order", percent_bar = FA #' @author Adrien Taudière #' @examples #' data(data_fungi) +#' data(data_fungi_sp_known) #' ridges_pq(data_fungi, "Time", alpha = 0.5, log10trans = FALSE) + xlim(c(0, 1000)) #' ridges_pq(data_fungi, "Time", alpha = 0.5) #' ridges_pq( @@ -3173,12 +3160,11 @@ tax_bar_pq <- function(physeq, fact = "Sample", taxa = "Order", percent_bar = FA #' scale = 0.8 #' ) #' ridges_pq(data_fungi, "Height", alpha = 0.5, log10trans = TRUE) -ridges_pq <- function( - physeq, - fact, - nb_seq = TRUE, - log10trans = TRUE, - ...) { +ridges_pq <- function(physeq, + fact, + nb_seq = TRUE, + log10trans = TRUE, + ...) { psm <- psmelt(physeq) psm <- psm %>% filter(Abundance > 0) @@ -3259,14 +3245,13 @@ ridges_pq <- function( #' "Order", "Class", #' nb_seq = FALSE, log10trans = FALSE #' ) -treemap_pq <- function( - physeq, - lvl1, - lvl2, - nb_seq = TRUE, - log10trans = TRUE, - plot_legend = FALSE, - ...) { +treemap_pq <- function(physeq, + lvl1, + lvl2, + nb_seq = TRUE, + log10trans = TRUE, + plot_legend = FALSE, + ...) { if (!nb_seq) { physeq <- as_binary_otu_table(physeq) } diff --git a/R/speedyseq_functions.R b/R/speedyseq_functions.R index e73707b7..a0414a40 100644 --- a/R/speedyseq_functions.R +++ b/R/speedyseq_functions.R @@ -49,11 +49,10 @@ #' @author Michael R. McLaren (orcid: [0000-0003-1575-473X](https://orcid.org/0000-0003-1575-473X)) modified by Adrien Taudiere setGeneric( "merge_taxa_vec", - function( - x, - group, - reorder = FALSE, - tax_adjust = 1L) { + function(x, + group, + reorder = FALSE, + tax_adjust = 1L) { standardGeneric("merge_taxa_vec") } ) @@ -349,12 +348,11 @@ bad_flush_right <- function(x, bad = "BAD", na_bad = FALSE, k = length(x)) { #' @author Michael R. McLaren (orcid: [0000-0003-1575-473X](https://orcid.org/0000-0003-1575-473X)) modified by Adrien Taudiere setGeneric( "merge_samples2", - function( - x, - group, - fun_otu = sum, - funs = list(), - reorder = FALSE) { + function(x, + group, + fun_otu = sum, + funs = list(), + reorder = FALSE) { standardGeneric("merge_samples2") } ) @@ -577,10 +575,12 @@ merge_groups <- function(x, group, f = unique_or_na) { #' @keywords internal #' #' @examples +#' \dontrun{ #' x <- data.frame(var1 = letters[1:3], var2 = 7:9) #' rownames(x) #' sample_data(x) #' sample_data_stable(x) +#' } #' @author Michael R. McLaren (orcid: [0000-0003-1575-473X](https://orcid.org/0000-0003-1575-473X)) sample_data_stable <- function(object) { # Modified from phyloseq's sample_data data.frame method; see diff --git a/R/table_functions.R b/R/table_functions.R index be8bcaf3..42372531 100644 --- a/R/table_functions.R +++ b/R/table_functions.R @@ -26,12 +26,11 @@ #' tax_datatable(GlobalPatterns, #' modality = GlobalPatterns@sam_data$SampleType #' ) -tax_datatable <- function( - physeq, - abundance = TRUE, - taxonomic_level = NULL, - modality = NULL, - ...) { +tax_datatable <- function(physeq, + abundance = TRUE, + taxonomic_level = NULL, + modality = NULL, + ...) { df <- as.data.frame(unclass(physeq@tax_table)) if (!is.null(taxonomic_level)) { @@ -122,14 +121,13 @@ tax_datatable <- function( #' bifactor = "Height", #' merge_sample_by = "Height", modality = "Time" #' ) -compare_pairs_pq <- function( - physeq = NULL, - bifactor = NULL, - modality = NULL, - merge_sample_by = NULL, - nb_min_seq = 0, - veg_index = "shannon", - na_remove = TRUE) { +compare_pairs_pq <- function(physeq = NULL, + bifactor = NULL, + modality = NULL, + merge_sample_by = NULL, + nb_min_seq = 0, + veg_index = "shannon", + na_remove = TRUE) { physeq <- clean_pq(physeq, clean_samples_names = FALSE, force_taxa_as_columns = TRUE, diff --git a/R/targets_misc.R b/R/targets_misc.R index 4c2eafd4..06d6cc10 100644 --- a/R/targets_misc.R +++ b/R/targets_misc.R @@ -21,13 +21,12 @@ #' @author Adrien Taudière list_fastq_files <- - function( - path, - paired_end = TRUE, - pattern = "fastq", - pattern_R1 = "_R1_", - pattern_R2 = "_R2_", - nb_files = Inf) { + function(path, + paired_end = TRUE, + pattern = "fastq", + pattern_R1 = "_R1_", + pattern_R2 = "_R2_", + nb_files = Inf) { list_files <- list.files(path, pattern = pattern, full.names = TRUE) if (paired_end) { fnfs <- sort(list_files[grepl(list_files, pattern = pattern_R1)]) diff --git a/R/tuckeyTest.R b/R/tuckeyTest.R index fec61c9e..30b3644a 100644 --- a/R/tuckeyTest.R +++ b/R/tuckeyTest.R @@ -22,7 +22,8 @@ #' GlobalPatterns@sam_data[, "Soil_logical"] <- #' ifelse(GlobalPatterns@sam_data[, "SampleType"] == "Soil", "Soil", "Not Soil") #' hill_tuckey_pq(GlobalPatterns, "Soil_logical") -hill_tuckey_pq <- function(physeq, +hill_tuckey_pq <- function( + physeq, modality, silent = TRUE, correction_for_sample_size = TRUE) { diff --git a/man/add_new_taxonomy_pq.Rd b/man/add_new_taxonomy_pq.Rd index 66868864..b5d740c8 100644 --- a/man/add_new_taxonomy_pq.Rd +++ b/man/add_new_taxonomy_pq.Rd @@ -27,10 +27,6 @@ a physeq object with a larger slot tax_table One of main use of this function is to add taxonomic assignment from a new database. -} -\examples{ -# example code - } \author{ Adrien Taudière diff --git a/man/iNEXT_pq.Rd b/man/iNEXT_pq.Rd index 96678471..e37660a3 100644 --- a/man/iNEXT_pq.Rd +++ b/man/iNEXT_pq.Rd @@ -39,7 +39,7 @@ GPsubset <- subset_taxa( rowSums(is.na(GPsubset@tax_table)) == 0 ) GPsubset@sam_data$human <- GPsubset@sam_data$SampleType \%in\% - c("Skin", "Feces", "Tong") + c("Skin", "Feces", "Tong") res_iNEXT <- iNEXT_pq( GPsubset, merge_sample_by = "human", diff --git a/man/multipatt_pq.Rd b/man/multipatt_pq.Rd index f76dc30d..c87b3a9b 100644 --- a/man/multipatt_pq.Rd +++ b/man/multipatt_pq.Rd @@ -44,6 +44,7 @@ Please make a reference to \code{indicspecies::multipatt()} if you use this function. } \examples{ +data(data_fungi) data_fungi_ab <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 10000) multipatt_pq(subset_samples(data_fungi_ab, !is.na(Time)), fact = "Time") multipatt_pq(subset_samples(data_fungi_ab, !is.na(Time)), diff --git a/man/multitax_bar_pq.Rd b/man/multitax_bar_pq.Rd index 0721dcff..b2b62b0c 100644 --- a/man/multitax_bar_pq.Rd +++ b/man/multitax_bar_pq.Rd @@ -46,6 +46,7 @@ Note that lvl3need to be nested in lvl2 which need to be nested in lvl1 } \examples{ +data(data_fungi_sp_known) multitax_bar_pq(data_fungi_sp_known, "Phylum", "Class", "Order", "Time") multitax_bar_pq(data_fungi_sp_known, "Phylum", "Class", "Order") multitax_bar_pq(data_fungi_sp_known, "Phylum", "Class", "Order", diff --git a/man/plot_LCBD_pq.Rd b/man/plot_LCBD_pq.Rd index 87f2e9d4..e2b3df05 100644 --- a/man/plot_LCBD_pq.Rd +++ b/man/plot_LCBD_pq.Rd @@ -45,6 +45,7 @@ Please make a reference to \code{vegan::beta.div()} if you use this function. } \examples{ +data(data_fungi) plot_LCBD_pq(data_fungi, nperm = 100, only_plot_significant = FALSE, pval = 0.2 diff --git a/man/plot_SCBD_pq.Rd b/man/plot_SCBD_pq.Rd index 699fffab..99684268 100644 --- a/man/plot_SCBD_pq.Rd +++ b/man/plot_SCBD_pq.Rd @@ -40,6 +40,7 @@ Please make a reference to \code{vegan::beta.div()} if you use this function. } \examples{ +data(data_fungi) plot_SCBD_pq(data_fungi) + geom_text(aes(label = paste(Genus, Species)), hjust = 1, vjust = 2) + xlim(c(0, NA)) diff --git a/man/plot_tsne_pq.Rd b/man/plot_tsne_pq.Rd index 8424c195..5e15e9ec 100644 --- a/man/plot_tsne_pq.Rd +++ b/man/plot_tsne_pq.Rd @@ -52,6 +52,7 @@ A ggplot object Partially inspired by \code{phylosmith::tsne_phyloseq()} function developed by Schuyler D. Smith. } \examples{ +data(data_fungi) plot_tsne_pq(data_fungi, fact = "Height", perplexity = 15) plot_tsne_pq(data_fungi, fact = "Time") + geom_label(aes(label = Sample_id, fill = Time)) plot_tsne_pq(data_fungi, fact = "Time", na_remove = FALSE, force_factor = FALSE) diff --git a/man/ridges_pq.Rd b/man/ridges_pq.Rd index c2ae345d..83818aff 100644 --- a/man/ridges_pq.Rd +++ b/man/ridges_pq.Rd @@ -32,6 +32,7 @@ taxonomic groups } \examples{ data(data_fungi) +data(data_fungi_sp_known) ridges_pq(data_fungi, "Time", alpha = 0.5, log10trans = FALSE) + xlim(c(0, 1000)) ridges_pq(data_fungi, "Time", alpha = 0.5) ridges_pq( diff --git a/man/rotl_pq.Rd b/man/rotl_pq.Rd index dfce860d..93206e20 100644 --- a/man/rotl_pq.Rd +++ b/man/rotl_pq.Rd @@ -32,6 +32,7 @@ use this function. } \examples{ library("rotl") +data(data_fungi) tr <- rotl_pq(data_fungi, species_colnames = "Genus_species") plot(tr) tr_Asco <- rotl_pq(data_fungi, species_colnames = "Genus_species", context_name = "Ascomycetes") diff --git a/man/sample_data_stable.Rd b/man/sample_data_stable.Rd index cb897110..39171112 100644 --- a/man/sample_data_stable.Rd +++ b/man/sample_data_stable.Rd @@ -15,11 +15,13 @@ they are \code{as.character(seq(1, row(object)))}. This function instead keeps t names as is. } \examples{ +\dontrun{ x <- data.frame(var1 = letters[1:3], var2 = 7:9) rownames(x) sample_data(x) sample_data_stable(x) } +} \author{ Michael R. McLaren (orcid: \href{https://orcid.org/0000-0003-1575-473X}{0000-0003-1575-473X}) } diff --git a/man/tbl_sum_samdata.Rd b/man/tbl_sum_samdata.Rd index 04a4bd3f..d31a0ba0 100644 --- a/man/tbl_sum_samdata.Rd +++ b/man/tbl_sum_samdata.Rd @@ -31,6 +31,7 @@ Please make a reference to \code{gtsummary::tbl_summary()} if you use this function. } \examples{ +data(data_fungi) tbl_sum_samdata(data_fungi) \%>\% gtsummary::as_kable() diff --git a/man/upset_test_pq.Rd b/man/upset_test_pq.Rd index 6e6b0a2e..4ab9ea2f 100644 --- a/man/upset_test_pq.Rd +++ b/man/upset_test_pq.Rd @@ -44,6 +44,7 @@ A \code{\link{ggplot}}2 plot \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} } \examples{ +data(data_fungi) upset_test_pq(data_fungi, "Height", var_to_test = c("OTU", "Class", "Guild")) upset_test_pq(data_fungi, "Time") From 6ba6d93a6e2e9027c90efb1a0f7a3c4bfd63b37c Mon Sep 17 00:00:00 2001 From: adrientaudiere Date: Thu, 28 Dec 2023 14:30:49 +0100 Subject: [PATCH 5/6] Minor bugs fix to pass R CMD CHECK --- .github/workflows/R-CMD-check.yaml | 2 ++ .github/workflows/pkgdown.yaml | 2 ++ .github/workflows/test-coverage.yaml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 73f5446e..48f96133 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,6 +1,8 @@ # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: + push: + branches: [main, master] pull_request: branches: [main, master] diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 8c6d2b6d..b56b44af 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -1,6 +1,8 @@ # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: + push: + branches: [main, master] pull_request: branches: [main, master] workflow_dispatch: diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index f66aafae..bef8175e 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -1,6 +1,8 @@ # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: + push: + branches: [main, master] pull_request: branches: [main, master] From d2d17ec50f69b2f9c207f6f0f18e2c7bccd35e4d Mon Sep 17 00:00:00 2001 From: adrientaudiere Date: Thu, 28 Dec 2023 15:29:40 +0100 Subject: [PATCH 6/6] fix: put dontrun un iNEXT example --- .github/workflows/R-CMD-check.yaml | 2 -- .github/workflows/test-coverage.yaml | 2 -- R/plot_functions.R | 54 ++++++++++++++-------------- man/iNEXT_pq.Rd | 54 ++++++++++++++-------------- 4 files changed, 56 insertions(+), 56 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 48f96133..73f5446e 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,8 +1,6 @@ # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: - push: - branches: [main, master] pull_request: branches: [main, master] diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index bef8175e..f66aafae 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -1,8 +1,6 @@ # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: - push: - branches: [main, master] pull_request: branches: [main, master] diff --git a/R/plot_functions.R b/R/plot_functions.R index 1298f580..cbc88169 100644 --- a/R/plot_functions.R +++ b/R/plot_functions.R @@ -2636,32 +2636,34 @@ SRS_curve_pq <- function(physeq, clean_pq = FALSE, ...) { #' @export #' #' @examples -#' library("iNEXT") -#' data("GlobalPatterns", package = "phyloseq") -#' GPsubset <- subset_taxa( -#' GlobalPatterns, -#' GlobalPatterns@tax_table[, 1] == "Bacteria" -#' ) -#' GPsubset <- subset_taxa( -#' GPsubset, -#' rowSums(GPsubset@otu_table) > 1000 -#' ) -#' GPsubset <- subset_taxa( -#' GPsubset, -#' rowSums(is.na(GPsubset@tax_table)) == 0 -#' ) -#' GPsubset@sam_data$human <- GPsubset@sam_data$SampleType %in% -#' c("Skin", "Feces", "Tong") -#' res_iNEXT <- iNEXT_pq( -#' GPsubset, -#' merge_sample_by = "human", -#' q = 1, -#' datatype = "abundance", -#' nboot = 2 -#' ) -#' ggiNEXT(res_iNEXT) -#' ggiNEXT(res_iNEXT, type = 2) -#' ggiNEXT(res_iNEXT, type = 3) +#' \dontrun{ +#' library("iNEXT") +#' data("GlobalPatterns", package = "phyloseq") +#' GPsubset <- subset_taxa( +#' GlobalPatterns, +#' GlobalPatterns@tax_table[, 1] == "Bacteria" +#' ) +#' GPsubset <- subset_taxa( +#' GPsubset, +#' rowSums(GPsubset@otu_table) > 5000 +#' ) +#' GPsubset <- subset_taxa( +#' GPsubset, +#' rowSums(is.na(GPsubset@tax_table)) == 0 +#' ) +#' GPsubset@sam_data$human <- GPsubset@sam_data$SampleType %in% +#' c("Skin", "Feces", "Tong") +#' res_iNEXT <- iNEXT_pq( +#' GPsubset, +#' merge_sample_by = "human", +#' q = 1, +#' datatype = "abundance", +#' nboot = 2 +#' ) +#' ggiNEXT(res_iNEXT) +#' ggiNEXT(res_iNEXT, type = 2) +#' ggiNEXT(res_iNEXT, type = 3) +#' } #' @author Adrien Taudière #' #' diff --git a/man/iNEXT_pq.Rd b/man/iNEXT_pq.Rd index e37660a3..f48edc79 100644 --- a/man/iNEXT_pq.Rd +++ b/man/iNEXT_pq.Rd @@ -24,32 +24,34 @@ see \code{\link[iNEXT:iNEXT]{iNEXT::iNEXT()}} documentation \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} } \examples{ -library("iNEXT") -data("GlobalPatterns", package = "phyloseq") -GPsubset <- subset_taxa( - GlobalPatterns, - GlobalPatterns@tax_table[, 1] == "Bacteria" -) -GPsubset <- subset_taxa( - GPsubset, - rowSums(GPsubset@otu_table) > 1000 -) -GPsubset <- subset_taxa( - GPsubset, - rowSums(is.na(GPsubset@tax_table)) == 0 -) -GPsubset@sam_data$human <- GPsubset@sam_data$SampleType \%in\% - c("Skin", "Feces", "Tong") -res_iNEXT <- iNEXT_pq( - GPsubset, - merge_sample_by = "human", - q = 1, - datatype = "abundance", - nboot = 2 -) -ggiNEXT(res_iNEXT) -ggiNEXT(res_iNEXT, type = 2) -ggiNEXT(res_iNEXT, type = 3) +\dontrun{ + library("iNEXT") + data("GlobalPatterns", package = "phyloseq") + GPsubset <- subset_taxa( + GlobalPatterns, + GlobalPatterns@tax_table[, 1] == "Bacteria" + ) + GPsubset <- subset_taxa( + GPsubset, + rowSums(GPsubset@otu_table) > 5000 + ) + GPsubset <- subset_taxa( + GPsubset, + rowSums(is.na(GPsubset@tax_table)) == 0 + ) + GPsubset@sam_data$human <- GPsubset@sam_data$SampleType \%in\% + c("Skin", "Feces", "Tong") + res_iNEXT <- iNEXT_pq( + GPsubset, + merge_sample_by = "human", + q = 1, + datatype = "abundance", + nboot = 2 + ) + ggiNEXT(res_iNEXT) + ggiNEXT(res_iNEXT, type = 2) + ggiNEXT(res_iNEXT, type = 3) +} } \author{ Adrien Taudière