diff --git a/singlecell/resources/chunks/SummarizeTCellActivation.R b/singlecell/resources/chunks/SummarizeTCellActivation.R new file mode 100644 index 000000000..3a0368933 --- /dev/null +++ b/singlecell/resources/chunks/SummarizeTCellActivation.R @@ -0,0 +1,21 @@ +if (!file.exists('/homeDir/.netrc')) { + print(list.files('/homeDir')) + stop('Unable to find file: /homeDir/.netrc') +} + +invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = '/homeDir/.netrc')) +Rdiscvr::SetLabKeyDefaults(baseUrl = serverBaseUrl, defaultFolder = defaultLabKeyFolder) + +for (datasetId in names(seuratObjects)) { + printName(datasetId) + seuratObj <- readSeuratRDS(seuratObjects[[datasetId]]) + + outFile <- paste0(outputPrefix, '.', makeLegalFileName(datasetId), '.activation.txt') + seuratObj <- Rdiscvr::SummarizeTNK_Activation(seuratObj, outFile = outFile, xFacetField = xFacetField, groupingFields = groupingFields, activationFieldName = activationFieldName, threshold = threshold) + + saveData(seuratObj, datasetId) + + # Cleanup + rm(seuratObj) + gc() +} \ No newline at end of file diff --git a/singlecell/src/org/labkey/singlecell/SingleCellModule.java b/singlecell/src/org/labkey/singlecell/SingleCellModule.java index 3e567c9f9..2080bf978 100644 --- a/singlecell/src/org/labkey/singlecell/SingleCellModule.java +++ b/singlecell/src/org/labkey/singlecell/SingleCellModule.java @@ -220,6 +220,7 @@ public static void registerPipelineSteps() SequencePipelineService.get().registerPipelineStep(new RunSDA.Provider()); SequencePipelineService.get().registerPipelineStep(new RunLDA.Provider()); SequencePipelineService.get().registerPipelineStep(new FilterDisallowedClasses.Provider()); + SequencePipelineService.get().registerPipelineStep(new SummarizeTCellActivation.Provider()); SequenceAnalysisService.get().registerReadsetListener(new SingleCellReadsetListener()); } diff --git a/singlecell/src/org/labkey/singlecell/pipeline/singlecell/SummarizeTCellActivation.java b/singlecell/src/org/labkey/singlecell/pipeline/singlecell/SummarizeTCellActivation.java new file mode 100644 index 000000000..3916ffe00 --- /dev/null +++ b/singlecell/src/org/labkey/singlecell/pipeline/singlecell/SummarizeTCellActivation.java @@ -0,0 +1,57 @@ +package org.labkey.singlecell.pipeline.singlecell; + +import org.json.JSONObject; +import org.labkey.api.sequenceanalysis.pipeline.AbstractPipelineStepProvider; +import org.labkey.api.sequenceanalysis.pipeline.PipelineContext; +import org.labkey.api.singlecell.pipeline.SeuratToolParameter; +import org.labkey.api.singlecell.pipeline.SingleCellStep; + +import java.util.Arrays; + +public class SummarizeTCellActivation extends AbstractRDiscvrStep +{ + public SummarizeTCellActivation(PipelineContext ctx, SummarizeTCellActivation.Provider provider) + { + super(provider, ctx); + } + + public static class Provider extends AbstractPipelineStepProvider + { + public Provider() + { + super("SummarizeTCellActivation", "Summarize TCell Activation", "RDiscvr", "This uses Rdiscvr::SummarizeTCellActivation to summarize cells with activation above a threshold.", Arrays.asList( + SeuratToolParameter.create("groupingFields", "Grouping Field(s)", "The fields used to group cells.", "sequenceanalysis-trimmingtextarea", new JSONObject(){{ + put("allowBlank", false); + put("height", 200); + put("delimiter", ","); + put("stripCharsRe", "/['\"]/g"); + }}, "SampleDate,Stim,Population,AssayType").delimiter(","), + SeuratToolParameter.create("threshold", "Threshold", "Cells with a score greater than or equal to this are considered activated", "ldk-numberfield", new JSONObject(){{ + put("allowBlank", false); + put("minValue", 0); + put("maxValue", 1); + put("decimalPrecision", 2); + }}, 0.5), + SeuratToolParameter.create("xFacetField", "X Facet Field", "A field used to facet the resulting plot", "textfield", new JSONObject(){{ + put("allowBlank", false); + }}, "Population"), + SeuratToolParameter.create("activationFieldName", "Activation Field Name", "The name of the field holding the score used to activation thresholding", "textfield", new JSONObject(){{ + put("allowBlank", false); + }}, "TandNK_Activation_UCell") + ), null, null); + } + + @Override + public SummarizeTCellActivation create(PipelineContext ctx) + { + return new SummarizeTCellActivation(ctx, this); + } + } + + @Override + public String getFileSuffix() + { + return "activation"; + } +} +