Skip to content

Commit 35eff13

Browse files
committed
Improve the logic for CheckExpectations and RIRA fields
1 parent 87243a7 commit 35eff13

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

singlecell/resources/chunks/CheckExpectations.R

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,23 @@ for (datasetId in names(seuratObjects)) {
5151
}
5252

5353
if (requireRiraImmune) {
54-
CheckField(seuratObj, datasetId, 'RIRA_Immune_v2.cellclass')
54+
# Note: if a given dataset has fewer than 200 cells, it will return NAs for RIRA:
55+
if (!'RIRA_Immune_v2.cellclass' %in% names(seuratObj@meta.data)) {
56+
addErrorMessage(paste0(paste0('Missing ', 'RIRA_Immune_v2.cellclass', ' for dataset: ', datasetId)))
57+
}
58+
59+
if ('DatasetId' %in% names(seuratObj@meta.data)) {
60+
for (ds in sort(unique(seuratObj@meta.data$DatasetId))) {
61+
dat <- seuratObj@meta.data$RIRA_Immune_v2.cellclass[seuratObj@meta.data$DatasetId == ds]
62+
if (any(is.na(dat))) {
63+
if (length(dat) > 200) {
64+
addErrorMessage(paste0('NA values found for RIRA_Immune_v2.cellclass for DatasetId: ', ds, ', for dataset: ', datasetId))
65+
} else {
66+
print(paste0('NA values found for RIRA_Immune_v2.cellclass for DatasetId: ', ds, ', for dataset: ', datasetId, '. ignoring because there are fewer than 200 total cells'))
67+
}
68+
}
69+
}
70+
}
5571
}
5672

5773
if (length(errorMessages) > 0) {

0 commit comments

Comments
 (0)