From 81aa5bcc4be7c46e3489f4e1d9a696a880b67f57 Mon Sep 17 00:00:00 2001 From: Chananchida Sang-aram VSCODE Date: Wed, 17 Jan 2024 11:27:53 +0100 Subject: [PATCH 1/3] update R version --- .github/workflows/check-bioc.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check-bioc.yml b/.github/workflows/check-bioc.yml index f04c9c1..94c64ef 100644 --- a/.github/workflows/check-bioc.yml +++ b/.github/workflows/check-bioc.yml @@ -49,9 +49,9 @@ jobs: fail-fast: false matrix: config: - - { os: ubuntu-latest, r: '4.1', bioc: '3.13', cont: "bioconductor/bioconductor_docker:RELEASE_3_13", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" } - - { os: macOS-latest, r: '4.1', bioc: '3.13'} - - { os: windows-latest, r: '4.1', bioc: '3.13'} + - { os: ubuntu-latest, r: '4.3.2', bioc: '3.18', cont: "bioconductor/bioconductor_docker:RELEASE_3_18", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" } + - { os: macOS-latest, r: '4.3.2', bioc: '3.18'} + - { os: windows-latest, r: '4.3.2', bioc: '3.18'} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true RSPM_ROOT: https://packagemanager.posit.co. From 9f453278f2afcf64949d8ae0342331a6e24a2543 Mon Sep 17 00:00:00 2001 From: Chananchida Sang-aram VSCODE Date: Wed, 17 Jan 2024 11:28:22 +0100 Subject: [PATCH 2/3] add UpdateSeuratObject for v5 compat --- tests/testthat/test-application_prediction.R | 1 + tests/testthat/test-differential_nichenet.R | 2 ++ tests/testthat/test-prioritization.R | 1 + 3 files changed, 4 insertions(+) diff --git a/tests/testthat/test-application_prediction.R b/tests/testthat/test-application_prediction.R index 67f416a..a75a0ce 100644 --- a/tests/testthat/test-application_prediction.R +++ b/tests/testthat/test-application_prediction.R @@ -5,6 +5,7 @@ test_that("Seurat wrapper works", { lr_network = readRDS(url("https://zenodo.org/record/7074291/files/lr_network_mouse_21122021.rds")) weighted_networks = readRDS(url("https://zenodo.org/record/7074291/files/weighted_networks_nsga2r_final_mouse.rds")) seurat_object_lite = readRDS(url("https://zenodo.org/record/3531889/files/seuratObj_test.rds")) + seurat_object_lite = Seurat::UpdateSeuratObject(seurat_object_lite) nichenet_output = nichenet_seuratobj_aggregate(seurat_obj = seurat_object_lite, receiver = "CD8 T", condition_oi = "LCMV", condition_reference = "SS", condition_colname = "aggregate", sender = c("Mono"), ligand_target_matrix = ligand_target_matrix, weighted_networks = weighted_networks, lr_network = lr_network) expect_type(nichenet_output,"list") diff --git a/tests/testthat/test-differential_nichenet.R b/tests/testthat/test-differential_nichenet.R index ba1f686..aeb2ffb 100644 --- a/tests/testthat/test-differential_nichenet.R +++ b/tests/testthat/test-differential_nichenet.R @@ -8,6 +8,8 @@ test_that("Differential NicheNet pipeline works", { lr_network = lr_network %>% dplyr::rename(ligand = from, receptor = to) %>% distinct(ligand, receptor) seurat_object_lite = readRDS(url("https://zenodo.org/record/3531889/files/seuratObj_test.rds")) + seurat_object_lite = Seurat::UpdateSeuratObject(seurat_object_lite) + seurat_object_lite@meta.data$celltype_aggregate = paste(seurat_object_lite@meta.data$celltype, seurat_object_lite@meta.data$aggregate,sep = "_") # user adaptation required on own dataset celltype_id = "celltype_aggregate" # metadata column name of the cell type of interest diff --git a/tests/testthat/test-prioritization.R b/tests/testthat/test-prioritization.R index b963808..3024556 100644 --- a/tests/testthat/test-prioritization.R +++ b/tests/testthat/test-prioritization.R @@ -5,6 +5,7 @@ test_that("Prioritization scheme works", { lr_network = readRDS(url("https://zenodo.org/record/7074291/files/lr_network_mouse_21122021.rds")) weighted_networks = readRDS(url("https://zenodo.org/record/7074291/files/weighted_networks_nsga2r_final_mouse.rds")) seurat_obj_test = readRDS(url("https://zenodo.org/record/3531889/files/seuratObj_test.rds")) + seurat_obj_test = Seurat::UpdateSeuratObject(seurat_obj_test) lr_network = lr_network %>% distinct(from, to) weighted_networks_lr = weighted_networks$lr_sig %>% inner_join(lr_network, by = c("from","to")) From 8effcd635674bc0d1b1850a9b81f631cfffd967b Mon Sep 17 00:00:00 2001 From: Chananchida Sang-aram VSCODE Date: Wed, 17 Jan 2024 11:28:36 +0100 Subject: [PATCH 3/3] fixed documentation --- R/application_visualization.R | 15 +++++---------- R/data.R | 5 +++-- man/make_mushroom_plot.Rd | 24 ++++++++++++++++++------ man/optimized_source_weights_df.Rd | 5 +++-- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/R/application_visualization.R b/R/application_visualization.R index 6ae5eec..5544d17 100644 --- a/R/application_visualization.R +++ b/R/application_visualization.R @@ -546,14 +546,9 @@ make_heatmap_bidir_lt_ggplot = function(matrix, y_name, x_name, y_axis = TRUE, x #' #' @description \code{make_mushroom_plot} Make a plot in which each glyph consists of two semicircles corresponding to ligand- and receptor- information. The size of the semicircle is the percentage of cells that express the protein, while the saturation corresponds to the scaled average expression value. #' -#' @usage -#' make_mushroom_plot(prioritization_table, top_n = 30, show_ranking = FALSE, show_all_datapoints = FALSE, true_color_range = FALSE, size = "scaled_avg_exprs", color = "scaled_lfc", -#' ligand_fill_colors = c("#DEEBF7", "#08306B"), receptor_fill_colors = c("#FEE0D2", "#A50F15"), -#' unranked_ligand_fill_colors = c(alpha("#FFFFFF", alpha=0.2), alpha("#252525", alpha=0.2)), unranked_receptor_fill_colors = c( alpha("#FFFFFF", alpha=0.2), alpha("#252525", alpha=0.2))) -#' #' @param prioritization_table A prioritization table as generated by \code{\link{generate_prioritization_tables}} #' @param top_n An integer indicating how many ligand-receptor pairs to show -#' @param show_ranking A logical indicating whether to show the ranking of the ligand-receptor pairs (default: FALSE) +#' @param show_rankings A logical indicating whether to show the ranking of the ligand-receptor pairs (default: FALSE) #' @param show_all_datapoints A logical indicating whether to show all ligand-receptor pairs (default: FALSE, if true they will be grayed out) #' @param true_color_range A logical indicating whether to use the true color range for the ligand-receptor pairs (default: FALSE; range 0-1 is used) #' @param size A string indicating which column to use for the size of the semicircles (default: "scaled_avg_exprs"; use column name without "_ligand" or "_receptor" suffix) @@ -576,13 +571,13 @@ make_heatmap_bidir_lt_ggplot = function(matrix, y_name, x_name, y_axis = TRUE, x #' # Create a prioritization table #' prior_table <- generate_prioritization_tables(processed_expr_table, processed_DE_table, ligand_activities, processed_condition_markers, prioritizing_weights) #' make_mushroom_plot(prior_table) -#' +#' #' # Show only top 20, and write rankings on the plot -#' make_mushroom_plot(prior_table, top_n = 20, show_ranking = TRUE) -#' +#' make_mushroom_plot(prior_table, top_n = 20, show_rankings = TRUE) +#' #' # Show all datapoints, and use true color range #' make_mushroom_plot(prior_table, show_all_datapoints = TRUE, true_color_range = TRUE) -#' +#' #' # Change the size and color columns #' make_mushroom_plot(prior_table, size = "pct_expressed", color = "scaled_avg_exprs") #' } diff --git a/R/data.R b/R/data.R index 9cd7104..9a16024 100644 --- a/R/data.R +++ b/R/data.R @@ -152,12 +152,13 @@ "annotation_data_sources" #' Optimized data source weights #' -#' A data.frame/tibble describing weight associated to each data source. These weights will be used for weighted aggregagion of source networks and were determined via parameter optimization (see NicheNet paper). +#' A data.frame/tibble describing weight associated to each data source. These weights will be used for weighted aggregation of source networks and were determined via parameter optimization (see NicheNet paper). #' #' @format A data frame/tibble #' \describe{ #' \item{source}{name of data source} -#' \item{weight}{weight associated to a data source} +#' \item{avg_weight}{weight associated to a data source, averaged over cross-validation folds} +#' \item{median_weight}{weight associated to a data source, averaged over cross-validation folds} #' } #' "optimized_source_weights_df" diff --git a/man/make_mushroom_plot.Rd b/man/make_mushroom_plot.Rd index 479f741..1ea8cad 100644 --- a/man/make_mushroom_plot.Rd +++ b/man/make_mushroom_plot.Rd @@ -4,15 +4,29 @@ \alias{make_mushroom_plot} \title{Make a "mushroom plot" of ligand-receptor interactions} \usage{ -make_mushroom_plot(prioritization_table, top_n = 30, show_ranking = FALSE, show_all_datapoints = FALSE, true_color_range = FALSE, size = "scaled_avg_exprs", color = "scaled_lfc", - ligand_fill_colors = c("#DEEBF7", "#08306B"), receptor_fill_colors = c("#FEE0D2", "#A50F15"), - unranked_ligand_fill_colors = c(alpha("#FFFFFF", alpha=0.2), alpha("#252525", alpha=0.2)), unranked_receptor_fill_colors = c( alpha("#FFFFFF", alpha=0.2), alpha("#252525", alpha=0.2))) +make_mushroom_plot( + prioritization_table, + top_n = 30, + show_rankings = FALSE, + show_all_datapoints = FALSE, + true_color_range = FALSE, + size = "scaled_avg_exprs", + color = "scaled_lfc", + ligand_fill_colors = c("#DEEBF7", "#08306B"), + receptor_fill_colors = c("#FEE0D2", "#A50F15"), + unranked_ligand_fill_colors = c(alpha("#FFFFFF", alpha = 0.2), alpha("#252525", alpha + = 0.2)), + unranked_receptor_fill_colors = c(alpha("#FFFFFF", alpha = 0.2), alpha("#252525", + alpha = 0.2)) +) } \arguments{ \item{prioritization_table}{A prioritization table as generated by \code{\link{generate_prioritization_tables}}} \item{top_n}{An integer indicating how many ligand-receptor pairs to show} +\item{show_rankings}{A logical indicating whether to show the ranking of the ligand-receptor pairs (default: FALSE)} + \item{show_all_datapoints}{A logical indicating whether to show all ligand-receptor pairs (default: FALSE, if true they will be grayed out)} \item{true_color_range}{A logical indicating whether to use the true color range for the ligand-receptor pairs (default: FALSE; range 0-1 is used)} @@ -28,8 +42,6 @@ make_mushroom_plot(prioritization_table, top_n = 30, show_ranking = FALSE, show_ \item{unranked_ligand_fill_colors}{A vector of the low and high colors to use for the unranked ligands when show_all_datapoints is TRUE (default: c(alpha("#FFFFFF", alpha=0.2), alpha("#252525", alpha=0.2)))} \item{unranked_receptor_fill_colors}{A vector of the low and high colors to use for the unkraed receptors when show_all_datapoints is TRUE (default: c(alpha("#FFFFFF", alpha=0.2), alpha("#252525", alpha=0.2)))} - -\item{show_ranking}{A logical indicating whether to show the ranking of the ligand-receptor pairs (default: FALSE)} } \value{ A ggplot object @@ -44,7 +56,7 @@ prior_table <- generate_prioritization_tables(processed_expr_table, processed_DE make_mushroom_plot(prior_table) # Show only top 20, and write rankings on the plot -make_mushroom_plot(prior_table, top_n = 20, show_ranking = TRUE) +make_mushroom_plot(prior_table, top_n = 20, show_rankings = TRUE) # Show all datapoints, and use true color range make_mushroom_plot(prior_table, show_all_datapoints = TRUE, true_color_range = TRUE) diff --git a/man/optimized_source_weights_df.Rd b/man/optimized_source_weights_df.Rd index 0f0fe4e..3c7f792 100644 --- a/man/optimized_source_weights_df.Rd +++ b/man/optimized_source_weights_df.Rd @@ -8,13 +8,14 @@ A data frame/tibble \describe{ \item{source}{name of data source} - \item{weight}{weight associated to a data source} + \item{avg_weight}{weight associated to a data source, averaged over cross-validation folds} + \item{median_weight}{weight associated to a data source, averaged over cross-validation folds} } } \usage{ optimized_source_weights_df } \description{ -A data.frame/tibble describing weight associated to each data source. These weights will be used for weighted aggregagion of source networks and were determined via parameter optimization (see NicheNet paper). +A data.frame/tibble describing weight associated to each data source. These weights will be used for weighted aggregation of source networks and were determined via parameter optimization (see NicheNet paper). } \keyword{datasets}