Skip to content

Commit 1570b18

Browse files
authored
re-added column_exist and matrix_to_dtable as exported utilities, changed col_name length 1 dependency to infinite
1 parent 80f70ed commit 1570b18

4 files changed

Lines changed: 4 additions & 13 deletions

File tree

R/omics-class.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,8 +1002,8 @@ omics <- R6::R6Class(
10021002
#--------------------------------------------------------------------#
10031003

10041004
if (!is.null(col_name)) {
1005-
if (!is.character(col_name) || length(col_name) != 1) {
1006-
cli::cli_abort("{.val col_name} must be a character and of length 1.")
1005+
if (!is.character(col_name)) {
1006+
cli::cli_abort("{.val col_name} must be a character.")
10071007
} else if (!column_exists(col_name, private$.metaData)) {
10081008
cli::cli_abort("The specified {.val {col_name}} does not exist in the {.field metaData}.")
10091009
}

R/utils.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#'
55
#' @param x A \link[base]{matrix}, \link[Matrix]{sparseMatrix} or \link[Matrix]{Matrix}.
66
#' @return A \link[data.table]{data.table} class.
7-
#' @noRd
7+
#' @export
88
matrix_to_dtable <- function(x) {
99
if (inherits(x, "denseMatrix") || inherits(x, "matrix") || inherits(x, "sparseMatrix")) {
1010
return(data.table::data.table(as.matrix(x)))
@@ -17,7 +17,7 @@ matrix_to_dtable <- function(x) {
1717
#' @param column A character vector.
1818
#' @param table A \link[data.table]{data.table} or \link[base]{data.frame}.
1919
#' @return A boolean value.
20-
#' @noRd
20+
#' @export
2121
column_exists <- function(column, table) {
2222

2323
## Error handling

tests/testthat/_snaps/omics-composition.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66
Error in `taxa$composition()`:
77
! The specified "1" does not exist in the metaData.
88

9-
---
10-
11-
Code
12-
taxa$composition(feature_rank = "Genus", col_name = c("treatment", "sex"))
13-
Condition
14-
Error in `taxa$composition()`:
15-
! "col_name" must be a character and of length 1.
16-
179
---
1810

1911
Code

tests/testthat/test-omics-composition.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ taxa <- metagenomics$new(
88
test_that("`omics$composition()` -- Argument checks", {
99
## feature_rank and feature_filter are already tested in `omics-feature_merge`
1010
expect_snapshot(taxa$composition(feature_rank = "Genus", col_name = "1"), error = TRUE)
11-
expect_snapshot(taxa$composition(feature_rank = "Genus", col_name = c("treatment", "sex")), error = TRUE)
1211
expect_snapshot(taxa$composition(feature_rank = "Genus", col_name = "nonexisting"), error = TRUE)
1312

1413
expect_snapshot(taxa$composition(feature_rank = "Genus", feature_top = "10"), error = TRUE)

0 commit comments

Comments
 (0)