Skip to content
Open
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
17 changes: 17 additions & 0 deletions R/makeShinyFilesGEX.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@ makeShinyFilesGEX <- function(
}
sc1conf$ID = as.character(sc1conf$ID) # Remove levels

# Filter sc1meta to only cells present in all dimension reductions.
# A mismatch occurs when the Seurat object contains cells in @meta.data that
# are absent from @reductions (e.g. after reference-based mapping or merging).
# Indexing a matrix with an unknown rowname throws "subscript out of bounds".
if(class(obj)[1] == "Seurat"){
for(iDR in dimred.to.use){
drCells = rownames(obj@reductions[[iDR]]@cell.embeddings)
nBefore = nrow(sc1meta)
sc1meta = sc1meta[cellID %in% drCells]
nDropped = nBefore - nrow(sc1meta)
if(nDropped > 0){
warning(paste0(nDropped, " cell(s) in metadata have no embeddings in '",
iDR, "' and were dropped from the Shiny app."))
}
}
}

# Make prefix_dimr.rds
sc1dimr = list()
if(class(obj)[1] == "Seurat"){
Expand Down
Loading