From 59c5505a3948362453aa55b879ffee480553f669 Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Thu, 9 Dec 2021 20:58:45 +0000 Subject: [PATCH] egl limit output --- klarigi/src/main/groovy/klarigi/App.groovy | 2 +- .../src/main/groovy/klarigi/Klarigi.groovy | 6 +-- .../src/main/groovy/klarigi/StepDown.groovy | 49 ++++++++++++++----- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/klarigi/src/main/groovy/klarigi/App.groovy b/klarigi/src/main/groovy/klarigi/App.groovy index 8641c5a..3500810 100644 --- a/klarigi/src/main/groovy/klarigi/App.groovy +++ b/klarigi/src/main/groovy/klarigi/App.groovy @@ -110,7 +110,7 @@ class App { } allExplanations.each { - k.output(it.cluster, it.results, pVals[it.cluster], o['output-type'], o['print-members'], o['output']) + k.output(it.cluster, it.results, pVals[it.cluster], o['egl'], o['output-type'], o['print-members'], o['output']) } if(o['output-exp-dataframe']) { diff --git a/klarigi/src/main/groovy/klarigi/Klarigi.groovy b/klarigi/src/main/groovy/klarigi/Klarigi.groovy index fef43fd..1522686 100644 --- a/klarigi/src/main/groovy/klarigi/Klarigi.groovy +++ b/klarigi/src/main/groovy/klarigi/Klarigi.groovy @@ -360,16 +360,16 @@ public class Klarigi { InformationContent.WriteSimilarity(results, toFile) } - def output(cid, results, pVals, outType, printMembers, toFile) { + def output(cid, results, pVals, egl, outType, printMembers, toFile) { def cSize = data.groupings[cid].size() if(outType) { if(outType == 'latex') { - StepDown.PrintLaTeX(cid, results, pVals, ontoHelper.labels, cSize, toFile) + StepDown.PrintLaTeX(cid, results, pVals, egl, ontoHelper.labels, cSize, toFile) } else if(outType == 'tsv') { StepDown.PrintTSV(cid, results, ontoHelper.labels, cSize, toFile) } } else { - StepDown.Print(cid, results, pVals, ontoHelper.labels, cSize, toFile, data.groupings[cid], printMembers) + StepDown.Print(cid, results, pVals, egl, ontoHelper.labels, cSize, toFile, data.groupings[cid], printMembers) } } diff --git a/klarigi/src/main/groovy/klarigi/StepDown.groovy b/klarigi/src/main/groovy/klarigi/StepDown.groovy index 526a7a6..d65474a 100644 --- a/klarigi/src/main/groovy/klarigi/StepDown.groovy +++ b/klarigi/src/main/groovy/klarigi/StepDown.groovy @@ -94,7 +94,7 @@ public class StepDown { return stepDown(candidates, c.MAX_IC, c.MAX_POWER, c.MAX_TOTAL_INCLUSION) } - static def Print(cid, res, pVals, labels, s, toFile, members, printMembers) { + static def Print(cid, res, pVals, egl, labels, s, toFile, members, printMembers) { def out = [] out << "----------------" out << "Group: $cid ($s members)" @@ -104,11 +104,21 @@ public class StepDown { out << "Overall inclusion: ${res[1].toDouble().round(2)}%" out << "Explanatory classes:" res[0].each { z -> - if(pVals) { - def ps = pVals[z.iri] - out << " IRI: ${labels[z.iri]} (${z.iri}), Power: ${z.nPower.toDouble().round(2)} (p<=${ps.powP}) (inc: ${z.nInclusion.toDouble().round(2)} (p<=${ps.incP}), exc: ${z.nExclusion.toDouble().round(2)} (p<=${ps.excP})), IC: ${z.nIc.toDouble().round(2)}" + if(egl) { + if(pVals) { + def ps = pVals[z.iri] + out << " IRI: ${labels[z.iri]} (${z.iri}), Inclusion: ${z.nInclusion.toDouble().round(2)} (p<=${ps.incP}), IC: ${z.nIc.toDouble().round(2)}" + } else { + out << " IRI: ${labels[z.iri]} (${z.iri}), Inclusion: ${z.nInclusion.toDouble().round(2)}, IC: ${z.nIc.toDouble().round(2)}" + } + } else { - out << " IRI: ${labels[z.iri]} (${z.iri}), Power: ${z.nPower.toDouble().round(2)} (inc: ${z.nInclusion.toDouble().round(2)}, exc: ${z.nExclusion.toDouble().round(2)}), IC: ${z.nIc.toDouble().round(2)}" + if(pVals) { + def ps = pVals[z.iri] + out << " IRI: ${labels[z.iri]} (${z.iri}), Power: ${z.nPower.toDouble().round(2)} (p<=${ps.powP}) (inc: ${z.nInclusion.toDouble().round(2)} (p<=${ps.incP}), exc: ${z.nExclusion.toDouble().round(2)} (p<=${ps.excP})), IC: ${z.nIc.toDouble().round(2)}" + } else { + out << " IRI: ${labels[z.iri]} (${z.iri}), Power: ${z.nPower.toDouble().round(2)} (inc: ${z.nInclusion.toDouble().round(2)}, exc: ${z.nExclusion.toDouble().round(2)}), IC: ${z.nIc.toDouble().round(2)}" + } } } out << "----------------" @@ -135,10 +145,16 @@ public class StepDown { } - static def PrintLaTeX(cid, res, pVals, labels, s, toFile) { + static def PrintLaTeX(cid, res, pVals, egl, labels, s, toFile) { def out = [] - out << "\\begin{tabular}{p{10cm}|c|c|c|c}" - out << "{\\bf Group: $cid ($s members)} & {\\bf Power} & {\\bf Inclusion} & {\\bf Exclusion} & {\\bf IC} \\\\" + out << "\\begin{tabular}{p{5cm}|l|l|l|l}" + + if(egl) { + out << "{\\bf Group: $cid ($s members)} & {\\bf Inclusion} & {\\bf IC} \\\\" + } else { + out << "{\\bf Group: $cid ($s members)} & {\\bf Inclusion} & {\\bf IC} \\\\" + } + res[0].sort { -it.nIc }.each { def pIri = it.iri if(pIri =~ 'obolibrary.org') { @@ -149,11 +165,20 @@ public class StepDown { pIri = it.iri.replaceAll('_', '\\\\_') } - if(pVals) { - def ps = pVals[it.iri] - out << "${labels[it.iri]} (${pIri}) & ${it.nPower.toDouble().round(2)} (p\$<\$=${ps.powP}) & ${it.nInclusion.toDouble().round(2)} (p\$<\$=${ps.incP}) & ${it.nExclusion.toDouble().round(2)} (p\$<\$=${ps.excP}) & ${it.ic.toDouble().round(2)} \\\\" + if(egl) { + if(pVals) { + def ps = pVals[it.iri] + out << "${labels[it.iri]} (${pIri}) & ${it.nInclusion.toDouble().round(2)} (p\$<\$=${ps.incP}) & ${it.ic.toDouble().round(2)} \\\\" + } else { + out << "${labels[it.iri]} (${pIri}) & ${it.nInclusion.toDouble().round(2)} & ${it.ic.toDouble().round(2)} \\\\" + } } else { - out << "${labels[it.iri]} (${pIri}) & ${it.nPower.toDouble().round(2)} & ${it.nInclusion.toDouble().round(2)} & ${it.nExclusion.toDouble().round(2)} & ${it.ic.toDouble().round(2)} \\\\" + if(pVals) { + def ps = pVals[it.iri] + out << "${labels[it.iri]} (${pIri}) & ${it.nPower.toDouble().round(2)} (p\$<\$=${ps.powP}) & ${it.nInclusion.toDouble().round(2)} (p\$<\$=${ps.incP}) & ${it.nExclusion.toDouble().round(2)} (p\$<\$=${ps.excP}) & ${it.ic.toDouble().round(2)} \\\\" + } else { + out << "${labels[it.iri]} (${pIri}) & ${it.nPower.toDouble().round(2)} & ${it.nInclusion.toDouble().round(2)} & ${it.nExclusion.toDouble().round(2)} & ${it.ic.toDouble().round(2)} \\\\" + } } } out << "{\\em Overall} & - & ${res[1].toDouble().round(2)} & - & - \\\\ "