Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -348,38 +348,52 @@ public static void executeR(SequenceOutputHandler.JobContext ctx, String dockerC
localBashScript.delete();
}

protected String prepareValueForR(SeuratToolParameter pd)
protected void addParameterVariables(SeuratToolParameter pd, List<String> body)
{
String val = StringUtils.trimToNull(pd.extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx()));
if (val == null)
{
return "NULL";
body.add((pd.getVariableName() + " <- NULL"));
}
else if ("false".equals(val))
{
return "FALSE";
body.add((pd.getVariableName() + " <- FALSE"));
}
else if ("true".equals(val))
{
return "TRUE";
body.add((pd.getVariableName() + " <- TRUE"));
}
else if (NumberUtils.isCreatable(val))
{
return val;
body.add((pd.getVariableName() + " <- " + val));
}
else if ("sequenceanalysis-trimmingtextarea".equals(pd.getFieldXtype()))
{
val = val.replace("'", "\\\'");
String[] vals = val.split(pd.getDelimiter());
return "c('" + StringUtils.join(vals, "','") + "')";
serializeMultiValueParam(pd, body, val);
}
else if (pd.isMultiValue())
{
String[] vals = val.split(pd.getDelimiter());
return "c('" + StringUtils.join(vals, "','") + "')";
serializeMultiValueParam(pd, body, val);
}
else
{
body.add((pd.getVariableName() + " <- '" + val + "'"));
}
}

return "'" + val + "'";
private void serializeMultiValueParam(SeuratToolParameter pd, List<String> body, String val)
{
String[] vals = val.split(pd.getDelimiter());
final int batchSize = 75;
int numBatches = (int)Math.ceil((double)vals.length / batchSize);

for (int i=0;i<numBatches;i++)
{
int start = (i * batchSize);
int end = Math.min(start + batchSize, vals.length);
body.add(pd.getVariableName() + " <- " + "c(" + (i == 0 ? "" : pd.getVariableName() + ", ") + "'" + StringUtils.join(Arrays.copyOfRange(vals, start, end), "','") + "')");
}
}

protected List<String> loadChunkFromFile() throws PipelineJobException
Expand DownExpand Up@@ -423,7 +437,7 @@ protected Chunk createParamChunk(SequenceOutputHandler.JobContext ctx, List<Seur
SeuratToolParameter stp = (SeuratToolParameter)pd;
if (stp.shouldIncludeInMarkdown(getPipelineCtx().getJob(), getProvider(), getStepIdx()))
{
body.add(((SeuratToolParameter) pd).getVariableName() + " <- " + prepareValueForR(stp));
addParameterVariables(stp, body);
}
}
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -50,7 +50,7 @@ public String getVariableName()
return _rName == null ? getName() : _rName;
}

public boolean shouldIncludeInMarkdown(PipelineJob job, PipelineStepProvider provider, int stepIdx)
public boolean shouldIncludeInMarkdown(PipelineJob job, PipelineStepProvider<?> provider, int stepIdx)
{
if (!_includeIfEmptyOrNull)
{
Expand Down
9 changes: 7 additions & 2 deletions singlecell/resources/chunks/TcrFilter.R
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,11 @@ for (datasetId in names(seuratObjects)) {

cdr3ForLocus <- gsub(cdr3ForLocus, pattern = paste0(fieldName, ':'), replacement = '')
matchingCells <- sapply(seuratObj@meta.data[[fieldName]], function(x){
values <- unlist(strsplit(x, split = ','))
if (is.na(x)) {
return(FALSE)
}

values <- unlist(strsplit(as.character(x), split = ','))
return(length(intersect(values, cdr3ForLocus)) != 0)
})

Expand All@@ -37,8 +41,9 @@ for (datasetId in names(seuratObjects)) {
if (all(is.null(cellsToKeep))) {
print('There were no matching cells')
} else {
print(paste0('Total passing cells: ', length(cellsToKeep)))
seuratObj <- subset(seuratObj, cells = cellsToKeep)
#saveData(seuratObj, datasetId)
saveData(seuratObj, datasetId)
totalPassed <- totalPassed + 1
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -188,7 +188,7 @@ public static void registerPipelineSteps()
SequencePipelineService.get().registerPipelineStep(new CheckExpectations.Provider());
SequencePipelineService.get().registerPipelineStep(new CommonFilters.Provider());
SequencePipelineService.get().registerPipelineStep(new RunVision.Provider());
SequencePipelineService.get().registerPipelineStep(new NimbleAppend.Provider());
SequencePipelineService.get().registerPipelineStep(new AppendNimble.Provider());
SequencePipelineService.get().registerPipelineStep(new AppendTcr.Provider());
SequencePipelineService.get().registerPipelineStep(new TcrFilter.Provider());

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,9 +15,9 @@
import java.util.List;
import java.util.Set;

public class NimbleAppend extends AbstractRDiscvrStep
public class AppendNimble extends AbstractRDiscvrStep
{
public NimbleAppend(PipelineContext ctx, NimbleAppend.Provider provider)
public AppendNimble(PipelineContext ctx, AppendNimble.Provider provider)
{
super(provider, ctx);
}
Expand All@@ -35,9 +35,9 @@ public Provider()


@Override
public NimbleAppend create(PipelineContext ctx)
public AppendNimble create(PipelineContext ctx)
{
return new NimbleAppend(ctx, this);
return new AppendNimble(ctx, this);
}
}

Expand All@@ -62,6 +62,7 @@ protected Chunk createParamChunk(SequenceOutputHandler.JobContext ctx, List<Seur
ret.bodyLines.add("nimbleGenomes <- list(");
String genomeStr = getProvider().getParameterByName("nimbleGenomes").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), String.class);
JSONArray json = new JSONArray(genomeStr);
String delim = "";
for (int i = 0; i < json.length(); i++)
{
JSONArray arr = json.getJSONArray(i);
Expand All@@ -72,7 +73,8 @@ protected Chunk createParamChunk(SequenceOutputHandler.JobContext ctx, List<Seur

int genomeId = arr.getInt(0);
String targetAssay = arr.getString(1);
ret.bodyLines.add("\t" + genomeId + " = " + targetAssay);
ret.bodyLines.add("\t" + delim + "'" + genomeId + "' = '" + targetAssay + "'");
delim = ",";
}
ret.bodyLines.add(")");

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,10 +72,15 @@ protected Chunk createParamChunk(SequenceOutputHandler.JobContext ctx, List<Seur

for (SeuratObjectWrapper so : inputObjects)
{
if (so.getSequenceOutputFile().getReadset() == null)
{
throw new PipelineJobException("Unable to find readset for outputfile: " + so.getSequenceOutputFileId() + ". This set requires single-dataset inputs. Removing this step may be a solution.");
}

Readset parentReadset = ctx.getSequenceSupport().getCachedReadset(so.getSequenceOutputFile().getReadset());
if (parentReadset == null)
{
throw new PipelineJobException("Unable to find readset for outputfile: " + so.getSequenceOutputFileId());
throw new PipelineJobException("Unable to find readset for outputfile: " + so.getSequenceOutputFileId() + ". This set requires single-dataset inputs. Removing this step may be a solution.");
}

Set<String> htosPerReadset = CellHashingServiceImpl.get().getHtosForParentReadset(parentReadset.getReadsetId(), ctx.getSourceDirectory(), ctx.getSequenceSupport(), false);
Expand Down