Skip to content

Commit

Permalink
Merge pull request #85 from adrientaudiere/dev
Browse files Browse the repository at this point in the history
V0.7.7 getting closer to CRAN
  • Loading branch information
adrientaudiere committed Feb 13, 2024
2 parents ad104f3 + 59ecb78 commit 295ebee
Show file tree
Hide file tree
Showing 69 changed files with 294 additions and 125 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Package: MiscMetabar
Type: Package
Title: Miscellaneous Functions for Metabarcoding Analysis
Version: 0.7.5
Version: 0.7.7
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 powerful by integrating a large number of analysis, some of them from other R packages.
Description: The MiscMetabar package aims to facilitate the description, transformation, exploration, and reproducibility of metabarcoding analysis. Mainly build on the top of phyloseq, dada2 R packages. MiscMetabar help to build reproducible and robust bioinformatics pipelines in R. MiscMetabar make ecological analysis of alpha and beta-diversity simple and powerful by integrating a large number of analysis, some of them from other R packages.
License: AGPL-3
Encoding: UTF-8
LazyData: true
Expand Down
5 changes: 4 additions & 1 deletion R/Deseq2_edgeR.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows"
#' data("GlobalPatterns", package = "phyloseq")
#' GP_archae <- subset_taxa(GlobalPatterns, GlobalPatterns@tax_table[, 1] == "Archaea")
#' \donttest{
#' plot_edgeR_pq(GP_archae, c("SampleType", "Soil", "Feces"),
#' color_tax = "Kingdom"
#' )
#' \dontrun{
#'
#' plot_edgeR_pq(GP_archae, c("SampleType", "Soil", "Feces"),
#' taxolev = "Class", color_tax = "Kingdom"
#' )
Expand Down Expand Up @@ -153,6 +154,7 @@ plot_edgeR_pq <-
#' @details
#' Please cite `DESeq2` package if you use chis function.
#' @examples
#' \donttest{
#' data("GlobalPatterns", package = "phyloseq")
#' GP <- subset_taxa(GlobalPatterns, GlobalPatterns@tax_table[, 1] == "Archaea")
#' GP <- subset_samples(GP, SampleType %in% c("Soil", "Skin"))
Expand All @@ -170,6 +172,7 @@ plot_edgeR_pq <-
#' tax_table = GP@tax_table, color_tax = "Class",
#' select_taxa = c("522457", "271582")
#' )
#' }
#' @author Adrien Taudière
#'
#' @return A \code{\link{ggplot}}2 plot representing DESeq2 results
Expand Down
16 changes: 14 additions & 2 deletions R/beta_div_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
#' @examples
#' data(enterotype)
#' graph_test_pq(enterotype, fact = "SeqTech")
#' \donttest{
#' graph_test_pq(enterotype, fact = "Enterotype", na_remove = TRUE)
#' }
#' @author Adrien Taudière
#'
#' @return A \code{\link{ggplot}}2 plot with a subtitle indicating the pvalue
Expand Down Expand Up @@ -123,10 +125,11 @@ graph_test_pq <- function(physeq,
#' more information.
#' @examples
#' data(enterotype)
#' \donttest{
#' adonis_pq(enterotype, "SeqTech*Enterotype", na_remove = TRUE)
#' adonis_pq(enterotype, "SeqTech")
#' adonis_pq(enterotype, "SeqTech", dist_method = "jaccard")
#' adonis_pq(enterotype, "SeqTech", dist_method = "robust.aitchison")
#' }
#' @export
#' @author Adrien Taudière
#' @details
Expand Down Expand Up @@ -234,7 +237,9 @@ adonis_pq <- function(physeq,
#' str(res)
#' length(res$LCBD)
#' length(res$SCBD)
#' \donttest{
#' LCBD_pq(data_fungi_sp_known, nperm = 5, method = "jaccard")
#' }
#'
#' @author Adrien Taudière
#' This function is mainly a wrapper of the work of others.
Expand Down Expand Up @@ -291,6 +296,7 @@ LCBD_pq <- function(physeq,
#' nperm = 100, only_plot_significant = FALSE,
#' pval = 0.2
#' )
#' \donttest{
#' plot_LCBD_pq(data_fungi_mini,
#' nperm = 100, only_plot_significant = TRUE,
#' pval = 0.2
Expand All @@ -309,6 +315,7 @@ LCBD_pq <- function(physeq,
#' legend.text = element_text(size = 10),
#' axis.title.x = element_text(size = 6)
#' )
#' }
#' @author Adrien Taudière
#' @details
#' This function is mainly a wrapper of the work of others.
Expand Down Expand Up @@ -430,9 +437,10 @@ plot_LCBD_pq <- function(physeq,
#' plot_SCBD_pq(data_fungi) +
#' geom_text(aes(label = paste(Genus, Species)), hjust = 1, vjust = 2) +
#' xlim(c(0, NA))
#'
#' \donttest{
#' plot_SCBD_pq(data_fungi, tax_level = "Class", tax_col = "Phylum", min_SCBD = 0) +
#' geom_jitter()
#' }
#' @author Adrien Taudière
#' @details
#' This function is mainly a wrapper of the work of others.
Expand Down Expand Up @@ -488,10 +496,12 @@ plot_SCBD_pq <- function(physeq,
#' 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")
#' \donttest{
#' multipatt_pq(subset_samples(data_fungi_ab, !is.na(Time)),
#' fact = "Time",
#' max.order = 1, control = permute::how(nperm = 99)
#' )
#' }
#' @author Adrien Taudière
#' @details
#' This function is mainly a wrapper of the work of others.
Expand Down Expand Up @@ -562,6 +572,7 @@ multipatt_pq <- function(physeq,
#' @export
#'
#' @examples
#' \donttest{
#' res_height <- ancombc_pq(
#' data_fungi_mini,
#' fact = "Height",
Expand Down Expand Up @@ -591,6 +602,7 @@ multipatt_pq <- function(physeq,
#' tax_level = "Family",
#' verbose = TRUE
#' )
#' }
#' @author Adrien Taudière
#' @details
#' This function is mainly a wrapper of the work of others.
Expand Down
14 changes: 7 additions & 7 deletions R/blast.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@
#' @examples
#' \dontrun{
#'
#' blastpath <- "...YOUR_PATH_TO_BLAST..."
#' blast_to_phyloseq(data_fungi,
#' seq2search = system.file("extdata", "ex.fasta",
#' package = "MiscMetabar", mustWork = TRUE
#' ),
#' blastpath = blastpath
#' )
#' # blastpath <- "...YOUR_PATH_TO_BLAST..."
#' # blast_to_phyloseq(data_fungi,
#' # seq2search = system.file("extdata", "ex.fasta",
#' # package = "MiscMetabar", mustWork = TRUE
#' # ),
#' # blastpath = blastpath
#' # )
#' }
blast_to_phyloseq <- function(physeq,
seq2search,
Expand Down
28 changes: 15 additions & 13 deletions R/dada_phyloseq.R
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,16 @@ track_wkflow_samples <- function(list_pq_obj, ...) {
#'
#' @examples
#' asv2otu(data_fungi_mini)
#' \donttest{
#' asv2otu(data_fungi_mini, method_clusterize = "longest")
#'
#' if (MiscMetabar:::is_swarm_installed()) {
#' d_swarm <- asv2otu(data_fungi_mini, method = "swarm")
#' }
#' if (MiscMetabar:::is_vsearch_installed()) {
#' d_vs <- asv2otu(data_fungi_mini, method = "vsearch")
#' }
#' }
#' @references
#' VSEARCH can be downloaded from
#' \url{https://github.com/torognes/vsearch}.
Expand Down Expand Up @@ -910,10 +913,8 @@ save_pq <- function(physeq, path = NULL, ...) {
#' @export
#'
#' @examples
#' \dontrun{
#' read_pq(path = "phyloseq_data")
#' read_pq(path = "phyloseq_data", taxa_are_rows = TRUE)
#' }
#' # read_pq(path = "phyloseq_folder")
#' # read_pq(path = "phyloseq_folder", taxa_are_rows = TRUE)
#'
read_pq <- function(path = NULL,
taxa_are_rows = FALSE,
Expand Down Expand Up @@ -1162,7 +1163,6 @@ lulu_pq <- function(physeq,
#' @export
#' @examples
#' \dontrun{
#' data(data_fungi_sp_known)
#' mumu_pq(data_fungi_sp_known)
#' }
#' @author Frédéric Mahé
Expand Down Expand Up @@ -1403,7 +1403,7 @@ subset_samples_pq <- function(physeq, condition) {
if (length(condition) != nsamples(physeq)) {
stop("Length of condition is different from the number of samples.")
}
if (is.null(sample_data(physeq))) {
if (is.null(physeq@sam_data)) {
message("Nothing subset. No sample_data in physeq.\n")
return(physeq)
} else {
Expand Down Expand Up @@ -1927,6 +1927,7 @@ plot_guild_pq <-
#' Please make a reference to `phangorn` package if you
#' use this function.
#' @examplesIf tolower(Sys.info()[["sysname"]]) != "windows"
#' \donttest{
#' library("phangorn")
#' df <- subset_taxa_pq(data_fungi_mini, taxa_sums(data_fungi_mini) > 9000)
#' df_tree <- build_phytree_pq(df, nb_bootstrap = 2)
Expand All @@ -1946,6 +1947,7 @@ 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",
Expand Down Expand Up @@ -2065,9 +2067,9 @@ build_phytree_pq <- function(physeq,
#' @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)
#' are_modality_even_depth(data_fungi_mini, "Time")$p.value
#' are_modality_even_depth(rarefy_even_depth(data_fungi_mini), "Time")$p.value
#' are_modality_even_depth(data_fungi_mini, "Height", boxplot = TRUE)
are_modality_even_depth <- function(physeq, fact, boxplot = FALSE) {
nb_seq <- sample_sums(physeq)
fact <- factor(unclass(physeq@sam_data[, fact])[[1]])
Expand Down Expand Up @@ -2108,9 +2110,9 @@ are_modality_even_depth <- function(physeq, fact, boxplot = FALSE) {
#' taxa_names(data_fungi)[order(as.vector(data_fungi@tax_table[, "Genus"]))]
#' )
#'
#' data_fungi_asc_ordered_by_abundance <- reorder_taxa_pq(
#' data_fungi,
#' taxa_names(data_fungi)[order(taxa_sums(data_fungi))]
#' data_fungi_mini_asc_ordered_by_abundance <- reorder_taxa_pq(
#' data_fungi_mini,
#' taxa_names(data_fungi_mini)[order(taxa_sums(data_fungi_mini))]
#' )
reorder_taxa_pq <- function(physeq, names_ordered, remove_phy_tree = FALSE) {
new_physeq <- physeq
Expand Down Expand Up @@ -2337,7 +2339,7 @@ physeq_or_string_to_dna <- function(physeq = NULL,
#' )
#'
#'
#' unlink(tempdir(), recursive = TRUE)
#' # unlink(tempdir(), recursive = TRUE)
#' }
#' @details
#' This function is mainly a wrapper of the work of others.
Expand Down
5 changes: 4 additions & 1 deletion R/miscellanous.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ perc <- function(x, y = NULL, accuracy = 0, add_symbol = FALSE) {
#' package = "MiscMetabar",
#' mustWork = TRUE
#' ))
#' count_seq(folder_path = "extdata/", pattern = "*.fasta")
#' count_seq(
#' folder_path = system.file("extdata", package = "MiscMetabar"),
#' pattern = "*.fasta"
#' )
count_seq <- function(file_path = NULL, folder_path = NULL, pattern = NULL) {
if (is.null(file_path) && is.null(folder_path)) {
stop("You need to specify one of file_path or folder_path param!")
Expand Down
Loading

0 comments on commit 295ebee

Please sign in to comment.