Skip to content

Commit c75fc6c

Browse files
committed
fix warning in unit tests
1 parent 0781ddb commit c75fc6c

22 files changed

+48
-76
lines changed

R/DA-comparing.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ compare_DA <- function(ps,
187187

188188
ps
189189
}
190-
pss <- mapply(generate_spiked_ps,
190+
pss <- mapply(generate_spiked_ps,
191191
count_tabs, rands,
192192
MoreArgs = list(group = group, ps = ps))
193193
pss <- rep(pss, each = length(methods))
@@ -841,12 +841,12 @@ generate_compare_args <- function(methods, args) {
841841
n_arg <- vector("integer", length(args))
842842
for (i in seq_along(args)) {
843843
curr_arg <- args[i]
844-
if (purrr::vec_depth(curr_arg) > 4) {
844+
if (purrr::pluck_depth(curr_arg) > 4) {
845845
stop("`args` could be 'list of list', ",
846846
"'list of list of list' to support for different arguments ",
847847
"for a certain DA method")
848848
}
849-
if (purrr::vec_depth(curr_arg) == 4) {
849+
if (purrr::pluck_depth(curr_arg) == 4) {
850850
curr_arg <- unlist(curr_arg, recursive = FALSE)
851851
names(curr_arg) <- paste(names(args)[i],
852852
seq_along(curr_arg),

R/DA-edgeR.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,11 @@ run_edger <- function(ps,
210210
)
211211
res <- res$table
212212
if ("FDR" %in% names(res)) {
213-
res <- dplyr::rename(res, pvalue = .data$PValue, padj = .data$FDR)
213+
res <- dplyr::rename(res, pvalue = "PValue", padj = "FDR")
214214
} else if ("FWER" %in% names(res)) {
215-
res <- dplyr::rename(res, pvalue = .data$PValue, padj = .data$FWER)
215+
res <- dplyr::rename(res, pvalue = "PValue", padj = "FWER")
216216
} else {
217-
res <- dplyr::rename(res, pvalue = .data$PValue)
217+
res <- dplyr::rename(res, pvalue = "PValue")
218218
res$padj <- res$pvalue
219219
}
220220

R/DA-lefse.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ run_lefse <- function(ps,
111111
if (!inherits(ps, "phyloseq")) {
112112
stop("`ps` must be phyloseq object", call. = FALSE)
113113
}
114-
114+
115115
# check rank names and para taxa_rank
116116
ps <- check_rank_names(ps)
117117
ps <- check_taxa_rank(ps, taxa_rank)
118-
118+
119119
transform <- match.arg(transform, c("identity", "log10", "log10p"))
120120
strict <- match.arg(strict, c("0", "1", "2"))
121121
strict <- as.numeric(strict)
@@ -146,13 +146,13 @@ run_lefse <- function(ps,
146146
grp_hie <- grp_info$group_hie
147147

148148
ps_summarized <- pre_ps_taxa_rank(ps_normed, taxa_rank)
149-
149+
150150
otus <- abundances(ps_summarized, norm = TRUE)
151151
# transform it for test
152152
otus_test <- as.data.frame(t(otus), stringsAsFactors = FALSE)
153153
feature <- tax_table(ps_summarized)@.Data[, 1]
154154
names(otus_test) <- feature
155-
155+
156156
# tax table
157157
tax <- matrix(feature) %>%
158158
tax_table()
@@ -187,7 +187,7 @@ run_lefse <- function(ps,
187187
)
188188
)
189189
sig_otus <- sig_otus[, wilcoxon_p, drop = FALSE]
190-
190+
191191
if (ncol(sig_otus) == 0) {
192192
warning("No marker was identified", call. = FALSE)
193193
mm <- microbiomeMarker(
@@ -199,7 +199,7 @@ run_lefse <- function(ps,
199199
sam_data = sample_data(ps_normed),
200200
tax_table = tax
201201
)
202-
202+
203203
return(mm)
204204
}
205205

R/DA-test-two-groups.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ run_test_two_groups <- function(ps,
8282
...) {
8383
stopifnot(inherits(ps, "phyloseq"))
8484
ps <- check_rank_names(ps)
85-
85+
8686
# ps_rank <- rank_names(ps)
8787
# if ("Picrust_trait" %in% ps_rank) {
8888
# picrust_rank <- c("Picrust_trait", "Picrust_description")
@@ -156,8 +156,8 @@ run_test_two_groups <- function(ps,
156156
test_res <- run_t_test(abd_norm_group, conf_level = conf_level, ...)
157157
} else if (method == "t.test") {
158158
test_res <- run_t_test(
159-
abd_norm_group,
160-
conf_level,
159+
abd_norm_group,
160+
conf_level,
161161
var_equal = TRUE, ...
162162
)
163163
} else if (method == "white.test") {
@@ -193,7 +193,7 @@ run_test_two_groups <- function(ps,
193193
row.names(test_res) <- paste0("feature", seq_len(nrow(test_res)))
194194

195195
test_filtered <- filter(test_res, .data$padj <= pvalue_cutoff)
196-
196+
197197
if (!is.null(diff_mean_cutoff)) {
198198
test_filtered <- filter(
199199
test_filtered,
@@ -290,7 +290,7 @@ run_t_test <- function(abd_group, conf_level = 0.95, var_equal = FALSE, ...) {
290290
ci_upper
291291
)
292292
names(res) <- c(
293-
"pvalue", mean_names,
293+
"pvalue", mean_names,
294294
"ef_diff_mean", "ci_lower", "ci_upper"
295295
)
296296

@@ -386,7 +386,7 @@ run_white_test <- function(norm_group1,
386386
ci_upper
387387
)
388388
names(res) <- c(
389-
"pvalue", mean_names,
389+
"pvalue", mean_names,
390390
"ef_diff_mean", "ci_lower", "ci_upper"
391391
)
392392

@@ -417,7 +417,7 @@ calc_permute_p <- function(norm_group1,
417417

418418
# calculate p value -------------------------------------------------------
419419
permuted_res <- purrr::rerun(
420-
nperm,
420+
nperm,
421421
calc_permute_ts(norm_group1, norm_group2)
422422
)
423423
permuted_ts <- purrr::map_df(
@@ -459,9 +459,9 @@ calc_permute_p <- function(norm_group1,
459459
}
460460
}
461461

462-
pvalue_one_side[hf_index] <- 1 /
462+
pvalue_one_side[hf_index] <- 1 /
463463
(nperm * length(high_freq_indices)) * one_side
464-
pvalue_two_side[hf_index] <- 1 /
464+
pvalue_two_side[hf_index] <- 1 /
465465
(nperm * length(high_freq_indices)) * two_side
466466
}
467467
} else {

R/lefse-utilities.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ bootstap_lda <- function(feature_abundance,
8282
sample_fract,
8383
seed = 2020) {
8484
# Bioconductor not allows set.seed
85-
ldas <- purrr::rerun(
86-
boot_n,
85+
ldas <- purrr::map(
86+
1:boot_n,\(i)
8787
bootstap_lda_one(
8888
feature_abundance,
8989
class,
@@ -186,8 +186,8 @@ cal_pair_lda <- function(feature_abundance,
186186
pair,
187187
function(x) {
188188
if (x %in% lda_row_nms) {
189-
# fixes #7, Since `pair` is a level, and `lda_means[pair[i], ]`
190-
# corced pair[i]` to numeric rather than use the corresponding
189+
# fixes #7, Since `pair` is a level, and `lda_means[pair[i], ]`
190+
# corced pair[i]` to numeric rather than use the corresponding
191191
# level of pair[i]
192192
ind <- match(x, lda_row_nms)
193193
lda_means[ind, ]
@@ -298,7 +298,7 @@ test_rep_wilcoxon <- function(subcls,
298298
br <- FALSE
299299
for (j in seq_along(subcls2)) {
300300
if (only_same_subcls &&
301-
gsub(pair[1], "", subcls1[i]) !=
301+
gsub(pair[1], "", subcls1[i]) !=
302302
gsub(pair[2], "", subcls2[j])) {
303303
ok <- ok + 1
304304
next
@@ -308,7 +308,7 @@ test_rep_wilcoxon <- function(subcls,
308308
cls2_abd <- feats_abd[subcls == subcls2[j]]
309309
med_comp <- FALSE
310310

311-
if (length(cls1_abd) < sample_min ||
311+
if (length(cls1_abd) < sample_min ||
312312
length(cls2_abd) < sample_min) {
313313
med_comp <- TRUE
314314
}
@@ -505,7 +505,7 @@ add_missing_levels <- function(feature) {
505505
# check whether tax have level prefix, such as `p__`
506506
check_tax_prefix <- function(taxa_nms) {
507507
prefix <- paste0(c("k", "p", "c", "o", "f", "g", "s"), "__")
508-
has_prefix <- purrr::map_lgl(prefix,
508+
has_prefix <- purrr::map_lgl(prefix,
509509
~ any(grepl(.x, taxa_nms, fixed = TRUE))
510510
)
511511

R/post-hoc-test.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,17 @@ run_posthoc_test <- function(ps,
155155
#' pht <- postHocTest(
156156
#' result = DataFrameList(
157157
#' featureA = DataFrame(
158-
#' comparisons = c("group2-group1",
159-
#' "group3-group1",
158+
#' comparisons = c("group2-group1",
159+
#' "group3-group1",
160160
#' "group3-group2"),
161161
#' diff_mean = runif(3),
162162
#' pvalue = rep(0.01, 3),
163163
#' ci_lower = rep(0.01, 3),
164164
#' ci_upper = rep(0.011, 3)
165165
#' ),
166166
#' featureB = DataFrame(
167-
#' comparisons = c("group2-group1",
168-
#' "group3-group1",
167+
#' comparisons = c("group2-group1",
168+
#' "group3-group1",
169169
#' "group3-group2"),
170170
#' diff_mean = runif(3),
171171
#' pvalue = rep(0.01, 3),
@@ -394,7 +394,7 @@ calc_welch_uncorrected_test <- function(obs, groups, conf_level = 0.95) {
394394

395395
welch_res <- purrr::map(
396396
comparison_groups,
397-
~ t.test(obs_split[[.x[1]]], obs_split[[.x[2]]],
397+
~ t.test(obs_split[[.x[1]]], obs_split[[.x[2]]],
398398
conf.level = conf_level)
399399
)
400400

tests/testthat/test-abundances.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
context("`abundances` methods")
2-
31
ps <- phyloseq::phyloseq(
42
otu_table = otu_table(
53
matrix(
@@ -37,6 +35,6 @@ test_that("abundances", {
3735
test_that("abundances normalization", {
3836
abd_norm <- normalize(ps, "TSS")
3937
expect_true(all(colSums(otu_table(abd_norm)) == 1))
40-
expect_is(abd_norm, "phyloseq")
41-
expect_is(normalize(otu_table(ps)), "otu_table")
38+
expect_s4_class(abd_norm, "phyloseq")
39+
expect_s4_class(normalize(otu_table(ps)), "otu_table")
4240
})

tests/testthat/test-assignment.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
context("assignment methods")
2-
31
marker <- marker_table(
42
data.frame(
53
feature = paste0("sp", 1:5),

tests/testthat/test-barplot.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
context("bar plot of effect size")
2-
31
test_that("feature label in bar plot", {
42
feature <- "Bacteria|Bacteroidetes|Bacteroidia|Bacteroidales|Bacteroidaceae"
53
short_feature <- "Bacteria|Bacteroidetes"

tests/testthat/test-import-qiime2.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
context("import qiime2 output into phyloseq object")
2-
31
test_that("whether the row.names of feature table is dna sequence or not", {
42
expect_false(is_dna_seq("3597a2689efaf5525ce460494a8ac383"))
53
expect_true(is_dna_seq(paste0(

0 commit comments

Comments
 (0)