Skip to content

Commit 0a4b557

Browse files
committed
Allow filtering of aggregate CITEseq barcodes
1 parent 0c6c0cf commit 0a4b557

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

singlecell/resources/chunks/AppendCiteSeq.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ for (datasetId in names(seuratObjects)) {
1616
matrixDir <- featureData[[datasetId]]
1717
if (!is.null(matrixDir)) {
1818
tryCatch({
19-
seuratObj <- CellMembrane::AppendCiteSeq(seuratObj, unfilteredMatrixDir = matrixDir, normalizeMethod = normalizeMethod, datasetId = datasetId, featureMetadata = featureMetadata, adtWhitelist = adtWhitelist, runCellBender = runCellBender)
19+
aggregateBarcodeFile <- NULL
20+
if (dropAggregateBarcodes) {
21+
aggregateBarcodeFile <- paste0(matrixDir, ".aggregateCounts.csv")
22+
if (!file.exists(aggregateBarcodeFile)) {
23+
stop(paste0('Unable to find file: ', aggregateBarcodeFile))
24+
}
25+
}
26+
27+
seuratObj <- CellMembrane::AppendCiteSeq(seuratObj, unfilteredMatrixDir = matrixDir, normalizeMethod = normalizeMethod, datasetId = datasetId, featureMetadata = featureMetadata, adtWhitelist = adtWhitelist, runCellBender = runCellBender, aggregateBarcodeFile = aggregateBarcodeFile)
2028
}, error = function(e){
2129
print(paste0('Error running AppendCiteSeq for: ', datasetId))
2230
print(conditionMessage(e))

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ private static List<ToolParameterDescriptor> getParams()
5858

5959
}}, false));
6060

61+
ret.add(SeuratToolParameter.create("dropAggregateBarcodes", "Drop Aggregate Barcodes", "If checked, any barcodes marked as protein aggregates by cellranger will be dropped.", "checkbox", new JSONObject(){{
62+
put("checked", true);
63+
}}, true));
64+
6165
return ret;
6266
}
6367

@@ -90,9 +94,11 @@ protected Map<Integer, File> prepareCountData(SingleCellOutput output, SequenceO
9094
{
9195
Map<Integer, File> dataIdToCalls = new HashMap<>();
9296

97+
boolean dropAggregateBarcodes = getProvider().getParameterByName("dropAggregateBarcodes").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Boolean.class, true);
9398
for (SeuratObjectWrapper wrapper : inputObjects)
9499
{
95100
File localCopyUmiCountDir = null;
101+
File localAggregateCountFile = null;
96102
if (wrapper.getSequenceOutputFileId() == null)
97103
{
98104
throw new PipelineJobException("Append CITE-seq is only support using seurat objects will a single input dataset. Consider moving this step easier in your pipeline, before merging or subsetting");
@@ -126,9 +132,32 @@ protected Map<Integer, File> prepareCountData(SingleCellOutput output, SequenceO
126132
{
127133
throw new PipelineJobException(e);
128134
}
129-
130135
ctx.getFileManager().addIntermediateFile(localCopyUmiCountDir);
131136

137+
if (dropAggregateBarcodes)
138+
{
139+
File aggregateCountFile = new File(existingCountMatrixUmiDir.getParentFile(), "antibody_analysis/aggregate_barcodes.csv");
140+
if (!aggregateCountFile.exists())
141+
{
142+
throw new PipelineJobException("Unable to find aggregate count file: " + aggregateCountFile.getPath());
143+
}
144+
localAggregateCountFile = new File(ctx.getOutputDir(), localCopyUmiCountDir.getName() + ".aggregateCounts.csv");
145+
try
146+
{
147+
if (localAggregateCountFile.exists())
148+
{
149+
localAggregateCountFile.delete();
150+
}
151+
152+
FileUtils.copyFile(aggregateCountFile, localAggregateCountFile);
153+
}
154+
catch (IOException e)
155+
{
156+
throw new PipelineJobException(e);
157+
}
158+
ctx.getFileManager().addIntermediateFile(localAggregateCountFile);
159+
}
160+
132161
File validAdt = CellHashingServiceImpl.get().getValidCiteSeqBarcodeMetadataFile(ctx.getSourceDirectory(), parentReadset.getReadsetId());
133162
if (!validAdt.exists())
134163
{

0 commit comments

Comments
 (0)