Skip to content
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
22 changes: 22 additions & 0 deletions R/makeShinyFilesDEG.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,28 @@ makeShinyFilesDEG <- function(
)
}

# Validate DEG cluster levels match metadata cluster levels
deg_clusters <- sort(unique(as.character(markergenes$cluster)))
meta_clusters <- sort(unique(as.character(obj@meta.data[[clusters]])))
if (!all(deg_clusters %in% meta_clusters)) {
missing <- setdiff(deg_clusters, meta_clusters)
stop(
"DEG markers contain cluster(s) not found in metadata column '", clusters, "': ",
paste(missing, collapse = ", "),
"\n DEG clusters: ", paste(deg_clusters, collapse = ", "),
"\n Metadata clusters: ", paste(meta_clusters, collapse = ", ")
)
}

# Validate that the clusters column exists in scConf (i.e. it was not filtered out)
if (!clusters %in% scConf$ID && !clusters %in% scConf$UI) {
stop(
"Cluster label '", clusters, "' was not included in the ShinyCell config (sc1conf). ",
"It may have been removed by metadata filtering (rmmeta/unsupported assay pattern). ",
"Please ensure this column is retained in the config."
)
}

# markergene h5 creation
n_rows <- nrow(markergenes)
n_cols <- ncol(markergenes)
Expand Down
4 changes: 2 additions & 2 deletions R/writer1.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ wrSVmainA1 <- function(prefix) {
' return(list(res,resDef,resLen))\n',
' }})\n',
' observeEvent(gsub("^Assay: ", "", input${prefix}a1ass1), {{\n',
' updateSelectizeInput(session, "{prefix}a1inp1", choices = getG{prefix}a1inp1()[[1]], \n',
' server = TRUE, selected = getG{prefix}a1inp1()[[2]], options = list( \n',
' updateSelectizeInput(session, "{prefix}a1inp1", choices = getG{prefix}a1inp1()[[1]], \n',
' server = TRUE, selected = getG{prefix}a1inp1()[[1]][1], options = list( \n',
' maxOptions = getG{prefix}a1inp1()[[3]], create = TRUE, \n',
' persist = TRUE, render = I(optCrt))) \n',
' }})\n',
Expand Down
4 changes: 3 additions & 1 deletion R/writer2.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ wrUImainA1 <- function(prefix, ptsiz) {
' selectInput("{prefix}a1ass1", "Data type to colour plot:",\n',
' choices = c("Cell Information", paste0("Assay: ", {prefix}def$assay)), \n',
' selected = "Cell Information"), \n',
' selectInput("{prefix}a1inp1", "Cell Info / Feature Name:", choices = NULL) %>% \n',
' selectInput("{prefix}a1inp1", "Cell Info / Feature Name:", \n',
' choices = {prefix}conf$UI, \n',
' selected = {prefix}conf$UI[1]) %>% \n',
' helper(type = "inline", size = "m", fade = TRUE,\n',
' title = "Cell Info / Gene to colour cells by",\n',
' content = c("Select cell info / feature to colour cells",\n',
Expand Down
Loading