Skip to content

Commit d4ad7d4

Browse files
committed
Store barcodes as list to enforce uniqueness
1 parent 0af7e45 commit d4ad7d4

File tree

13 files changed

+40
-28
lines changed

13 files changed

+40
-28
lines changed

singlecell/api-src/org/labkey/api/singlecell/CellHashingService.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
import java.util.ArrayList;
2727
import java.util.Arrays;
2828
import java.util.Collections;
29+
import java.util.HashSet;
2930
import java.util.List;
31+
import java.util.Set;
3032
import java.util.stream.Collectors;
3133

3234
abstract public class CellHashingService
@@ -71,14 +73,14 @@ static public void setInstance(CellHashingService instance)
7173

7274
abstract public List<ToolParameterDescriptor> getDefaultHashingParams(boolean includeExcludeFailedcDNA);
7375

74-
abstract public List<String> getHtosForParentReadset(Integer parentReadsetId, File webserverJobDir, SequenceAnalysisJobSupport support) throws PipelineJobException;
76+
abstract public Set<String> getHtosForParentReadset(Integer parentReadsetId, File webserverJobDir, SequenceAnalysisJobSupport support) throws PipelineJobException;
7577

7678
public static class CellHashingParameters
7779
{
7880
public BARCODE_TYPE type;
7981

8082
private File htoOrCiteseqBarcodesFile;
81-
public List<String> allowableHtoOrCiteseqBarcodes;
83+
public Set<String> allowableHtoOrCiteseqBarcodes;
8284

8385
public File cellBarcodeWhitelistFile;
8486

@@ -227,18 +229,18 @@ public void validate(boolean allowMissingHtoReadset)
227229
}
228230
}
229231

230-
public List<String> getAllowableBarcodeNames() throws PipelineJobException
232+
public Set<String> getAllowableBarcodeNames() throws PipelineJobException
231233
{
232234
if (allowableHtoOrCiteseqBarcodes != null)
233235
{
234-
return Collections.unmodifiableList(allowableHtoOrCiteseqBarcodes);
236+
return Collections.unmodifiableSet(allowableHtoOrCiteseqBarcodes);
235237
}
236238
if (htoOrCiteseqBarcodesFile == null)
237239
{
238240
throw new IllegalArgumentException("Barcode file was null");
239241
}
240242

241-
List<String> allowableBarcodes = new ArrayList<>();
243+
Set<String> allowableBarcodes = new HashSet<>();
242244
try (CSVReader reader = new CSVReader(Readers.getReader(htoOrCiteseqBarcodesFile), '\t'))
243245
{
244246
String[] line;

singlecell/resources/chunks/NormalizeAndScale.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ for (datasetId in names(seuratObjects)) {
44
seuratObjects[[datasetId]] <- NULL
55
gc()
66

7-
seuratObj <- CellMembrane::NormalizeAndScale(seuratObj, variableFeatureSelectionMethod = variableFeatureSelectionMethod)
7+
seuratObj <- CellMembrane::NormalizeAndScale(seuratObj, variableFeatureSelectionMethod = variableFeatureSelectionMethod, block.size = block.size)
88

99
newSeuratObjects[[datasetId]] <- seuratObj
1010

singlecell/resources/chunks/RemoveCellCycle.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
for (datasetId in names(seuratObjects)) {
22
seuratObj <- seuratObjects[[datasetId]]
33

4-
seuratObj <- CellMembrane::RemoveCellCycle(seuratObj)
4+
seuratObj <- CellMembrane::RemoveCellCycle(seuratObj, block.size = block.size)
55

66
newSeuratObjects[[datasetId]] <- seuratObj
77

singlecell/resources/chunks/SaveData.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ for (datasetId in names(newSeuratObjects)) {
1414

1515
savedFiles <- rbind(savedFiles, data.frame(datasetId = datasetId, datasetName = datasetName, filename = fn, outputFileId = outputFileId))
1616

17-
CellMembrane::WriteCellBarcodes(seuratObj, file = barcodeFile)
17+
# WriteCellBarcodes
18+
write.table(data.frame(CellBarcode = colnames(seuratObj)), file = barcodeFile, quote = F, row.names = F, sep = ',', col.names = F)
1819
}
1920

2021
write.table(savedFiles, file = 'savedSeuratObjects.txt', quote = FALSE, sep = '\t', row.names = FALSE, col.names = FALSE)

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ private File generateCellHashingCalls(File citeSeqCountOutDir, File outputDir, S
12261226
cellbarcodeWhitelist = "'/work/" + cellBarcodeWhitelistFile.getName() + "'";
12271227
}
12281228

1229-
List<String> allowableBarcodes = parameters.getAllowableBarcodeNames();
1229+
Set<String> allowableBarcodes = parameters.getAllowableBarcodeNames();
12301230
String allowableBarcodeParam = allowableBarcodes != null ? "c('" + StringUtils.join(allowableBarcodes, "','") + "')" : "NULL";
12311231

12321232
writer.println("cellhashR::CallAndGenerateReport(rawCountData = '/work/" + citeSeqCountOutDir.getName() + "', reportFile = '/work/" + htmlFile.getName() + "', callFile = '/work/" + callsFile.getName() + "', metricsFile = '/work/" + metricsFile.getName() + "', cellbarcodeWhitelist = " + cellbarcodeWhitelist + ", barcodeWhitelist = " + allowableBarcodeParam + ", title = '" + parameters.getReportTitle() + "', methods = c('" + StringUtils.join(methodNames, "','") + "'))");
@@ -1466,12 +1466,12 @@ else if (line.startsWith("Percentage unmapped"))
14661466
}
14671467

14681468
@Override
1469-
public List<String> getHtosForParentReadset(Integer parentReadsetId, File webserverJobDir, SequenceAnalysisJobSupport support) throws PipelineJobException
1469+
public Set<String> getHtosForParentReadset(Integer parentReadsetId, File webserverJobDir, SequenceAnalysisJobSupport support) throws PipelineJobException
14701470
{
14711471
return getHtosForParentReadset(parentReadsetId, webserverJobDir, support, true);
14721472
}
14731473

1474-
public List<String> getHtosForParentReadset(Integer parentReadsetId, File webserverJobDir, SequenceAnalysisJobSupport support, boolean throwIfNotFound) throws PipelineJobException
1474+
public Set<String> getHtosForParentReadset(Integer parentReadsetId, File webserverJobDir, SequenceAnalysisJobSupport support, boolean throwIfNotFound) throws PipelineJobException
14751475
{
14761476
Integer htoReadset = getCachedHashingReadsetMap(support).get(parentReadsetId);
14771477
if (htoReadset == null)
@@ -1482,16 +1482,16 @@ public List<String> getHtosForParentReadset(Integer parentReadsetId, File webser
14821482
}
14831483
else
14841484
{
1485-
return (Collections.emptyList());
1485+
return (Collections.emptySet());
14861486
}
14871487
}
14881488

14891489
return getHtosForReadset(htoReadset, webserverJobDir);
14901490
}
14911491

1492-
public List<String> getHtosForReadset(Integer hashingReadsetId, File webserverJobDir) throws PipelineJobException
1492+
public Set<String> getHtosForReadset(Integer hashingReadsetId, File webserverJobDir) throws PipelineJobException
14931493
{
1494-
List<String> htosPerReadset = new ArrayList<>();
1494+
Set<String> htosPerReadset = new HashSet<>();
14951495
try (CSVReader reader = new CSVReader(Readers.getReader(CellHashingServiceImpl.get().getCDNAInfoFile(webserverJobDir)), '\t'))
14961496
{
14971497
String[] line;

singlecell/src/org/labkey/singlecell/SingleCellController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,11 @@ public URLHelper getSuccessURL(Object form)
429429
return getContainer().getStartURL(getUser());
430430
}
431431

432+
@Override
432433
public ModelAndView getView(Object form, BindException errors) throws Exception
433434
{
434435
LinkedHashSet<ClientDependency> cds = new LinkedHashSet<>();
435-
for (PipelineStepProvider fact : SequencePipelineService.get().getAllProviders())
436+
for (PipelineStepProvider<?> fact : SequencePipelineService.get().getAllProviders())
436437
{
437438
cds.addAll(fact.getClientDependencies());
438439
}

singlecell/src/org/labkey/singlecell/analysis/CellRangerSeuratHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ else if (rs.getReadsetId() == null)
671671
throw new PipelineJobException("Unable to find hashing readset for GEX readset: " + rs.getReadsetId());
672672
}
673673

674-
List<String> htosPerReadset = CellHashingServiceImpl.get().getHtosForReadset(hashingReadsetId, ctx.getSourceDirectory());
674+
Set<String> htosPerReadset = CellHashingServiceImpl.get().getHtosForReadset(hashingReadsetId, ctx.getSourceDirectory());
675675
if (htosPerReadset.size() > 1)
676676
{
677677
ctx.getLogger().info("Total HTOs for readset: " + htosPerReadset.size());

singlecell/src/org/labkey/singlecell/analysis/LoupeCellHashingHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.LinkedHashSet;
2525
import java.util.List;
2626
import java.util.Map;
27+
import java.util.Set;
2728

2829
public class LoupeCellHashingHandler extends AbstractParameterizedOutputHandler<SequenceOutputHandler.SequenceOutputProcessor>
2930
{
@@ -179,7 +180,7 @@ else if (rs.getReadsetId() == null)
179180
throw new PipelineJobException("Unable to find Hashing/Cite-seq readset for GEX readset: " + rs.getReadsetId());
180181
}
181182

182-
List<String> htosPerReadset = CellHashingServiceImpl.get().getHtosForReadset(htoReadset.getReadsetId(), ctx.getSourceDirectory());
183+
Set<String> htosPerReadset = CellHashingServiceImpl.get().getHtosForReadset(htoReadset.getReadsetId(), ctx.getSourceDirectory());
183184
if (htosPerReadset.size() > 1)
184185
{
185186
ctx.getLogger().info("Total HTOs for readset: " + htosPerReadset.size());

singlecell/src/org/labkey/singlecell/analysis/SeuratCellHashingHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.ArrayList;
2121
import java.util.List;
2222
import java.util.Map;
23+
import java.util.Set;
2324

2425
public class SeuratCellHashingHandler extends AbstractParameterizedOutputHandler<SequenceOutputHandler.SequenceOutputProcessor>
2526
{
@@ -135,7 +136,7 @@ else if (rs.getReadsetId() == null)
135136
throw new PipelineJobException("Unable to find Hashing/Cite-seq readset for GEX readset: " + rs.getReadsetId());
136137
}
137138

138-
List<String> htosPerReadset = CellHashingServiceImpl.get().getHtosForReadset(htoReadset.getReadsetId(), ctx.getSourceDirectory());
139+
Set<String> htosPerReadset = CellHashingServiceImpl.get().getHtosForReadset(htoReadset.getReadsetId(), ctx.getSourceDirectory());
139140
if (htosPerReadset.size() > 1)
140141
{
141142
ctx.getLogger().info("Total HTOs for readset: " + htosPerReadset.size());

singlecell/src/org/labkey/singlecell/pipeline/singlecell/DoubletFinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static class Provider extends AbstractPipelineStepProvider<SingleCellStep
2020
public Provider()
2121
{
2222
super("DoubletFinder", "DoubletFinder", "DoubletFinder", "This will run DoubletFinder to identify putative doublets.", Arrays.asList(
23-
SeuratToolParameter.create("dropDoublets", "Drop Doublets", "This will run DoubletFinder on the seurat object(s)", "checkbox", new JSONObject(){{
23+
SeuratToolParameter.create("dropDoublets", "Drop Doublets", "If true, any cells flagged as doublets will be dropped from the seurat object", "checkbox", new JSONObject(){{
2424

2525
}}, false)
2626
), null, null);

0 commit comments

Comments
 (0)