Skip to content

Commit 8c80884

Browse files
committed
Pass GTF file to OOSAP/Seurat
1 parent 4032250 commit 8c80884

File tree

1 file changed

+9
-37
lines changed

1 file changed

+9
-37
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/alignment/CellRangerWrapper.java

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060

6161
public class CellRangerWrapper extends AbstractCommandWrapper
6262
{
63+
public static final String GTF_FILE = "GTF File";
64+
6365
public CellRangerWrapper(@Nullable Logger logger)
6466
{
6567
super(logger);
@@ -93,10 +95,7 @@ public Provider()
9395
put("extensions", Arrays.asList("gtf"));
9496
put("width", 400);
9597
put("allowBlank", false);
96-
}}, null),
97-
ToolParameterDescriptor.create("premrna", "Use pre-mRNA GTF", "Normally, reads are only counted if they overlap exons. If selected, the pipeline will convert the GTF to list all transcript intervals as exon, meaning reads within introns will be counted as well. This could be useful for single-nuclei sequencing (which captures pre-mRNA), or if your GTF exon annotations may be lacking.", "checkbox", new JSONObject(){{
98-
99-
}}, false)
98+
}}, null)
10099
), PageFlowUtil.set("sequenceanalysis/field/GenomeFileSelectorField.js"), "https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/what-is-cell-ranger", true, false, ALIGNMENT_MODE.MERGE_THEN_ALIGN);
101100
}
102101

@@ -137,7 +136,6 @@ public String getAlignmentDescription()
137136

138137
protected static String getAlignDescription(PipelineStepProvider provider, PipelineContext ctx, int stepIdx, boolean addAligner)
139138
{
140-
boolean isPreMrna = isPreMrna(provider, ctx, stepIdx);
141139
Integer gtfId = provider.getParameterByName("gtfFile").extractValue(ctx.getJob(), provider, stepIdx, Integer.class);
142140
File gtfFile = ctx.getSequenceSupport().getCachedData(gtfId);
143141
if (gtfFile == null)
@@ -160,11 +158,6 @@ protected static String getAlignDescription(PipelineStepProvider provider, Pipel
160158
lines.add("GTF: " + gtfFile.getName());
161159
}
162160

163-
if (isPreMrna)
164-
{
165-
lines.add("Converted to pre-mRNA GTF");
166-
}
167-
168161
return lines.isEmpty() ? null : StringUtils.join(lines, '\n');
169162
}
170163

@@ -177,14 +170,7 @@ public String getIndexCachedDirName(PipelineJob job)
177170
throw new IllegalArgumentException("Missing gtfFile parameter");
178171
}
179172

180-
boolean premrna = isPreMrna(getProvider(), getPipelineCtx(), getStepIdx());
181-
182-
return "cellRanger-" + gtfId + (premrna ? "-premrna" : "");
183-
}
184-
185-
private static boolean isPreMrna(PipelineStepProvider provider, PipelineContext ctx, int stepIdx)
186-
{
187-
return provider.getParameterByName("premrna").extractValue(ctx.getJob(), provider, stepIdx, Boolean.class, false);
173+
return "cellRanger-" + gtfId;
188174
}
189175

190176
@Override
@@ -226,13 +212,6 @@ public IndexOutput createIndex(ReferenceGenome referenceGenome, File outputDir)
226212

227213
File gtfEdit = new File(indexDir.getParentFile(), FileUtil.getBaseName(gtfFile) + ".geneId.gtf");
228214

229-
//See: https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/advanced/references
230-
boolean premrna = getProvider().getParameterByName("premrna").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Boolean.class, false);
231-
if (premrna)
232-
{
233-
getPipelineCtx().getLogger().debug("Creating a pre-mRNA version of the GTF");
234-
}
235-
236215
try (CSVReader reader = new CSVReader(Readers.getReader(gtfFile), '\t', CSVWriter.NO_QUOTE_CHARACTER); CSVWriter writer = new CSVWriter(PrintWriters.getPrintWriter(gtfEdit), '\t', CSVWriter.NO_QUOTE_CHARACTER, CSVWriter.NO_ESCAPE_CHARACTER))
237216
{
238217
String[] line;
@@ -251,12 +230,6 @@ public IndexOutput createIndex(ReferenceGenome referenceGenome, File outputDir)
251230
continue;
252231
}
253232

254-
if (premrna && "transcript".equalsIgnoreCase(line[2]))
255-
{
256-
exonsAdded++;
257-
line[2] = "exon";
258-
}
259-
260233
writer.writeNext(line);
261234
}
262235
}
@@ -270,12 +243,7 @@ public IndexOutput createIndex(ReferenceGenome referenceGenome, File outputDir)
270243
getPipelineCtx().getLogger().info("dropped " + linesDropped + " lines lacking gene_id, transcript_id, or with an empty value for gene_id/transcript_id");
271244
}
272245

273-
if (premrna)
274-
{
275-
getPipelineCtx().getLogger().info("total transcripts converted to exon: " + exonsAdded);
276-
}
277-
278-
boolean useAlternateGtf = linesDropped > 0 || premrna;
246+
boolean useAlternateGtf = linesDropped > 0;
279247
if (useAlternateGtf)
280248
{
281249
gtfFile = gtfEdit;
@@ -364,6 +332,10 @@ public AlignmentOutput performAlignment(Readset rs, File inputFastq1, @Nullable
364332
args.add("--sample=" + StringUtils.join(sampleNames, ","));
365333
}
366334

335+
Integer gtfId = getProvider().getParameterByName("gtfFile").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Integer.class);
336+
File gtfFile = getPipelineCtx().getSequenceSupport().getCachedData(gtfId);
337+
output.addInput(gtfFile, GTF_FILE);
338+
367339
File indexDir = AlignerIndexUtil.getWebserverIndexDir(referenceGenome, getIndexCachedDirName(getPipelineCtx().getJob()));
368340
args.add("--transcriptome=" + indexDir.getPath());
369341

0 commit comments

Comments
 (0)