Skip to content

Commit

Permalink
Add sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
bbimber committed Jan 26, 2025
1 parent 146ac85 commit 2fe0f76
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions R/NimbleAppend.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ AppendNimbleCounts <- function(seuratObject, nimbleFile, targetAssayName, maxAmb

# Cast nimble df to matrix
featureNames <- df$V1
if (any(duplicated(featureNames))) {
stop('Error, there were duplicate feature names')
}

df <- subset(df, select=-(V1))
m <- Reduce(methods::cbind2, lapply(df, Matrix::Matrix, sparse = TRUE))
dimnames(m) <- list(featureNames, colnames(df))
Expand Down Expand Up @@ -210,6 +214,9 @@ AppendNimbleCounts <- function(seuratObject, nimbleFile, targetAssayName, maxAmb
}
} else {
# Add nimble as separate assay
if (any(duplicated(rownames(m)))) {
stop('Error: The count matrix had duplicate rownames')
}
seuratObject[[targetAssayName]] <- Seurat::CreateAssayObject(counts = m, min.features = 0, min.cells = 0)

fs <- rep('Nimble', nrow(seuratObject@assays[[targetAssayName]]))
Expand Down

0 comments on commit 2fe0f76

Please sign in to comment.