From e15018d952da28dfa2c9a55f8561056e5ae18753 Mon Sep 17 00:00:00 2001 From: Stefano Mangiola Date: Mon, 12 Feb 2024 14:54:34 +1100 Subject: [PATCH] replace everywhere one_of --- NAMESPACE | 2 +- R/functions.R | 22 +++++++++++----------- R/methods_SE.R | 2 +- R/tidySummarizedExperiment.R | 14 +++++++------- R/utilities.R | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index e9ca7bc4..846b657b 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -202,7 +202,7 @@ importFrom(tidyr,replace_na) importFrom(tidyr,spread) importFrom(tidyr,unite) importFrom(tidyr,unnest) -importFrom(tidyselect,one_of) +importFrom(tidyselect,any_of) importFrom(ttservice,bind_cols) importFrom(ttservice,bind_rows) importFrom(utils,capture.output) diff --git a/R/functions.R b/R/functions.R index 067140fc..00436838 100755 --- a/R/functions.R +++ b/R/functions.R @@ -118,7 +118,7 @@ create_tt_from_bam_sam_bulk <- genes %>% select( suppressWarnings( - one_of("GeneID", "symbol") + any_of("GeneID", "symbol") ) ) %>% as_tibble() %>% @@ -418,7 +418,7 @@ get_differential_transcript_abundance_bulk <- function(.data, select(!!.transcript, !!.sample, !!.abundance, - one_of(parse_formula(.formula))) %>% + any_of(parse_formula(.formula))) %>% distinct() %>% # drop factors as it can affect design matrix @@ -438,14 +438,14 @@ get_differential_transcript_abundance_bulk <- function(.data, # if ( # # If I have some discrete covariates # df_for_edgeR %>% - # select(one_of(parse_formula(.formula))) %>% + # select(any_of(parse_formula(.formula))) %>% # select_if(function(col) # is.character(col) | is.factor(col) | is.logical(col)) %>% # ncol %>% gt(0) & # # # If I have at least 2 samples per group # df_for_edgeR %>% - # select(!!.sample, one_of(parse_formula(.formula))) %>% + # select(!!.sample, any_of(parse_formula(.formula))) %>% # select_if(function(col) !is.numeric(col) & !is.integer(col) & !is.double(col) ) %>% # distinct %>% # group_by_at(vars(-!!.sample)) %>% @@ -462,7 +462,7 @@ get_differential_transcript_abundance_bulk <- function(.data, design = model.matrix( object = .formula, - data = df_for_edgeR %>% select(!!.sample, one_of(parse_formula(.formula))) %>% distinct %>% arrange(!!.sample) + data = df_for_edgeR %>% select(!!.sample, any_of(parse_formula(.formula))) %>% distinct %>% arrange(!!.sample) ) # Replace `:` with ___ because it creates error with edgeR @@ -884,7 +884,7 @@ get_differential_transcript_abundance_bulk_voom <- function(.data, select(!!.transcript, !!.sample, !!.abundance, - one_of(parse_formula(.formula))) %>% + any_of(parse_formula(.formula))) %>% distinct() %>% # drop factors as it can affect design matrix @@ -895,7 +895,7 @@ get_differential_transcript_abundance_bulk_voom <- function(.data, design = model.matrix( object = .formula, - data = df_for_voom %>% select(!!.sample, one_of(parse_formula(.formula))) %>% distinct %>% arrange(!!.sample) + data = df_for_voom %>% select(!!.sample, any_of(parse_formula(.formula))) %>% distinct %>% arrange(!!.sample) ) # Print the design column names in case I want contrasts @@ -1125,7 +1125,7 @@ get_differential_transcript_abundance_deseq2 <- function(.data, select(!!.transcript, !!.sample, !!.abundance, - one_of(parse_formula(.formula))) %>% + any_of(parse_formula(.formula))) %>% distinct() %>% # drop factors as it can affect design matrix @@ -1521,7 +1521,7 @@ test_gene_enrichment_bulk_EGSEA <- function(.data, # Prepare the data frame select(!!.entrez, !!.sample, !!.abundance, - one_of(parse_formula(.formula))) %>% + any_of(parse_formula(.formula))) %>% distinct() %>% # Add entrez from symbol @@ -1529,7 +1529,7 @@ test_gene_enrichment_bulk_EGSEA <- function(.data, # Check if at least two samples for each group if (df_for_edgeR %>% - select(!!.sample, one_of(parse_formula(.formula))) %>% + select(!!.sample, any_of(parse_formula(.formula))) %>% distinct %>% count(!!as.symbol(parse_formula(.formula))) %>% distinct(n) %>% @@ -1543,7 +1543,7 @@ test_gene_enrichment_bulk_EGSEA <- function(.data, design = model.matrix( object = .formula, - data = df_for_edgeR %>% select(!!.sample, one_of(parse_formula(.formula))) %>% distinct %>% arrange(!!.sample) + data = df_for_edgeR %>% select(!!.sample, any_of(parse_formula(.formula))) %>% distinct %>% arrange(!!.sample) ) # Print the design column names in case I want contrasts diff --git a/R/methods_SE.R b/R/methods_SE.R index b6ba071b..8aa478b5 100755 --- a/R/methods_SE.R +++ b/R/methods_SE.R @@ -1135,7 +1135,7 @@ setMethod("adjust_abundance", new_range_data = new_range_data %>% # I have to use this trick because rowRanges() and rowData() share @elementMetadata - select(-one_of(colnames(new_row_data) %>% outersect(quo_name(.transcript)))) %>% + select(-any_of(colnames(new_row_data) %>% outersect(quo_name(.transcript)))) %>% suppressWarnings() diff --git a/R/tidySummarizedExperiment.R b/R/tidySummarizedExperiment.R index 2a9609bf..87c17489 100644 --- a/R/tidySummarizedExperiment.R +++ b/R/tidySummarizedExperiment.R @@ -1,6 +1,6 @@ eliminate_GRanges_metadata_columns_also_present_in_Rowdata = function(.my_data, se){ .my_data %>% - select(-one_of(colnames(rowData(se)))) %>% + select(-any_of(colnames(rowData(se)))) %>% # In case there is not metadata column suppressWarnings() @@ -8,7 +8,7 @@ eliminate_GRanges_metadata_columns_also_present_in_Rowdata = function(.my_data, #' @importFrom dplyr select -#' @importFrom tidyselect one_of +#' @importFrom tidyselect any_of #' @importFrom tibble as_tibble #' @importFrom tibble tibble #' @importFrom SummarizedExperiment rowRanges @@ -146,7 +146,7 @@ subset_tibble_output = function(.data, count_info, sample_info, gene_info, range sample_info %>% when( colnames(.) %>% intersect(output_colnames) %>% length() %>% equals(0) ~ NULL, - select(., one_of(s_(.data)$name, output_colnames)) %>% + select(., any_of(s_(.data)$name, output_colnames)) %>% suppressWarnings() ) @@ -155,7 +155,7 @@ subset_tibble_output = function(.data, count_info, sample_info, gene_info, range range_info %>% when( colnames(.) %>% intersect(output_colnames) %>% length() %>% equals(0) ~ NULL, - select(., one_of(f_(.data)$name, output_colnames)) %>% + select(., any_of(f_(.data)$name, output_colnames)) %>% suppressWarnings() ) @@ -164,7 +164,7 @@ subset_tibble_output = function(.data, count_info, sample_info, gene_info, range gene_info %>% when( colnames(.) %>% intersect(output_colnames) %>% length() %>% equals(0) ~ NULL, - select(., one_of(f_(.data)$name, output_colnames)) %>% + select(., any_of(f_(.data)$name, output_colnames)) %>% suppressWarnings() ) @@ -173,7 +173,7 @@ subset_tibble_output = function(.data, count_info, sample_info, gene_info, range count_info %>% when( colnames(.) %>% intersect(output_colnames) %>% length() %>% equals(0) ~ NULL, - select(., one_of(f_(.data)$name, s_(.data)$name, output_colnames)) %>% + select(., any_of(f_(.data)$name, s_(.data)$name, output_colnames)) %>% suppressWarnings() ) @@ -206,7 +206,7 @@ subset_tibble_output = function(.data, count_info, sample_info, gene_info, range output_df %>% # Cleanup - select(one_of(output_colnames)) %>% + select(any_of(output_colnames)) %>% suppressWarnings() } diff --git a/R/utilities.R b/R/utilities.R index 1bf9cbe7..4d7f3a1a 100755 --- a/R/utilities.R +++ b/R/utilities.R @@ -306,7 +306,7 @@ scale_design = function(df, .formula) { ungroup() %>% spread(cov, value) %>% arrange(as.integer(sample_idx)) %>% - select(`(Intercept)`, one_of(parse_formula(.formula))) + select(`(Intercept)`, any_of(parse_formula(.formula))) } get_tt_columns = function(.data){