Skip to content

Commit

Permalink
Merge pull request #79 from adrientaudiere/dev
Browse files Browse the repository at this point in the history
v0.7.3 for submission to CRAN
  • Loading branch information
adrientaudiere authored Feb 7, 2024
2 parents 4cf7b3f + 673fcf4 commit e81237d
Show file tree
Hide file tree
Showing 42 changed files with 250 additions and 1,811 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
^.vscode$
^citation.cff$
^vignettes/articles$
^cran-comments\.md$
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: MiscMetabar
Type: Package
Title: Miscellaneous Functions for Metabarcoding Analysis
Version: 0.7.2
Version: 0.7.3
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.
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export(clean_physeq)
export(clean_pq)
export(compare_pairs_pq)
export(count_seq)
export(cutadapt_remove_primers)
export(diff_fct_diff_class)
export(dist_bycol)
export(dist_pos_control)
Expand Down
1 change: 1 addition & 0 deletions R/MiscMetabar-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ if (getRversion() >= "2.15.1") {
}

#' @keywords internal
#' @noRd
"_PACKAGE"

## usethis namespace: start
Expand Down
18 changes: 9 additions & 9 deletions R/beta_div_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -590,15 +590,15 @@ multipatt_pq <- function(physeq,
#' geom_point()
#'
#' res_time <- ancombc_pq(
#' subset_taxa_pq(
#' data_fungi_sp_known,
#' taxa_sums(data_fungi_sp_known) > 5000
#' ),
#' fact = "Time",
#' levels_fact = c("0", "15"),
#' tax_level = "Family",
#' verbose = TRUE
#' )
#' subset_taxa_pq(
#' data_fungi_sp_known,
#' taxa_sums(data_fungi_sp_known) > 5000
#' ),
#' fact = "Time",
#' levels_fact = c("0", "15"),
#' tax_level = "Family",
#' verbose = TRUE
#' )
#' @author Adrien Taudière
#' @details
#' This function is mainly a wrapper of the work of others.
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{
#'
#'
#' 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
#'
#'
#'
#' subset_taxa_tax_control(data_fungi,
#' as.numeric(data_fungi@otu_table[, 300]),
Expand Down
70 changes: 37 additions & 33 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
#'
#'
#' 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 @@ -490,14 +490,14 @@ track_wkflow_samples <- function(list_pq_obj, ...) {
#' @param tax_adjust (Default 0) See the man page
#' of [merge_taxa_vec()] for more details.
#' To conserved the taxonomic rank of the most abundant ASV,
#' set tax_adjust to 0 (default). For the moment only tax_adjust = 0 is
#' set tax_adjust to 0 (default). For the moment only tax_adjust = 0 is
#' robust
#' @param vsearch_cluster_method (default: "--cluster_size) See other possible
#' methods in the [vsearch pdf manual](https://github.com/torognes/vsearch/releases/download/v2.23.0/vsearch_manual.pdf) (e.g. `--cluster_size` or `--cluster_smallmem`)
#' - `--cluster_fast` : Clusterize the fasta sequences in filename, automatically sort by decreasing sequence length beforehand.
#' - `--cluster_size` : Clusterize the fasta sequences in filename, automatically sort by decreasing sequence abundance beforehand.
#' - `--cluster_smallmem` : Clusterize the fasta sequences in filename without automatically modifying their order beforehand. Sequence are expected to be sorted by decreasing sequence length, unless *--usersort* is used.
#' In that case you may set `vsearch_args` to vsearch_args = "--strand both --usersort"
#' In that case you may set `vsearch_args` to vsearch_args = "--strand both --usersort"
#' @param vsearch_args (default : "--strand both") a one length character element defining other parameters to
#' passed on to vsearch.
#' @param keep_temporary_files (logical, default: FALSE) Do we keep temporary files
Expand All @@ -511,6 +511,7 @@ track_wkflow_samples <- function(list_pq_obj, ...) {
#' @param swarm_args (default : "--fastidious") a one length character
#' element defining other parameters to passed on to swarm See other possible
#' methods in the [SWARM pdf manual](https://github.com/torognes/swarm/blob/master/man/swarm_manual.pdf)
#' @param method_clusterize (default "overlap") the method for the [DECIPHER::Clusterize()] method
#' @param ... Others arguments passed on to [DECIPHER::Clusterize()]
#' @details This function use the `merge_taxa_vec` function to
#' merge taxa into clusters. By default tax_adjust = 0. See the man page
Expand Down Expand Up @@ -539,8 +540,9 @@ asv2otu <- function(physeq = NULL,
vsearch_args = "--strand both",
keep_temporary_files = FALSE,
swarmpath = "swarm",
d = 1,
swarm_args = "--fastidious",
d = 1,
swarm_args = "--fastidious",
method_clusterize = "overlap",
...) {
if (inherits(physeq, "phyloseq")) {
verify_pq(physeq)
Expand All @@ -566,6 +568,7 @@ asv2otu <- function(physeq = NULL,
cutoff = 1 - id,
# e.g. `cutoff = 0.03` for a 97% OTU
processors = nproc,
method = method_clusterize,
...
)

Expand Down Expand Up @@ -597,15 +600,15 @@ asv2otu <- function(physeq = NULL,
)
} else if (method == "swarm") {
new_obj <- swarm_clustering(
physeq = physeq,
dna_seq = dna_seq,
d = d,
swarmpath = swarmpath,
vsearch_path = vsearchpath,
nproc = nproc,
swarm_args = swarm_args,
tax_adjust = tax_adjust,
keep_temporary_files = keep_temporary_files
physeq = physeq,
dna_seq = dna_seq,
d = d,
swarmpath = swarmpath,
vsearch_path = vsearchpath,
nproc = nproc,
swarm_args = swarm_args,
tax_adjust = tax_adjust,
keep_temporary_files = keep_temporary_files
)
} else {
stop("Method allows 2 values only : `clusterize`, `vsearch` or `swarm`")
Expand Down Expand Up @@ -650,7 +653,7 @@ asv2otu <- function(physeq = NULL,
#' @export
#' @author Adrien Taudière
#' @examples
#'
#'
#' # write_pq(data_fungi, path = "phyloseq")
#' # write_pq(data_fungi, path = "phyloseq", one_file = TRUE)
#' @seealso [MiscMetabar::save_pq()]
Expand Down Expand Up @@ -857,7 +860,7 @@ write_pq <- function(physeq,
#' @author Adrien Taudière
#' @examples
#' \dontrun{
#'
#'
#' save_pq(data_fungi, path = "phyloseq")
#' }
#' @seealso [MiscMetabar::write_pq()]
Expand Down Expand Up @@ -1375,7 +1378,7 @@ verify_pq <- function(
#' the number of samples
#'
#' @examples
#'
#'
#' cond_samp <- grepl("A1", data_fungi@sam_data[["Sample_names"]])
#' subset_samples_pq(data_fungi, cond_samp)
#'
Expand Down Expand Up @@ -1429,7 +1432,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
#'
#'
#' subset_taxa_pq(data_fungi, data_fungi@tax_table[, "Phylum"] == "Ascomycota")
#'
#' cond_taxa <- grepl("Endophyte", data_fungi@tax_table[, "Guild"])
Expand Down Expand Up @@ -1534,7 +1537,7 @@ subset_taxa_pq <- function(physeq,
#' @author Adrien Taudière
#'
#' @examples
#'
#'
#' 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 @@ -1670,7 +1673,8 @@ tbl_sum_samdata <- function(physeq, remove_col_unique_value = TRUE, ...) {
#' @description
#' `r lifecycle::badge("experimental")`
#'
#' Please cite this [publication](https://doi.org/10.1016/j.funeco.2015.06.006).
#' Please cite Nguyen et al. 2016 (\doi{doi:10.1016/j.funeco.2015.06.006})
#'
#'
#' @inheritParams clean_pq
#' @param taxLevels Name of the 7 columns in tax_table required by funguild
Expand All @@ -1680,7 +1684,7 @@ 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,
Expand Down Expand Up @@ -1749,7 +1753,7 @@ add_funguild_info <- function(physeq,
#' @author Adrien Taudière
#' @examples
#' \dontrun{
#'
#'
#' df <- subset_taxa_pq(data_fungi, taxa_sums(data_fungi) > 5000)
#' df <- add_funguild_info(df,
#' taxLevels = c(
Expand Down Expand Up @@ -1873,7 +1877,7 @@ plot_guild_pq <-
#' This function build tree phylogenetic tree and if nb_bootstrap is
#' set, it build also the 3 corresponding bootstrapped tree.
#'
#' Default parameters are based on https://doi.org/10.12688/f1000research.8986.2
#' Default parameters are based on \doi{doi:10.12688/f1000research.8986.2}
#' and phangorn vignette [Estimating phylogenetic trees with phangorn](https://klausvigo.github.io/phangorn/articles/Trees.html). You should understand your data, especially the markers,
#' before using this function.
#'
Expand Down Expand Up @@ -1912,7 +1916,7 @@ plot_guild_pq <-
#' use this function.
#' @examples
#' library("phangorn")
#'
#'
#' 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 @@ -2049,7 +2053,7 @@ build_phytree_pq <- function(physeq,
#' @author Adrien Taudière
#' @importFrom stats kruskal.test
#' @examples
#'
#'
#' 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 @@ -2087,7 +2091,7 @@ are_modality_even_depth <- function(physeq, fact, boxplot = FALSE) {
#' @export
#' @author Adrien Taudière
#' @examples
#'
#'
#' 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 @@ -2159,7 +2163,7 @@ reorder_taxa_pq <- function(physeq, names_ordered, remove_phy_tree = FALSE) {
#' @export
#'
#' @examples
#'
#'
#' 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 @@ -2218,7 +2222,7 @@ add_info_to_sam_data <- function(physeq,
#' @export
#'
#' @examples
#'
#'
#' dna <- physeq_or_string_to_dna(data_fungi)
#' dna
#'
Expand Down Expand Up @@ -2290,10 +2294,9 @@ physeq_or_string_to_dna <- function(physeq = NULL,
#' `r lifecycle::badge("experimental")`
#'
#' @return a list of command and
#'
#' @export
#' @author Adrien Taudière
#'
#'
#' @examples
#' \dontrun{
#' cutadapt_remove_primers("inst/extdata", "TTC", "GAA",
Expand Down Expand Up @@ -2327,7 +2330,7 @@ physeq_or_string_to_dna <- function(physeq = NULL,
#' }
#' @details
#' This function is mainly a wrapper of the work of others.
#' Please cite [cutadapt](http://doi.org/10.14806/ej.17.1.200).
#' Please cite cutadapt (\doi{doi:10.14806/ej.17.1.200}).


cutadapt_remove_primers <- function(path_to_fastq,
Expand Down Expand Up @@ -2412,9 +2415,10 @@ cutadapt_remove_primers <- function(path_to_fastq,
}
}
if (cmd_is_run) {
writeLines(unlist(cmd), paste0(tempdir(), "script_cutadapt.sh"))
system2("bash", paste0(tempdir(), "script_cutadapt.sh"))
writeLines(unlist(cmd), paste0(tempdir(), "/script_cutadapt.sh"))
system2("bash", paste0(tempdir(), "/script_cutadapt.sh"))
message(paste0("Output files are available in the folder ", normalizePath(folder_output)))
unlink(paste0(tempdir(), "/script_cutadapt.sh"))
}
return(cmd)
}
Expand Down
Loading

0 comments on commit e81237d

Please sign in to comment.