diff --git a/Makefile b/Makefile index 3114f76..297526d 100644 --- a/Makefile +++ b/Makefile @@ -14,20 +14,8 @@ README.md: bin/wtfgenes.js bin/wtfgenes.js -h | perl -pe 's//>/g;' | perl -e 'open FILE,"){last if/
/;print}close FILE;print"
\n";while(<>){print};print"
\n"' >temp.md mv temp.md $@ -webclient: jquery plotly web/wtfgenes.js - -jquery: web/jquery-1.12.2.min.js - -plotly: web/plotly-latest.min.js - -web/plotly-latest.min.js: - cd web; curl -O https://cdn.plot.ly/plotly-latest.min.js - -web/jquery-1.12.2.min.js: - cd web; curl -O https://code.jquery.com/jquery-1.12.2.min.js - -web/wtfgenes.js: web/client.js - browserify $< -o $@ +webclient: + cd web; make cpp-js-comparison: cd test/data/yeast; make go-basic.obo gene_association.sgd diff --git a/test/mcmc.js b/test/mcmc.js index fd05820..d336916 100644 --- a/test/mcmc.js +++ b/test/mcmc.js @@ -247,7 +247,7 @@ describe('MCMC', function() { } function testRelevantTerms(mcmc,move) { - assert.deepEqual (move.model.relevantTerms, [0,1,3,4,5,6,7,8]) + assert.deepEqual (move.model.relevantTerms, [0,3,4,5,6,7,8]) } describe('#randomize', function() { diff --git a/test/model.js b/test/model.js index b580259..108944f 100644 --- a/test/model.js +++ b/test/model.js @@ -48,13 +48,13 @@ describe('Model', function() { describe('#constructor', function() { it('should identify relevant terms', function() { - assert.deepEqual (mutantModel.relevantTerms, [0,1,3,4,5,6,7,8]) - assert.deepEqual (normalModel.relevantTerms, [0,1,2,3,4,7]) - assert (normalModel.isRelevant[1]) + assert.deepEqual (mutantModel.relevantTerms, [0,3,4,5,6,7,8]) + assert.deepEqual (normalModel.relevantTerms, [0,2,3,4,7]) + assert (normalModel.isRelevant[3]) assert (!normalModel.isRelevant[5]) }) it('should identify neighbors of relevant terms', function() { - assert.deepEqual (mutantModel.relevantNeighbors, [[5,7],[3,7],[0],[1,4,6],[3,5],[0,4,8],[3],[0,1],[5]]) + assert.deepEqual (mutantModel.relevantNeighbors, [[5,7],[3,7],[0],[4,6],[3,5],[0,4,8],[3],[0],[5]]) }) it('should create default params', function() { assert.deepEqual (mutantModel.paramSet.paramNames(), ['fn','fp','t']) @@ -74,7 +74,7 @@ describe('Model', function() { describe('#setTermState', function() { it('should update termState & isActiveTerm', function() { for (var t = 0; t < 9; ++t) - if (t != 2) { + if (t != 1 && t != 2) { mutantModel.setTermState(t,1); for (var s = 0; s < 9; ++s) assert.equal (mutantModel.getTermState(s), s == t ? 1 : 0) @@ -87,13 +87,11 @@ describe('Model', function() { assert.deepEqual (mutantModel._termState, [0,0,0,0,0,0,0,0,0]) }) it('should update nActiveTermsByGene', function() { - mutantModel.setTermState(1,1); mutantModel.setTermState(3,1); mutantModel.setTermState(8,1); - assert.equal (mutantModel._nActiveTermsByGene[2], 2) + assert.equal (mutantModel._nActiveTermsByGene[2], 1) assert.equal (mutantModel._nActiveTermsByGene[3], 0) - assert.equal (mutantModel._nActiveTermsByGene[4], 3) - mutantModel.setTermState(1,0); + assert.equal (mutantModel._nActiveTermsByGene[4], 2) mutantModel.setTermState(3,0); mutantModel.setTermState(8,0); }) @@ -111,7 +109,7 @@ describe('Model', function() { describe('#toJSON', function() { it('should convert term state to JSON', function() { for (var t = 0; t < 9; ++t) - if (t != 2) { + if (t != 1 && t != 2) { mutantModel.setTermState(t,1); assert.deepEqual (mutantModel.toJSON(), [onto.termName[t]]) mutantModel.setTermState(t,0); @@ -156,12 +154,12 @@ describe('Model', function() { describe('#getCounts', function() { it('should return Bernoulli parameter counts', function() { - assert.deepEqual (mutCount.toJSON(), {succ:{fp:3},fail:{t:8,fp:2}}) - assert.deepEqual (normCount.toJSON(), {succ:{fp:2},fail:{t:6,fp:3}}) + assert.deepEqual (mutCount.toJSON(), {succ:{fp:3},fail:{t:7,fp:2}}) + assert.deepEqual (normCount.toJSON(), {succ:{fp:2},fail:{t:5,fp:3}}) normalModel.setTermState (7, 1) var newNormCount = normalModel.getCounts() - assert.deepEqual (newNormCount.toJSON(), {succ:{t:1,fn:3},fail:{t:5,fn:2}}) + assert.deepEqual (newNormCount.toJSON(), {succ:{t:1,fn:3},fail:{t:4,fn:2}}) normalModel.setTermState (7, 0) }) }) @@ -186,11 +184,11 @@ describe('Model', function() { it('should correctly identify new false negatives', function() { var m2 = new Model ({ assocs: assocs, geneSet: mutants, terms: ['arachnid','primate','gorilla'] }) var c2 = m2.getCounts() - assert.deepEqual (c2.toJSON(), {succ:{t:3,fn:2},fail:{t:5,fn:3}}) + assert.deepEqual (c2.toJSON(), {succ:{t:3,fn:2},fail:{t:4,fn:3}}) var d2 = m2.getCountDelta({0:0}) assert.deepEqual (d2.toJSON(), {succ:{t:-1,fn:-1},fail:{t:1,fp:1}}) m2.setTermStates({0:0}) - assert.deepEqual (m2.getCounts().toJSON(), {succ:{t:2,fn:1},fail:{t:6,fn:3,fp:1}}) + assert.deepEqual (m2.getCounts().toJSON(), {succ:{t:2,fn:1},fail:{t:5,fn:3,fp:1}}) assert.deepEqual (c2.add(d2).toJSON(), m2.getCounts().toJSON()) }) }) diff --git a/web/Makefile b/web/Makefile new file mode 100644 index 0000000..5515698 --- /dev/null +++ b/web/Makefile @@ -0,0 +1,11 @@ + +all: jquery-1.12.2.min.js plotly-latest.min.js wtfgenes.js + +plotly-latest.min.js: + cd web; curl -O https://cdn.plot.ly/plotly-latest.min.js + +jquery-1.12.2.min.js: + cd web; curl -O https://code.jquery.com/jquery-1.12.2.min.js + +wtfgenes.js: client.js $(wildcard ../lib/*.js) + browserify client.js -o $@ diff --git a/web/client.js b/web/client.js index fe09812..75858dd 100644 --- a/web/client.js +++ b/web/client.js @@ -109,9 +109,13 @@ var wtf = this Plotly.plot( wtf.ui.logLikePlot[0], [{ y: wtf.mcmc.logLikelihoodTrace }], - { title: "Convergence", - xaxis: { title: "Number of samples" }, - yaxis: { title: "Log-likelihood" } } ) + { title: "MCMC convergence", + xaxis: { title: "Number of samples" }, + yaxis: { title: "Log-likelihood" }, + margin: 0, + width: 400, + height: 400 } ) + setTimeout (redrawLogLikelihood.bind(wtf), 100) } @@ -167,7 +171,7 @@ resumeAnalysis.call(wtf) wtf.ui.startButton.prop('disabled',false) - wtf.ui.interButton = $('') + wtf.ui.interButton.show() wtf.ui.interButton.click (function() { wtf.ui.interButton.prop('disabled',true) wtf.mcmc.logTermPairs() @@ -180,9 +184,10 @@ wtf.ui.samplesPerTerm = $('0') wtf.ui.samplesPerSec = $('0') wtf.ui.mcmcStats = $('') - wtf.ui.mcmcStats.append (" ", wtf.ui.totalSamples, " samples (", wtf.ui.samplesPerTerm, " samples/term, ", wtf.ui.samplesPerSec, " samples/sec)") + wtf.ui.mcmcStats.append (wtf.ui.totalSamples, " samples
", wtf.ui.samplesPerTerm, " samples/term
", wtf.ui.samplesPerSec, " samples/sec") - wtf.ui.inputDiv.append (wtf.ui.interButton, wtf.ui.mcmcStats) + wtf.ui.statusDiv.append (wtf.ui.mcmcStats) + wtf.ui.statusDiv.show() runMCMC.call(wtf) plotLogLikelihood.call(wtf) @@ -219,7 +224,7 @@ } function log() { - this.ui.parentDiv.append ('
' + Array.prototype.slice.call(arguments).join('') + '') + this.ui.logDiv.append ('
' + Array.prototype.slice.call(arguments).join('') + '') } function WTFgenes (conf) { @@ -235,10 +240,13 @@ // initialize UI if (!wtf.ui.parentDiv) { - wtf.ui.parentDiv = $('
') + wtf.ui.parentDiv = $('
') $("body").append (wtf.ui.parentDiv) } + wtf.ui.logDiv = $('
') + wtf.ui.parentDiv.append (wtf.ui.logDiv) + // load data files, initialize ontology & associations var ontologyReady = $.Deferred(), assocsReady = $.Deferred() @@ -254,7 +262,6 @@ // load associations ontologyReady.done (function() { - wtf.log() wtf.log ("Loading gene-term associations...") $.get(wtf.assocsURL) .done (function (assocsJson) { @@ -274,26 +281,35 @@ enableExampleLink (wtf) } - wtf.ui.geneSetTextArea = $('