Skip to content

Commit

Permalink
Simplifies calibration check utility
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebouchard committed May 28, 2019
1 parent 9a03b31 commit 0cad03d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main/java/humi/v5/CalibrationTest.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,32 @@ import org.apache.commons.math3.stat.descriptive.SummaryStatistics
class CalibrationTest extends Experiment {

@Arg File reference
@Arg String referenceDataset

@Arg File intervals

@Arg @DefaultValue("dataset")
String datasetField = "dataset"

@Arg @DefaultValue("sgrna")
String sgRNAField = "sgrna"

override run() {
val truth = loadReference()
val radia = new SummaryStatistics
val coverage = new SummaryStatistics
for (line : BriefIO::readLines(intervals).indexCSV) { //}.filter[get(datasetField) != referenceDataset]) {
for (line : BriefIO::readLines(intervals).indexCSV) {
val sgRNA = Integer::parseInt(line.get(sgRNAField))
if (!truth.containsKey(sgRNA)) throw new RuntimeException
val logRatio = Double::parseDouble(line.get(DeltaMethod.Columns.logRatio.toString))
val radius = Double::parseDouble(line.get(DeltaMethod.Columns.logRatioIntervalRadius.toString))
radia.addValue(radius)
coverage.addValue(if (Math::abs(logRatio - truth.get(sgRNA)) < radius) 1.0 else 0.0)
truth.remove(sgRNA)
}
println(radia.mean)
println(coverage.mean)
}

def loadReference() {
val result = new LinkedHashMap<Integer, Double>
for (line : BriefIO::readLines(reference).indexCSV) { //}.filter[get(datasetField) == referenceDataset]) {
for (line : BriefIO::readLines(reference).indexCSV) {
val sgRNA = Integer::parseInt(line.get(sgRNAField))
val logRatio = Double::parseDouble(line.get(DeltaMethod.Columns.logRatio.toString))
result.put(sgRNA, logRatio)
Expand Down

0 comments on commit 0cad03d

Please sign in to comment.