Skip to content

Commit 5a50bd4

Browse files
committed
Add step to allow custom UCell scores
1 parent 8a3b5d4 commit 5a50bd4

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
for (datasetId in names(seuratObjects)) {
2+
printName(datasetId)
3+
seuratObj <- readRDS(seuratObjects[[datasetId]])
4+
5+
toCalculate <- list()
6+
for (geneSet in geneSets) {
7+
vals <- unlist(strsplit(geneSet, split = ':'))
8+
if (length(vals) != 2) {
9+
stop(paste0('Improper gene set: ', geneSet))
10+
}
11+
12+
toCalculate[[vals[1]]] <- unlist(strsplit(vals[2], split = ','))
13+
}
14+
15+
seuratObj <- UCell::AddModuleScore_UCell(seuratObj, features = toCalculate)
16+
saveData(seuratObj, datasetId)
17+
18+
# Cleanup
19+
rm(seuratObj)
20+
gc()
21+
}

singlecell/src/org/labkey/singlecell/SingleCellModule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ public static void registerPipelineSteps()
208208
SequencePipelineService.get().registerPipelineStep(new TcrFilter.Provider());
209209
SequencePipelineService.get().registerPipelineStep(new PlotAssayFeatures.Provider());
210210
SequencePipelineService.get().registerPipelineStep(new IntegrateData.Provider());
211+
SequencePipelineService.get().registerPipelineStep(new CustomUCell.Provider());
211212
}
212213

213214
@Override
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package org.labkey.singlecell.pipeline.singlecell;
2+
3+
import org.json.JSONObject;
4+
import org.labkey.api.sequenceanalysis.pipeline.AbstractPipelineStepProvider;
5+
import org.labkey.api.sequenceanalysis.pipeline.PipelineContext;
6+
import org.labkey.api.sequenceanalysis.pipeline.ToolParameterDescriptor;
7+
import org.labkey.api.singlecell.pipeline.SingleCellStep;
8+
9+
import java.util.Arrays;
10+
import java.util.Collection;
11+
import java.util.HashSet;
12+
import java.util.Set;
13+
14+
public class CustomUCell extends AbstractRiraStep
15+
{
16+
final static String DELIM = "<>";
17+
18+
public CustomUCell(PipelineContext ctx, CustomUCell.Provider provider)
19+
{
20+
super(provider, ctx);
21+
}
22+
23+
public static class Provider extends AbstractPipelineStepProvider<SingleCellStep>
24+
{
25+
public Provider()
26+
{
27+
super("CustomUCell", "Subset", "UCell/RIRA", "The seurat object will be subset based on the expression below, which is passed directly to Seurat's subset(subset = X).", Arrays.asList(
28+
ToolParameterDescriptor.create("geneSets", "Gene Sets(s)", "This should contain one UCell module per line, where the module is in the format (no spaces): SetName:Gene1,Gene2,Gene3. The first token is the name given to UCell and the second is a comma-delimited list of gene names.", "sequenceanalysis-trimmingtextarea", new JSONObject(){{
29+
put("allowBlank", false);
30+
put("replaceAllWhitespace", true);
31+
put("height", 150);
32+
put("width", 600);
33+
put("delimiter", DELIM);
34+
}}, null)
35+
), Arrays.asList("/sequenceanalysis/field/TrimmingTextArea.js"), null);
36+
}
37+
38+
39+
@Override
40+
public CustomUCell create(PipelineContext ctx)
41+
{
42+
return new CustomUCell(ctx, this);
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)