Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace everywhere one_of #312

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 11 additions & 11 deletions R/functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ create_tt_from_bam_sam_bulk <-
genes %>%
select(
suppressWarnings(
one_of("GeneID", "symbol")
any_of("GeneID", "symbol")
)
) %>%
as_tibble() %>%
Expand Down Expand Up @@ -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
Expand All @@ -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)) %>%
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1521,15 +1521,15 @@ 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
filter(!!.entrez %>% is.na %>% not())

# 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) %>%
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/methods_SE.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
14 changes: 7 additions & 7 deletions R/tidySummarizedExperiment.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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()
}


#' @importFrom dplyr select
#' @importFrom tidyselect one_of
#' @importFrom tidyselect any_of
#' @importFrom tibble as_tibble
#' @importFrom tibble tibble
#' @importFrom SummarizedExperiment rowRanges
Expand Down Expand Up @@ -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()
)

Expand All @@ -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()
)

Expand All @@ -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()
)

Expand All @@ -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()
)

Expand Down Expand Up @@ -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()

}
Expand Down
2 changes: 1 addition & 1 deletion R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
Loading