Skip to content

Commit

Permalink
Bug fixes, including typos in standard data file and corrupted/trunca…
Browse files Browse the repository at this point in the history
…ted reference genome. Adding additional radar plot to report showing bias based on relative abundance.
  • Loading branch information
michael-weinstein committed Jan 17, 2020
1 parent 94ede02 commit db9ef98
Show file tree
Hide file tree
Showing 5 changed files with 822,883 additions and 9 deletions.
23 changes: 21 additions & 2 deletions analyzeStandardReads.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,33 @@ def saveResult(result:miqScoreNGSReadCountPublic.MiqScoreData):
return outputFilePath


def generateReportReplacementTable(sampleMiq, goodExampleMiq, badExampleMiq, readFatePrintNames:dict=None):
readFateTable = miqScoreShotgunPublicSupport.reporting.generateReadFateChartBody(miqScoreShotgunPublicSupport.reporting.generateAbsoluteReadFateCounts(sampleMiq), readFatePrintNames)
replacementTable = {"SAMPLENAME": sampleMiq.sampleID,
"MIQSCORE": str(round(sampleMiq.miqScore)),
"READFATETABLE": readFateTable,
"READFATECHART": sampleMiq.plots["readFates"],
"COMPOSITIONBARPLOT": sampleMiq.plots["compositionPlot"],
"GOODRADARPLOTLYSIS": goodExampleMiq.plots["radarPlots"]["Lysis Difficulty"],
"SAMPLERADARPLOTLYSIS": sampleMiq.plots["radarPlots"]["Lysis Difficulty"],
"BADRADARPLOTLYSIS": badExampleMiq.plots["radarPlots"]["Lysis Difficulty"],
"GOODRADARPLOTABUNDANCE": goodExampleMiq.plots["radarPlots"]["Abundance"],
"SAMPLERADARPLOTABUNDANCE": sampleMiq.plots["radarPlots"]["Abundance"],
"BADRADARPLOTABUNDANCE": badExampleMiq.plots["radarPlots"]["Abundance"],
"GOODRADARPLOTGC": goodExampleMiq.plots["radarPlots"]["GC Content"],
"SAMPLERADARPLOTGC": sampleMiq.plots["radarPlots"]["GC Content"],
"BADRADARPLOTGC": badExampleMiq.plots["radarPlots"]["GC Content"]}
return replacementTable


def generateReport(result:miqScoreNGSReadCountPublic.MiqScoreData):
referenceData = miqScoreNGSReadCountPublic.referenceHandler.StandardReference(parameters.referenceDataFile.value)
templateFilePath = os.path.join(os.path.split(os.path.abspath(__file__))[0], "reference", "shotgunReportTemplate.html")
templateFile = open(templateFilePath, 'r')
template = templateFile.read()
templateFile.close()
goodMiq, badMiq = miqScoreNGSReadCountPublic.loadExampleData(parameters.goodMiqExample.value, parameters.badMiqExample.value, referenceData, "Genomic")
replacementTable = miqScoreShotgunPublicSupport.reporting.generateReplacementTable(result, goodMiq, badMiq, readFatePrintNames=readFatePrintNames)
replacementTable = generateReportReplacementTable(result, goodMiq, badMiq, readFatePrintNames=readFatePrintNames)
report = miqScoreNGSReadCountPublic.reportGeneration.generateReport(template, replacementTable)
reportFilePath = os.path.join(parameters.outputFolder.value, "%s.html" % parameters.sampleName.value)
print("Output report to %s" % reportFilePath)
Expand All @@ -230,7 +249,7 @@ def generateReport(result:miqScoreNGSReadCountPublic.MiqScoreData):
logger.debug("Starting analysis")
bamFilePath = os.path.join(parameters.outputFolder.value, "%s.bam" %parameters.sampleName.value)
if applicationMode == "PE":
miqScoreShotgunPublicSupport.alignmentAnalysis.bwaHandler.bwaAlignPE(parameters.forwardReads.value, parameters.reverseReads.value, parameters.workingFolder.value, bamFilePath, parameters.referenceGenome.value)
#miqScoreShotgunPublicSupport.alignmentAnalysis.bwaHandler.bwaAlignPE(parameters.forwardReads.value, parameters.reverseReads.value, parameters.workingFolder.value, bamFilePath, parameters.referenceGenome.value) #TODO Return this line to functionality if disabled
readTable = miqScoreShotgunPublicSupport.alignmentAnalysis.alignmentAnalysisPE.bamFileProcessor(bamFilePath)
elif applicationMode == "SE":
miqScoreShotgunPublicSupport.alignmentAnalysis.bwaHandler.bwaAlignSE(parameters.reads.value, parameters.workingFolder.value, bamFilePath, parameters.referenceGenome.value)
Expand Down
2 changes: 1 addition & 1 deletion defaults/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
reverseReads = os.path.join(sequenceFolder, "standard_submitted_R2.fastq")
referenceFolder = os.path.join(os.path.split(__main__.__file__)[0], "reference")
referenceGenome = os.path.join(referenceFolder, "zrGutStandard.fasta")
#referenceGenome = "/opt/miqScoreShotgun/reference/zrGutStandard.fa" #for external debugging
#referenceGenome = "/opt/miqScoreShotgun/reference/zrGutStandard.fasta" #for external debugging
referenceDataFile = os.path.join(referenceFolder, "zrGutStandard.json")
goodMiqExample = os.path.join(referenceFolder, "goodMiq.json")
badMiqExample = os.path.join(referenceFolder, "badMiq.json")
Expand Down
16 changes: 16 additions & 0 deletions reference/shotgunReportTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ <h3><strong>MIQ (Measurement Integrity Quotient Score)</strong></h3>
<h3><strong>Bias Detection (Radar) Plots</strong></h3>
<table border="0" style="border-collapse: collapse; width: 100%; margin-left: auto; margin-right: auto;">
<tbody>


<tr>
<td style="width: 33.3333%;">
<p><img src="data:image/png;base64,%%GOODRADARPLOTLYSIS%%" alt="Good Example Radar Plot" width="395" height="296" caption="false" style="display: block; margin-left: auto; margin-right: auto;" /></p>
Expand All @@ -38,6 +40,20 @@ <h3><strong>Bias Detection (Radar) Plots</strong></h3>
</tr>
<tr>
<td style="width: 33.3333%;">
<p><img src="data:image/png;base64,%%GOODRADARPLOTABUNDANCE%%" alt="Good Example Radar Plot" width="395" height="296" caption="false" style="display: block; margin-left: auto; margin-right: auto;" /></p>
<p style="text-align: center;">Good (Example)</p>
</td>
<td style="width: 33.3333%; text-align: center;">
<p><img src="data:image/png;base64,%%SAMPLERADARPLOTABUNDANCE%%" alt="Your Sample" width="395" height="296" caption="false" /></p>
<p><strong>%%SAMPLENAME%%</strong></p>
</td>
<td style="width: 33.3333%; text-align: center;">
<p><img src="data:image/png;base64,%%BADRADARPLOTABUNDANCE%%" alt="Bad Example Radar Plot" width="395" height="296" caption="false" /></p>
<p>Biased (Example)</p>
</td>
</tr>
<tr>
<td style="width: 33.3333%;">
<p><img src="data:image/png;base64,%%GOODRADARPLOTGC%%" alt="Good Example Radar Plot" width="395" height="296" caption="false" style="display: block; margin-left: auto; margin-right: auto;" /></p>
<p style="text-align: center;">Good (Example)</p>
</td>
Expand Down
Loading

0 comments on commit db9ef98

Please sign in to comment.