Skip to content

Commit ee59f84

Browse files
committed
Support AvgExpression single cell step
1 parent 2c68e95 commit ee59f84

18 files changed

+95
-21
lines changed

singlecell/resources/chunks/AvgExpression.R

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ for (datasetId in names(seuratObjects)) {
22
seuratObj <- seuratObjects[[datasetId]]
33
seuratObjects[[datasetId]] <- NULL
44

5-
ret <- Seurat::AverageExpression(seuratObj, assays = NULL, features = rownames(seuratObj), group.by = groupField, slot = "counts", verbose = FALSE)
6-
cellsPerGroup <- t(as.matrix(table(seuratObj[[assay]][[groupField]])))
7-
rownames(cellsPerGroup) <- 'TotalCells'
8-
ret[['CellsPerGroup']] <- cellsPerGroup
9-
10-
saveFile <- paste0(outputPrefix, '.', datasetId, '.avg.', groupField, '.rds')
11-
saveRDS(ret, file = saveFile)
5+
df <- CellMembrane::AvgExpression(seuratObj, groupField = groupField)
6+
write.table(df, file = paste0(outputPrefix, '.', datasetId, '.avg.', groupField, '.txt'), sep = '\t', row.names = FALSE, quote = FALSE)
7+
rm(df)
128

139
# Cleanup
1410
rm(seuratObj)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
for (datasetId in names(seuratObjects)) {
2+
seuratObj <- seuratObjects[[datasetId]]
3+
seuratObjects[[datasetId]] <- NULL
4+
5+
for (field in fieldNames) {
6+
if (!(field %in% names(seuratObj@meta.data))) {
7+
next
8+
}
9+
10+
P1 <- Seurat::DimPlot(seuratObj, group.by = field, reduction = 'tsne')
11+
P2 <- Seurat::DimPlot(seuratObj, group.by = field, reduction = 'umap')
12+
13+
P1 <- P1 | P2
14+
P1 <- P1 + patchwork::plot_annotation(title = field)
15+
}
16+
17+
# Cleanup
18+
rm(seuratObj)
19+
gc()
20+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static class Provider extends AbstractPipelineStepProvider<SingleCellStep
3939
{
4040
public Provider()
4141
{
42-
super("AppendCiteSeq", "Possibly Append CITE-seq Data", "OOSAP", "If available, this will process and append CITE-seq data to the Seurat object(s).", getParams(), null, null);
42+
super("AppendCiteSeq", "Possibly Append CITE-seq Data", "CellMembrane", "If available, this will process and append CITE-seq data to the Seurat object(s).", getParams(), null, null);
4343
}
4444

4545
@Override

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,11 @@ public AvgExpression create(PipelineContext ctx)
3232
return new AvgExpression(ctx, this);
3333
}
3434
}
35+
36+
@Override
37+
public boolean createsSeuratObjects()
38+
{
39+
return false;
40+
}
3541
}
3642

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static class Provider extends AbstractPipelineStepProvider<SingleCellStep
1717
{
1818
public Provider()
1919
{
20-
super("CiteSeqDimRedux", "CiteSeq DimRedux", "Seurat", "This will run DimRedux steps on the ADT data.", Arrays.asList(
20+
super("CiteSeqDimRedux", "CiteSeq DimRedux", "CellMembrane/Seurat", "This will run DimRedux steps on the ADT data.", Arrays.asList(
2121

2222
), null, null);
2323
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
import org.labkey.api.util.PageFlowUtil;
9+
10+
import java.util.Arrays;
11+
import java.util.Collection;
12+
13+
public class DimPlots extends AbstractCellMembraneStep
14+
{
15+
public DimPlots(PipelineContext ctx, DimPlots.Provider provider)
16+
{
17+
super(provider, ctx);
18+
}
19+
20+
public static class Provider extends AbstractPipelineStepProvider<SingleCellStep>
21+
{
22+
public Provider()
23+
{
24+
super("DimPlots", "Create DimPlots", "Seurat", "This will generate DimPlots grouped by the variables below. Any variable not present is skipped.", Arrays.asList(
25+
SeuratToolParameter.create("fieldNames", "Fields To Plot", "Enter one field name per line", "sequenceanalysis-trimmingtextarea", new JSONObject(){{
26+
put("allowBlank", false);
27+
put("height", 150);
28+
put("delimiter", ",");
29+
}}, null)
30+
), Arrays.asList("/sequenceanalysis/field/TrimmingTextArea.js"), null);
31+
}
32+
33+
34+
@Override
35+
public DimPlots create(PipelineContext ctx)
36+
{
37+
return new DimPlots(ctx, this);
38+
}
39+
}
40+
41+
@Override
42+
public Collection<String> getRLibraries()
43+
{
44+
return PageFlowUtil.set("Seurat", "patchwork");
45+
}
46+
47+
@Override
48+
public boolean createsSeuratObjects()
49+
{
50+
return false;
51+
}
52+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static class Provider extends AbstractPipelineStepProvider<SingleCellStep
1919
{
2020
public Provider()
2121
{
22-
super("Downsample", "Downsample Cells", "OOSAP", "This will downsample cells from the input object(s) based on the parameters below. Downsampling will be applied independently to each incoming Seurat object. If a second field is provided, cells within each object will be subset using that field, and then downsampled.", Arrays.asList(
22+
super("Downsample", "Downsample Cells", "CellMembrane/Seurat", "This will downsample cells from the input object(s) based on the parameters below. Downsampling will be applied independently to each incoming Seurat object. If a second field is provided, cells within each object will be subset using that field, and then downsampled.", Arrays.asList(
2323
SeuratToolParameter.create("targetCells", "Target Cells Per Unit of Data", "Each unit of data will be downsampled to this level", "ldk-integerfield", new JSONObject(){{
2424
put("allowBlank", false);
2525
}}, null),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static class Provider extends AbstractPipelineStepProvider<SingleCellStep
1919
{
2020
public Provider()
2121
{
22-
super("FilterRawCounts", "Filter Raw Counts", "Seurat/OOSAP", "This will use OOSAP/Seurat to perform basic filtering on cells based on UMI count, feature count, etc.", Arrays.asList(
22+
super("FilterRawCounts", "Filter Raw Counts", "CellMembrane/Seurat", "This will use CellMembrane/Seurat to perform basic filtering on cells based on UMI count, feature count, etc.", Arrays.asList(
2323
SeuratToolParameter.create("nCountRnaLow", "Min UMI Count", "Cells with UMI counts below this value will be discarded", "ldk-integerfield", new JSONObject(){{
2424
put("minValue", 0);
2525
}}, 0, "nCount_RNA.low", false),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static class Provider extends AbstractPipelineStepProvider<SingleCellStep
1919
{
2020
public Provider()
2121
{
22-
super("FindClustersAndDimRedux", "Find Clusters And Dim Redux", "OOSAP", "This will run tSNA and UMAP for the input object.", Arrays.asList(
22+
super("FindClustersAndDimRedux", "Find Clusters And Dim Redux", "CellMembrane/Seurat", "This will run tSNA and UMAP for the input object.", Arrays.asList(
2323
SeuratToolParameter.create("minDimsToUse", "Min. PCs to Use", "The minimum number of PCs to use", "ldk-integerfield", new JSONObject(){{
2424
put("minValue", 0);
2525
}}, 15)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static class Provider extends AbstractPipelineStepProvider<SingleCellStep
1919
{
2020
public Provider()
2121
{
22-
super("FindMarkers", "Find Markers", "OOSAP", "This will run Final_All_Markers on the input object(s), save the results as a TSV.", Arrays.asList(
22+
super("FindMarkers", "Find Markers", "CellMembrane/Seurat", "This will run Final_All_Markers on the input object(s), save the results as a TSV.", Arrays.asList(
2323
SeuratToolParameter.create("identFields", "Identity Field(s)", "When running FindMarkers, these field(s) will be used to group the data, identify markers for each group of cells. Enter one field per row.", "sequenceanalysis-trimmingtextarea", new JSONObject(){{
2424
put("allowBlank", false);
2525
put("height", 200);

0 commit comments

Comments
 (0)