Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix celesta plot_cells indexing bug #90

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tools/celesta/celesta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
Expand Down
16 changes: 5 additions & 11 deletions tools/celesta/celesta_plot_cells.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -37,34 +35,30 @@ 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
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,
Expand Down
2 changes: 1 addition & 1 deletion tools/celesta/macros.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<macros>
<token name="@TOOL_VERSION@">0.0.0.9</token>
<token name="@VERSION_SUFFIX@">2</token>
<token name="@VERSION_SUFFIX@">3</token>
<token name="@PROFILE@">20.01</token>

<xml name="celesta_requirements">
Expand Down
Loading