Skip to content

Commit f56aa0e

Browse files
committed
Adjust validation for single-lane hashing
1 parent 5d29ff0 commit f56aa0e

2 files changed

Lines changed: 38 additions & 12 deletions

File tree

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1+
if (!file.exists('/homeDir/.netrc')) {
2+
print(list.files('/homeDir'))
3+
stop('Unable to find file: /homeDir/.netrc')
4+
}
5+
6+
invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = '/homeDir/.netrc'))
7+
Rdiscvr::SetLabKeyDefaults(baseUrl = serverBaseUrl, defaultFolder = defaultLabKeyFolder)
8+
19
for (datasetId in names(seuratObjects)) {
2-
printName(datasetId)
3-
seuratObj <- readSeuratRDS(seuratObjects[[datasetId]])
10+
printName(datasetId)
11+
seuratObj <- readSeuratRDS(seuratObjects[[datasetId]])
12+
13+
if (!'HasCDR3Data' %in% names(seuratObj@meta.data)) {
14+
seuratObj <- Rdiscvr::DownloadAndAppendTcrClonotypes(seuratObj)
15+
}
416

5-
seuratObj <- Rdiscvr::ClassifyTNKByExpression(seuratObj)
17+
seuratObj <- Rdiscvr::ClassifyTNKByExpression(seuratObj)
618

7-
saveData(seuratObj, datasetId)
19+
saveData(seuratObj, datasetId)
820

9-
# Cleanup
10-
rm(seuratObj)
11-
gc()
21+
# Cleanup
22+
rm(seuratObj)
23+
gc()
1224
}

singlecell/src/org/labkey/singlecell/CellHashingServiceImpl.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public void prepareHashingAndCiteSeqFilesIfNeeded(File sourceDir, PipelineJob jo
127127
FieldKey.fromString("citeseqReadsetId/totalFiles"),
128128
FieldKey.fromString("citeseqPanel"),
129129
FieldKey.fromString("status"),
130+
FieldKey.fromString("plateId"),
130131
FieldKey.fromString("readsetId"))
131132
);
132133

@@ -151,6 +152,7 @@ public void prepareHashingAndCiteSeqFilesIfNeeded(File sourceDir, PipelineJob jo
151152
writer.writeNext(new String[]{"ReadsetId", "CDNA_ID", "SubjectId", "Stim", "Population", "HashingReadsetId", "HasHashingReads", "HTO_Name", "HTO_Seq", "CiteSeqReadsetId", "HasCiteSeqReads", "CiteSeqPanel"});
152153
Set<String> distinctHTOs = new HashSet<>();
153154
Set<Boolean> hashingStatus = new HashSet<>();
155+
Map<String, Set<String>> plateToHto = new HashMap<>();
154156
AtomicInteger totalWritten = new AtomicInteger(0);
155157
for (Readset rs : cachedReadsets)
156158
{
@@ -186,10 +188,17 @@ public void prepareHashingAndCiteSeqFilesIfNeeded(File sourceDir, PipelineJob jo
186188
uniqueGex.add(results.getInt(FieldKey.fromString("readsetId")));
187189
}
188190

189-
boolean useCellHashing = results.getObject(FieldKey.fromString("sortId/hto")) != null;
190-
hashingStatus.add(useCellHashing);
191-
if (useCellHashing)
191+
boolean hasHTO = results.getObject(FieldKey.fromString("sortId/hto")) != null;
192+
193+
if (!plateToHto.containsKey(results.getString(FieldKey.fromString("plateId"))))
192194
{
195+
plateToHto.put(results.getString(FieldKey.fromString("plateId")), new HashSet<>());
196+
}
197+
198+
if (hasHTO)
199+
{
200+
plateToHto.get(results.getString(FieldKey.fromString("plateId"))).add(results.getString(FieldKey.fromString("sortId/hto")));
201+
193202
if (results.getObject(FieldKey.fromString("hashingReadsetId")) == null)
194203
{
195204
// NOTE: there can be lanes with single HTOs/lane. This will fail down the line
@@ -244,12 +253,17 @@ public void prepareHashingAndCiteSeqFilesIfNeeded(File sourceDir, PipelineJob jo
244253
throw new PipelineJobException("There is a problem with either cell hashing or CITE-seq. See the file: " + output.getName());
245254
}
246255

256+
// If there is one HTO per plate, hashing is not actually needed:
257+
for (String plateId : plateToHto.keySet())
258+
{
259+
Set<String> htos = plateToHto.get(plateId);
260+
hashingStatus.add(htos.size() > 1);
261+
}
262+
247263
if (hashingStatus.size() > 1)
248264
{
249265
job.getLogger().info("The selected readsets/cDNA records use a mixture of cell hashing and non-hashing.");
250266
}
251-
252-
//NOTE: hashingStatus.isEmpty() indicates there are no cDNA records associated with the data
253267
}
254268

255269
if (doH5Caching)

0 commit comments

Comments
 (0)