From 3868a48a58f154dbd50f40bb314495bfaf448df2 Mon Sep 17 00:00:00 2001 From: kwells4 Date: Fri, 12 May 2023 11:00:39 -0600 Subject: [PATCH 1/3] making compatable with older versions of dplyr --- R/import-vdj.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/import-vdj.R b/R/import-vdj.R index a0b7ba2b..2b2a7184 100644 --- a/R/import-vdj.R +++ b/R/import-vdj.R @@ -963,8 +963,7 @@ import_vdj <- function(input = NULL, vdj_dir = NULL, prefix = "", # left_join + mutate is much faster than valr::bed_intersect, probably due # to the extreme number of "chromosomes" vdj_muts <- dplyr::left_join( - mut_coords, vdj_coords, by = "contig_id", suffix = c("", ".seg"), - relationship = "many-to-many" + mut_coords, vdj_coords, by = "contig_id", suffix = c("", ".seg") ) vdj_muts <- dplyr::filter( From 839a92a3e28e575968ff7edff22391708fc296b4 Mon Sep 17 00:00:00 2001 From: kwells4 Date: Fri, 16 Jun 2023 17:02:59 -0600 Subject: [PATCH 2/3] fixing relationship argument to be dependent on dplyr version --- R/import-vdj.R | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/R/import-vdj.R b/R/import-vdj.R index a0b7ba2b..3033d31f 100644 --- a/R/import-vdj.R +++ b/R/import-vdj.R @@ -932,11 +932,11 @@ import_vdj <- function(input = NULL, vdj_dir = NULL, prefix = "", # Get the full length sequence of the vdj region with and without c region vdj_coords <- vdj_coords %>% - dplyr::mutate(new_len = ifelse(seg == "c", 0, len)) %>% - dplyr::group_by(contig_id) %>% - dplyr::mutate(full_len = sum(len), - full_len_vdj = sum(new_len)) %>% - dplyr::select(!new_len) + dplyr::mutate(new_len = ifelse(.data$seg == "c", 0, .data$len)) %>% + dplyr::group_by(.data$contig_id) %>% + dplyr::mutate(full_len = sum(.data$len), + full_len_vdj = sum(.data$new_len)) %>% + dplyr::select(!"new_len") mut_coords <- dplyr::mutate( mut_coords, @@ -962,10 +962,17 @@ import_vdj <- function(input = NULL, vdj_dir = NULL, prefix = "", # some annotations overlap each other! Example: AAACCTGAGAACTGTA-1_contig_1 # left_join + mutate is much faster than valr::bed_intersect, probably due # to the extreme number of "chromosomes" - vdj_muts <- dplyr::left_join( - mut_coords, vdj_coords, by = "contig_id", suffix = c("", ".seg"), - relationship = "many-to-many" - ) + if (utils::packageVersion("dplyr") > "1.1.1") { + # relationship argument gained in 1.1.1 https://dplyr.tidyverse.org/news/index.html + vdj_muts <- dplyr::left_join( + mut_coords, vdj_coords, by = "contig_id", suffix = c("", ".seg"), + relationship = "many-to-many" + ) + } else { + vdj_muts <- dplyr::left_join( + mut_coords, vdj_coords, by = "contig_id", suffix = c("", ".seg") + ) + } vdj_muts <- dplyr::filter( vdj_muts, .data$start < .data$end.seg & .data$end > .data$start.seg @@ -1028,7 +1035,7 @@ import_vdj <- function(input = NULL, vdj_dir = NULL, prefix = "", sum_column <- "full_len" } else { all_muts <- all_muts %>% - dplyr::filter(seg != "c") + dplyr::filter(.data$seg != "c") sum_column <- "full_len_vdj" } From f76c26b535c17bd38f960968cb13c05c2d27d4fe Mon Sep 17 00:00:00 2001 From: Ryan Sheridan Date: Mon, 19 Jun 2023 10:46:59 -0600 Subject: [PATCH 3/3] fix test warnings --- R/calc-gene-usage.R | 2 +- R/import-vdj.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/calc-gene-usage.R b/R/calc-gene-usage.R index 356d6b4e..12b6ebc9 100644 --- a/R/calc-gene-usage.R +++ b/R/calc-gene-usage.R @@ -659,7 +659,7 @@ plot_gene_pairs <- function(input, data_col, chains, cluster_col = NULL, n_lab_dat$legend <- n_lab_dat$axis <- n_lab_dat$corner if ((!is.null(grp_col) || !is.null(clst_col)) && identical(method, "bar")) { - n_lab_dat$axis <- dplyr::rename(df_in, .n = .data$freq) + n_lab_dat$axis <- dplyr::rename(df_in, .n = "freq") } # Set common arguments diff --git a/R/import-vdj.R b/R/import-vdj.R index 3033d31f..af7400c4 100644 --- a/R/import-vdj.R +++ b/R/import-vdj.R @@ -313,7 +313,7 @@ import_vdj <- function(input = NULL, vdj_dir = NULL, prefix = "", # contigs that did not have any mutations will have NAs indel_ctigs <- purrr::map( indel_ctigs, - ~ mutate(.x, dplyr::across(all_of(indel_cols), tidyr::replace_na, 0)) + ~ mutate(.x, dplyr::across(all_of(indel_cols), ~ tidyr::replace_na(.x, 0))) ) contigs <- indel_ctigs