Skip to content

Commit

Permalink
feat: add function tbl_sum_samdata
Browse files Browse the repository at this point in the history
  • Loading branch information
adrientaudiere committed Dec 1, 2023
1 parent 7ca9f19 commit 9169a72
Show file tree
Hide file tree
Showing 29 changed files with 292 additions and 18 deletions.
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(LCBD_pq)
export(SRS_curve_pq)
export(accu_plot)
export(accu_samp_threshold)
Expand Down Expand Up @@ -42,13 +43,15 @@ export(lulu_phyloseq)
export(lulu_pq)
export(merge_krona)
export(multi_biplot_pq)
export(multipatt_pq)
export(multiplot)
export(multitax_bar_pq)
export(otu_circle)
export(perc)
export(phyloseq_to_edgeR)
export(physeq_graph_test)
export(physeq_heat_tree)
export(plot_LCBD_pq)
export(plot_deseq2_phyloseq)
export(plot_deseq2_pq)
export(plot_edgeR_phyloseq)
Expand All @@ -75,6 +78,7 @@ export(summary_plot_phyloseq)
export(summary_plot_pq)
export(tax_bar_pq)
export(tax_datatable)
export(tbl_sum_samdata)
export(track_wkflow)
export(track_wkflow_samples)
export(treemap_pq)
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# MiscMetabar 0.51 (in development)

- Add function `LCBD_pq()` and `plot_LCBD_pq()` to compute, test and plot local contributions to beta diversity (LCBD) of samples
- Add function `LCBD_pq()` and `plot_LCBD_pq()` to compute, test and plot local contributions to beta diversity (LCBD) of samples
- Add function `tbl_sum_samdata()` to summarize information from sample data in a table

# MiscMetabar 0.5

Expand Down
22 changes: 19 additions & 3 deletions R/beta_div_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -355,24 +355,40 @@ plot_LCBD_pq <- function(physeq,
}


#' @title Test and plot multipatt result
#' @description
#' `r lifecycle::badge("experimental")`
#'
#' A wrapper for the [indicspecies::multipatt()] function in the case of `physeq`
#' object.
#' @inheritParams clean_pq
#' @param fact (required) Name of the factor in `physeq@sam_data` used to plot
#' different lines
#' @param p_adjust_method (chr, default "BH"): the method used to adjust p-value
#' @param pval (int, default 0.05): the value to determine the significance of
#' LCBD
#' @param control see `?indicspecies::multipatt()`
#' @param ... Others arguments passed on to [indicspecies::multipatt()] function
#'
#' @return A ggplot object
#' @export
#' @examples
#' multipatt_pq(subset_samples(data_fungi, !is.na(Time)), fact="Time")
#' multipatt_pq(subset_samples(data_fungi, !is.na(Time)), fact="Time",
#' max.order = 1, control = how(nperm=9999))
#' @author Adrien Taudière

multipatt_pq <- function(physeq,
fact,
p_adjust_method = "BH",
pval = 0.05,
control = how(nperm = 999),
max.order = 3,
...){

res <-
multipatt(as.matrix(physeq@otu_table),
indicspecies::multipatt(as.matrix(physeq@otu_table),
physeq@sam_data[[fact]],
control = control,
max.order = max.order,
...)

res_df <- res$sign
Expand Down
4 changes: 2 additions & 2 deletions R/plot_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ hill_pq <-
colnames(otu_hill) <- c("Hill_0", "Hill_1", "Hill_2")

df_hill <- data.frame(otu_hill, physeq@sam_data)
df_hill[, c(1:3)] <- apply(df_hill[, c(1:3)], 2, as.numeric)
df_hill[, 1:3] <- apply(df_hill[, 1:3], 2, as.numeric)

p_var <- hill_tuckey_pq(physeq, variable, correction_for_sample_size = correction_for_sample_size)

Expand Down Expand Up @@ -1654,7 +1654,7 @@ rotl_pq <- function(physeq,
#' @inheritParams clean_pq
#' @param taxonomic_level (default: NULL): a vector of selected
#' taxonomic level using
#' their column numbers (e.g. taxonomic_level = c(1:7))
#' their column numbers (e.g. taxonomic_level = 1:7)
#' @param ... Arguments passed on to \code{\link[metacoder]{heat_tree}}
#'
#' @return A plot
Expand Down
4 changes: 2 additions & 2 deletions R/table_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @inheritParams clean_pq
#' @param abundance (default: TRUE) Does the number of sequences is print
#' @param taxonomic_level (default: NULL) a vector of selected taxonomic
#' level using their column numbers (e.g. taxonomic_level = c(1:7))
#' level using their column numbers (e.g. taxonomic_level = 1:7)
#' @param modality (default: NULL) A sample modality to split
#' OTU abundancy by level of the modality
#' @param ... Other argument for the datatable function
Expand Down Expand Up @@ -229,7 +229,7 @@ compare_pairs_pq <- function(physeq = NULL,
}

res_df_t <- t(as_tibble(res, .name_repair = "minimal"))
colnames(res_df_t) <- paste0("V", seq_along(ncol(res_df_t))
colnames(res_df_t) <- paste0("V", seq_along(ncol(res_df_t)))
res_df <- as_tibble(res_df_t)
# res_df <- as_tibble(t(as_tibble(res, .name_repair = "universal")), .name_repair = "universal")

Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ knitr::opts_chunk$set(
)
```

# MiscMetabar
# MiscMetabar <a href="https://adrientaudiere.github.io/MiscMetabar/"><img src="man/figures/logo.png" align="right" height="138" alt="MiscMetabar website" /></a>

See the pkdown site [here](https://adrientaudiere.github.io/MiscMetabar/).

Expand Down
73 changes: 73 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This file was generated by the {rix} R package v0.4.1 on 2023-11-21
# with following call:
# >rix(r_ver = "976fa3369d722e76f37c77493d99829540d43845",
# > r_pkgs = c("quarto",
# > "dplyr",
# > "DT",
# > "flexdashboard",
# > "forcats",
# > "formattable",
# > "ggplot2",
# > "ggVennDiagram",
# > "grid",
# > "gridExtra",
# > "here",
# > "knitr",
# > "networkD3",
# > "optparse",
# > "plotly",
# > "qs",
# > "quarto",
# > "rmarkdown",
# > "stringr",
# > "targets",
# > "this.path",
# > "treemap",
# > "vegan",
# > "viridis",
# > "visNetwork"),
# > system_pkgs = "quarto",
# > tex_pkgs = c("amsmath",
# > "framed",
# > "fvextra",
# > "environ",
# > "fontawesome5",
# > "orcidlink",
# > "pdfcol",
# > "tcolorbox",
# > "tikzfill"),
# > ide = "rstudio",
# > project_path = ".",
# > overwrite = TRUE,
# > print = TRUE,
# > shell_hook = "")
# It uses nixpkgs' revision 976fa3369d722e76f37c77493d99829540d43845 for reproducibility purposes
# which will install R version 4.3.1
# Report any issues to https://github.com/b-rodrigues/rix
let
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/976fa3369d722e76f37c77493d99829540d43845.tar.gz") {};
rpkgs = builtins.attrValues {
inherit (pkgs.rPackages) quarto dplyr DT flexdashboard forcats formattable ggplot2 ggVennDiagram grid gridExtra here knitr networkD3 optparse plotly qs quarto rmarkdown stringr targets this_path treemap vegan viridis visNetwork;
};
tex = (pkgs.texlive.combine {
inherit (pkgs.texlive) scheme-small amsmath framed fvextra environ fontawesome5 orcidlink pdfcol tcolorbox tikzfill;
});
system_packages = builtins.attrValues {
inherit (pkgs) R glibcLocalesUtf8 quarto;
};
rstudio_pkgs = pkgs.rstudioWrapper.override {
packages = [ rpkgs ];
};
in
pkgs.mkShell {
LOCALE_ARCHIVE = if pkgs.system == "x86_64-linux" then "${pkgs.glibcLocalesUtf8}/lib/locale/locale-archive" else "";
LANG = "en_US.UTF-8";
LC_ALL = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";

buildInputs = [ rpkgs tex system_packages rstudio_pkgs ];

}
33 changes: 33 additions & 0 deletions man/LCBD_pq.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/MiscMetabar-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added man/figures/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion man/heat_tree_pq.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions man/multipatt_pq.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions man/plot_LCBD_pq.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/sankey_pq.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/tax_datatable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9169a72

Please sign in to comment.