Skip to content

Commit

Permalink
pval fix, and --include-all mode for scoring
Browse files Browse the repository at this point in the history
  • Loading branch information
reality committed Feb 12, 2022
1 parent 3de679c commit 6baacc1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
7 changes: 4 additions & 3 deletions klarigi/src/main/groovy/klarigi/App.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']) {
Expand Down
3 changes: 2 additions & 1 deletion klarigi/src/main/groovy/klarigi/Classifier.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 18 additions & 7 deletions klarigi/src/main/groovy/klarigi/Klarigi.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand All @@ -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)),
Expand All @@ -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()}"

Expand All @@ -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) ]
}
}

Expand Down

0 comments on commit 6baacc1

Please sign in to comment.