From 406c9f0bac401ac49719c8f3c51793a1b1a0ea8c Mon Sep 17 00:00:00 2001 From: theHumanBorch Date: Fri, 3 May 2024 14:00:10 -0500 Subject: [PATCH] working on final issues of dplyr|igraph conflict --- NAMESPACE | 4 ++++ R/clonalCluster.R | 13 +++++++------ R/clonalNetwork.R | 4 +--- R/combineExpression.R | 9 ++++++--- man/clonalNetwork.Rd | 6 ++---- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 276286ad..682a158c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -47,9 +47,13 @@ importFrom(SummarizedExperiment,colData) importFrom(VGAM,dpareto) importFrom(cubature,adaptIntegrate) importFrom(dplyr,"%>%") +importFrom(dplyr,across) +importFrom(dplyr,all_of) importFrom(dplyr,arrange) importFrom(dplyr,bind_rows) +importFrom(dplyr,coalesce) importFrom(dplyr,count) +importFrom(dplyr,desc) importFrom(dplyr,filter) importFrom(dplyr,group_by) importFrom(dplyr,left_join) diff --git a/R/clonalCluster.R b/R/clonalCluster.R index 3a445bc7..2b4af6f7 100644 --- a/R/clonalCluster.R +++ b/R/clonalCluster.R @@ -42,6 +42,8 @@ #' @importFrom rlang %||% #' @importFrom SummarizedExperiment colData<- colData #' @importFrom stats na.omit +#' @importFrom S4Vectors DataFrame +#' #' @export #' @concept Visualizing_Clones #' @return Either amended input with edit-distanced clusters added @@ -177,12 +179,11 @@ clonalCluster <- function(input.data, col.name <- names(PreMeta) %||% colnames(PreMeta) input.data[[col.name]] <- PreMeta } else { - rownames <- rownames(colData(input.data)) - combined_col_names <- unique(c(colnames(colData(input.data)), colnames(PreMeta))) - full_data <- merge(colData(input.data), PreMeta[rownames, , drop = FALSE], by = "row.names", all = TRUE) - colData(input.data) <- full_data[, combined_col_names] - - rownames(colData(input.data)) <- rownames + combined_col_names <- unique(c(colnames(colData(sc.data)), colnames(PreMeta))) + full_data <- merge(colData(sc.data), PreMeta[rownames, , drop = FALSE], by = "row.names", all.x = TRUE) + rownames(full_data) <- full_data[, 1] + full_data <- full_data[, -1] + colData(sc.data) <- DataFrame(full_data[, combined_col_names]) } } else { #Reorder columns diff --git a/R/clonalNetwork.R b/R/clonalNetwork.R index 8bd1d4d7..4f9d921c 100644 --- a/R/clonalNetwork.R +++ b/R/clonalNetwork.R @@ -45,7 +45,6 @@ #' @param chain indicate if both or a specific chain should be used - #' e.g. "both", "TRA", "TRG", "IGH", "IGL". #' @param exportTable Exports a table of the data into the global -#' environment in addition to the visualization. #' @param exportClones Exports a table of clones that are shared #' across multiple identity groups and ordered by the total number #' of clone copies. @@ -55,7 +54,7 @@ #' @import ggplot2 #' @importFrom stringr str_sort #' @importFrom igraph graph_from_data_frame V `V<-` -#' @importFrom dplyr %>% group_by select summarize_all count n +#' @importFrom dplyr %>% group_by select summarize_all count n across all_of desc #' @importFrom tidygraph as_tbl_graph activate #' @importFrom ggraph ggraph geom_edge_bend geom_node_point scale_edge_colour_gradientn circle guide_edge_colourbar #' @importFrom stats setNames @@ -72,7 +71,6 @@ clonalNetwork <- function(sc.data, filter.graph = FALSE, cloneCall = "strict", chain = "both", - exportTable = FALSE, exportClones = FALSE, palette = "inferno") { to <- from <- weight <- y <- NULL diff --git a/R/combineExpression.R b/R/combineExpression.R index 5d1890e5..afcfebe4 100644 --- a/R/combineExpression.R +++ b/R/combineExpression.R @@ -45,9 +45,10 @@ #' @param addLabel This will add a label to the frequency header, allowing #' the user to try multiple group.by variables or recalculate frequencies after #' subsetting the data. -#' @importFrom dplyr bind_rows %>% summarise left_join mutate select n +#' @importFrom dplyr bind_rows %>% summarise left_join mutate select n all_of coalesce #' @importFrom rlang %||% sym := #' @importFrom SummarizedExperiment colData<- colData +#' @importFrom S4Vectors DataFrame #' @export #' @concept SC_Functions #' @return Single-cell object with clone information added to meta data @@ -205,8 +206,10 @@ combineExpression <- function(input.data, warning(.warn_str) } combined_col_names <- unique(c(colnames(colData(sc.data)), colnames(PreMeta))) - full_data <- merge(colData(sc.data), PreMeta[rownames, , drop = FALSE], by = "row.names", all = TRUE) - colData(sc.data) <- full_data[, combined_col_names] + full_data <- merge(colData(sc.data), PreMeta[rownames, , drop = FALSE], by = "row.names", all.x = TRUE) + rownames(full_data) <- full_data[, 1] + full_data <- full_data[, -1] + colData(sc.data) <- DataFrame(full_data[, combined_col_names]) rownames(colData(sc.data)) <- rownames } diff --git a/man/clonalNetwork.Rd b/man/clonalNetwork.Rd index 95d0d950..7b7e9bbe 100644 --- a/man/clonalNetwork.Rd +++ b/man/clonalNetwork.Rd @@ -14,7 +14,6 @@ clonalNetwork( filter.graph = FALSE, cloneCall = "strict", chain = "both", - exportTable = FALSE, exportClones = FALSE, palette = "inferno" ) @@ -48,15 +47,14 @@ in the data.} \item{chain}{indicate if both or a specific chain should be used - e.g. "both", "TRA", "TRG", "IGH", "IGL".} -\item{exportTable}{Exports a table of the data into the global -environment in addition to the visualization.} - \item{exportClones}{Exports a table of clones that are shared across multiple identity groups and ordered by the total number of clone copies.} \item{palette}{Colors to use in visualization - input any \link[grDevices]{hcl.pals}.} + +\item{exportTable}{Exports a table of the data into the global} } \value{ ggplot object