Skip to content

Commit e5072b5

Browse files
committed
capture mean coverage as metric for lofreq
1 parent a3939c1 commit e5072b5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/analysis/LofreqAnalysis.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public Output performAnalysisPerSampleRemote(Readset rs, File inputBam, Referenc
158158
int minCoverage = getProvider().getParameterByName("minCoverage").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Integer.class);
159159
int positionsSkipped = 0;
160160
int gapIntervals = 0;
161+
double avgDepth;
161162

162163
File mask = new File(outputDir, "mask.bed");
163164
Map<String, Integer> gatkDepth = new HashMap<>();
@@ -166,6 +167,8 @@ public Output performAnalysisPerSampleRemote(Readset rs, File inputBam, Referenc
166167
String[] line;
167168

168169
Interval intervalOfCurrentGap = null;
170+
double totalDepth = 0;
171+
double totalPositions = 0;
169172

170173
int i = 0;
171174
while ((line = reader.readNext()) != null)
@@ -180,6 +183,9 @@ public Output performAnalysisPerSampleRemote(Readset rs, File inputBam, Referenc
180183
int depth = Integer.parseInt(line[1]);
181184
gatkDepth.put(line[0], depth);
182185

186+
totalPositions++;
187+
totalDepth += depth;
188+
183189
if (depth < minCoverage)
184190
{
185191
positionsSkipped++;
@@ -224,6 +230,8 @@ public Output performAnalysisPerSampleRemote(Readset rs, File inputBam, Referenc
224230
writer.writeNext(new String[]{intervalOfCurrentGap.getContig(), String.valueOf(intervalOfCurrentGap.getStart()-1), String.valueOf(intervalOfCurrentGap.getEnd())});
225231
gapIntervals++;
226232
}
233+
234+
avgDepth = totalDepth / totalPositions;
227235
}
228236
catch (IOException e)
229237
{
@@ -548,6 +556,7 @@ public Output performAnalysisPerSampleRemote(Readset rs, File inputBam, Referenc
548556
writer.writeNext(new String[]{"LoFreq Analysis", "VariantGT50", String.valueOf(totalGT50)});
549557
writer.writeNext(new String[]{"LoFreq Analysis", "IndelsGTThreshold", String.valueOf(totalIndelGTThreshold)});
550558
writer.writeNext(new String[]{"LoFreq Analysis", "TotalConsensusVariantsInPBS", String.valueOf(totalConsensusInPBS)});
559+
writer.writeNext(new String[]{"LoFreq Analysis", "MeanCoverage", String.valueOf(avgDepth)});
551560
}
552561
catch (IOException e)
553562
{

0 commit comments

Comments
 (0)