Skip to content

Commit db3288c

Browse files
committed
Bugfixes to cell hashing assignment
1 parent f9dacd0 commit db3288c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

singlecell/resources/chunks/CommonFilters.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ for (datasetId in names(seuratObjects)) {
9595
stop('Missing field: HTO.Classification')
9696
}
9797

98+
# NOTE: this is added to fix an edge case that could occur if hashing not properly set
99+
if (all(is.na(seuratObj$HTO.Classification))) {
100+
print('HTO.Classification was NA, setting to NotUsed')
101+
seuratObj$HTO.Classification <- 'NotUsed'
102+
}
103+
98104
tryCatch({
99105
cells <- Seurat::WhichCells(seuratObj, expression = HTO.Classification!='ND' & HTO.Classification!='Discordant' & HTO.Classification!='Doublet' & HTO.Classification!='Low Counts')
100106
if (length(cells) == 0) {

singlecell/resources/chunks/SeuratPrototype.R

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,8 @@ for (datasetId in names(seuratObjects)) {
3232
metricData <- rbind(metricData, data.frame(dataId = datasetId, readsetId = datasetIdToReadset[[datasetId]], metricname = 'FractionDiscordantHashing', metricvalue = fractionDiscordantHashing))
3333
} else {
3434
# Ensure these fields exist:
35-
if (!'HTO.Classification' %in% names(seuratObj@meta.data)) {
36-
seuratObj$HTO.Classification <- c('NotUsed')
37-
}
38-
39-
if (!'HTO' %in% names(seuratObj@meta.data)) {
40-
seuratObj$HTO <- c('NotUsed')
41-
}
35+
seuratObj$HTO.Classification <- c('NotUsed')
36+
seuratObj$HTO <- c('NotUsed')
4237
}
4338

4439
if (is.null(usesCiteSeq[[datasetId]])) {

0 commit comments

Comments
 (0)