From 0df1502817ed36cab7e856c793adb314306225ce Mon Sep 17 00:00:00 2001 From: Sean Hackett Date: Thu, 19 Sep 2024 09:37:53 -0700 Subject: [PATCH] cleanup syntax --- R/data_classes.R | 30 ++++++++++++++++-------------- R/filters.R | 19 +++++++++++++------ 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/R/data_classes.R b/R/data_classes.R index f17ce37..8bf2ca6 100644 --- a/R/data_classes.R +++ b/R/data_classes.R @@ -59,14 +59,14 @@ #' ) #' @export create_tidy_omic <- function( - df, - feature_pk, - feature_vars = NULL, - sample_pk, - sample_vars = NULL, - omic_type_tag = "general", - verbose = TRUE - ) { + df, + feature_pk, + feature_vars = NULL, + sample_pk, + sample_vars = NULL, + omic_type_tag = "general", + verbose = TRUE + ) { checkmate::assertDataFrame(df) checkmate::assertString(omic_type_tag) @@ -367,12 +367,14 @@ check_tidy_omic <- function(tidy_omic, fast_check = TRUE) { #' "feature_id", "sample_id" #' ) #' @export -create_triple_omic <- function(measurement_df, - feature_df = NULL, - sample_df = NULL, - feature_pk, - sample_pk, - omic_type_tag = "general") { +create_triple_omic <- function( + measurement_df, + feature_df = NULL, + sample_df = NULL, + feature_pk, + sample_pk, + omic_type_tag = "general" + ) { # testing checkmate::assertClass(measurement_df, "data.frame") diff --git a/R/filters.R b/R/filters.R index e0c35dd..b1a1d7e 100644 --- a/R/filters.R +++ b/R/filters.R @@ -9,11 +9,13 @@ #' filter_value} #' \item{range}{filter filter_variable to using the range (i.e., lower and #' upper limit) provided in filter_value} -#' \item{apply}{a quosure as a \code{filter_value} to a table of interest} +#' \item{quo}{a quosure as a \code{filter_value} to a table of interest} #' } #' @param filter_table table where the filter should be applied #' @param filter_variable variable to apply the filter to #' @param filter_value values to filter based on +#' @param invert If FALSE (default) entities will be retained; if TRUE, they +#' will be removed. #' #' @returns A \code{tomic} object where a subset of features, samples or #' measurmenets have been filtered. @@ -51,17 +53,22 @@ #' filter_value = rlang::quo(BP == "biological process unknown") #' ) #' @export -filter_tomic <- function(tomic, - filter_type, - filter_table, - filter_value, - filter_variable = NULL) { +filter_tomic <- function( + tomic, + filter_type, + filter_table, + filter_value, + filter_variable = NULL, + invert = FALSE + ) { + checkmate::assertClass(tomic, "tomic") checkmate::assertChoice(filter_type, c("category", "range", "quo")) checkmate::assertChoice( filter_table, c("features", "samples", "measurements") ) + checkmate::assertLogical(invert, len = 1) # convert to triple_omic triple_omic <- tomic_to(tomic, "triple_omic")