Skip to content

Commit 2a7c82c

Browse files
committed
Add step to plot features across arbitrary assays
1 parent 5bd964b commit 2a7c82c

File tree

4 files changed

+88
-1
lines changed

4 files changed

+88
-1
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/analysis/GenotypeGVCFHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public Collection<String> getAllowableActionNames()
109109
{
110110
Set<String> allowableNames = new HashSet<>();
111111
allowableNames.add(getName());
112-
for (PipelineStepProvider provider: SequencePipelineService.get().getProviders(VariantProcessingStep.class))
112+
for (PipelineStepProvider<?> provider: SequencePipelineService.get().getProviders(VariantProcessingStep.class))
113113
{
114114
allowableNames.add(provider.getLabel());
115115
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
for (datasetId in names(seuratObjects)) {
2+
printName(datasetId)
3+
seuratObj <- readRDS(seuratObjects[[datasetId]])
4+
5+
for (assayName in assayNames) {
6+
print(paste0('Processing assay: ', assayName))
7+
featureNames <- rownames(seuratObj@assays[assayName])
8+
if (length(featureNames) > 100) {
9+
warning(paste0('There are too many features in this assay, skipping: ', assayName))
10+
next
11+
}
12+
13+
for (featureName in featureNames) {
14+
if (ncol(Seurat::FetchData(seuratObj, vars = c('ident', featureName))) != 2) {
15+
next
16+
}
17+
18+
tryCatch({
19+
P1 <- Seurat::FeaturePlot(seuratObj, features = c(featureName), reduction = 'tsne', min.cutoff = 'q05', max.cutoff = 'q95')
20+
P2 <- Seurat::FeaturePlot(seuratObj, features = c(featureName), reduction = 'umap', min.cutoff = 'q05', max.cutoff = 'q95')
21+
P1 <- P1 | P2
22+
23+
P1 <- P1 + patchwork::plot_annotation(title = featureName) + patchwork::plot_layout(guides = "collect")
24+
25+
print(P1)
26+
}, error = function(e){
27+
print(paste0('Error running NimbleFeaturePlots for: ', datasetId))
28+
print(conditionMessage(e))
29+
traceback()
30+
})
31+
}
32+
}
33+
34+
# Cleanup
35+
rm(seuratObj)
36+
gc()
37+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ public static void registerPipelineSteps()
191191
SequencePipelineService.get().registerPipelineStep(new AppendNimble.Provider());
192192
SequencePipelineService.get().registerPipelineStep(new AppendTcr.Provider());
193193
SequencePipelineService.get().registerPipelineStep(new TcrFilter.Provider());
194+
SequencePipelineService.get().registerPipelineStep(new PlotAssayFeatures.Provider());
194195

195196
SequenceAnalysisService.get().registerFileHandler(new NimbleHandler());
196197
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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 PlotAssayFeatures extends AbstractCellMembraneStep
12+
{
13+
public PlotAssayFeatures(PipelineContext ctx, PlotAssayFeatures.Provider provider)
14+
{
15+
super(provider, ctx);
16+
}
17+
18+
public static class Provider extends AbstractPipelineStepProvider<SingleCellStep>
19+
{
20+
public Provider()
21+
{
22+
super("PlotAssayFeatures", "Plot Assay Features", "CellMembrane/Seurat", "This will create FeaturePlots for all features in the selected assays.", Arrays.asList(
23+
SeuratToolParameter.create("assayNames", "Assay Name(s)", "The name(s) of the asays to plot.", "sequenceanalysis-trimmingtextarea", new JSONObject(){{
24+
put("height", 150);
25+
put("delimiter", ",");
26+
put("allowBlank", false);
27+
}}, null).delimiter(",")
28+
), null, null);
29+
}
30+
31+
@Override
32+
public PlotAssayFeatures create(PipelineContext ctx)
33+
{
34+
return new PlotAssayFeatures(ctx, this);
35+
}
36+
}
37+
38+
@Override
39+
public boolean createsSeuratObjects()
40+
{
41+
return false;
42+
}
43+
44+
@Override
45+
public String getFileSuffix()
46+
{
47+
return "cite-plots";
48+
}
49+
}

0 commit comments

Comments
 (0)