diff celesta_plot_cells.R @ 3:283636dbfba5 draft default tip

planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/celesta commit 36453551b1045adf20925d4eb6b5816c64475728
author goeckslab
date Thu, 19 Sep 2024 17:17:51 +0000
parents 8001319743c0
children
line wrap: on
line diff
--- a/celesta_plot_cells.R	Mon Sep 16 18:51:31 2024 +0000
+++ b/celesta_plot_cells.R	Thu Sep 19 17:17:51 2024 +0000
@@ -17,8 +17,6 @@
 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 @@
 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(CelestaObj@prior_info[, 1] %in% cell_types_to_plot)
 
-# get indices of cell types to plot from the prior marker table
-cell_type_indices <- which(row.names(prior) %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 @@
 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,