Skip to content

Commit c6c53c9

Browse files
committed
move test to the VIP rather than console
1 parent 984798e commit c6c53c9

4 files changed

Lines changed: 64 additions & 31 deletions

File tree

VIPInterface.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,19 +1259,18 @@ def isMeta(data):
12591259
if not os.path.exists(strPath):
12601260
return "FALSE"
12611261
return "TRUE"
1262-
## in order for the following VIP auto testing work after updating
1263-
## 1. generating the test data by one of the following steps:
1264-
## > manually selecting all information on VIP or loading a session for all plots, and then run 'randomPlot' in the browser console;
1265-
## > manually selecting two group of cells, and then run "randomSelGene(grpName)", grpName is a required string of a category name, such as 'cell_type'
1266-
## > run 'createTest(grpName)' in the browser console to randomly generate test case, grpName is a string of a category name, such as 'cell_type'
1267-
## 2. make sure the h5ad file name is listed in vip.env as a variable 'testVIP';
1262+
1263+
#make sure the h5ad file full name is listed in vip.env as a variable 'testVIP';
12681264
def testVIPready(data):
12691265
strH5ad = os.path.basename(data["h5ad"])
12701266
if 'testVIP' in data and strH5ad==data["testVIP"]:
1267+
both = True
12711268
for one in [re.sub("h5ad$","info.txt",strH5ad),re.sub("h5ad$","img.txt",strH5ad)]:
1272-
if not os.path.exists(strExePath+"/../common/web/static/testVIP/"+one):
1273-
return "FALSE"
1274-
return "TRUE"
1269+
both = both and os.path.exists(strExePath+"/../common/web/static/testVIP/"+one)
1270+
if both:
1271+
return "SHOW"
1272+
else:
1273+
return "TRUE"
12751274
return "FALSE"
12761275

12771276
def saveTest(data):

config.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,11 @@ make install-dist
133133
cd ..
134134

135135
## finished setting up ------
136-
strPath=$(python -c "import server as _; print(_.__file__.replace('/server/__init__.py',''))")
136+
strPath="$(python -c 'import site; print(site.getsitepackages()[0])')"
137137
strweb="${strPath}/server/common/web/static/."
138138

139139
cp VIPInterface.py $strPath/server/app/.
140140
cp interface.html $strweb
141-
142-
cp jquery.min.js $strweb
143-
cp -R DataTables $strweb
144-
cp -R jspanel $strweb
145-
146-
cp jquery-ui.min.js $strweb
147-
cp color_*.png $strweb
148-
cp -R ace $strweb
149-
cp -R stackedbar $strweb
150-
cp -R d3plot $strweb
151141
cp volcano.R $strPath/server/app/.
152142
cp violin.R $strPath/server/app/.
153143
cp Density2D.R $strPath/server/app/.

interface.html

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<!-- <script src="static/saveVIP.js"></script> -->
3131
<!-- for testing the VIP -->
3232
<script src="https://interactivereport.github.io/cellxgene_VIP/static/testVIP.js"></script>
33-
<!-- <script src="static/testVIP/testVIP.js"></script> -->
33+
<!-- <script src="static/testVIP.js"></script> -->
3434
<!-- end -->
3535
<style>
3636
.dropup,
@@ -499,13 +499,13 @@
499499
<button class="tablinks" onclick="ABBRall()">Check All Annotations</button>
500500
<button class="tablinks" onclick="selFun(event, 'BRUSH');">Brush</button>
501501
<button class="tablinks" onclick="sync();">Sync</button>
502-
<button id="VIPtestBT" class="tablinks" onclick="selFun(event, 'tVIP');testVIP('tVIP');">Test</button>
502+
<button id="VIPtestBT" class="tablinks" onclick="selFun(event, 'tVIP')">Test</button>
503503
</div>
504504
</div>
505505
<div id="separator" ></div>
506506
<div id="panel-right" >
507507

508-
<input id="loadfile" type="file" onchange="load()" style="display:none" files="static/testVIP/info.txt"/>
508+
<input id="loadfile" type="file" onchange="load()" style="display:none"/>
509509
<div id="ABBR" class="tabcontent"> <!-- Abbreviation -->
510510
<h3>Create a combinatorial annotation</h3>
511511
<ol type="1">
@@ -1201,10 +1201,10 @@ <h3>Interactive stacked barplot of cell distribution of selected cells over two
12011201
</div>
12021202
<p>Annotations:</p><p id="STACBARgrp"></p>
12031203
<p>Color by <select id="STACBARcol"></select></p>
1204-
<p>Figure width: <input id="STACBARwidth" type="number" step="50" value="800"/> , height: <input id="STACBARheight" type="number" step="40" value="480"/></p>
1204+
<p>Figure width: <input id="STACBARwidth" type="number" step="50" value="800"/> , height: <input id="STACBARheight" type="number" step="40" value="480"/></p>
12051205
<p>x-Axis font size: <input id="STACBARxfontsize" type="number" step="2" value="16"/> ,
12061206
label rotate: <input id="STACBARxlabelrotate" type="number" step="5" value="-60"/> ,
1207-
label shift: <input id="STACBARxlabelshift" type="number" step="2" value="-24"/></p>
1207+
label shift: <input id="STACBARxlabelshift" type="number" step="2" value="-24"/></p>
12081208
</div>
12091209

12101210

@@ -1333,7 +1333,32 @@ <h3>Brushed ranges</h3>
13331333
<div id="CLIresize" style="height: 'auto'; width: 'auto'; padding: 0.5em;"></div>
13341334
</div><!--CLI-->
13351335

1336-
<div id="tVIP" class="tabcontent"></div>
1336+
<div id="tVIP" class="tabcontent">
1337+
<h3>Test the VIP functionality</h3>
1338+
<p><button id="tVIPtest" class="tVIPbt" onclick="testVIP('tVIPnote')"><b>Test by the latest case</b></button></p>
1339+
<fieldset>
1340+
<legend>Create a test case</legend>
1341+
<p>by: <select id="tVIPgrp"></select></p>
1342+
<p><button class="tVIPbt tVIPbtA" onclick="tVIPcreate('random','tVIPnote')">Create</button><br>
1343+
The prcess will<br>
1344+
1. Split the annotations of selected category into two groups randomly;<br>
1345+
2. Select 500 cells from each group;<br>
1346+
3. Apply DEG for those two groups of cells;<br>
1347+
4. Select top DEGs randomly in to groups;<br>
1348+
5. Choose user selections in VIP randomly;<br>
1349+
6. Perform plotting function one by one;<br>
1350+
7. Save the test case on the server for future use (overwrite preivous).
1351+
</p>
1352+
<p><button class="tVIPbt tVIPbtA" onclick="tVIPcreate('cells','tVIPnote')">Create on selected cells</button><br>
1353+
The test generation will ignore the first 2 steps in the above process, and run all the rest.
1354+
</p>
1355+
<p><button class="tVIPbt tVIPbtA" onclick="tVIPcreate('selections','tVIPnote')">Create on selections</button><br>
1356+
The user have selected all options on VIP including the genes and gene sets (or loaded previous session).
1357+
This process will process all VIP plots one by one and save it as a test case on the server (overwrite preivous).
1358+
</p>
1359+
</fieldset>
1360+
<div id="tVIPnote"></div>
1361+
</div>
13371362
</div>
13381363

13391364
</div>
@@ -1603,9 +1628,14 @@ <h3>Brushed ranges</h3>
16031628
data:JSON.stringify({'method':"testVIPready",'dataset': window.store.getState().config.displayNames.dataset+'.h5ad'}),
16041629
contentType: 'application/json;charset=UTF-8',
16051630
success: function(res){
1631+
$("#tVIPtest").prop('disabled',true);
16061632
if(res == "TRUE"){
16071633
$("#VIPtestBT").show();
16081634
}
1635+
if(res == "SHOW"){
1636+
$("#tVIPtest").prop('disabled',false);
1637+
$("#VIPtestBT").show();
1638+
}
16091639
},
16101640
error: function(request,status,error){
16111641
console.log(request.status+': cannot get VIP test information ...');
@@ -1662,6 +1692,7 @@ <h3>Brushed ranges</h3>
16621692
var densS = document.getElementById("DENSsplit");
16631693
var densG = document.getElementById("DENSgrp");
16641694
var embed = document.getElementById("EMBEDsplit");
1695+
var tVIP = document.getElementById("tVIPgrp");
16651696

16661697
for(const one of grps){
16671698
if (one.startsWith(">")) continue;
@@ -1676,6 +1707,7 @@ <h3>Brushed ranges</h3>
16761707
densS.add(createOpt(one));
16771708
densG.add(createOpt(one));
16781709
embed.add(createOpt(one));
1710+
tVIP.add(createOpt(one));
16791711
}
16801712
densS.add(createOpt('None'));
16811713
densG.add(createOpt('None'));
@@ -1854,6 +1886,9 @@ <h3>Brushed ranges</h3>
18541886
CLIref();
18551887
preDEGVolcanoref("preDEGvolcano");
18561888
preDEGmultiref();
1889+
if(window.store.getState().colors.colorAccessor != null){
1890+
$('#tVIPgrp').val(window.store.getState().colors.colorAccessor);
1891+
}
18571892
}
18581893
function ABBRref(){
18591894
}
@@ -4476,6 +4511,19 @@ <h3>Brushed ranges</h3>
44764511
numberLoad(content['number']);
44774512
sortableLoad(content['sortable']);
44784513
}
4514+
// test the VIP
4515+
function tVIPcreate(act,eID){
4516+
$(".tVIPbt").prop('disabled',true);
4517+
$("#"+eID).html("");
4518+
4519+
if(act=='random'){
4520+
createTest($("#tVIPgrp").val(),'tVIPnote');
4521+
}else if(act=='cells'){
4522+
randomInitDEG($("#tVIPgrp").val(),'tVIPnote');
4523+
}else if(act=='selections'){
4524+
randomPlot('tVIPnote');
4525+
}
4526+
}
44794527
// ignore global definition for stackedBar legend circle
44804528
function GetStyle(CLASSname){
44814529
var styleSheets = document.styleSheets;

update.VIPInterface.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@ echo "usually update once"
44
fi
55

66
## finished setting up ------
7-
strPath=$(python -c "import server as _; print(_.__file__.replace('/server/__init__.py',''))")
7+
strPath="$(python -c 'import site; print(site.getsitepackages()[0])')"
88
strweb="${strPath}/server/common/web/static/."
99

1010
cp VIPInterface.py $strPath/server/app/.
1111
cp interface.html $strweb
1212
cp vip.env $strPath/server/app/. 2>/dev/null | true
1313

1414
if [ -n "$1" ]; then
15-
cp -R testVIP $strweb
16-
cp saveVIP.js $strweb
17-
cp -R stackedbar $strweb
18-
cp -R d3plot $strweb
1915
cp bubbleMap.R $strPath/server/app/.
2016
cp violin.R $strPath/server/app/.
2117
cp volcano.R $strPath/server/app/.

0 commit comments

Comments
 (0)