Skip to content

Commit

Permalink
Merge pull request #103 from adrientaudiere/dev
Browse files Browse the repository at this point in the history
refactor: Better lint
  • Loading branch information
adrientaudiere authored Oct 10, 2024
2 parents f152692 + e058a30 commit d54233e
Show file tree
Hide file tree
Showing 191 changed files with 884 additions and 902 deletions.
18 changes: 18 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
linters: linters_with_tags(
tags = c("default", "common_mistakes", "package_development", "consistency", "correctness", "robustness"),
undesirable_operator_linter = NULL,
line_length_linter(120),
keyword_quote_linter = NULL,
condition_message_linter = NULL,
paste_linter = NULL,
implicit_integer_linter = NULL,
packages = "lintr",
exclude_tags = "deprecated"
)
encoding: "UTF-8"

exclusions: list(
# excluded from all lints:
"tests/testthat.R"
)

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.10.1
Version: 0.10.2
Authors@R: person("Adrien", "Taudière", email = "[email protected]",
role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0003-1088-1182"))
Description: Facilitate the description, transformation, exploration, and reproducibility of metabarcoding analyses. 'MiscMetabar' is mainly built on top of the 'phyloseq', 'dada2' and 'targets' R packages. It helps to build reproducible and robust bioinformatics pipelines in R. 'MiscMetabar' makes ecological analysis of alpha and beta-diversity easier, more reproducible and more powerful by integrating a large number of tools. Important features are described in Taudière A. (2023) <doi:10.21105/joss.06038>.
Expand Down
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

# MiscMetabar 0.10.1 (in development)
# MiscMetabar 0.10.2 (in development)

- Improve code thanks to {lintr} package
# MiscMetabar 0.10.1

> CRAN 2024-09-10
- Delete function `heat_tree_pq()` because {metacoder} package is archived from CRAN.

Expand Down
6 changes: 4 additions & 2 deletions R/alpha_div_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ hill_test_rarperm_pq <- function(physeq,
#' Package leaps must then be loaded, and this can only be applied to linear models
#' with covariates and no interactions. If "d", a simple summary of the candidate set
#' is printed, including the number of candidate models.
#' @param crit The Information Criterion to be used. Default is the small-sample corrected AIC (aicc). This should be a function that accepts a fitted model as first argument. Other provided functions are the classic AIC, the Bayes IC (bic), and QAIC/QAICc (qaic and qaicc).
#' @param crit The Information Criterion to be used. Default is the small-sample corrected AIC (aicc).
#' This should be a function that accepts a fitted model as first argument.
#' Other provided functions are the classic AIC, the Bayes IC (bic), and QAIC/QAICc (qaic and qaicc).
#' @param ... Other arguments passed on to [glmulti::glmulti()] function
#'
#' @return A data.frame summarizing the glmulti results with columns
Expand Down Expand Up @@ -380,7 +382,7 @@ glmutli_pq <-
if (fitfunction == "lm") {
test <- vector("list", nrow(top_glmulti))
R2__h0 <- NULL
for (i in 1:nrow(top_glmulti)) {
for (i in seq_along(nrow(top_glmulti))) {
test[[i]] <- summary(res_glmulti@objects[[i]])
R2__h0[i] <- test[[i]]$adj.r.squared
}
Expand Down
20 changes: 5 additions & 15 deletions R/beta_div_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ graph_test_pq <- function(physeq,
nperm = nperm,
...
)
if (!return_plot) {
return(res_graph_test)
} else {
if (return_plot) {
p <- phyloseqGraphTest::plot_test_network(res_graph_test) +
labs(
title = title,
Expand All @@ -90,6 +88,8 @@ graph_test_pq <- function(physeq,
)
)
return(p)
} else {
return(res_graph_test)
}
}
################################################################################
Expand Down Expand Up @@ -831,11 +831,8 @@ signif_ancombc <- function(ancombc_res,
clnames <- colnames(signif_ancombc_res)

name_modality <-
gsub(
"passed_ss", "",
clnames[grepl("passed_ss", clnames) &
!grepl("Intercept", clnames)]
)
gsub("passed_ss", "", clnames[grepl("passed_ss", clnames) &
!grepl("Intercept", clnames)])

if (filter_passed) {
signif_ancombc_res <- signif_ancombc_res %>%
Expand Down Expand Up @@ -1356,13 +1353,6 @@ var_par_rarperm_pq <-
)
}

if (dist_method %in% c("robust.aitchison", "aitchison")) {
dist_physeq <-
vegdist(as(otu_table(physeq, taxa_are_rows = FALSE), "matrix"), method = dist_method)
} else {
dist_physeq <- phyloseq::distance(physeq, method = dist_method)
}

res_perm <- vector("list", nperm)
for (i in 1:nperm) {
res_perm[[i]] <-
Expand Down
18 changes: 9 additions & 9 deletions R/blast.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ blast_to_phyloseq <- function(physeq,
blast_tab_OK <- FALSE
}

if (!keep_temporary_files) {
if (keep_temporary_files) {
message(paste0("Temporary files are located at ", tempdir()))
} else {
unlink(paste0(tempdir(), "/", "blast_result.txt"))
unlink(list.files(tempdir(), pattern = "dbase"))
unlink(paste0(tempdir(), "/", "db.fasta"))
} else {
message(paste0("Temporary files are located at ", tempdir()))
}

if (!blast_tab_OK) {
Expand Down Expand Up @@ -292,12 +292,12 @@ blast_pq <- function(physeq,
blast_tab_OK <- FALSE
}

if (!keep_temporary_files) {
if (keep_temporary_files) {
message(paste0("Temporary files are located at ", tempdir()))
} else {
unlink(paste0(tempdir(), "/", "blast_result.txt"))
unlink(list.files(tempdir(), pattern = "dbase"))
unlink(paste0(tempdir(), "/", "db.fasta"))
} else {
message(paste0("Temporary files are located at ", tempdir()))
}

if (!blast_tab_OK) {
Expand Down Expand Up @@ -542,12 +542,12 @@ blast_to_derep <- function(derep,
blast_tab_OK <- FALSE
}

if (!keep_temporary_files) {
if (keep_temporary_files) {
message(paste0("Temporary files are located at ", tempdir()))
} else {
unlink(paste0(tempdir(), "/", "blast_result.txt"))
unlink(list.files(tempdir(), pattern = "dbase"))
unlink(paste0(tempdir(), "/", "db.fasta"))
} else {
message(paste0("Temporary files are located at ", tempdir()))
}

if (!blast_tab_OK) {
Expand Down
Loading

0 comments on commit d54233e

Please sign in to comment.