Skip to content

Commit 3d10a5c

Browse files
committed
Update Seurat/subset step
1 parent 22e49a5 commit 3d10a5c

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

singlecell/resources/chunks/SubsetSeurat.R

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

5-
seuratObj <- CellMembrane::SubsetSeurat(seuratObj, expressionStrings = expressionStrings)
5+
seuratObj <- subset(seuratObj, subset = <EXPRESSION>)
66

77
newSeuratObjects[[datasetId]] <- seuratObj
88

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

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
package org.labkey.singlecell.pipeline.singlecell;
22

3+
import org.apache.commons.lang3.StringUtils;
34
import org.json.JSONObject;
5+
import org.labkey.api.pipeline.PipelineJobException;
46
import org.labkey.api.sequenceanalysis.pipeline.AbstractPipelineStepProvider;
57
import org.labkey.api.sequenceanalysis.pipeline.PipelineContext;
8+
import org.labkey.api.sequenceanalysis.pipeline.ToolParameterDescriptor;
69
import org.labkey.api.singlecell.pipeline.SeuratToolParameter;
710
import org.labkey.api.singlecell.pipeline.SingleCellStep;
811

912
import java.util.Arrays;
13+
import java.util.Collection;
14+
import java.util.HashSet;
15+
import java.util.List;
16+
import java.util.Set;
17+
import java.util.stream.Collectors;
1018

1119
public class SubsetSeurat extends AbstractCellMembraneStep
1220
{
@@ -19,13 +27,13 @@ public static class Provider extends AbstractPipelineStepProvider<SingleCellStep
1927
{
2028
public Provider()
2129
{
22-
super("SubsetSeurat", "Subset", "CellMembrane/Seurat", "The seurat object will be subset based on the expressions below, one per line, which are passed directly to Seurat's subset(subset = X).", Arrays.asList(
23-
SeuratToolParameter.create("expressionStrings", "Expressions", "Enter one expression per line", "sequenceanalysis-trimmingtextarea", new JSONObject(){{
30+
super("SubsetSeurat", "Subset", "CellMembrane/Seurat", "The seurat object will be subset based on the expression below, which is passed directly to Seurat's subset(subset = X).", Arrays.asList(
31+
SeuratToolParameter.create("expression", "Expression", "Filter Expression", "textarea", new JSONObject(){{
2432
put("allowBlank", false);
2533
put("height", 150);
2634
put("delimiter", ",");
2735
}}, null)
28-
), Arrays.asList("/sequenceanalysis/field/TrimmingTextArea.js"), null);
36+
), null, null);
2937
}
3038

3139

@@ -36,6 +44,34 @@ public SubsetSeurat create(PipelineContext ctx)
3644
}
3745
}
3846

47+
@Override
48+
public Collection<String> getRLibraries()
49+
{
50+
Set<String> ret = new HashSet<>();
51+
ret.add("Seurat");
52+
ret.addAll(super.getRLibraries());
53+
54+
return ret;
55+
}
56+
57+
final static String EXPRESSION = "<EXPRESSION>";
58+
59+
@Override
60+
protected List<String> loadChunkFromFile() throws PipelineJobException
61+
{
62+
ToolParameterDescriptor pd = getProvider().getParameterByName("expression");
63+
final String val = StringUtils.trimToNull(pd.extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx()));
64+
65+
return super.loadChunkFromFile().stream().map(x -> {
66+
if (x.contains(EXPRESSION))
67+
{
68+
x = x.replaceAll(EXPRESSION, val);
69+
}
70+
71+
return x;
72+
}).collect(Collectors.toList());
73+
}
74+
3975
@Override
4076
public String getFileSuffix()
4177
{

0 commit comments

Comments
 (0)