Skip to content

Commit 0aa431f

Browse files
committed
Support ClrNormalizeByGroup
1 parent 0e124f9 commit 0aa431f

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
for (datasetId in names(seuratObjects)) {
2+
printName(datasetId)
3+
seuratObj <- readRDS(seuratObjects[[datasetId]])
4+
gc()
5+
6+
seuratObj <- CellMembrane::ClrNormalizeByGroup(seuratObj, groupingVar = groupingVar, assayName = assayName, targetAssayName = targetAssayName, margin = margin, minCellsPerGroup = minCellsPerGroup, calculatePerCellUCell = calculatePerCellUCell)
7+
8+
saveData(seuratObj, datasetId)
9+
10+
# Cleanup
11+
rm(seuratObj)
12+
gc()
13+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ public static void registerPipelineSteps()
167167
SequencePipelineService.get().registerPipelineStep(new FindMarkers.Provider());
168168
SequencePipelineService.get().registerPipelineStep(new MergeSeurat.Provider());
169169
SequencePipelineService.get().registerPipelineStep(new NormalizeAndScale.Provider());
170+
SequencePipelineService.get().registerPipelineStep(new ClrNormalizeByGroup.Provider());
170171

171172
SequencePipelineService.get().registerPipelineStep(new PrepareRawCounts.Provider());
172173

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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.singlecell.pipeline.SeuratToolParameter;
7+
import org.labkey.api.singlecell.pipeline.SingleCellStep;
8+
9+
import java.util.Arrays;
10+
11+
public class ClrNormalizeByGroup extends AbstractCellMembraneStep
12+
{
13+
public ClrNormalizeByGroup(PipelineContext ctx, ClrNormalizeByGroup.Provider provider)
14+
{
15+
super(provider, ctx);
16+
}
17+
18+
public static class Provider extends AbstractPipelineStepProvider<SingleCellStep>
19+
{
20+
public Provider()
21+
{
22+
super("ClrNormalizeByGroup", "CLR Normalize By Group", "CellMembrane/Seurat", "This will run standard Seurat CLR normalization on the desired assay, subsetting by group.", Arrays.asList(
23+
SeuratToolParameter.create("groupingVar", "Group Variable", "The variable on which to group.", "textfield", new JSONObject(){{
24+
put("allowBlank", false);
25+
}}, "cDNA_ID"),
26+
SeuratToolParameter.create("assayName", "Source Assay", "The source assay", "textfield", new JSONObject(){{
27+
put("allowBlank", false);
28+
}}, "ADT"),
29+
SeuratToolParameter.create("targetAssayName", "Target Assay", "The target assay. Will overwrite the source if blank.", "textfield", new JSONObject(){{
30+
31+
}}, null),
32+
SeuratToolParameter.create("margin", "Margin", "Passing to NormalizeData. Either 1 or 2.", "ldk-integerfield", new JSONObject(){{
33+
put("allowBlank", false);
34+
}}, 1),
35+
SeuratToolParameter.create("minCellsPerGroup", "Min Cells Per Group", "Any group with fewer than this many cells will be dropped.", "ldk-integerfield", new JSONObject(){{
36+
37+
}}, 20),
38+
SeuratToolParameter.create("calculatePerCellUCell", "Calculate Per Feature UCell ", "If checked, ScaleData will only be performed on VariableFeatures, which should dramatically reduce time and memory", "checkbox", new JSONObject(){{
39+
put("checked", true);
40+
}}, true)
41+
), Arrays.asList("/sequenceanalysis/field/TrimmingTextArea.js"), null);
42+
}
43+
44+
45+
@Override
46+
public ClrNormalizeByGroup create(PipelineContext ctx)
47+
{
48+
return new ClrNormalizeByGroup(ctx, this);
49+
}
50+
}
51+
52+
@Override
53+
public String getFileSuffix()
54+
{
55+
return "clrByGroup";
56+
}
57+
}
58+
59+

0 commit comments

Comments
 (0)