Skip to content

Commit

Permalink
egl limit output
Browse files Browse the repository at this point in the history
  • Loading branch information
reality committed Dec 9, 2021
1 parent 4411b1d commit 59c5505
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 16 deletions.
2 changes: 1 addition & 1 deletion klarigi/src/main/groovy/klarigi/App.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down
6 changes: 3 additions & 3 deletions klarigi/src/main/groovy/klarigi/Klarigi.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
49 changes: 37 additions & 12 deletions klarigi/src/main/groovy/klarigi/StepDown.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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 << "----------------"
Expand All @@ -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') {
Expand All @@ -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)} & - & - \\\\ "
Expand Down

0 comments on commit 59c5505

Please sign in to comment.