Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev #71

Merged
merged 14 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -40,9 +42,9 @@ jobs:
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
# if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
folder: docs
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.6.0
Version: 0.6.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.
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# MiscMetabar 0.6.1 (in development)
# MiscMetabar 0.6.1 (in development)

- Minor bugs fix to pass R CMD CHECK

# MiscMetabar 0.6.0

Expand Down
81 changes: 39 additions & 42 deletions R/beta_div_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
...
Expand Down Expand Up @@ -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))
Expand All @@ -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)
Expand Down Expand Up @@ -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)),
Expand All @@ -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
Expand Down
110 changes: 53 additions & 57 deletions R/blast.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")
}
Expand Down
9 changes: 4 additions & 5 deletions R/controls.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Loading