From a33f6b657eb2a245e1b622999682bcbea03984c5 Mon Sep 17 00:00:00 2001 From: CameronFRWatson Date: Wed, 18 Sep 2024 15:00:10 -0700 Subject: [PATCH 1/3] Fix celesta plot_cells indexing bug --- tools/celesta/celesta.xml | 1 - tools/celesta/celesta_plot_cells.R | 16 +++++----------- tools/celesta/macros.xml | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/tools/celesta/celesta.xml b/tools/celesta/celesta.xml index 98335b3..ed73c7d 100644 --- a/tools/celesta/celesta.xml +++ b/tools/celesta/celesta.xml @@ -43,7 +43,6 @@ #end if #for $p in $runmode.plot_cells: && Rscript '$__tool_directory__/celesta_plot_cells.R' - --prior '$prior_info' --celltypes '${p.cell_types}' --size '${p.test_size}' --height '${p.height}' diff --git a/tools/celesta/celesta_plot_cells.R b/tools/celesta/celesta_plot_cells.R index 51e47ea..f54adf6 100644 --- a/tools/celesta/celesta_plot_cells.R +++ b/tools/celesta/celesta_plot_cells.R @@ -17,8 +17,6 @@ suppressWarnings(suppressMessages(library(CELESTA))) option_list <- list( make_option(c("-r", "--rds"), action = "store", default = "celestaobj.rds", type = "character", help = "Path to CelestaObj RDS"), - make_option(c("-p", "--prior"), action = "store", default = NA, type = "character", - help = "Path to prior marker info file"), make_option(c("-c", "--celltypes"), action = "store", default = NA, type = "character", help = "Comma-separated list of cell types to plot"), make_option(c("-s", "--size"), action = "store", default = 1, type = "double", @@ -37,26 +35,23 @@ opt <- parse_args(OptionParser(option_list = option_list)) CelestaObj <- readRDS(opt$rds) cell_types_to_plot <- strsplit(opt$celltypes, ",")[[1]] -# read prior marker info -prior <- read.csv(opt$prior, row.names = 1) - # get indices of cell types to plot from the prior marker table -cell_type_indices <- which(row.names(prior) %in% cell_types_to_plot) +cell_type_indices <- which(CelestaObj@prior_info[,1] %in% cell_types_to_plot) +print('Cell types selected for plotting:') print(cell_types_to_plot) +print('Indices of cell types selected for plotting:') print(cell_type_indices) -print(row.names(prior)) - # create output directory if it doesn"t already exist dir.create("cell_assign_plots") # create the cell type plot g <- PlotCellsAnyCombination(cell_type_assignment_to_plot = CelestaObj@final_cell_type_assignment[, (CelestaObj@total_rounds + 1)], coords = CelestaObj@coords, - prior_info = prior_marker_info, + prior_info = CelestaObj@prior_info, cell_number_to_use = cell_type_indices, - test_size = 1, + test_size = opt$size, save_plot = FALSE) # create a unique output name for the plot based on the input cell types @@ -64,7 +59,6 @@ cell_types_cleaned <- paste(make_clean_names(cell_types_to_plot), collapse = "") output_name <- paste(c("plot_cells_", cell_types_cleaned, ".png"), collapse = "") # save to subdir -# FIXME: may want to expose plotting params to galaxy ggsave( path = "cell_assign_plots", filename = output_name, diff --git a/tools/celesta/macros.xml b/tools/celesta/macros.xml index aac15ff..d6415ce 100644 --- a/tools/celesta/macros.xml +++ b/tools/celesta/macros.xml @@ -1,6 +1,6 @@ 0.0.0.9 - 2 + 3 20.01 From dc5e103e1a60ed089aeee6602bd1825265424be6 Mon Sep 17 00:00:00 2001 From: CameronFRWatson Date: Wed, 18 Sep 2024 15:40:08 -0700 Subject: [PATCH 2/3] lintr fixes --- tools/celesta/celesta_plot_cells.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/celesta/celesta_plot_cells.R b/tools/celesta/celesta_plot_cells.R index f54adf6..f149957 100644 --- a/tools/celesta/celesta_plot_cells.R +++ b/tools/celesta/celesta_plot_cells.R @@ -38,9 +38,9 @@ cell_types_to_plot <- strsplit(opt$celltypes, ",")[[1]] # get indices of cell types to plot from the prior marker table cell_type_indices <- which(CelestaObj@prior_info[,1] %in% cell_types_to_plot) -print('Cell types selected for plotting:') +print("Cell types selected for plotting:") print(cell_types_to_plot) -print('Indices of cell types selected for plotting:') +print("Indices of cell types selected for plotting:") print(cell_type_indices) # create output directory if it doesn"t already exist From 4fec4b252102dc4f1e33f7223794964a1f8f25bc Mon Sep 17 00:00:00 2001 From: CameronFRWatson Date: Wed, 18 Sep 2024 15:46:59 -0700 Subject: [PATCH 3/3] more lintr fixes --- tools/celesta/celesta_plot_cells.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/celesta/celesta_plot_cells.R b/tools/celesta/celesta_plot_cells.R index f149957..a87cb91 100644 --- a/tools/celesta/celesta_plot_cells.R +++ b/tools/celesta/celesta_plot_cells.R @@ -36,7 +36,7 @@ CelestaObj <- readRDS(opt$rds) cell_types_to_plot <- strsplit(opt$celltypes, ",")[[1]] # get indices of cell types to plot from the prior marker table -cell_type_indices <- which(CelestaObj@prior_info[,1] %in% cell_types_to_plot) +cell_type_indices <- which(CelestaObj@prior_info[, 1] %in% cell_types_to_plot) print("Cell types selected for plotting:") print(cell_types_to_plot)