diff --git a/klarigi/src/main/groovy/klarigi/App.groovy b/klarigi/src/main/groovy/klarigi/App.groovy index 760cf64..c1a43da 100644 --- a/klarigi/src/main/groovy/klarigi/App.groovy +++ b/klarigi/src/main/groovy/klarigi/App.groovy @@ -47,6 +47,7 @@ class App { _ longOpt: 'min-inclusion', 'Explanations with inclusion below this level will not be considered for explanations.', args: 1 _ longOpt: 'min-power', 'Explanations with power below this level will not be considered for explanations.', args: 1 _ longOpt: 'min-ic', 'Explanations with IC below this level will not be considered for explanations.', args: 1 + _ longOpt: 'include-all', 'Ignore all min scores', type: Boolean _ longOpt: 'max-exclusion', 'Variables with exclusion higher than this will not count to total overall inclusion in the stepdown algorithm. They will, however, still appear in explanations.', args: 1 _ longOpt: 'max-inclusion', 'Variables with inclusion higher than this will not count to total overall inclusion in the stepdown algorithm. They will, however, still appear in explanations.', args: 1 @@ -120,11 +121,11 @@ class App { System.exit(1) } - allExplanations = k.explainClusters(groups, excludeClasses, o['scores-only'], o['output-scores'], o['output-type'], o['power'], threads, o['debug']) + allExplanations = k.explainClusters(groups, excludeClasses, o['scores-only'], o['output-scores'], o['output-type'], o['power'], threads, o['debug'], o['include-all']) } else if(o['group'] && o['group'] != '*') { - allExplanations = k.explainClusters([o['group']], excludeClasses, o['scores-only'], o['output-scores'], o['output-type'], o['power'], threads, o['debug']) + allExplanations = k.explainClusters([o['group']], excludeClasses, o['scores-only'], o['output-scores'], o['output-type'], o['power'], threads, o['debug'], o['include-all']) } else { - allExplanations = k.explainAllClusters(o['output-scores'], excludeClasses, o['scores-only'], o['output-type'], o['power'], threads, o['debug']) + allExplanations = k.explainAllClusters(o['output-scores'], excludeClasses, o['scores-only'], o['output-type'], o['power'], threads, o['debug'], o['include-all']) } if(o['scores-only']) { diff --git a/klarigi/src/main/groovy/klarigi/Classifier.groovy b/klarigi/src/main/groovy/klarigi/Classifier.groovy index 46c441c..ccad0cf 100644 --- a/klarigi/src/main/groovy/klarigi/Classifier.groovy +++ b/klarigi/src/main/groovy/klarigi/Classifier.groovy @@ -38,7 +38,8 @@ public class Classifier { def score = 0 if(subeq.any { codes.containsKey(it) }) { //score = e.nPower * e.nIc - score = e.nExclusion * e.nIc + //score = e.nExclusion * e.nIc + score = e.nExclusion } return score diff --git a/klarigi/src/main/groovy/klarigi/Klarigi.groovy b/klarigi/src/main/groovy/klarigi/Klarigi.groovy index 651bf3a..8069864 100644 --- a/klarigi/src/main/groovy/klarigi/Klarigi.groovy +++ b/klarigi/src/main/groovy/klarigi/Klarigi.groovy @@ -254,13 +254,23 @@ public class Klarigi { } ae.each { g, gp -> - def candidates = scorer.scoreClasses(g, excludeClasses, threads, ae[g].keySet().toList(), true) + def cSet = ae[g].keySet().toList() + def candidates = scorer.scoreClasses(g, excludeClasses, threads, cSet, true) candidates.each { v -> def k = v.iri ae[g][k].incVals << v.nInclusion ae[g][k].excVals << v.nExclusion ae[g][k].powVals << v.nPower + + cSet -= k + } + + // Add zeros for remaining bois + cSet.each { k -> + ae[g][k].incVals << 0 + ae[g][k].excVals << 0 + ae[g][k].powVals << 0 } } } @@ -269,6 +279,7 @@ public class Klarigi { ae.each { c, terms -> ps[c] = [:] terms.each { iri, cv -> + if(iri == "http://purl.obolibrary.org/obo/HP_0009763") { println cv.incVals } ps[c][iri] = [ incP: new BigDecimal(cv.incVals.findAll { it >= cv.nInclusion }.size() / cv.incVals.size()).round(new MathContext(3)), excP: new BigDecimal(cv.excVals.findAll { it >= cv.nExclusion }.size() / cv.excVals.size()).round(new MathContext(3)), @@ -286,9 +297,9 @@ public class Klarigi { ps } - def explainCluster(cid, powerMode, excludeClasses, scoreOnly, outputScores, outputType, threads, debug) { + def explainCluster(cid, powerMode, excludeClasses, scoreOnly, outputScores, outputType, threads, debug, includeAll) { def scorer = new Scorer(ontoHelper, coefficients, data) - def candidates = scorer.scoreAllClasses(cid, excludeClasses, threads) + def candidates = scorer.scoreAllClasses(cid, excludeClasses, threads, includeAll) println "$cid: Scoring completed. Candidates: ${candidates.size()}" @@ -315,15 +326,15 @@ public class Klarigi { return res } - def explainClusters(groups, excludeClasses, scoreOnly, outputScores, outputType, powerMode, threads, debug) { + def explainClusters(groups, excludeClasses, scoreOnly, outputScores, outputType, powerMode, threads, debug, includeAll) { data.groupings.findAll { g, v -> groups.contains(g) }.collect { g, v -> - [ cluster: g, results: explainCluster(g, powerMode, excludeClasses, scoreOnly, outputScores, outputType, threads, debug) ] + [ cluster: g, results: explainCluster(g, powerMode, excludeClasses, scoreOnly, outputScores, outputType, threads, debug, includeAll) ] } } - def explainAllClusters(outputScores, excludeClasses, scoreOnly, outputType, powerMode, threads, debug) { + def explainAllClusters(outputScores, excludeClasses, scoreOnly, outputType, powerMode, threads, debug, includeAll) { data.groupings.collect { g, v -> - [ cluster: g, results: explainCluster(g, powerMode, excludeClasses, scoreOnly, outputScores, outputType, threads, debug) ] + [ cluster: g, results: explainCluster(g, powerMode, excludeClasses, scoreOnly, outputScores, outputType, threads, debug, includeAll) ] } }