Skip to content

Commit 4add0ff

Browse files
committed
Initial SDA support
1 parent d6b1344 commit 4add0ff

File tree

4 files changed

+100
-1
lines changed

4 files changed

+100
-1
lines changed

singlecell/api-src/org/labkey/api/singlecell/pipeline/AbstractSingleCellPipelineStep.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ abstract public class AbstractSingleCellPipelineStep extends AbstractPipelineSte
3636
{
3737
public static final String SEURAT_THREADS = "seuratMaxThreads";
3838

39-
public AbstractSingleCellPipelineStep(PipelineStepProvider provider, PipelineContext ctx)
39+
public AbstractSingleCellPipelineStep(PipelineStepProvider<?> provider, PipelineContext ctx)
4040
{
4141
super(provider, ctx);
4242
}
@@ -309,6 +309,11 @@ public static void executeR(SequenceOutputHandler.JobContext ctx, String dockerC
309309

310310
if (seuratThreads != null)
311311
{
312+
if (maxThreads != null && maxThreads < seuratThreads)
313+
{
314+
seuratThreads = maxThreads;
315+
}
316+
312317
writer.println("\t-e SEURAT_MAX_THREADS=" + seuratThreads + " \\");
313318
}
314319

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
if (Sys.getenv('SEURAT_MAX_THREADS') != '') {
2+
nThreads <- Sys.getenv('SEURAT_MAX_THREADS')
3+
}
4+
5+
for (datasetId in names(seuratObjects)) {
6+
printName(datasetId)
7+
seuratObj <- readRDS(seuratObjects[[datasetId]])
8+
gc()
9+
10+
outputFolder <- ''
11+
if (dir.exists(outputFolder)) {
12+
unlink(outputFolder, recursive = TRUE)
13+
}
14+
15+
sdaResults <- bindArgs(CellMembrane::RunSDA, seuratObj)()
16+
17+
# Cleanup
18+
rm(seuratObj)
19+
gc()
20+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ public static void registerPipelineSteps()
211211
SequencePipelineService.get().registerPipelineStep(new PlotAssayFeatures.Provider());
212212
SequencePipelineService.get().registerPipelineStep(new IntegrateData.Provider());
213213
SequencePipelineService.get().registerPipelineStep(new CustomUCell.Provider());
214+
SequencePipelineService.get().registerPipelineStep(new RunSDA.Provider());
214215
}
215216

216217
@Override
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package org.labkey.singlecell.pipeline.singlecell;
2+
3+
import org.json.old.JSONObject;
4+
import org.labkey.api.sequenceanalysis.pipeline.AbstractPipelineStepProvider;
5+
import org.labkey.api.sequenceanalysis.pipeline.PipelineContext;
6+
import org.labkey.api.singlecell.pipeline.SeuratToolParameter;
7+
import org.labkey.api.singlecell.pipeline.SingleCellStep;
8+
9+
import java.util.Arrays;
10+
11+
public class RunSDA extends AbstractCellMembraneStep
12+
{
13+
public RunSDA(PipelineContext ctx, RunSDA.Provider provider)
14+
{
15+
super(provider, ctx);
16+
}
17+
18+
public static class Provider extends AbstractPipelineStepProvider<SingleCellStep>
19+
{
20+
public Provider()
21+
{
22+
super("RunSDA", "Run SDA", "CellMembrane/SDA", "This will run SDA on the seurat object.", Arrays.asList(
23+
SeuratToolParameter.create("numComps", "Num Comps", "Passed to SDAtools::run_SDA(). 30 is a good minimum but depends on input data complexity.", "ldk-integerfield", new JSONObject(){{
24+
put("minValue", 0);
25+
}}, 50),
26+
SeuratToolParameter.create("featureInclusionList", "Genes to Include", "These genes, entered comma-separated or one/line, will be added to the default Seurat::VariableFeatures gene set when running PCA", "sequenceanalysis-trimmingtextarea", new JSONObject(){{
27+
put("height", 150);
28+
put("delimiter", ",");
29+
put("stripCharsRe", "/(^['\"]+)|(['\"]+$)/g");
30+
}}, null).delimiter(","),
31+
SeuratToolParameter.create("featureExclusionList", "Genes to Exclude", "These genes, entered comma-separated or one/line, will be excluded from the genes passed to RunPCA (which is otherwise determined by Seurat::VariableFeatures)", "sequenceanalysis-trimmingtextarea", new JSONObject(){{
32+
put("height", 150);
33+
put("delimiter", ",");
34+
put("stripCharsRe", "/(^['\"]+)|(['\"]+$)/g");
35+
}}, null).delimiter(","),
36+
SeuratToolParameter.create("minAsinhThreshold", "asinh Threshold", "This is used to filter genes. Only features with asinh(TOTAL_COUNTS) above this value are included.", "ldk-numberfield", new JSONObject(){{
37+
put("minValue", 0);
38+
put("decimalPrecision", 2);
39+
}}, 0.5, "minAsinhThreshold", false),
40+
SeuratToolParameter.create("minLibrarySize", "Min Library Size", "Passed to dropsim::normaliseDGE() min_library_size", "ldk-integerfield", new JSONObject(){{
41+
put("minValue", 0);
42+
}}, 50),
43+
SeuratToolParameter.create("max_iter", "Max Iterations", "Passed directly to SDAtools::run_SDA()", "ldk-integerfield", new JSONObject(){{
44+
put("minValue", 0);
45+
}}, 10000),
46+
SeuratToolParameter.create(SEURAT_THREADS, "Max Threads", "The number of threads to use. Cannot be higher than the threads allocated to the job.", "ldk-integerfield", new JSONObject(){{
47+
put("minValue", 0);
48+
}}, 8)
49+
), Arrays.asList("/sequenceanalysis/field/TrimmingTextArea.js"), null);
50+
}
51+
52+
53+
@Override
54+
public RunSDA create(PipelineContext ctx)
55+
{
56+
return new RunSDA(ctx, this);
57+
}
58+
}
59+
60+
@Override
61+
public boolean createsSeuratObjects()
62+
{
63+
return false;
64+
}
65+
66+
@Override
67+
public String getFileSuffix()
68+
{
69+
return "sda";
70+
}
71+
}
72+
73+

0 commit comments

Comments
 (0)