1 //////////Loopback AngularJS SDK Approach 2 angular 3 4 .module('app') 5 .controller('SignatureMetaController', ['$scope','$filter', '$state','$window','$location','$http','$httpParamSerializer', '$anchorScroll','$uibModal', '$log','signatures','genes','compoundsFactory',//'$sce', 6 'SignatureMeta','SearchTerm', 'IlincsR','GeneList','GeneInfo','SignatureList','SignatureUpload','SignatureLibraries','PharmAction','Container','FileUploader','ngMeta','modals','historyFactory','envService','CompoundMOA',/*'Concordancelib6',*/ 7 function($scope,$filter,$state,$window,$location,$http,$httpParamSerializer, $anchorScroll,$uibModal, $log,signatures,genes,compoundsFactory, //$sce, 8 SignatureMeta,SearchTerm, IlincsR,GeneList,GeneInfo,SignatureList,SignatureUpload,SignatureLibraries,PharmAction,Container,FileUploader,ngMeta,modals,historyFactory,envService, CompoundMOA/*, Concordancelib6*/) { 9 10 function getOneSignature(sigId) { 11 // SignatureMeta 12 // .findOne({ filter:{where: {signatureid: sigId}}}) 13 // .$promise 14 // .then(function(results) { 15 // // console.log(results); 16 // $scope.opened=results; 17 // }); 18 19 20 SignatureMeta.findOne({ filter:{where: {signatureid: sigId}}}, 21 function(data){ 22 // console.log(data); 23 $scope.opened=data; 24 if ($scope.opened.integratedMoas) { 25 $scope.mechanismsOfAction=$scope.opened.integratedMoas.split("|"); 26 } 27 if ($scope.opened.GeneTargets) { 28 $scope.geneTargets=$scope.opened.GeneTargets.split("|") 29 } 30 signatures.getSignatureLibraryInfo(data.libraryid,successLibInfo); 31 // console.log($scope.openedLibInfo); 32 // console.log(signatures.signatureLibraries[data.libraryid]); 33 if (data.cellline){ 34 getL1000FWDlink(data.cellline); 35 } 36 if ($scope.opened.libraryid=='LIB_5') { 37 getPharmActionSig($scope.opened); 38 getMoaActionSig($scope.opened); 39 getKnownTargetActionSig($scope.opened); 40 } 41 if ($scope.opened.libraryid!='LIB_9') { 42 $scope.opened.Pval=true; 43 } 44 }, 45 function(errorResponse){ 46 console.log("Signature not found."); 47 console.log(errorResponse); 48 $scope.wrongSignature = true; 49 // $location.path('404'); 50 51 }); 52 } 53 54 function successLibInfo(info) { 55 $scope.openedLibInfo=info; 56 // console.log($scope.openedLibInfo); 57 $scope.connectedLibs=$scope.openedLibInfo.connLibs.split(","); 58 // console.log(signatures.signatureLibraries[data.libraryid]); 59 } 60 61 $scope.isConnectedLib = function(lib) { 62 return $scope.connectedLibs.indexOf(lib) !== -1; 63 } 64 65 function returnOneSignature(sigId) { 66 return SignatureMeta.findOne({ filter:{where: {signatureid: sigId}}}); 67 } 68 69 70 function getL1000FWDlink(cellLine) { 71 // console.log("get L1000FWD url"); 72 73 IlincsR.getL1000FWDcell({ cellLine:cellLine}, 74 function(data){ 75 // console.log(data); 76 // $scope.opened=data; 77 if (data.url){ 78 $scope.L1000FWDcellLink=data.url; 79 } 80 }, 81 function(errorResponse){ 82 console.log("Error geting links to L1000FWD."); 83 console.log(errorResponse); 84 85 }); 86 } 87 88 89 // {"where":{"lincspertid": "LSM-1403","libraryid":"LIB_5"}} 90 function getLincsPertIdSignatures(lincsPertId,lib) { 91 SignatureMeta 92 .find({ filter:{where: {lincspertid: lincsPertId,libraryid:lib}}}) 93 .$promise 94 .then(function(results) { 95 // console.log(results); 96 $scope.foundSignatures = results; //data for findTerm 97 $scope.dataLoading = false;
98 // formatDataTable(check); 99 // console.log($scope.foundSignatures.length); 100 // if ($scope.foundSignatures.length){ 101 // formatDataTableForLib(lib,true); 102 // } 103 104 // if ($scope.foundSignatures.length>0) { 105 formatDataTableForLib(lib,false); 106 // } else { 107 // console.log($scope.foundSignatures.length); 108 // setTimeout(function() { 109 // // console.log($scope.geneList); 110 // formatDataTableForLib(lib,false); 111 // }, 1000); 112 // } 113 }); 114 } 115 116 function getSignatures() { 117 SignatureMeta 118 .find() 119 .$promise 120 .then(function(results) { 121 $scope.allsignatures = results; 122 $scope.dataLoading = false; 123 124 $scope.customTheme = { 125 iconUp: 'fa fa-sort-amount-asc pull-right samplesHead', 126 iconDown: 'fa fa-sort-amount-desc pull-right samplesHead', 127 listItemsPerPage: [5,25, 50, 100], 128 itemsPerPage: 10, 129 loadOnInit: true 130 }; 131 132 $scope.resource = { 133 "header": //response.data.header, 134 [ 135 { "check": "" }, 136 { "signatureid": "signatureid" }, 137 { "libraryid": "libraryid" }, 138 { "cellline":"cellline"}, 139 { "factor": "factor" } 140 ,{ "compound": "compound"} 141 ], 142 "rows": $scope.allsignatures 143 }; 144 }); 145 146 147 } 148 149 function getConcordantSignatures(signatureID) { 150 151 152 activeLibs=["LIB_1","LIB_2","LIB_3","LIB_5","LIB_6","LIB_7","LIB_8"]; 153 154 angular.forEach(activeLibs, function(lib) { 155 // searchSignaturesInLib($scope.searchTerm,lib,true); 156 getConcordantSignaturesInLib(signatureID,lib); 157 }) 158 159 // SignatureMeta 160 // .findTerm({term:term,library:lib}) 161 // .$promise 162 // .then(function(results) { 163 // $scope.foundSignatures = results.data; //data for findTerm 164 // $scope.dataLoading = false; 165 // // formatDataTable(check); 166 // formatDataTableForLib(lib); 167 // 168 // }); 169 170 } 171 172 173 174 175 176 function getConcordantSignaturesInLib(signatureID,library) { 177 178 SignatureMeta 179 .findConcordantSignatures({sigID:signatureID,lib:library}) 180 .$promise 181 .then(function(results) { 182 // $scope.concordantSignaturesLib1 = results; 183 // console.log(results); 184 $scope.dataLoading = false; 185 186 $scope.foundSignatures = results; 187 formatDataTableForLib(library,true); 188 189 // $scope.customTheme = { 190 // iconUp: 'fa fa-sort-amount-asc pull-right samplesHead', 191 // iconDown: 'fa fa-sort-amount-desc pull-right samplesHead', 192 // listItemsPerPage: [10, 20, 50, 100, 1000], 193 // itemsPerPage: 5, 194 // loadOnInit: true 195 // }; 196 // 197 // $scope.resourceLib1 = { 198 // "header": //response.data.header, 199 // [ 200 // { "check": "" }, 201 // { "signatureid": "Signature Id" }, 202 // { "datasetid": "Dataset"}, 203 // { "factor": "Factor" }, 204 // { "level1": "Level1" }, 205 // { "level2": "Level2" }, 206 // { "similarity": "Concordance" }, 207 // ], 208 // "rows": $scope.concordantSignaturesLib1 209 // }; 210 }); 211 212 } 213 214 function getEnrichedSignatures(genes) { 215 216
217 // activeLibs=["LIB_1","LIB_2","LIB_3","LIB_5","LIB_6","LIB_7","LIB_8"]; 218 219 // angular.forEach(activeLibs, function(lib) { 220 // searchSignaturesInLib($scope.searchTerm,lib,true); 221 getEnrichedSignaturesInLib("LIB_1",genes); 222 // }) 223 224 225 } 226 227 function getEnrichedSignaturesInLib(library,genes) { 228 229 // console.log(library); 230 // console.log(genes); 231 // IlincsR.GeneListEnrichment({libName:library,geneList:"8574,51170,5654,2625,4931"}) 232 // .$promise 233 // .then(function(results) { 234 // console.log(results); 235 // // $scope.dataLoading = false; 236 // // 237 // // $scope.foundSignatures = results; 238 // // formatDataTableForLib(library,true); 239 // // 240 // }); 241 // var testgenes="5613,5743,5921,808,1022,3383,6464,5261,2553,10682,7016"; 242 IlincsR.GeneListEnrichment({libName:library,geneList:genes}, 243 function(data){//$scope.sigList = data; 244 //$scope.currentLib = data.lib 245 // console.log("here"); 246 // console.log(data); 247 $scope.dataLoading = false; 248 $scope.foundSignatures = data.sigScores; 249 formatDataTableForLib(library,true); 250 }, 251 function(errorResponse){console.log("Signature list not found."),console.log(errorResponse)}); 252 253 } 254 255 function searchSignatures(term,check) { 256 // SignatureMeta 257 // // .find({ filter:{ 258 // // where: 259 // // {or:[{libraryid:term},{cid:term}, 260 // // {signatureid:{like:"%"+term+"%"}}, 261 // // {antibodytarget:{like:"%"+term+"%"}}, 262 // // {compound:{like:"%"+term+"%"}}, 263 // // {factor:{like:"%"+term+"%"}}, 264 // // {cellline:{like:"%"+term+"%"}}, 265 // // {level1:{like:"%"+term+"%"}}, 266 // // {level2:{like:"%"+term+"%"}}, 267 // // {level2:{time:"%"+term+"%"}}, 268 // // {treatment: term}]}} 269 // // }) 270 // .findTerm({term:term}) 271 // .$promise 272 // .then(function(results) { 273 // $scope.foundSignatures = results.data; //data for findTerm 274 // $scope.dataLoading = false; 275 // formatDataTable(check); 276 // }); 277 278 return SignatureMeta.findTermWithSynonyms({term:term,public:$scope.prodEnv}, 279 function(results){ 280 console.log("findTermWithSynonyms"); 281 $scope.foundSignatures = results.data; //data for findTerm 282 $scope.dataLoading = false; 283 formatDataTable(check); 284 }, 285 function(errorResponse){ 286 console.log("Erro in signature search."); 287 console.log(errorResponse); 288 // console.log(errorResponse.data.error.message); 289 290 }); 291 292 } 293 294 function searchSignaturesInLib(term,lib,check,limit) { 295 // if (limit) { 296 // SignatureMeta 297 // .findTerm({term:term,library:lib,limit:limit}) 298 // .$promise 299 // .then(function(results) { 300 // // console.log(results); 301 // $scope.foundSignatures = results.data; //data for findTerm 302 // $scope.dataLoading = false; 303 // // formatDataTable(check); 304 // formatDataTableForLib(lib); 305 // }); 306 // } else { 307 // SignatureMeta 308 // // .find({ filter:{ 309 // // where: 310 // // {or:[{libraryid:term},{cid:term}, 311 // // {signatureid:{like:"%"+term+"%"}}, 312 // // {antibodytarget:{like:"%"+term+"%"}}, 313 // // {compound:{like:"%"+term+"%"}}, 314 // // {factor:{like:"%"+term+"%"}}, 315 // // {cellline:{like:"%"+term+"%"}}, 316 // // {level1:{like:"%"+term+"%"}}, 317 // // {level2:{like:"%"+term+"%"}}, 318 // // {level2:{time:"%"+term+"%"}}, 319 // // {treatment: term}]}} 320 // // }) 321 // .findTerm({term:term,library:lib}) 322 // .$promise 323 // .then(function(results) { 324 // // console.log(results); 325 // $scope.foundSignatures = results.data; //data for findTerm 326 // $scope.dataLoading = false;
327 // // formatDataTable(check); 328 // formatDataTableForLib(lib); 329 // 330 // }); 331 // } 332 return SignatureMeta.findTermWithSynonyms({term:term,library:lib,limit:limit}, 333 function(results){ 334 $scope.foundSignatures = results.data; //data for findTerm 335 $scope.dataLoading = false; 336 formatDataTableForLib(lib); 337 }, 338 function(errorResponse){ 339 console.log("Erro in signature search."); 340 console.log(errorResponse); 341 // console.log(errorResponse.data.error.message); 342 }); 343 } 344 345 function formatDataTable(check) { 346 $scope.customTheme = { 347 iconUp: 'fa fa-sort-amount-asc pull-right samplesHead', 348 iconDown: 'fa fa-sort-amount-desc pull-right samplesHead', 349 listItemsPerPage: [5,25, 50, 100], 350 // itemsPerPage: check ? 10:5, 351 itemsPerPage: 5, 352 loadOnInit: true 353 }; 354 if (check) { 355 $scope.resource = { 356 "header": //response.data.header, 357 [ 358 { "check": "" }, 359 { "signatureid": "Signature Id" }, 360 { "library": "Library" }, 361 { "cellline":"Cell line"}, 362 { "tissue":"Tissue"}, 363 { "factor": "Factor" } 364 ,{ "compound": "Perturbagen"} 365 ], 366 "rows": $scope.foundSignatures 367 }; 368 } else { 369 $scope.resource = { 370 "header": //response.data.header, 371 [ 372 // { "check": "" }, 373 { "signatureid": "Signature Id" }, 374 { "library": "Library" }, 375 { "cellline":"Cell line"}, 376 { "tissue":"Tissue"}, 377 { "factor": "Factor" } 378 ,{ "compound": "Perturbagen"} 379 ], 380 "rows": $scope.foundSignatures 381 }; 382 } 383 } 384 385 function formatDataTableForLib(lib,concordant) { 386 387 $scope.customTheme = { 388 iconUp: 'fa fa-sort-amount-asc pull-right samplesHead', 389 iconDown: 'fa fa-sort-amount-desc pull-right samplesHead', 390 listItemsPerPage: [5,25, 50, 100], 391 // itemsPerPage: check ? 10:5, 392 itemsPerPage: 5, 393 loadOnInit: true 394 }; 395 if (lib=="LIB_1") { 396 $scope.resourceLib1 = { 397 "header": //response.data.header, 398 [ 399 { "check": "" }, 400 // { "signatureid": "Signature Id" }, 401 // { "datasetid": "Dataset"}, 402 // { "factor": "Factor" }, 403 // { "level1": "Level1" }, 404 // { "level2": "Level2" }, 405 { "tableNames": "Signature Id" }, 406 { "datasetID": "Dataset"}, 407 { "factor": "Factor" }, 408 { "Level1": "Treatment" }, 409 { "Level2": "Baseline" }, 410 ], 411 "rows": $scope.foundSignatures 412 }; 413 if (concordant&&$scope.foundSignatures.length) { 414 $scope.resourceLib1.header.push({"similarity":"Concordance"}); 415 if ($scope.uploadedSignatures) {$scope.resourceLib1.header.push({"pValue":"pValue"},{"nGenes":"nGenes"})} 416 } 417 // if (concordant&&$scope.foundSignatures.length) { $scope.resourceLib1.header.push({"zScores":"Z score"}) } 418 // console.log($scope.resourceLib1); 419 } 420 if (lib=="LIB_8") { 421 $scope.resourceLib8 = { 422 "header": //response.data.header, 423 [ 424 { "check": "" }, 425 { "signatureid": "Signature Id" }, 426 { "datasetid": "Dataset"}, 427 { "factor": "Factor" }, 428 { "level1": "Treatment" }, 429 { "level2": "Baseline" }, 430 ], 431 "rows": $scope.foundSignatures 432 }; 433 if (concordant&&$scope.foundSignatures.length) { 434 $scope.resourceLib8.header.push({"similarity":"Concordance"}); 435 if ($scope.uploadedSignatures) {$scope.resourceLib8.header.push({"pValue":"pValue"},{"nGenes":"nGenes"})} 436 } 437 } 438 439 if (lib=="LIB_2") { 440 $scope.resourceLib2 = { 441 "header": //response.data.header, 442 [ 443 { "check": "" }, 444 { "signatureid": "Signature Id" }, 445 { "compound": "Perturbagen"}, 446 { "concentration": "Concentration" }, 447 { "cellline": "Cell Line" }, 448 { "tissue": "Tissue" } 449 ], 450 "rows": $scope.foundSignatures 451 }; 452 // if (concordant&&$scope.foundSignatures.length) { $scope.resourceLib2.header.push({"similarity":"Concordance"}) } 453 if (concordant&&$scope.foundSignatures.length) { 454 $scope.resourceLib2.header.push({"similarity":"Concordance"}); 455 if ($scope.uploadedSignatures) {$scope.resourceLib2.header.push({"pValue":"pValue"},{"nGenes":"nGenes"})} 456 } 457 } 458 459 if (lib=="LIB_3") { 460 $scope.resourceLib3 = { 461 "header": //response.data.header, 462 [ 463 { "check": "" }, 464 { "signatureid": "Signature Id" }, 465 { "antibodytarget": "Transcription Factor"}, 466 { "treatment": "Treatment" }, 467 { "cellline": "Cell Line" }, 468 { "tissue": "Tissue" } 469 ], 470 "rows": $scope.foundSignatures 471 }; 472 if (concordant&&$scope.foundSignatures.length) { 473 $scope.resourceLib3.header.push({"similarity":"Concordance"}); 474 // if ($scope.uploadedSignatures) {$scope.resourceLib3.header.push({"pValue":"pValue"},{"nGenes":"nGenes"})} 475 } 476 } 477 478 if (lib=="LIB_5") { 479 $scope.resourceLib5 = { 480 "header": //response.data.header, 481 [ 482 { "check": "" }, 483 { "signatureid": "Signature Id" }, 484 { "compound": "Perturbagen"}, 485 { "concentration": "Concentration" }, 486 { "cellline": "Cell Line" }, 487 { "tissue": "Tissue" }, 488 { "time": "Time" } 489 ], 490 "rows": $scope.foundSignatures 491 }; 492 if (concordant&&$scope.foundSignatures.length) { 493 $scope.resourceLib5.header.push({"similarity":"Concordance"}); 494 if ($scope.uploadedSignatures) {$scope.resourceLib5.header.push({"pValue":"pValue"},{"nGenes":"nGenes"})} 495 } 496 } 497 if (lib=="LIB_6") { 498 $scope.resourceLib6 = { 499 "header": //response.data.header, 500 [ 501 { "check": "" }, 502 { "signatureid": "Signature Id" }, 503 { "treatment": "Target gene"}, 504 // { "concentration": "Concentration" }, 505 { "perturbagenID": "CGS ID" }, 506 { "cellline": "Cell Line" }, 507 { "tissue": "Tissue" }, 508 { "time": "Time" } 509 ], 510 "rows": $scope.foundSignatures 511 }; 512 if (concordant&&$scope.foundSignatures.length) { 513 $scope.resourceLib6.header.push({"similarity":"Concordance"}); 514 if ($scope.uploadedSignatures) {$scope.resourceLib6.header.push({"pValue":"pValue"},{"nGenes":"nGenes"})} 515 } 516 } 517 if (lib=="LIB_7") { 518 $scope.resourceLib7 = { 519 "header": //response.data.header, 520 [ 521 { "check": "" }, 522 { "signatureid": "Signature Id" }, 523 { "treatment": "Target gene"}, 524 // { "concentration": "Concentration" }, 525 { "perturbagenID": "shRNA ID" }, 526 { "cellline": "Cell Line" }, 527 { "tissue": "Tissue" }, 528 { "time": "Time" } 529 ], 530 "rows": $scope.foundSignatures 531 }; 532 if (concordant&&$scope.foundSignatures.length) { 533 $scope.resourceLib7.header.push({"similarity":"Concordance"}); 534 if ($scope.uploadedSignatures) {$scope.resourceLib7.header.push({"pValue":"pValue"},{"nGenes":"nGenes"})} 535 } 536 } 537 538 } 539 540 function getSigHeader(isENC) { 541 var header=[]; 542 if (isENC) { 543 header = 544 [ 545 { "GeneID": "Gene ID" }, 546 { "GeneNames": "Symbol" }, 547 { "Score":"Score"}, 548 { "Probability": "Probability" } 549 // { "prob": "Probability" } 550 ] 551 } 552 else { 553 // console.log($scope.sigCTRS); 554 // if ($scope.sigCTRS){ 555 // header =[ 556 // { "ID_geneid": "Gene ID" }, 557 // { "signatureID": "Symbol" }, 558 // { "Value_LogDiffExp":"Correlation"} 559 // ] 560 // } else 561 if ($scope.opened.libraryid=='LIB_9'){ 562 header = [ 563 { "probeID": "Probe ID" }, 564 { "ID_geneid": "Gene ID" }, 565 { "signatureID": "Symbol" }, 566 { "Value_LogDiffExp":"Differential Expression"}//, 567 ] 568 } 569 else { 570 header = [ 571 // { "signatureID": "signature ID" }, 572 // { "GeneID": "Gene ID" }, 573 // { "GeneNames": "Symbol" }, 574 // { "coefficients":"Differential Expression"}, 575 // { "Pvals": "P Value" } 576 { "ID_geneid": "Gene ID" }, 577 { "signatureID": "Symbol" }, 578 { "Value_LogDiffExp":"Differential Expression"}//, 579 // { "Significance_pvalue": "P Value" } 580 // { "Diff_Exp":"Differential Expression"}, 581 // { "P_Value": "P Value" } 582 // { "score":"Score"}, 583 // { "prob": "Probability" } 584 ] 585 } 586 // console.log($scope.lib9); 587 // console.log($scope.opened.libraryid); 588 // if (!$scope.lib9) 589 header.push({ "Significance_pvalue": "P Value" }); 590 } 591 return header; 592 } 593 594 function getDownloadSignature(signatures,full,noOfTopGenes,pValue,foldChange,geneList) { 595 // console.log(noOfTopGenes); 596 // console.log(pValue); 597 // console.log(foldChange); 598 // console.log(geneList); 599 // IlincsR 600 // .downloadSignature({sigID: signatures,display:true,noOfTopGenes:noOfTopGenes}) 601 // .$promise 602 // .then(function(results) { 603 // // $scope.signatureData=results.data; 604 // // console.log(results.data); 605 // 606 // // $scope.sigDownShow = true; 607 // $scope.customDownTheme = { 608 // iconUp: 'fa fa-sort-amount-asc pull-right samplesHead', 609 // iconDown: 'fa fa-sort-amount-desc pull-right samplesHead', 610 // listItemsPerPage: [5, 10, 20, 100, 1000], 611 // itemsPerPage: 5, 612 // loadOnInit: true 613 // }; 614 // // var header=[]; 615 // // if ($scope.sigENC) { 616 // // header = 617 // // [ 618 // // { "GeneID": "Gene ID" }, 619 // // { "GeneNames": "Symbol" }, 620 // // { "score":"Score"}, 621 // // { "prob": "Probability" } 622 // // ] 623 // // } 624 // // else { 625 // // header = [ 626 // // // { "signatureID": "signature ID" }, 627 // // { "GeneID": "Gene ID" }, 628 // // { "GeneNames": "Symbol" }, 629 // // { "coefficients":"Differential Expression"}, 630 // // { "Pvals": "P Value" } 631 // // // { "Diff_Exp":"Differential Expression"}, 632 // // // { "P_Value": "P Value" } 633 // // // { "score":"Score"}, 634 // // // { "prob": "Probability" } 635 // // ] 636 // // } 637 // var header=getSigHeader($scope.sigENC); 638 // 639 // 640 // if (!noOfTopGenes){ 641 // $scope.signatureData=results.data.signature; 642 // $scope.signatureFile=results.data.fileName[0]; 643 // // $scope.sessionID=results.data.fileName[0].substring(4,results.data.fileName[0].length-4); 644 // $scope.sessionID=results.data.fileName[0].substring(4,results.data.fileName[0].length); 645 // $scope.sigDownLoad =false; 646 // $scope.dataDownLoading =false; 647 // 648 // 649 // $scope.downloadSigResource = { 650 // "header": header, 651 // "rows": $scope.signatureData 652 // //response.data 653 // // ,"pagination": { 654 // // "page": 2 655 // // } 656 // }; 657 // } else 658 // // if ($state.current.name=="signature") 659 // { 660 // $scope.signatureDataShort = results.data.signature; 661 // $scope.signatureFileShort=results.data.fileName[0]; 662 // $scope.morpheusJson= encodeURIComponent(JSON.stringify({ 663 // // "dataset" :"http://dev.ilincs.org/tmp/"+$scope.signatureFileShort+".gct", //gimm 6 ver 664
664// "dataset" : "http://"+window.location.host+"/tmp/" +$scope.signatureFileShort +".gct", //dev and www ver 665 // // "tools" :[{ name: "Hierarchical Clustering", params: {cluster: "Rows and columns",linkage_method: "Complete"} }], 666 // "colorScheme":{"valueToColorScheme":{"null":{"fractions":[0,0.5,1],"colors":["#0000ff","#000000","#fffe00"],"min":-2,"max":2,"missingColor":"#c0c0c0","scalingMode":1,"stepped":false,"transformValues":0}}}, 667 // "rows" : [ { "field" : "ID_geneid", "display" : ["text"] },{ "field" : "Name_GeneSymbol", "display" : ["text"] }] 668 // })); 669 // // console.log($scope.morpheusJson); 670 // // $scope.sessionIDShort=results.data.fileName[0].substring(4,results.data.fileName[0].length-4); 671 // $scope.sessionIDShort=results.data.fileName[0].substring(4,results.data.fileName[0].length); 672 // // $scope.volcanoGeneList = $scope.signatureDataShort.map(function(a) {return a.GeneID;}); 673 // $scope.volcanoGeneList = $scope.signatureDataShort.map(function(a) {return a.ID_geneid;}); 674 // 675 // $scope.downloadShortSigResource = { 676 // "header": header, 677 // "rows": $scope.signatureDataShort 678 // }; 679 // 680 // // return $scope.volcanoGeneList; 681 // parseGenesForExternal($scope.signatureDataShort); 682 // $scope.generatingSignature=false; 683 // } 684 // 685 // }); 686 687 688 IlincsR.downloadSignature({sigID: signatures,display:true,noOfTopGenes:noOfTopGenes,pValue:pValue,foldChange:foldChange,geneList:geneList}, 689 function(results){ 690 // console.log(results); 691 // console.log(results.data.signature.length); 692 if (results.data.signature[0]!=null) { 693 $scope.customDownTheme = { 694 iconUp: 'fa fa-sort-amount-asc pull-right samplesHead', 695 iconDown: 'fa fa-sort-amount-desc pull-right samplesHead', 696 listItemsPerPage: [5, 10, 20, 100, 1000], 697 itemsPerPage: 5, 698 loadOnInit: true 699 }; 700 var header=getSigHeader($scope.sigENC); 701 702 703 // if (!noOfTopGenes){ 704 if (full){ 705 $scope.signatureData=results.data.signature; 706 $scope.signatureFile=results.data.fileName[0]; 707 // $scope.sessionID=results.data.fileName[0].substring(4,results.data.fileName[0].length-4); 708 $scope.sessionID=results.data.fileName[0].substring(4,results.data.fileName[0].length); 709 $scope.sigDownLoad =false; 710 $scope.dataDownLoading =false; 711 712 713 $scope.downloadSigResource = { 714 "header": header, 715 "rows": $scope.signatureData 716 //response.data 717 // ,"pagination": { 718 // "page": 2 719 // } 720 }; 721 } else 722 // if ($state.current.name=="signature") 723 { 724 $scope.signatureDataShort = results.data.signature; 725 $scope.signatureFileShort=results.data.fileName[0]; 726 $scope.morpheusJson= encodeURIComponent(JSON.stringify({ 727 // "dataset" :"http://dev.ilincs.org/tmp/"+$scope.signatureFileShort+".gct", //gimm 6 ver 728 "dataset" : "http://"+window.location.host+"/tmp/" +$scope.signatureFileShort +".gct", //dev and www ver 729 // "tools" :[{ name: "Hierarchical Clustering", params: {cluster: "Rows and columns",linkage_method: "Complete"} }], 730 "colorScheme":{"valueToColorScheme":{"null":{"fractions":[0,0.5,1],"colors":["#0000ff","#000000","#fffe00"],"min":-2,"max":2,"missingColor":"#c0c0c0","scalingMode":1,"stepped":false,"transformValues":0}}}, 731 "rows" : [ { "field" : "ID_geneid", "display" : ["text"] },{ "field" : "Name_GeneSymbol", "display" : ["text"] }] 732 })); 733 // console.log($scope.morpheusJson); 734 // $scope.sessionIDShort=results.data.fileName[0].substring(4,results.data.fileName[0].length-4); 735 $scope.sessionIDShort=results.data.fileName[0].substring(4,results.data.fileName[0].length); 736 // $scope.volcanoGeneList = $scope.signatureDataShort.map(function(a) {return a.GeneID;}); 737 $scope.volcanoGeneList = $scope.signatureDataShort.map(function(a) {return a.ID_geneid;}); 738 739 $scope.downloadShortSigResource = { 740 "header": header, 741 "rows": $scope.signatureDataShort 742 }; 743 744 // console.log($scope.signatureDataShort); 745 // $scope.maxSelectedPval = Math.max.apply(Math, $scope.signatureDataShort.map(function(v) { return v.Significance_pvalue; })) 746 if ($scope.sigENC) { 747 // console.log($scope.sigENC); 748 $scope.maxSelectedProbability = Math.max.apply(Math, $scope.signatureDataShort.map(function(v) { if (typeof v.Probability == 'number') { return v.Probability} else {return 1} })) 749 $scope.minSelectedScore = Math.max.apply(Math, $scope.signatureDataShort.map(function(v) { if (typeof v.Score == 'number') { return v.Score} else {return 0} })) 750 // console.log($scope.maxSelectedProbability); 751 } else { 752 $scope.maxSelectedPval = Math.max.apply(Math, $scope.signatureDataShort.map(function(v) { if (typeof v.Significance_pvalue == 'number') { return v.Significance_pvalue} else {return 1} })) 753 // console.log($scope.maxSelectedPval); 754 } 755 // return $scope.volcanoGeneList;
756 parseGenesForExternal($scope.signatureDataShort); 757 } 758 } else { 759 // console.log("empty signature"); 760 // $scope.errorResponseDownload= results.data.fileName; 761 // $scope.wrongSignatureData = true; 762 $scope.errorNoSelectedGenes= results.data.fileName[0]; 763 // $scope.downloadShortSigResource = { 764 // // "header": [], 765 // "rows": [] 766 // }; 767 // $scope.downloadShortSigResource.rows=[]; 768 // $scope.errorResponseDownload= results.data.fileName; 769 // console.log(results.data.fileName); 770 } 771 $scope.generatingSignature=false; 772 }, 773 function(errorResponse){ 774 console.log("Signature Data not found."); 775 console.log(errorResponse); 776 $scope.errorResponseDownload= errorResponse.data.error; 777 // $scope.wrongSignature = true; 778 779 $scope.wrongSignatureData = true; 780 $scope.generatingSignature=false; 781 // $location.path('404'); 782 783 }); 784 } 785 786 787 function getDownloadManySignatures(signatures) { 788 IlincsR 789 .downloadSignature({sigID: signatures}) 790 .$promise 791 .then(function(results) { 792 $scope.signaturesData=results.data; 793 $scope.sigDownManyShow = true; 794 $scope.sigDownManyLoad =false; 795 796 $scope.customDownManyTheme = { 797 iconUp: 'fa fa-chevron-circle-up', 798 iconDown: 'fa fa-chevron-circle-down', 799 listItemsPerPage: [10, 20, 50, 100, 1000], 800 itemsPerPage: 10, 801 loadOnInit: true 802 }; 803 804 $scope.downloadManySigResource = { 805 "header": //response.data.header, 806 [ 807 { "signatureID": "signature ID" }, 808 { "GeneID": "gene ID" }, 809 { "GeneNames": "Symbol" }, 810 { "coefficients":"Differential Expression"}, 811 { "Pvals": "P Value" } 812 // { "Diff_Exp":"Differential Expression"}, 813 // { "P_Value": "P Value" } 814 ], 815 "rows": $scope.signaturesData 816 }; 817 818 }); 819 } 820 821 function getDownloadManySignaturesFilename(signatures) { 822 // console.log(signatures); 823 IlincsR 824 .downloadSignature({sigID: signatures,display:false}) 825 .$promise 826 .then(function(results) { 827 //$scope.signaturesData=results.data; 828 // return results.data.fileName; 829 $scope.dataDownLoadingSigs = false; 830 console.log(results); 831 console.log('/tmp/'+results.data); 832 $window.location.href = '/tmp/'+results.data+'.xls'; 833 834 }); 835 } 836 837 function getGroupAnalysis(sigs,noOfGenes,file) { 838 $scope.sigsToGroupAnalysis=sigs; 839 // console.log(file); 840 // $scope.libToGroupAnalysis=lib; 841 // console.log(noOfGenes); 842 // debugger; 843 IlincsR 844 // .GroupLincsAnalysis({idList: sigs,libName: lib}) 845 .GroupLincsAnalysis({idList: sigs,noOfGenes: noOfGenes,sigFile:file}) 846 .$promise 847 .then(function(results) { 848 $scope.groupAnalysisResults = results.data; 849 850 // console.log(results.data); 851 $scope.morpheusJson= encodeURIComponent(JSON.stringify({ 852 // "dataset" :"http://dev.ilincs.org/tmp/filteredeset_"+results.data[1] +".gct", //gimm 6 ver 853 "dataset" : "http://"+window.location.host+"/tmp/filteredeset_" +results.data[1] +".gct", //dev and www ver 854 // "tools" :[{ "name": "Hierarchical Clustering", "params": {"cluster": "Rows and columns"} }], 855 // "colorScheme":{"valueToColorScheme":{"null":{"fractions":[0,0.5,1],"colors":["#0000ff","#000000","#fffe00"],"missingColor":"#c0c0c0","scalingMode":0,"stepped":false,"transformValues":0}}}, 856 "tools" :[{ name: "Hierarchical Clustering", params: {cluster: "Rows and columns",linkage_method: "Complete"} }], 857 "colorScheme":{"valueToColorScheme":{"null":{"fractions":[0,0.5,1],"colors":["#0000ff","#000000","#fffe00"],"min":-2,"max":2,"missingColor":"#c0c0c0","scalingMode":1,"stepped":false,"transformValues":0}}}, 858 // "columns" : [ { "field" : "id", "display" : ["text"] },{ "field" : $scope.resultRecord.group, "display" : ["color"] } ], 859 "rows" : [ { "field" : "ID_geneid", "display" : ["text"] },{ "field" : "Name_GeneSymbol", "display" : ["text"] }] 860 })); 861 $scope.morpheusJsonProteinTarget= encodeURIComponent(JSON.stringify({ 862 // "dataset" :"http://dev.ilincs.org/tmp/"+results.data[1] +"_ProteinTargets.gct", //gimm 6 ver 863 "dataset" : "http://"+window.location.host+"/tmp/" +results.data[1] +"_ProteinTargets.gct", //dev and www ver 864 // "tools" :[{ "name": "Hierarchical Clustering", "params": {"cluster": "Rows and columns"} }], 865 "tools" :[{ name: "Hierarchical Clustering", params: {cluster: "Rows and columns",linkage_method: "Complete"} }], 866 // "colorScheme":{"valueToColorScheme":{"null":{"fractions":[0,0.5,1],"colors":["#0000ff","#000000","#fffe00"],"missingColor":"#c0c0c0","scalingMode":0,"stepped":false,"transformValues":0}}}, 867 "colorScheme":{"valueToColorScheme":{"null":{"fractions":[0,0.5,1],"colors":["#0000ff","#000000","#fffe00"],"min":-2,"max":2,"missingColor":"#c0c0c0","scalingMode":1,"stepped":false,"transformValues":0}}}, 868 // "columns" : [ { "field" : "id", "display" : ["text"] },{ "field" : $scope.resultRecord.group, "display" : ["color"] } ], 869 "rows" : [ { "field" : "signatureID", "display" : ["text"] }] 870 })); 871 // console.log(results.data[0]); 872 var status = results.data[0].includes("Done"); 873 // console.log(status); 874 // if (results.data[0]!="Done"&&results.data[0]!="All signatures found - Done"&&results.data[0]!="Some signatures not found - Done") { 875 if (!status) {
876 $scope.analyzeError = true; 877 // console.log(results); 878 $scope.analysisStatus = results.data; 879 } else { 880 $scope.analysisStatus=results.data[0] 881 } 882 $scope.analyzeLoading = false; 883 }); 884 885 // IlincsR.GroupLincsAnalysis({idList: sigs,noOfGenes: noOfGenes,sigFile:file}, 886 // function(results){ 887 // $scope.groupAnalysisResults = results.data; 888 // 889 // // console.log(results.data); 890 // $scope.morpheusJson= encodeURIComponent(JSON.stringify({ 891 // // "dataset" :"http://dev.ilincs.org/tmp/filteredeset_"+results.data[1] +".gct", //gimm 6 ver 892 // "dataset" : "http://"+window.location.host+"/tmp/filteredeset_" +results.data[1] +".gct", //dev and www ver 893 // // "tools" :[{ "name": "Hierarchical Clustering", "params": {"cluster": "Rows and columns"} }], 894 // // "colorScheme":{"valueToColorScheme":{"null":{"fractions":[0,0.5,1],"colors":["#0000ff","#000000","#fffe00"],"missingColor":"#c0c0c0","scalingMode":0,"stepped":false,"transformValues":0}}}, 895 // "tools" :[{ name: "Hierarchical Clustering", params: {cluster: "Rows and columns",linkage_method: "Complete"} }], 896 // "colorScheme":{"valueToColorScheme":{"null":{"fractions":[0,0.5,1],"colors":["#0000ff","#000000","#fffe00"],"min":-2,"max":2,"missingColor":"#c0c0c0","scalingMode":1,"stepped":false,"transformValues":0}}}, 897 // // "columns" : [ { "field" : "id", "display" : ["text"] },{ "field" : $scope.resultRecord.group, "display" : ["color"] } ], 898 // "rows" : [ { "field" : "ID_geneid", "display" : ["text"] },{ "field" : "Name_GeneSymbol", "display" : ["text"] }] 899 // })); 900 // // console.log(results.data[0]); 901 // var status = results.data[0].includes("Done"); 902 // // console.log(status); 903 // // if (results.data[0]!="Done"&&results.data[0]!="All signatures found - Done"&&results.data[0]!="Some signatures not found - Done") { 904 // 905 // // $scope.analysisStatus=results.data[0] 906 // $scope.analysisStatus="Done"; 907 // 908 // $scope.analyzeLoading = false; 909 // }, 910 // function(errorResponse){ 911 // console.log(errorResponse); 912 // // console.log("Signature list not found."); 913 // // console.log(errorResponse); 914 // // $scope.wrongSignature = true; 915 // // // $location.path('404'); 916 // $scope.analyzeError = true; 917 // // $scope.analysisStatus=results.data[0]; 918 // $scope.analysisStatus=results.data.error.message; 919 // $scope.analyzeLoading = false; 920 // 921 // }); 922 } 923 924 function getGroupAnalysisWithGenes(sigs,lib,genes) { 925 $scope.sigsToGroupAnalysis=sigs; 926 $scope.libToGroupAnalysis=lib; 927 IlincsR 928 .GroupLincsAnalysis({idList: sigs,libName: lib,geneList: genes}) 929 .$promise 930 .then(function(results) { 931 // console.log(results.data); 932 $scope.groupAnalysisResults = results.data; 933 $scope.morpheusJson= encodeURIComponent(JSON.stringify({ 934 // "dataset" :"http://dev.ilincs.org/tmp/filteredeset_"+results.data[1] +".gct", //gimm 6 ver 935 "dataset" : "http://"+window.location.host+"/tmp/filteredeset_" +results.data[1] +".gct", //dev and www ver 936 // "tools" :[{ "name": "Hierarchical Clustering", "params": {"cluster": "Rows and columns"} }], 937 "tools" :[{ name: "Hierarchical Clustering", params: {cluster: "Rows and columns",linkage_method: "Complete"} }], 938 // "colorScheme":{"valueToColorScheme":{"null":{"fractions":[0,0.5,1],"colors":["#0000ff","#000000","#fffe00"],"missingColor":"#c0c0c0","scalingMode":0,"stepped":false,"transformValues":0}}}, 939 "colorScheme":{"valueToColorScheme":{"null":{"fractions":[0,0.5,1],"colors":["#0000ff","#000000","#fffe00"],"min":-2,"max":2,"missingColor":"#c0c0c0","scalingMode":1,"stepped":false,"transformValues":0}}}, 940 // "columns" : [ { "field" : "id", "display" : ["text"] },{ "field" : $scope.resultRecord.group, "display" : ["color"] } ], 941 "rows" : [ { "field" : "ID_geneid", "display" : ["text"] },{ "field" : "Name_GeneSymbol", "display" : ["text"] }] 942 })); 943 $scope.morpheusJsonProteinTarget= encodeURIComponent(JSON.stringify({ 944 // "dataset" :"http://dev.ilincs.org/tmp/"+results.data[1] +"_ProteinTargets.gct", //gimm 6 ver 945 "dataset" : "http://"+window.location.host+"/tmp/" +results.data[1] +"_ProteinTargets.gct", //dev and www ver 946 // "tools" :[{ "name": "Hierarchical Clustering", "params": {"cluster": "Rows and columns"} }], 947 "tools" :[{ name: "Hierarchical Clustering", params: {cluster: "Rows and columns",linkage_method: "Complete"} }], 948 // "colorScheme":{"valueToColorScheme":{"null":{"fractions":[0,0.5,1],"colors":["#0000ff","#000000","#fffe00"],"missingColor":"#c0c0c0","scalingMode":0,"stepped":false,"transformValues":0}}}, 949 "colorScheme":{"valueToColorScheme":{"null":{"fractions":[0,0.5,1],"colors":["#0000ff","#000000","#fffe00"],"min":-2,"max":2,"missingColor":"#c0c0c0","scalingMode":1,"stepped":false,"transformValues":0}}}, 950 // "columns" : [ { "field" : "id", "display" : ["text"] },{ "field" : $scope.resultRecord.group, "display" : ["color"] } ], 951 "rows" : [ { "field" : "signatureID", "display" : ["text"] }] 952 })); 953 // console.log(results.data[0]); 954 var status = results.data[0].includes("Done"); 955 if (!status) { 956 // if (results.data[0]!="Done"&&results.data[0]!="All signatures found - Done"&&results.data[0]!="Some signatures not found - Done") {
957 $scope.analyzeError = true; 958 } else { 959 $scope.analysisStatus=results.data[0] 960 } 961 962 $scope.analyzeLoading = false; 963 964 }) 965 } 966 967 function getGroupAnalysisWithGenesError() { 968 console.log("Signature list error."); 969 $scope.groupAnalysisResults= true; 970 $scope.analyzeError = true; 971 $scope.analyzeLoading = false; 972 } 973 974 function getConcordantTo(signature) { 975 Concordancelib6 976 .ConcordantSignatures({sigId: signature}) 977 .$promise 978 .then(function(data) { 979 $scope.concordantSignatures = data.result; 980 }); 981 } 982 983 984 function getSearchTerm(item) { 985 SearchTerm 986 .findOne({filter:{where:{id:item}}}) 987 .$promise 988 .then(function(results) { 989 // $scope.list = results.content.split(','); 990 // $scope.searchTerm; 991 // console.log($scope.list); 992 // getGeneinfo(); 993 // console.log("Signature Term"); 994 // console.log(results.content); 995 $scope.searchTerm=results.content; 996 searchSignatures($scope.searchTerm,false); 997 }); 998 } 999 1000 1001 //gene list for multigroupanalisys/////////////////////////////////////////////////////////////////////////////////////// 1002 function getGeneList() { 1003 // console.log($state.params); 1004 GeneList 1005 .findOne({filter:{where:{id:$state.params.geneListNum}}}) 1006 // .find({ filter:{where:{and:[{lincsDsgc:{neq:"NA"}},{lincsDsgc:{neq:null}}]}}}) 1007 // {"limit":10,"where":{"and":[{"lincsDsgc":{"neq":"NA"}},{"lincsDsgc":{"neq":null}}]}} //explorer 1008 // {"limit":10,"where":{"or":[{"lincsDsgc":{"neq":null}}]} 1009 //.find({ filter:{limit: 5}}) 1010 // Platforms 1011 // .inPortal({platform: "LINCS"}) 1012 .$promise 1013 .then(function(data) { 1014 // console.log("GeneList Data"); 1015 // console.log(data); 1016 $scope.geneList = data.content; 1017 // $scope.datasets = data.result; 1018 // creatEsetWithInfo($scope.geneListData.content); 1019 return $scope.geneList; 1020 }); 1021 1022 1023 } 1024 1025 function getGeneListCb(geneListId,success,error) { 1026 GeneList.findOne({filter:{where:{id:geneListId}}}, 1027 function(data){ 1028 // console.log(data); 1029 success(data.content); 1030 },function(errorResponse){ 1031 console.log(errorResponse); 1032 }); 1033 } 1034 1035 1036 function getSignatureList(id) { 1037 // SignatureList 1038 // .findOne({filter:{where:{id:id}}}) 1039 // .$promise 1040 // .then(function(data) { 1041 // console.log(data); 1042 // $scope.sigList = data.content; 1043 // }); 1044 // $scope.signatureList = 1045 SignatureList.findOne({filter:{where:{id:id}}}, 1046 function(data){$scope.sigList = data.content; 1047 $scope.currentLib = data.lib}, 1048 function(errorResponse){console.log("Signature list not found."),console.log(errorResponse)}); 1049 // // console.log($scope.signatureList); 1050 // // console.log($scope.sigList); 1051 return $scope.sigList; 1052 1053 }; 1054 1055 1056 function getAnalyzeUploadedSignature(lib,file,path) { 1057 // console.info("lib",lib); 1058 // console.info("file",file); 1059 // console.info("path",path); 1060 IlincsR.AnalyzeUploadedSignature({lib:lib,file:file,path:path}, 1061 // console.info("data",data); 1062 function(data){ 1063 1064 // $scope.currentLib = data.lib 1065 1066 // formatDataTable(check); 1067 // formatDataTableForLib("LIB_5"); 1068 // if (data==[]){ 1069 // // if (data.data[0].signatureid=="NA"&&data.data[0].similarity=="NA") { 1070 // $scope.foundSignatures=[] 1071 // } else { 1072 // // console.log(data.data); 1073 // // $scope.foundSignatures = data.data; 1074 // // console.log(data); 1075 // $scope.foundSignatures = data; 1076 // } 1077 $scope.remark=data.remark; 1078 $scope.foundSignatures=data.data; 1079 $scope.dataLoading = false;
1080 formatDataTableForLib(lib,true); 1081 }, 1082 function(errorResponse){ 1083 console.log("Wrong library or File."); 1084 console.log(errorResponse); 1085 $scope.dataLoading = false; 1086 $scope.wrongFile = true; 1087 // $scope.foundSignatures = []; 1088 // console.log(errorResponse) 1089 }); 1090 // // console.log($scope.signatureList); 1091 // // console.log($scope.sigList); 1092 // return $scope.sigList; 1093 1094 }; 1095 1096 function getSignatureListAndAnalyze(id) { 1097 // console.log($scope.geneList); 1098 1099 getGeneList(); 1100 // console.log(genes); 1101 SignatureList.findOne({filter:{where:{id:id}}}, 1102 function(data){$scope.sigList = data.content; 1103 $scope.currentLib = data.lib; 1104 // getGeneList(); 1105 // console.log($scope.geneList); 1106 // console.log(data.content); 1107 // getGroupAnalysisWithGenes(data.content,data.lib,$scope.geneList); 1108 if ($scope.geneList) { 1109 getGroupAnalysisWithGenes(data.content,data.lib,$scope.geneList); 1110 } else { 1111 setTimeout(function() { 1112 // console.log($scope.geneList); 1113 getGroupAnalysisWithGenes(data.content,data.lib,$scope.geneList); 1114 }, 1000); 1115 } 1116 1117 // getGroupAnalysisWithGenes("LINCSCP_1,LINCSCP_100,LINCSCP_13825","LIB_5",$scope.geneList) 1118 }, 1119 function(errorResponse){ 1120 console.log("Signature list not found."); 1121 console.log(errorResponse); 1122 getGroupAnalysisWithGenesError(); 1123 }); 1124 1125 1126 1127 }; 1128 1129 1130 1131 1132 1133 function goGroupAnalyze(id,noOfGenes,file) { 1134 // console.log($scope.geneList); 1135 1136 // getGeneList(); 1137 // console.log(genes); 1138 SignatureList.findOne({filter:{where:{id:id}}}, 1139 function(data){$scope.sigList = data.content; 1140 $scope.currentLib = data.lib; 1141 // getGeneList(); 1142 // console.log($scope.geneList); 1143 // console.log(data.content); 1144 // getGroupAnalysisWithGenes(data.content,data.lib,$scope.geneList); 1145 getGroupAnalysis(data.content,noOfGenes,file); 1146 1147 // getGroupAnalysisWithGenes("LINCSCP_1,LINCSCP_100,LINCSCP_13825","LIB_5",$scope.geneList) 1148 }, 1149 function(errorResponse){console.log("Signature list not found."),console.log(errorResponse)}); 1150 1151 1152 }; 1153 1154 1155 function getSignaturesByPharmAction(action) { 1156 1157 // $scope.pharmActionTerm 1158 // console.log(term); 1159 SignatureMeta.findByPharmAction({term:action}, 1160 function(data){ 1161 // $scope.signaturesWithPharmAction = data; 1162 $scope.foundSignatures = data; 1163 $scope.dataLoading = false; 1164 // formatDataTable(check); 1165 formatDataTableForLib("LIB_5"); 1166 }, 1167 function(errorResponse){console.log("pharm Actions not found."),console.log(errorResponse)}); 1168 1169 1170 }; 1171 1172 function getSignaturesByKnownTargetAction(action) { 1173 1174 // $scope.pharmActionTerm 1175 // console.log(term); 1176 SignatureMeta.findByKnownTargetAction({term:action}, 1177 function(data){ 1178 // $scope.signaturesWithPharmAction = data; 1179 $scope.foundSignatures = data; 1180 $scope.dataLoading = false; 1181 // formatDataTable(check); 1182 formatDataTableForLib("LIB_5"); 1183 }, 1184 function(errorResponse){console.log("pharm Actions not found."),console.log(errorResponse)}); 1185 1186 1187 }; 1188 1189 1190 function getSignaturesByMoaAction(action) { 1191 1192 // $scope.pharmActionTerm 1193 // console.log(term); 1194 SignatureMeta.findByMoaAction({term:action}, 1195 function(data){ 1196 // $scope.signaturesWithPharmAction = data; 1197 $scope.foundSignatures = data; 1198 $scope.dataLoading = false;
1199 // formatDataTable(check); 1200 formatDataTableForLib("LIB_5"); 1201 }, 1202 function(errorResponse){console.log("pharm Actions not found."),console.log(errorResponse)}); 1203 1204 1205 }; 1206 1207 1208 function downloadVolcanoData(fileName) { 1209 // console.log("going for the file"); 1210 Container.download({container:"volcano",file:fileName}, 1211 function(data){ 1212 var csvFile = data; 1213 var csvString =""; 1214 // console.info("type of csvFile",typeof csvFile); 1215 // console.info("csvFile",csvFile); 1216 // console.info("csvFile stringied",JSON.stringify(csvFile)); 1217 // console.info("csvFile stringied",csvFile.toString()); 1218 angular.forEach(csvFile, function(value,key) { 1219 // console.info("key",key); 1220 if (key!="$promise"&&key!="$resolve"){ 1221 csvString=csvString+value; 1222 } 1223 }) 1224 csvString = csvString.substring(0, csvString.length - 5); //removing true from the end which come from last enter 1225 // console.info("csvString",csvString); 1226 // console.info("csvFile to JSON",csvJSON(JSON.stringify(csvFile))); 1227 1228 // console.info("csvFile to JSON",csvJSON(csvString)); 1229 // csvJSON(csvString) 1230 // console.info("type of csvJSON(csvString)",typeof csvJSON(csvString)); 1231 // $scope.volcanoGeneList=JSON.stringify((eval("(" + csvJSON(csvString) + ")"))); 1232 if ($state.current.name=="signature"){ 1233 1234 $scope.signatureDataShort=JSON.parse(csvJSON(csvString)); 1235 // console.log($scope.signatureDataShort); 1236 // $scope.volcanoGeneList = $scope.signatureDataShort.map(function(a) {return a.GeneID;}); 1237 $scope.volcanoGeneList = $scope.signatureDataShort.map(function(a) {return a.ID_geneid;}); 1238 // console.log($scope.volcanoGeneList); 1239 // $scope.sessionIDShort=results.data.fileName[0].substring(4,results.data.fileName[0].length-4); 1240 $scope.sessionIDShort=fileName; 1241 parseGenesForExternal($scope.signatureDataShort); 1242 1243 $scope.downloadShortSigResource = { 1244 "header": getSigHeader($scope.sigENC), 1245 "rows": $scope.signatureDataShort 1246 1247 }; 1248 1249 } else { 1250 $scope.volcanoGeneData=JSON.parse(csvJSON(csvString)); 1251 // console.info("type of $scope.volcanoGeneList",typeof $scope.volcanoGeneData); 1252 $scope.volcanoGeneList = $scope.volcanoGeneData.map(function(a) {return a.GeneID;}); 1253 // return $scope.volcanoGeneList; 1254 parseGenesForExternal($scope.volcanoGeneData); 1255 // $scope.dataLoading=true; 1256 // getEnrichedSignatures($scope.volcanoGeneList); 1257 } 1258 $scope.generatingSignature=false; 1259 }, 1260 function(errorResponse){console.log("File not found or wrong format."),console.log(errorResponse)}); 1261 // // console.log($scope.signatureList); 1262 // // console.log($scope.sigList); 1263 1264 1265 }; 1266
1267 function parseGenesForExternal(genes){ 1268 var GenesEnrichr=""; 1269 var GenesJava=""; 1270 var GeneIds=""; 1271 var ExpressionReactome=""; 1272 var GeneMANIA=""; 1273 var GeneString=""; 1274 var piNETsignature=""; 1275 var UpGenes=[]; 1276 var DownGenes=[]; 1277 angular.forEach(genes, function(gene) { 1278 // console.info("key",key); 1279 // console.info("genedata",gene); 1280 if (GenesJava!=""){ 1281 GenesJava=GenesJava+"DELIM"; 1282 } 1283 // GenesJava=GenesJava+gene.GeneID; //to be changed to symbol 1284 GenesJava=GenesJava+gene.ID_geneid; //to be changed to symbol 1285 1286 if (GeneIds!=""){ 1287 GeneIds=GeneIds+","; 1288 } 1289 GeneIds=GeneIds+gene.ID_geneid; 1290 1291 if (GenesEnrichr!=""){ 1292 GenesEnrichr=GenesEnrichr+"\n"; 1293 } 1294 // GenesEnrichr=GenesEnrichr+gene.GeneNames; 1295 GenesEnrichr=GenesEnrichr+gene.Name_GeneSymbol; 1296 1297 if (ExpressionReactome!=""){ 1298 ExpressionReactome=ExpressionReactome+"\n"; 1299 } else {ExpressionReactome="#Genes\t#DiffExp\n"; } 1300 ExpressionReactome=ExpressionReactome+gene.Name_GeneSymbol+"\t"+gene.Value_LogDiffExp; //gene.GeneID for gene id shows CheBI but 0 in ENSEMBL 1301 1302 if (piNETsignature!=""){ 1303 piNETsignature=piNETsignature+","; 1304 } 1305 piNETsignature=piNETsignature+gene.Name_GeneSymbol+" "+gene.Value_LogDiffExp; //gene.GeneID for gene id shows CheBI but 0 in ENSEMBL 1306 1307 if (GeneString!=""){ 1308 GeneString=GeneString+","; 1309 } 1310 GeneString=GeneString+gene.Name_GeneSymbol; 1311 1312 if (GeneMANIA!=""){ 1313 GeneMANIA=GeneMANIA+"|"; 1314 } 1315 GeneMANIA=GeneMANIA+gene.Name_GeneSymbol; 1316 1317 if (gene.Value_LogDiffExp>0) { 1318 UpGenes.push(gene.Name_GeneSymbol); //to be changed to symbol 1319 } else { 1320 DownGenes.push(gene.Name_GeneSymbol) //to be changed to symbol 1321 } 1322 1323 }) 1324 // console.info("GenesEnrichr",GenesEnrichr); 1325 $scope.volcanoGeneListEnrichr=GenesEnrichr; 1326 $scope.GeneListJava=GenesJava; 1327 $scope.GeneListIDs=GeneIds; 1328 $scope.expressionReactome=ExpressionReactome; 1329 $scope.piNETsignature=piNETsignature; 1330 $scope.GeneMANIA=GeneMANIA; 1331 $scope.GeneString=GeneString; 1332 $scope.volcanoUpGenes=UpGenes; 1333 $scope.volcanoDownGenes=DownGenes; 1334 } 1335 1336 1337 1338 1339 1340 //var csv is the CSV file with headers 1341 function csvJSON(csv){ 1342 1343 var lines=csv.split("\n"); 1344 1345 var result = []; 1346 1347 var headers=lines[0].split("\t"); 1348 1349 for(var i=1;i<lines.length;i++){ 1350 1351 var obj = {}; 1352 var currentline=lines[i].split("\t"); 1353 1354 // if (currentline.length>1){ 1355 for(var j=0;j<headers.length;j++){ 1356 obj[headers[j]] = currentline[j]; 1357 } 1358 // } 1359 1360 result.push(obj); 1361 1362 } 1363 1364 //return result; //JavaScript object 1365 return JSON.stringify(result); //JSON 1366 } 1367 1368 1369 function onSuccessUpload(sessionID){ 1370 // console.log("running success callback"); 1371 // console.log(signatures.uploaded); 1372 // console.log(signatures.uploaded[sessionID]); 1373 // console.log(signatures.uploaded[sessionID].Remark); 1374 // console.log($scope.uploadedFileName); 1375 if (signatures.uploaded[sessionID].Remark=="Done"){ 1376 // $state.transitionTo('uploadedSignature',{file:signatures.uploaded[sessionID].fileName[0],libs:'LIB_2'}); 1377 // localStorage.setObj('uploadedSignature', signatures.uploaded); 1378 // $state.transitionTo('uploadedSignature',{file:signatures.uploaded[sessionID].sessionID,libs:'LIB_2'}); 1379 // console.log($scope.uploadRecordId); 1380 if ($scope.uploadRecordId) { 1381 // SignatureUpload.create({fileName:signatures.uploaded[sessionID].orgFileName,sessionId:signatures.uploaded[sessionID].sessionID,entries:signatures.uploaded[sessionID].entries,genesFound:signatures.uploaded[sessionID].foundGenes,pValue:signatures.uploaded[sessionID].Pval}, 1382 // SignatureUpload.prototype$updateAttributes //loopback2 1383 SignatureUpload.updateAttributes({ id: $scope.uploadRecordId},{fileName:signatures.uploaded[sessionID].orgFileName,sessionId:signatures.uploaded[sessionID].sessionID,entries:signatures.uploaded[sessionID].entries,genesFound:signatures.uploaded[sessionID].foundGenes,pValue:signatures.uploaded[sessionID].Pval}, 1384 function(data){ 1385 // console.log(data); 1386 historyFactory.saveResultInSessionHistory('signatureUploadHistory',data.id); 1387 // $state.transitionTo('uploadedSignature',{file:data.id}); 1388 if ($state.params.source) $state.transitionTo('uploadedSignature',{file:data.id,source:$state.params.source}); 1389 else $state.transitionTo('uploadedSignature',{file:data.id}); 1390 }, 1391 function(errorResponse){ 1392 console.log("Creating Uploaded Signatures record in database Failed."),console.log(errorResponse) 1393 $scope.wrongFile=true; 1394 $scope.errorMessage=errorResponse; 1395 }); 1396 } else { 1397 var newRecord; 1398 // $state.params.source=="GRSN" 1399 if ($state.params.source) newRecord = {fileName:signatures.uploaded[sessionID].orgFileName,sessionId:signatures.uploaded[sessionID].sessionID,entries:signatures.uploaded[sessionID].entries,genesFound:signatures.uploaded[sessionID].foundGenes,pValue:signatures.uploaded[sessionID].Pval,source:$state.params.source} 1400 else newRecord = {fileName:signatures.uploaded[sessionID].orgFileName,sessionId:signatures.uploaded[sessionID].sessionID,entries:signatures.uploaded[sessionID].entries,genesFound:signatures.uploaded[sessionID].foundGenes,pValue:signatures.uploaded[sessionID].Pval}; 1401 SignatureUpload.create(newRecord, 1402 // SignatureUpload.prototype$updateAttributes({ id: $scope.uploadRecordId},{fileName:signatures.uploaded[sessionID].orgFileName,sessionId:signatures.uploaded[sessionID].sessionID,entries:signatures.uploaded[sessionID].entries,genesFound:signatures.uploaded[sessionID].foundGenes,pValue:signatures.uploaded[sessionID].Pval}, 1403 function(data){ 1404 console.log(data); 1405 historyFactory.saveResultInSessionHistory('signatureUploadHistory',data.id); 1406 if ($state.params.source) $state.transitionTo('uploadedSignature',{file:data.id,source:$state.params.source}); 1407 else $state.transitionTo('uploadedSignature',{file:data.id}); 1408 }, 1409 function(errorResponse){ 1410 console.log("Creating Uploaded Signatures record in database Failed."),console.log(errorResponse) 1411 $scope.wrongFile=true; 1412 $scope.errorMessage=errorResponse; 1413 }); 1414 } 1415 // // SignatureUpload.create({fileName:signatures.uploaded[sessionID].orgFileName,sessionId:signatures.uploaded[sessionID].sessionID,entries:signatures.uploaded[sessionID].entries,genesFound:signatures.uploaded[sessionID].foundGenes,pValue:signatures.uploaded[sessionID].Pval}, 1416 // SignatureUpload.prototype$updateAttributes({ id: $scope.uploadRecordId},{fileName:signatures.uploaded[sessionID].orgFileName,sessionId:signatures.uploaded[sessionID].sessionID,entries:signatures.uploaded[sessionID].entries,genesFound:signatures.uploaded[sessionID].foundGenes,pValue:signatures.uploaded[sessionID].Pval}, 1417 // function(data){ 1418 // // console.log(data); 1419 // historyFactory.saveResultInSessionHistory('signatureUploadHistory',data.id); 1420 // // $state.transitionTo('uploadedSignature',{file:data.id}); 1421 // }, 1422 // function(errorResponse){ 1423 // console.log("Creating Uploaded Signatures record in database Failed."),console.log(errorResponse) 1424 // $scope.wrongFile=true; 1425 // $scope.errorMessage=errorResponse; 1426 // }); 1427 // 1428 // $state.transitionTo('uploadedSignature',{file:signatures.uploaded[sessionID].sessionID}); 1429 } else { 1430 $scope.wrongFile=true; 1431 $scope.errorMessage=signatures.uploaded[sessionID].Remark; 1432 } 1433 // // console.log(signatures.results.data.current[$scope.library]); 1434 // //onSuccess 1435 // $scope.resolved=$scope.dataReady.status; 1436 // $scope.resource=signatures.results.data.current[$scope.library]; 1437 // // $scope.customTheme=$scope.resource.customTheme; 1438 // $scope.filterBy=signatures.results.data.current[$scope.library].filterBy; 1439 // $scope.filterSig=signatures.results.data.current[$scope.library].filterSig; 1440 // $scope.opened=false; 1441 // $scope.resolved=signatures.results.dataReady[$scope.library].status; 1442 // $scope.dataReady=signatures.results.dataReady[$scope.library]; 1443 // // 1444 // // console.log("no of rows",scope.resource.rows.length); 1445 // // console.info("no of rows",scope.resource.rows.length); 1446 // // // scope.rows=scope.resource.rows.length; 1447 // // console.info("no of rows",scope.rows); 1448 } 1449 1450 function onErrorUpload(err){ 1451 //onError 1452 console.log("Error from callback: ",err); 1453 $scope.wrongFile=true; 1454 $scope.errorMessage=err; 1455 $scope.preprocessingFile=false; 1456 // $scope.resource={rows:[],opened:true}; 1457 // // console.log("rows length: ",$scope.resource.rows.length); 1458 // // $scope.resource.rows.length=0; 1459 // // $scope.resource.opened=true; 1460 // $scope.resolved=true; 1461 // // console.log("resolved: ",$scope.resolved); 1462 // $scope.opened=true; 1463 } 1464 1465 function getPharmActionSig(sig){ 1466 //console.log(sig); 1467 //cosnole.log("in getPharmActionSig"); 1468 1469 PharmAction
1470 .find({filter:{where:{and:[{lincspertid:sig.lincspertid},{perturbagenid:sig.perturbagenID}]}}}) 1471 .$promise 1472 .then(function(data) { 1473 console.log(data); 1474 // console.log(data.length); 1475 $scope.pharmActions = data; 1476 // $scope.pharmActionsStr = data.join(", "); 1477 $scope.pharmActionsStr=data.map(function(a) {return a.pharmaction;}).join(", "); 1478 // $scope.pharmActionsNumber = data; 1479 }); 1480 1481 }; 1482 1483 // function getPharmActions(term) { 1484 $scope.getPharmActions = function(term){ 1485 1486 1487 1488 PharmAction.findTerm({term:term}, 1489 function(data){$scope.pharmActions = data; 1490 //console.log(data); 1491 }, 1492 function(errorResponse){console.log("pharm Actions not found."),console.log(errorResponse)}); 1493 1494 1495 }; 1496 1497 $scope.getGeneTargets = function(term){ 1498 // $scope.pharmActionTerm 1499 //console.log(term); 1500 // console.log("---------"); 1501 1502 if(term){ 1503 //{filter:{where:{and:[{symbol:{"inq":parsedGenes.split(",")}},{taxid:9606}]},fields:["geneid"]}} 1504 //term = term.replace(/["]/gi, ''); 1505 // sql= 'SELECT DISTINCT pharmaction FROM `pertIDToPharmAction` Where pharmaction LIKE "%'+term+'%"' 1506 //var pattern = new RegExp('.*'+term+'.*', "i"); /* case-insensitive RegExp search */ 1507 //Post.find({ where: {title: { like: pattern} } }, 1508// where : { 1509// name: { 1510// like: search_string, 1511// options: "i" 1512// } 1513// }; 1514 //CompoundMOA.find({filter:{where:{"geneTargets":{"regexp":term,options:"i"}}}}, 1515// filter.where = { 1516// name: { 1517// ilike: '%'+ search_string +'%' 1518// } 1519// }; 1520 CompoundMOA.find({filter:{where:{"geneTargets":{like: '%' +term+'%' , options: "i" }}}}, 1521 function(data){ 1522 $scope.cpTarget = data; 1523 console.log(data); 1524 }, 1525 function(errorResponse){console.log("Targets not found."),console.log(errorResponse)}); 1526 1527 } 1528 else{ 1529 CompoundMOA.find({term:term}, 1530 function(data){ 1531 $scope.cpTarget = data; 1532 //console.log(data); 1533 }, 1534 function(errorResponse){console.log("Targets not found."),console.log(errorResponse)}); 1535 } 1536 1537 1538 }; 1539 1540 1541 $scope.getMOAs = function(term){ 1542 // $scope.pharmActionTerm 1543 //console.log(term); 1544 // console.log("---------"); 1545 if(term){ 1546 //{filter:{where:{and:[{symbol:{"inq":parsedGenes.split(",")}},{taxid:9606}]},fields:["geneid"]}} 1547 1548 CompoundMOA.find({filter:{where:{"mechanismOfAction":{like: '%' +term+'%' , options: "i" }}}}, 1549 function(data){ 1550 $scope.cpMOA = data; 1551 console.log(data); 1552 }, 1553 function(errorResponse){console.log("MOA not found."),console.log(errorResponse)}); 1554 1555 } 1556 else{ 1557 CompoundMOA.find({term:term}, 1558 function(data){ 1559 $scope.cpMOA = data; 1560 //console.log(data); 1561 }, 1562 function(errorResponse){console.log("MOA not found."),console.log(errorResponse)}); 1563 1564 } 1565 1566 1567 1568 1569 1570 1571 }; 1572 1573 $scope.changePharmActionTerm = function(term){ 1574 $scope.pharmActionTerm=term; 1575 $scope.getPharmActions(term); 1576 } 1577 1578 $scope.changeKnownTargetActionTerm = function(term){ 1579 $scope.knownTargetActionTerm=term; 1580 $scope.getGeneTargets(term); 1581 } 1582 1583 $scope.changeMoaActionTerm = function(term){ 1584 $scope.moaActionTerm=term; 1585 $scope.getMOAs(term); 1586 } 1587 1588 $scope.choosePharmAction = function(action){ 1589 $scope.activePharmAction=action; 1590 getSignaturesByPharmAction(action); 1591 // $scope.getPharmActions(term); 1592 } 1593 1594 $scope.choosePharmActionNew = function(action){ 1595 $scope.activePharmAction=action; 1596 //console.log($scope.activePharmAction); 1597 // getSignaturesByPharmAction(action); 1598 // $scope.getPharmActions(term); 1599 $state.transitionTo('signatures.search.pharmAction.action',{action:action}); 1600 } 1601 1602 $scope.chooseMoaActionNew = function(action){ 1603 $scope.activeMoaAction=action; 1604 //console.log($scope.activeMoaAction); 1605 // getSignaturesByPharmAction(action); 1606 // $scope.getPharmActions(term); 1607 $state.transitionTo('signatures.search.moaAction.action',{action:action}); 1608 } 1609 1610 $scope.chooseKonwnTargerActionNew = function(action){ 1611 $scope.activeKnownTargetAction=action; 1612 // getSignaturesByPharmAction(action); 1613 // $scope.getPharmActions(term); 1614 $state.transitionTo('signatures.search.knownTargetAction.action',{action:action}); 1615 } 1616 1617 $scope.chosenPharmAction = function(action){ 1618 if (action==$scope.activePharmAction) return true 1619 else false; 1620 // $scope.getPharmActions(term); 1621 } 1622 $scope.chosenKnownTargetAction = function(action){ 1623 if (action==$scope.activeKnownTargetAction) return true 1624 else false; 1625 // $scope.getPharmActions(term); 1626 } 1627 $scope.chosenMoaAction = function(action){ 1628 if (action==$scope.activeMoaAction) return true 1629 else false; 1630 // $scope.getPharmActions(term); 1631 } 1632 1633 1634 1635 $scope.openSig = function(item){ 1636 getOneSignature(item); 1637 }; 1638 1639 1640 1641 $scope.open = function(item){ 1642 if ($scope.isOpen(item)){ 1643 $scope.opened = undefined; 1644 $scope.signatureData = undefined; 1645 } else { 1646 $scope.signatureData = undefined; 1647 $scope.opened = item; 1648 // $location.hash('top'); 1649 // $anchorScroll(); 1650 } 1651 1652 }; 1653 1654 $scope.isOpen = function(item){ 1655 return $scope.opened === item; 1656 }; 1657 1658 $scope.anyItemOpen = function() { 1659 return $scope.opened !== undefined; 1660 }; 1661 1662 $scope.close = function() { 1663 $scope.opened = undefined; 1664 $scope.signatureData = undefined; 1665 $scope.sigDownShow = false;
1666 }; 1667 1668 $scope.resetSigs = function(toBeRemoved) { 1669 // console.log("resetSignaturess"); 1670 if (!toBeRemoved){ 1671 $scope.filterSig=[]; 1672 } else { 1673 // $scope.filterSig=["GDS_1017"]; 1674 angular.forEach(toBeRemoved, function(sig) { 1675 index=$scope.filterSig.indexOf(sig.signatureid) 1676 // console.log(sig.signatureid); 1677 if (index>-1){ 1678 // if ($scope.filterchk.length<2) { 1679 $scope.filterSig.splice(index,1); 1680 // } else { 1681 // $scope.filterchk.shift(); 1682 // $scope.filterchk.push($scope.newFilter) 1683 // } 1684 } 1685 }) 1686 } 1687 1688 }; 1689 1690 $scope.allSigs = function(sigs) { 1691 1692 var filtered = $filter('filter')(sigs, $scope.filterBy); 1693 // console.log(filtered); 1694 angular.forEach(filtered, function(sig) { 1695 index=$scope.filterSig.indexOf(sig.signatureid) 1696 // console.log(sig.signatureid); 1697 if (index<0){ 1698 // if ($scope.filterchk.length<2) { 1699 $scope.filterSig.push(sig.signatureid) 1700 // } else { 1701 // $scope.filterchk.shift(); 1702 // $scope.filterchk.push($scope.newFilter) 1703 // } 1704 } 1705 }) 1706 }; 1707 1708 $scope.visibleRows = function(sigs) { 1709 $scope.displayedRows=[]; 1710 angular.forEach(sigs, function(sig) { 1711 $scope.displayedRows.push(sig.signatureid); 1712 }) 1713 return false; 1714 } 1715 1716 $scope.visibleRowsInLib = function(sigs,lib) { 1717 $scope.displayedRowsInLib7=[]; 1718 angular.forEach(sigs, function(sig) { 1719 $scope.displayedRowsInLib7.push(sig.signatureid); 1720 }) 1721 return false; 1722 } 1723 1724 $scope.allVisibleSigs = function(sigs) { 1725 // console.log("resetSignaturess"); 1726 1727 angular.forEach(sigs, function(sig) { 1728 index=$scope.filterSig.indexOf(sig) 1729 if (index<0){ 1730 $scope.filterSig.push(sig) 1731 } 1732 }) 1733 }; 1734 1735 $scope.displayedRow = function(sig) { 1736 1737 index=$scope.displayedRows.indexOf(sig) 1738 // console.log(sig); 1739 if (index<0){ 1740 $scope.displayedRows.push(sig); 1741 } 1742 1743 return true; 1744 } 1745 1746 1747 $scope.chooseSigs = function(group) { 1748 // Do something with node or tree 1749 // console.log("chooseSignatures"); 1750 // console.log(group); 1751 $scope.newSig=group; 1752 index=$scope.filterSig.indexOf($scope.newSig) 1753 // console.log(); 1754 if (index<0){ 1755 // if ($scope.filterchk.length<2) { 1756 $scope.filterSig.push($scope.newSig) 1757 // } else { 1758 // $scope.filterchk.shift(); 1759 // $scope.filterchk.push($scope.newFilter) 1760 // } 1761 } else { 1762 // console.log("remove Sig"); 1763 $scope.filterSig.splice(index,1); 1764 } 1765 }; 1766 1767 $scope.selectVisibleSigs = function() { 1768 console.log("selectVisible"); 1769 // console.log($scope.resource); 1770 // console.log($scope.visibleSigs); 1771 // console.log($scope.resourceLib5); 1772 } 1773 1774 $scope.chooseSignature = function(signature) { 1775 // Do something with node or tree 1776 // console.log("chooseSignatures"); 1777 // console.log(group); 1778 $scope.newSig=signature.signatureid; 1779 $scope.lastSigLibrary=signature.libraryid; 1780 index=$scope.filterSig.indexOf($scope.newSig) 1781 // console.log(); 1782 if (index<0){ 1783 // if ($scope.filterchk.length<2) { 1784 $scope.filterSig.push($scope.newSig) 1785 // } else { 1786 // $scope.filterchk.shift(); 1787 // $scope.filterchk.push($scope.newFilter) 1788 // } 1789 } else { 1790 // console.log("remove Sig"); 1791 $scope.filterSig.splice(index,1); 1792 } 1793 }; 1794 1795 $scope.chosenSig = function(item) { 1796 1797 if ($scope.filterSig.indexOf(item)<0) { 1798 return false 1799 } else { 1800 return true 1801 } 1802 1803 } 1804 1805 $scope.addToLocalSigs = function(sigs) { 1806 1807 // console.info("passed Signatures: ",sigs); 1808 if (localStorage.getObj("SignatureListStorage")) { 1809 $scope.localSigs = localStorage.getObj("SignatureListStorage"); 1810 } else { 1811 $scope.localSigs = []; 1812 } 1813 1814 angular.forEach(sigs, function(sig) { 1815 // console.log("Checking Signature: "+sig); 1816 1817 1818 1819 index=$scope.localSigs.indexOf(sig); 1820 // console.log("Signature index: "+index); 1821 if (index<0){ 1822 // if ($scope.filterchk.length<2) { 1823 $scope.localSigs.push(sig) 1824 // } else { 1825 // $scope.filterchk.shift(); 1826 // $scope.filterchk.push($scope.newFilter) 1827 // } 1828 } 1829 // else { 1830 // console.log("Signature already in local storage"); 1831 // // $scope.filterSig.splice(index,1); 1832 // } 1833 }) 1834 localStorage.setObj('SignatureListStorage', $scope.localSigs); 1835 } 1836 1837 $scope.checkActiveLibs = function(lib) { 1838 1839 index=$scope.activeLibs.indexOf(lib) 1840 // console.log(); 1841 if (index<0){ return false 1842 } else { 1843 return true; 1844 } 1845 } 1846 1847 1848
1849 $scope.analyzeSigs = function() { 1850 // start loading 1851 $scope.analyzeLoading = true; 1852 $scope.groupAnalysisResults = undefined; 1853 $scope.signaturesData = undefined; 1854 $scope.sigDownManyShow = false; 1855 console.log("analyzeSignatures"); 1856 // $scope.lastSigLibrary="LIB_5" 1857 // $scope.GeneList="57535,11010,283987,2920,2113,10612,9619,3263,2300,1282,148327,84002,8038,114793"; 1858 // $scope.GeneList="780,7849,6193,23,9552,387,10921,10285,533,6194,23326,351,1213,9761,3927,1465,808,5792,3337,7494"; 1859 1860 console.log($scope.geneList); 1861 // getGroupAnalysis("LINCSCP_1,LINCSCP_100,LINCSCP_13825","LIB_5") 1862 // getGroupAnalysis($scope.filterSig,$scope.lastSigLibrary); 1863 console.log($scope.lastSigLibrary); 1864 1865 // getGroupAnalysisWithGenes("LINCSCP_1,LINCSCP_100,LINCSCP_13825","LIB_5","780,7849,6193,23,9552,387,10921,10285,533,6194,23326,351,1213,9761,3927,1465,808,5792,3337,7494"); 1866 getGroupAnalysisWithGenes($scope.filterSig,$scope.lastSigLibrary,$scope.geneList); 1867 // console.log(group); 1868 // IlincsR 1869 // .diffExpPreResults({genelist: genes,experiment: dataset}) 1870 // // //.find({ filter:{limit: 5}}) 1871 // .$promise 1872 // .then(function(result) { 1873 // console.log(result); 1874 // $scope.preresult=result; 1875 // }); 1876 }; 1877 1878 $scope.analyzeResults = function() { 1879 if ($scope.filterSig.length) { 1880 // console.log("go to results"); 1881 1882 // SignatureList.create({ content: $scope.filterSig,lib:$scope.lastSigLibrary }).$promise 1883 // .then(function(data) { 1884 // // console.log("GeneList Data"); 1885 // // console.log(data); 1886 // resultsHistory.saveResultInSessionHistory('sigGroupAnalysisHistory',data.id); 1887 // $scope.SigListNum = data.id; 1888 // // $scope.geneList = data.content; 1889 // // $scope.datasets = data.result; 1890 // // creatEsetWithInfo($scope.geneListData.content); 1891 // $state.go('analyzeWithGenes.signaturesAnalysisResults',{SignatureListNumber:$scope.SigListNum}); 1892 // });; 1893 // // console.log($scope.SigListNum.$promise.id); 1894 1895 SignatureList.create({ content: $scope.filterSig,lib:$scope.lastSigLibrary }, 1896 function(data){ 1897 // console.log("GeneList Data"); 1898 // console.log(data); 1899 historyFactory.saveResultInSessionHistory('signatureListHistory',data.id); 1900 $scope.SigListNum = data.id; 1901 // $scope.geneList = data.content; 1902 // $scope.datasets = data.result; 1903 // creatEsetWithInfo($scope.geneListData.content); 1904 $state.go('analyzeWithGenes.signaturesAnalysisResults',{SignatureListNumber:$scope.SigListNum}); 1905 }, 1906 function(errorResponse){ 1907 console.log("Error. Compounds not found."); 1908 console.log(errorResponse); 1909 return onError(errorResponse); 1910 }); 1911 1912 } 1913 } 1914 1915 1916 $scope.goToUpload = function() { 1917 $scope.uploadPrimary=true; 1918 $scope.pharmAction=false; 1919 $scope.showOldSigsLink=false; 1920 // $state.go('signatures.search.upload'); 1921 // $state.transitionTo('signatures.search.upload',null,{reload: true}); 1922 $state.go('signaturesUpload'); 1923 } 1924 1925 $scope.goToUploadNew = function() { 1926 $scope.uploadPrimary=true; 1927 $scope.pharmAction=false; 1928 $scope.showOldSigsLink=false; 1929 // $state.go('signatures.search.upload'); 1930 // $state.transitionTo('signatures.search.upload',null,{reload: true}); 1931 $state.go('signatures.search.upload'); 1932 } 1933 1934 $scope.goToPharmAction = function() { 1935 $scope.uploadPrimary=false; 1936 $scope.pharmAction=true; 1937 $scope.showOldSigsLink=false; 1938 $state.go('signatures.search.pharmAction'); 1939 } 1940 1941 $scope.closeResults = function() { 1942 $scope.groupAnalysisResults = undefined; 1943 $scope.signaturesData = undefined; 1944 $scope.sigDownManyShow = false; 1945 }; 1946 1947 $scope.checkProteinTargets = function() { 1948 // not_generated_WrongLibrary 1949 // not_generated_NoTargets 1950 // console.log($scope.groupAnalysisResults); 1951 check = $scope.groupAnalysisResults[2].substring(0, 4); 1952 // console.log(check); 1953 if (check!="not_") { 1954 return true 1955 } 1956 else { 1957 return false 1958 } 1959 1960 } 1961 1962 $scope.chooseUploadLib = function(item) { 1963 $scope.activeUploadLib=item; 1964 // $scope.foundSignatures=undefined; 1965 // $scope.goAnalyzeUploaded(); 1966 }; 1967 1968 $scope.chosenUploadLib = function(item) { 1969 // console.log(item); 1970 if ($scope.activeUploadLib==item) { 1971 return true 1972 } else { 1973 return false 1974 } 1975 1976 } 1977 1978 $scope.goAnalyzeUploaded = function() { 1979 // console.log(item); 1980 // $scope.hitAnalyze="true" 1981 $scope.dataLoading=true; 1982 // console.info('Library',$scope.activeUploadLib); 1983 // console.info('File',uploader.queue[0].file.name); 1984 getAnalyzeUploadedSignature($scope.activeUploadLib,uploader.queue[0].file.name,undefined); 1985 1986 } 1987 1988 $scope.goAnalyzeUploadedNew = function() { 1989 // console.log(item); 1990 // $scope.hitAnalyze="true" 1991 // $scope.dataLoading=true; 1992 // console.info('Library',$scope.activeUploadLib); 1993 // console.info('File',uploader.queue[0].file.name); 1994 // getAnalyzeUploadedSignature($scope.activeUploadLib,uploader.queue[0].file.name,undefined); 1995 $scope.uploadedFileName=uploader.queue[0].file.name; 1996 $state.transitionTo('signaturesUpload.analyze',{file:$scope.uploadedFileName,libs:$scope.activeUploadLib}); 1997 } 1998 1999 $scope.goAnalyzeConcordantWithUploaded = function() { 2000 var path=""; 2001 var file=""; 2002 // console.log(item); 2003 // $scope.hitAnalyze="true" 2004 $scope.dataLoading=true; 2005 // console.info('Library',$scope.activeUploadLib); 2006 // console.info('SessionID',$state.params.sessionID); 2007 if ($state.current.name=="concordantWithSigGenes"){ 2008 if ($state.params.sessionID.substring(0,8)=="genelist"){ 2009 file=$state.params.sessionID; 2010 path="/mnt/raid/tmp/iLincs/volcano/"; 2011 2012 } else{ 2013 // console.log(); 2014 file="sig_"+$state.params.sessionID+".xls";//".csv";// 2015 path="/mnt/raid/tmp/"; 2016 } 2017 }else { 2018 // if ($state.params.geneList) { 2019 // console.log($state.params.geneList); 2020 // file="genelist_temp_volcano_"+$state.params.sessionID+".xls";//".txt";// 2021 // } else { 2022 // file="temp_volcano_"+$state.params.sessionID+".xls";//".txt";// 2023 file="completeSig_"+$state.params.sessionID+".xls";//".txt";// 2024 // file="download_data"+$state.params.sessionID+".xls";//".txt";// 2025 // } 2026 path="/mnt/raid/tmp/"; 2027 } 2028 2029 // console.info('File',file); 2030 getAnalyzeUploadedSignature($scope.activeUploadLib,file,path); 2031 2032 } 2033 2034 2035 $scope.filterbyAttr = function(attr){ 2036 console.log(attr); 2037 } 2038 2039 $scope.filterCellline = function(item){ 2040 $scope.filterBy.cellline=item; 2041 } 2042 2043 $scope.clearFilter = function(name){ 2044 2045 if ($scope.filterBy[name]=="") { 2046 // console.log("undefine filter",name)
2047 $scope.filterBy[name]=undefined; 2048 } 2049 } 2050 2051 2052 $scope.clearTissueFilter = function(){ 2053 2054 if ($scope.filterBy.tissue=="") { 2055 // console.log("undefine filter") 2056 $scope.filterBy.tissue=undefined; 2057 } 2058 } 2059 2060 $scope.clearCelllineFilter = function(){ 2061 2062 if ($scope.filterBy.cellline=="") { 2063 // console.log("undefine filter") 2064 $scope.filterBy.cellline=undefined; 2065 } 2066 } 2067 2068 $scope.clearCompoundFilter = function(){ 2069 2070 if ($scope.filterBy.compound=="") { 2071 // console.log("undefine filter") 2072 $scope.filterBy.compound=undefined; 2073 } 2074 } 2075 2076 $scope.clearTreatmentFilter = function(lib){ 2077 2078 if (lib) { 2079 switch (lib) { 2080 case "LIB_7": 2081 if ($scope.filterByLib7.treatment=="") { 2082 $scope.filterByLib7.treatment=undefined; 2083 } 2084 break; 2085 default: 2086 2087 } 2088 } else { 2089 if ($scope.filterBy.treatment=="") { 2090 // console.log("undefine filter") 2091 $scope.filterBy.treatment=undefined; 2092 } 2093 } 2094 } 2095 2096 $scope.clearPerturbagenIDFilter = function(lib){ 2097 2098 if (lib) { 2099 switch (lib) { 2100 case "LIB_7": 2101 if ($scope.filterByLib7.perturbagenID=="") { 2102 $scope.filterByLib7.perturbagenID=undefined; 2103 } 2104 break; 2105 default: 2106 2107 } 2108 } else { 2109 if ($scope.filterBy.perturbagenID=="") { 2110 // console.log("undefine filter") 2111 $scope.filterBy.perturbagenID=undefined; 2112 } 2113 } 2114 } 2115 2116 $scope.clearConcentrationFilter = function(){ 2117 2118 if ($scope.filterBy.concentration=="") { 2119 // console.log("undefine filter") 2120 $scope.filterBy.concentration=undefined; 2121 } 2122 } 2123 2124 2125 $scope.clearSimilarityFilter = function(){ 2126 2127 // console.info("similarity array",$scope.filterBy.similarity[index]); 2128 if ($scope.filterBy.similarity=="") { 2129 // console.log("undefine filter") 2130 $scope.filterBy.similarity=undefined; 2131 } 2132 } 2133 2134 $scope.termSearch = function(){ 2135 $scope.filterBy=""; 2136 } 2137 2138 $scope.fieldSearch = function(){ 2139 console.log("fieldSearch") 2140 $scope.filterBy=""; 2141 $scope.filterBy=undefined; 2142 $scope.filterBy={}; 2143 } 2144 2145 2146 2147 $scope.showSignatureData = function(item){ 2148 // $scope.sigDownLoad = true; 2149 // $scope.filterByDown={}; 2150 // // $scope.filterSig 2151 // getDownloadSignature(item); 2152 2153 $scope.filterByDown={}; 2154 $scope.sigDownShow =!$scope.sigDownShow; 2155 } 2156 2157 $scope.showSignatureTab = function(item,init){ 2158 // console.log("showSignatureTab"); 2159 // $scope.activeSigTabs=undefined; 2160 // $scope.filterByDown={}; 2161 if (item=="full") { 2162 // $scope.sigDownShow =!$scope.sigDownShow; 2163 // if ($scope.sigDownShow&$scope.showShortSig) {$scope.showShortSig =!$scope.showShortSig;} 2164 $scope.sigDownShow =true; 2165 $scope.showShortSig =false; 2166 if ($scope.tabs.activeSigTabs==0&&!init) $scope.tabs.activeSigTabs=1; 2167 $scope.tabs.SigDataTabs=0; 2168 $scope.tabs.connectedSigTabs=0; 2169 $scope.tabs.connectedPerturbations=0; 2170 // if (!$state.$current.params.selected===undefined) 2171 $state.go($state.$current.name,{selected:undefined}, { location: 'replace'}); 2172 } else { 2173 // $scope.showShortSig =!$scope.showShortSig; 2174 // if($scope.sigDownShow&$scope.showShortSig){$scope.sigDownShow =!$scope.sigDownShow;} 2175 $scope.sigDownShow =false; 2176 $scope.showShortSig =true; 2177 if ($scope.tabs.activeSigTabs==0&&!init) $scope.tabs.activeSigTabs=1; 2178 $scope.tabs.SigDataTabs=1; 2179 $scope.tabs.connectedSigTabs=1; 2180 $scope.tabs.connectedPerturbations=1; 2181 $state.go($state.$current.name,{selected:"t"}, { location: 'replace'}); 2182 } 2183 // $scope.activeSigTabs=1; 2184 } 2185 2186 2187 2188 2189 $scope.showSignatureInTable = function(item,val){ 2190 // console.info("$scope.filterByDown",$scope.filterByDown); 2191 // console.info("item",item); 2192 // $scope.filterByDown.geneID=[]; 2193 2194 // $scope.filterByDown={}; 2195 if ($scope.downloadSigResource) { 2196 $scope.sigDownShow =val; 2197 $scope.filterByDown.GeneID = "\""+item+"\""; 2198 2199 } 2200 } 2201 2202 $scope.geneFromVolcano = function(gene){ 2203 2204 // console.info("gene",gene); 2205 // console.info("gene type",typeof gene); 2206 // console.info("$scope.volcanoGeneList",$scope.volcanoGeneList); 2207 // console.info("genelist type",typeof $scope.volcanoGeneList[1]); 2208 2209 index=$scope.volcanoGeneList.indexOf(gene.toString()); 2210 // console.info("index",index); 2211 if (index>-1) { 2212 return true; 2213 } else { 2214 return false;
2215 } 2216 2217 2218 } 2219 2220 $scope.geneIsSelected = function(gene){ 2221 2222 // console.info("gene",gene); 2223 // console.info("gene type",typeof gene); 2224 // console.info("$scope.volcanoGeneList",$scope.volcanoGeneList); 2225 // console.info("genelist type",typeof $scope.volcanoGeneList[1]); 2226 // if (typeof gene=="number"){ 2227 // index=$scope.volcanoGeneList.indexOf(gene.toString()); 2228 // } else { 2229 index=$scope.volcanoGeneList.indexOf(gene); 2230 // } 2231 2232 // console.info("index",index); 2233 if (index>-1) { 2234 return true; 2235 } else { 2236 return false; 2237 } 2238 2239 2240 } 2241 2242 $scope.showManySignaturesData = function(){ 2243 $scope.sigDownManyLoad = true; 2244 $scope.filterByDownMany={}; 2245 signatures=$scope.filterSig.toString(); 2246 getDownloadManySignatures(signatures); 2247 // getDownloadSignature(signatures); 2248 } 2249 2250 //modals functions 2251 2252 2253 $scope.openModal = function (size) { 2254 2255 var modalInstance = $uibModal.open({ 2256 animation: $scope.animationsEnabled, 2257 // templateUrl: 'myModalContent.html', 2258 templateUrl: 'views/templates/modals/example.html', 2259 controller: 'ModalInstanceCtrl', 2260 size: size, 2261 resolve: { 2262 items: function () { 2263 return $scope.items; 2264 } 2265 } 2266 }); 2267 2268 modalInstance.result.then(function (selectedItem) { 2269 $scope.selected = selectedItem; 2270 }, function () { 2271 $log.info('Modal dismissed at: ' + new Date()); 2272 }); 2273 }; 2274 2275 $scope.openPickSignaturesModal = function (sigs) { 2276 // console.log("pick signatures"); 2277 // console.log($scope.signature); 2278 // console.log($scope.file); 2279 // debugger; 2280 var modalInstance = $uibModal.open({ 2281 animation: $scope.animationsEnabled, 2282 // templateUrl: 'myModalContent.html', 2283 templateUrl: 'views/templates/modals/pickSignatures.html', 2284 controller: 'ModalInstanceCtrl', 2285 size: 'xxl', 2286 resolve: { 2287 sigs: function () { 2288 // return $scope.filterSig; 2289 return sigs; 2290 }, 2291 genes: function () { 2292 return $scope.geneList; 2293 }, 2294 files: function () { 2295 return $scope.file; 2296 }, 2297 refSig: function () { 2298 return null; 2299 } 2300 } 2301 }); 2302 2303 // modalInstance.result.then(function (selectedItem) { 2304 // $scope.selected = selectedItem; 2305 // }, function () { 2306 // $log.info('Modal dismissed at: ' + new Date()); 2307 // }); 2308 }; 2309 2310 $scope.openSignatureDetailsModal = function (sig) { 2311 2312 // console.log(sig); 2313 // console.log(sig.signatureid); 2314 2315 var modalInstance = $uibModal.open({ 2316 animation: $scope.animationsEnabled, 2317 // templateUrl: 'myModalContent.html', 2318 templateUrl: 'views/templates/modals/signatureDetails.html', 2319 controller: 'signatureDetailsModalCtrl', 2320 size: 'xxl', 2321 resolve: { 2322 sig: function () { 2323 if (sig.signatureid) return sig 2324 else { 2325 // console.log(sig); 2326 // var signat; 2327 return returnOneSignature(sig) 2328 // return SignatureMeta.findOne({ filter:{where: {signatureid: sig}}}); 2329 // return signat; 2330 } 2331 } 2332 } 2333 }); 2334 }; 2335 2336 $scope.openDatasetInfoModal = function (dataset) { 2337 2338 // console.log(dataset); 2339 2340 var modalInstance = $uibModal.open({ 2341 animation: $scope.animationsEnabled, 2342 // templateUrl: 'myModalContent.html', 2343 templateUrl: 'views/templates/modals/datasetInfo.html', 2344 controller: 'datasetInfoModalCtrl', 2345 size: 'xxl', 2346 // dataset: dataset 2347 resolve: { 2348 dataset: function () {return dataset} 2349 // sig: function () { 2350 // if (sig.signatureid) return sig 2351 // else { 2352 // // console.log(sig); 2353 // // var signat; 2354 // return returnOneSignature(sig) 2355 // // return SignatureMeta.findOne({ filter:{where: {signatureid: sig}}}); 2356 // // return signat; 2357 // } 2358 // } 2359 } 2360 }); 2361 }; 2362 2363 2364 // $scope.openSignatureDetailsModalFromID = function (sig) { 2365 // 2366 // console.log(sig.signatureid); 2367 // 2368 // var modalInstance = $uibModal.open({ 2369 // animation: $scope.animationsEnabled, 2370 // // templateUrl: 'myModalContent.html', 2371 // templateUrl: 'views/templates/modals/signatureDetails.html', 2372 // controller: 'signatureDetailsModalCtrl', 2373 // size: 'xxl', 2374 // resolve: { 2375 // sig: function () { 2376 // if (sig.signatureid) return sig 2377 // else {returnOneSignature(sig)} 2378 // } 2379 // } 2380 // }); 2381 2382 // modalInstance.result.then(function (selectedItem) { 2383 // $scope.selected = selectedItem; 2384 // }, function () { 2385 // $log.info('Modal dismissed at: ' + new Date()); 2386 // }); 2387 // }; 2388 2389 $scope.openWaitModal = function (size,time,msg) { 2390 2391 // console.log(sig); 2392 // console.log(sig.signatureid); 2393 2394 var modalInstance = $uibModal.open({ 2395 animation: $scope.animationsEnabled, 2396 // templateUrl: 'myModalContent.html', 2397 templateUrl: 'views/templates/modals/wait.html', 2398 controller: 'waitModalCtrl', 2399 size: size, 2400 backdrop : 'static', 2401 // keyboard : false, 2402 resolve: { 2403 time: function () {return time;}, 2404 msg: function () { 2405 return msg; 2406 } 2407 } 2408 }); 2409 2410 } 2411 2412 2413 2414 $scope.openIframeModal = function (linkID,type) { 2415 2416 // console.log(linkID); 2417 // console.log(type); 2418 var template; 2419 if (type=="YouTube" ) { 2420 template='views/templates/modals/YouTube.html'; 2421 } 2422 else if (type=="help") { 2423 template='views/templates/modals/help.html'; 2424 //document.getElementById('iFrameName').src = "http://www.ilincs.org/help/"; 2425 //$scope.currentSiteUrlByPassed = "http://www.ilincs.org/help/"+linkID; 2426 } 2427 else { 2428 template='views/templates/modals/iFrame.html'; 2429 } 2430 2431 var modalInstance = $uibModal.open({ 2432 animation: $scope.animationsEnabled, 2433 // templateUrl: 'myModalContent.html', 2434 templateUrl: template,
2435 controller: 'iFrameModalInstanceCtrl', 2436 size: 'xxl', 2437 windowClass: 'app-modal-window', 2438 resolve: { 2439 linkID: function () { 2440 return linkID; 2441 }, 2442 type: function () { 2443 return type; 2444 } 2445 } 2446 }); 2447 2448 2449 // modalInstance.result.then(function (selectedItem) { 2450 // $scope.selected = selectedItem; 2451 // }, function () { 2452 // $log.info('Modal dismissed at: ' + new Date()); 2453 // }); 2454 } 2455 2456 $scope.openModalGSEAplot = function (signatureId,genes,nGenes) { 2457 2458 // console.log(signatureId,genes,nGenes); 2459 var modalInstance = $uibModal.open({ 2460 animation: $scope.animationsEnabled, 2461 // templateUrl: 'myModalContent.html', 2462 templateUrl: 'views/templates/modals/GSEAplot.html', 2463 controller: 'modalGSEAplotCtrl', 2464 size: 'xxl', 2465 windowClass: 'app-modal-window', 2466 resolve: { 2467 signatureId: function () { 2468 return signatureId; 2469 }, 2470 geneList: function () { 2471 return genes; 2472 }, 2473 nGenes: function () { 2474 return nGenes; 2475 } 2476 } 2477 }); 2478 } 2479 2480 $scope.toggleAnimation = function () { 2481 $scope.animationsEnabled = !$scope.animationsEnabled; 2482 }; 2483 2484 $scope.downloadSigs= function (sigs) { 2485 $scope.dataDownLoadingSigs = true; 2486 getDownloadManySignaturesFilename(sigs); 2487 } 2488 2489 $scope.removeFromList = function (item) { 2490 $scope.showUploadList=false; 2491 $scope.wrongFile=false; 2492 item.remove(); 2493 } 2494 2495 2496 $scope.tooltipText = function (text) { 2497 console.log("tooltipText"); 2498 return "concordance js"; 2499 } 2500 2501 $scope.checkHowSignifigant = function (concordance,lib) { 2502 // (row.similarity,'LIB_2') 2503 // switch lib {} 2504 // if ((concordance>0.371)||(concordance<-0.371)) 2505 // { 2506 // return true 2507 // } else { 2508 // return false 2509 // } 2510 // if (Math.abs(concordance)>=0.371) 2511 // { 2512 // return "significance-5" 2513 // 2514 // } else { 2515 // 2516 // if (Math.abs(concordance)>=0.261) { 2517 // return "significance-4" 2518 // } 2519 // else { 2520 // if (Math.abs(concordance)>=0.235) { 2521 // return "significance-3" 2522 // } 2523 // else { 2524 // if (Math.abs(concordance)>=0.216) { 2525 // return "significance-2" 2526 // } 2527 // else { 2528 // return "significance-1" 2529 // } 2530 // } 2531 // } 2532 // } 2533 // var pos01=0.371; 2534 // var pos025=0.3083077; 2535 // var pos05=0.2608042; 2536 // var pos10=0.2157037;//0.216; 2537 // // var neg01=-0.371; 2538 // var neg025=-0.3083077; 2539 // var neg05=-0.2608042; 2540 // var neg10=-0.2157037;//-0.216; 2541 2542 // console.log(Array.isArray(signatures)); 2543 // var sigType=$state.params.signatureID.substring(0,3); 2544 // if (sigType=="ENC") { 2545 // $scope.sigENC=true; 2546 // } else { 2547 // $scope.sigENC=false; 2548 // } 2549 // console.info("isENC",$scope.sigENC); 2550 // console.info("lib",lib); 2551 // if ($scope.sigENC||lib=="LIB_3"){ 2552 // $scope.pos05=14.82684; 2553 // $scope.pos10=10.36439; 2554 // $scope.neg05=-14.82684; 2555 // $scope.neg10=-10.36439; 2556 // } else { 2557 // switch (lib) { 2558 // case "LIB_1": 2559 // $scope.pos05=0.1994; 2560 // $scope.pos10=0.1729; 2561 // $scope.neg05=-0.1994; 2562 // $scope.neg10=-0.1729; 2563 // break; 2564 // case "LIB_2": 2565 // $scope.pos05=0.2608042; 2566 // $scope.pos10=0.2157037; 2567 // $scope.neg05=-0.2608042; 2568 // $scope.neg10=-0.2157037; 2569 // break; 2570 // case "LIB_5": 2571 // $scope.pos05=0.3289; 2572 // $scope.pos10=0.2920; 2573 // $scope.neg05=-0.3289; 2574 // $scope.neg10=-0.2920; 2575 // break; 2576 // case "LIB_6": 2577 // $scope.pos05=0.3701; 2578 // $scope.pos10=0.331; 2579 // $scope.neg05=-0.3701; 2580 // $scope.neg10=-0.331; 2581 // break; 2582 // case "LIB_7": 2583 // $scope.pos05=0.3324; 2584 // $scope.pos10=0.2937; 2585 // $scope.neg05=-0.3324; 2586 // $scope.neg10=-0.2937; 2587 // break; 2588 // } 2589 // } 2590 2591 2592 $scope.pos05=$scope.getConcordanceValue("pos05",lib); 2593 $scope.pos10=$scope.getConcordanceValue("pos10",lib); 2594 $scope.neg05=$scope.getConcordanceValue("neg05",lib); 2595 $scope.neg10=$scope.getConcordanceValue("neg10",lib); 2596 2597 // console.info("pos05",$scope.pos05); 2598 2599 var x = concordance; 2600 switch (true) { 2601 // case (x>=pos01): 2602 // return "pos01" 2603 // break;
2604 // case (x<pos01&&x>=pos10): 2605 // return "pos10" 2606 // break; 2607 // case (x>=pos025): 2608 // return "signif pos025" 2609 // break; 2610 // case (x<pos025&&x>=pos10): 2611 // return "signif pos10" 2612 // break; 2613 case (x>=$scope.pos05): 2614 return "signif pos05" 2615 break; 2616 case (x>=$scope.pos10): //(x<pos05&&x>=pos10): 2617 return "signif pos10" 2618 break; 2619 case (x<$scope.pos10&&x>0): 2620 return "signif posRest" 2621 break; 2622 // case (x<=neg01): 2623 // return "neg01" 2624 // break; 2625 // case (x>neg01&&x<=neg10): 2626 // return "neg10" 2627 // break; 2628 // case (x<=neg025): 2629 // return "signif neg025" 2630 // break; 2631 // case (x>neg025&&x<=neg10): 2632 // return "signif neg10" 2633 // break; 2634 case (x>$scope.neg10): //(x>neg10&&x<0): 2635 return "signif negRest" 2636 break; 2637 case (x>$scope.neg05&&x<=$scope.neg10)://(x>neg05): 2638 return "signif neg10" 2639 break; 2640 case (x<=$scope.neg05): 2641 return "signif neg05" 2642 break; 2643 default: 2644 return "" 2645 } 2646 2647 2648 } 2649 2650 $scope.getConcordanceValue= function(val,lib){ 2651 if ($scope.sigENC||lib=="LIB_3"){ 2652 // console.log("enc mode"); 2653 switch (val){ 2654 2655 case "pos05": return 8.946850; 2656 case "pos10": return 4.669846; 2657 case "neg10": return -7.238341; 2658 case "neg05": return -11.648286; 2659 } 2660 } else { 2661 // console.log("getting values"); 2662 switch (lib) { 2663 case "LIB_1": 2664 switch (val){ 2665 case "pos05": return 0.176644; 2666 case "pos10": return 0.15035; 2667 case "neg10": return -0.145081; 2668 case "neg05": return -0.16911; 2669 } 2670 break; 2671 case "LIB_2": 2672 switch (val){ 2673 case "pos05": return 0.259328; 2674 case "pos10": return 0.212926; 2675 case "neg10": return -0.125341; 2676 case "neg05": return -0.144081; 2677 } 2678 break; 2679 case "LIB_5": 2680 switch (val){ 2681 case "pos05": return 0.321475; 2682 case "pos10": return 0.28295; 2683 case "neg10": return -0.199421; 2684 case "neg05": return -0.234868; 2685 } 2686 break; 2687 case "LIB_6": 2688 switch (val){ 2689 case "pos05": return 0.364163; 2690 case "pos10": return 0.322974; 2691 case "neg10": return -0.224126; 2692 case "neg05": return -0.262584; 2693 } 2694 break; 2695 case "LIB_7": 2696 switch (val){ 2697 case "pos05": return 0.323791; 2698 case "pos10": return 0.282988; 2699 case "neg10": return -0.202592; 2700 case "neg05": return -0.239246; 2701 } 2702 break; 2703 case "LIB_8": 2704 switch (val){ 2705 case "pos05": return 0.103731; 2706 case "pos10": return 0.090643; 2707 case "neg10": return -0.119243; 2708 case "neg05": return -0.136783; 2709 } 2710 break; 2711 } 2712 } 2713 } 2714 2715 $scope.legendTooltipPath = function() { 2716 if ($scope.sigENC) { 2717 return "views/templates/tooltips/popoverEncodeConcordance.html" 2718 } else { 2719 return "views/templates/tooltips/popoverConcordance.html" 2720 } 2721 } 2722 2723 $scope.filtersComparator = function (actual, expected) { 2724 2725 // if ((typeof actual)=="string"){ 2726 2727 // console.info("actual type",typeof actual); 2728 // if ((typeof actual)=="object"){ 2729 // actual=actual.toString(); 2730 // console.info("actual object",actual); 2731 // } 2732 2733 if ((typeof actual)=="boolean") { 2734 return actual == expected; 2735 } else { 2736 if ((typeof actual)=="number"){ 2737 actual=actual.toString(); 2738 } 2739 2740 if ((typeof actual)=="undefined"||(typeof actual)=="null"||(typeof actual)=="object"){ 2741 // actual=""; 2742 return 0; 2743 } 2744 // console.info("expected lower",expected.toLowerCase()); 2745 // console.info("function",actual.toLowerCase().indexOf(expected.toLowerCase())>=0); 2746 // return actual.toLowerCase().indexOf(expected.toLowerCase()) >= 0; 2747 // console.info("expected.substring(0,1)",expected.substring(0,1)) 2748 if ((expected.substring(0,1)=="\"")&&(expected.substring(expected.length-1,expected.length)=="\"")){ 2749 // console.info("expected.substring(1,expected.length-1)",expected.substring(1,expected.length-1)) 2750 // console.info("actual",actual) 2751 return actual==expected.substring(1,expected.length-1); 2752 } else { 2753 return actual.toLowerCase().indexOf(expected.toLowerCase()) >= 0; 2754 } 2755 } 2756 2757 } 2758 2759 $scope.filtersComparatorChoice = function (actual, expected) { 2760 if ($scope.uploadedSignatures) { 2761 return $scope.filtersComparator(actual, expected) 2762 } else { 2763 return $scope.filtersComparatorConcordance(actual, expected) 2764 } 2765 } 2766 2767 $scope.filtersComparatorConcordance = function (actual, expected) { 2768 // console.info("actual",actual); 2769 // console.info("actual class",typeof actual); 2770 // console.info("expected",expected); 2771 // // console.info("actual 0.12789",Math.round(0.12789,3)); 2772 // console.info("filter number",$filter('number')(15, 5)); 2773 2774 // console.info("function",actual.toLowerCase().indexOf(expected)); 2775 // console.info("function",actual.indexOf(expected)); 2776 2777 // if (actual.indexOf) { 2778 // return actual.toLowerCase().indexOf(expected) === 0; 2779 // } 2780 // return expected; //do nothing 2781 2782 if ((typeof actual)=="undefined"||(typeof actual)=="null"||(typeof actual)=="object"){ 2783 // actual=""; 2784 return 0; 2785 } 2786 2787 if ((typeof actual)=="boolean") { 2788 return actual == expected; 2789 } else { 2790 if ((typeof actual)=="string"){ 2791 // console.info("expected lower",expected.toLowerCase()); 2792 // console.info("function",actual.toLowerCase().indexOf(expected.toLowerCase())>=0); 2793 return actual.toLowerCase().indexOf(expected.toLowerCase()) >= 0; 2794 } else { 2795 // console.info("actual rounded",Math.round(actual)) 2796 // console.info("actual rounded",$filter('number')(actual, 3)); 2797 // console.info("expected rounded",$filter('number')( expected, 3)); 2798 // var whichClass=$scope.checkHowSignifigant(concordance,lib); 2799 2800 // console.info("active library",$scope.activeLibrary); 2801 // console.info("joined",expected.join(' ')); 2802 // if ((typeof expected)=="String"){ 2803 switch (expected.join(' ')) { 2804 case "pos05": 2805 // console.log("pos05"); 2806 // console.info("returned pos05",$scope.getConcordanceValue("pos05",$scope.activeLibrary)); 2807 // console.info("pos05",$scope.getConcordanceValue("pos05",$scope.activeLibrary)); 2808 // console.info("actual",actual); 2809 // console.info("what to return",actual>=$scope.getConcordanceValue("pos05",$scope.activeLibrary)); 2810 return (actual>=$scope.getConcordanceValue("pos05",$scope.activeLibrary)); 2811 case "pos05 neg10": 2812 return ((actual>=$scope.getConcordanceValue("pos05",$scope.activeLibrary))||(actual>=$scope.getConcordanceValue("neg05",$scope.activeLibrary)&&actual<$scope.getConcordanceValue("neg10",$scope.activeLibrary))); 2813 break; 2814 case "pos05 neg10 neg05": 2815 return ((actual>=$scope.getConcordanceValue("pos05",$scope.activeLibrary))||(actual<=$scope.getConcordanceValue("neg10",$scope.activeLibrary))); 2816 break; 2817 case "pos05 neg05": 2818 return ((actual>=$scope.getConcordanceValue("pos05",$scope.activeLibrary))||(actual<=$scope.getConcordanceValue("neg05",$scope.activeLibrary))); 2819 break; 2820 case "pos05 pos10": 2821 return (actual>=$scope.getConcordanceValue("pos10",$scope.activeLibrary)); 2822 break; 2823 case "pos05 pos10 neg10": 2824 return (actual>=$scope.getConcordanceValue("pos10",$scope.activeLibrary)||(actual>=$scope.getConcordanceValue("neg05",$scope.activeLibrary)&&actual<$scope.getConcordanceValue("neg10",$scope.activeLibrary))); 2825 break; 2826 case "pos05 pos10 neg10 neg05": 2827 return (actual>=$scope.getConcordanceValue("pos10",$scope.activeLibrary)||actual<=$scope.getConcordanceValue("neg10",$scope.activeLibrary)); 2828 break; 2829 case "pos05 pos10 neg05": 2830 return (actual>=$scope.getConcordanceValue("pos10",$scope.activeLibrary)||actual<=$scope.getConcordanceValue("neg05",$scope.activeLibrary)); 2831 break; 2832 case "pos10": 2833 return (actual>=$scope.getConcordanceValue("pos10",$scope.activeLibrary)&&actual<$scope.getConcordanceValue("pos05",$scope.activeLibrary)); 2834 break; 2835 case "pos10 neg10": 2836 return ((actual>=$scope.getConcordanceValue("pos10",$scope.activeLibrary)&&actual<$scope.getConcordanceValue("pos05",$scope.activeLibrary))||(actual>=$scope.getConcordanceValue("neg05",$scope.activeLibrary)&&actual<$scope.getConcordanceValue("neg10",$scope.activeLibrary))); 2837 break; 2838 case "pos10 neg10 neg05": 2839 return ((actual>=$scope.getConcordanceValue("pos10",$scope.activeLibrary)&&actual<$scope.getConcordanceValue("pos05",$scope.activeLibrary))||(actual<=$scope.getConcordanceValue("neg10",$scope.activeLibrary))); 2840 break; 2841 case "pos10 neg05": 2842 return ((actual>=$scope.getConcordanceValue("pos10",$scope.activeLibrary)&&actual<$scope.getConcordanceValue("pos05",$scope.activeLibrary))||(actual<=$scope.getConcordanceValue("neg05",$scope.activeLibrary))); 2843 break; 2844 case "neg05": 2845 // console.log("pos05"); 2846 return (actual<=$scope.getConcordanceValue("neg05",$scope.activeLibrary)); 2847 case "neg10 neg05": 2848 return (actual<=$scope.getConcordanceValue("neg10",$scope.activeLibrary)); 2849 break; 2850 case "neg10": 2851 return (actual>=$scope.getConcordanceValue("neg05",$scope.activeLibrary)&&actual<$scope.getConcordanceValue("neg10",$scope.activeLibrary)); 2852 break; 2853 // default: 2854 // return angular.equals($filter('number')(actual, 3),$filter('number')( expected, 3)); 2855 } 2856 2857 // } else { 2858 // return angular.equals($filter('number')(actual, 3),$filter('number')( expected, 3)); 2859 // } 2860 // if (expected=="pos05") { 2861 // // if (actual>0){ 2862 // // return true; 2863 // // } else { 2864 // // return false;
2865 // // } 2866 // return (actual>0.3); 2867 // 2868 // } else { 2869 // return angular.equals($filter('number')(actual, 3),$filter('number')( expected, 3)); 2870 // } 2871 } 2872 } 2873 // return angular.equals(actual, expected) //exact macth 2874 }; 2875 2876 $scope.concordanceDropDown = function(lib){ 2877 $scope.activeLibrary=lib; 2878 return [{"value":"pos05","label":"<span class=\"legendDrop pos05\"></span> top 0.5%(+)"},{"value":"pos10","label":"<span class=\"legendDrop pos10\"></span> top 1.0%(+)"},{"value":"neg10","label":"<span class=\"legendDrop neg10\"></span> top 1.0%(-)"},{"value":"neg05","label":"<span class=\"legendDrop neg05\"></span> top 0.5%(-)"}]; 2879 2880 } 2881 2882 $scope.useGenes = function(genes){ 2883 // console.info("geneListNum : ",$state.params.geneListNum); 2884 localStorage.setObj("GeneList",[]); 2885 localStorage.setItem('GeneString',[]); 2886 $state.go('genes.list',{genes:genes}); 2887 } 2888 2889 $scope.postToL1000CDS2URLEncoded = function(){ 2890 console.log("sending data to L1000CDS2"); 2891 $scope.generatingL1000CDS2=true; 2892 2893 2894 var myUrl ="https://maayanlab.cloud/L1000CDS2/queryURLEncoded"; 2895 2896 // var data = {"upGenes":["KDM5A","EGR1","RELB"],"dnGenes":["USP22","PHGDH","HADH"]}; 2897 var data = {"upGenes":$scope.volcanoUpGenes,"dnGenes":$scope.volcanoDownGenes}; 2898 // 2899 var config = {"aggravate":true,"searchMethod":"geneSet","share":true,"combination":true,"db-version":"latest"}; 2900 // 2901 // var metadata = [{"key":"Tag","value":"gene-set python example"},{"key":"Cell","value":"MCF7"}]; 2902 var metadata = [{"key":"Tag","value":"Genes from iLincs"}]; 2903 // 2904 var payload = {"data":data,"config":config,"meta":metadata}; 2905 2906 // console.log(payload); 2907 2908 // console.info("stringify",{input:JSON.stringify(payload)}) 2909 // $http.post('http://jsonplaceholder.typicode.com/posts',{ 2910 // title: 'foo', 2911 // body: 'bar', 2912 // userId: 1 2913 // }) 2914 // {input:JSON.stringify(payload)} 2915 // Michal tests 2916 // $http.get('http://mr84.synology.me:8005/testnocors/index.html') 2917 // $http.get('http://mr84.synology.me:8005/testcors/index.html') 2918 // works with disabled CORS 2919 // $http.post('https://maayanlab.cloud/L1000CDS2/query', 2920 // { 2921 // "data": {"genes":["ADAM10","ADAM12","ADAMTS10","ARHGAP1","ARHGAP28","ARSE","ASAM","ATP13A4","BMP1","BMP7","BNC2","BRDT","BTN1A1","C12ORF53","C1QTNF6","C20ORF58","C3ORF59","C4ORF26","C6ORF65","C7ORF10","C8B","C9ORF53","CCDC36","CCR6","CD59","CDKL1","CETN2","CHRNA3","CILP2","CNTN1","CNTN6","COL16A1","COL6A1","COPZ2","CORIN","CPB2","CSMD1","CX3CR1","CYP27C1","DEPDC7","F8A1","FAM127A","FAM127B","FAM26E","FAM77D","FAM7A1","FASN","FBLN1","FKBP10","FKBP5","FKBP7","FLJ14213","FLRT2","FST","GAS7","GLI2","GLIS1","GPR1","GPR32","HMCN1","HS3ST3A1","IGF2AS","IGFBP6","IGFL2","IL13RA1","KCNMB4","KERA","KIAA0574","KIAA1217","KIF26B","KIRREL","L1TD1","LEPRE1","LIPC","LL22NC03-75B3.6","LOC554202","LOXL2","LRRC15","MN1","MYL3","MYO1H","NALCN","NEGR1","NETO1","NPFFR2","NRG1","NSDHL","NUAK1","ODZ4","OR6M1","OSTALPHA","PANX3","PBEF1","PCOLCE","PCSK9","PDLIM2","PEBP4","PPAPDC3","PPP1R2","PPP1R2P3","PROL1","PTHR1","PTPRD","PTPRN","RAB5C","RASGRF2","RBP2","SALL1","SCN2B","SELPLG","SEMA3D","SLAMF9","SLC10A3","SLC16A12","SLC24A2","SLC38A4","SLC38A5","SPARC","ST6GAL2","ST7L","STAT5A","STGC3","THBS2","TLL2","TLOC1","TMEM106A","TNFSF11","TRIM59","UPK3A","WISP1","ZFPM2","ZMAT3","ZNF689"], 2922 // "vals":[0.180332,0.145189,0.168047,0.13882,0.158224,0.143072,0.145892,0.15365,0.144291,0.157614,0.14744,0.154325,0.147376,0.155081,0.159286,0.25514,0.162077,0.208984,0.15986,0.169436,0.16125,0.153146,0.181141,0.200862,0.137231,0.139624,0.143746,0.165085,0.170691,0.168352,0.18958,0.137049,0.147329,0.145576,0.148437,0.197561,0.163244,0.143887,0.158658,0.141172,0.162165,0.15575,0.141131,0.146965,0.153985,0.173928,0.159943,0.178655,0.138075,0.144719,0.138163,0.183944,0.152835,0.191298,0.143365,0.13743,0.217921,0.206099,0.224969,0.156594,0.137776,0.164921,0.146842,0.141019,0.1566,0.145863,0.172826,0.159286,0.142403,0.146848,0.142655,0.165754,0.136826,0.163144,0.14944,0.199848,0.143898,0.15202,0.164264,0.171155,0.142497,0.137905,0.143324,0.188078,0.144467,0.153205,0.153134,0.162089,0.140169,0.141084,0.182308,0.18585,0.151393,0.144854,0.154917,0.171325,0.145968,0.14204,0.176913,0.139823,0.239401,0.224412,0.15331,0.171594,0.143887,0.207916,0.228734,0.151457,0.170017,0.148021,0.16305,0.139618,0.156758,0.214209,0.156776,0.144239,0.159145,0.137295,0.147036,0.170123,0.154389,0.16196,0.138756,0.140333,0.138627,0.174978,0.154677,0.154548,0.138345,0.147347,0.155644,0.14839,0.144913]}, 2923 // "config":{"aggravate":false,"share":false,"combination":false,"db-version":"latest","searchMethod":"CD"}, 2924 // "meta":[{"key":"Tag","value":"Signature Example"}] 2925 // }) 2926 2927 //basssd
2928 // {input:JSON.stringify({"data": {"genes":["ADAM10","ADAM12","ADAMTS10","ARHGAP1","ARHGAP28","ARSE","ASAM","ATP13A4","BMP1","BMP7","BNC2","BRDT","BTN1A1","C12ORF53","C1QTNF6","C20ORF58","C3ORF59","C4ORF26","C6ORF65","C7ORF10","C8B","C9ORF53","CCDC36","CCR6","CD59","CDKL1","CETN2","CHRNA3","CILP2","CNTN1","CNTN6","COL16A1","COL6A1","COPZ2","CORIN","CPB2","CSMD1","CX3CR1","CYP27C1","DEPDC7","F8A1","FAM127A","FAM127B","FAM26E","FAM77D","FAM7A1","FASN","FBLN1","FKBP10","FKBP5","FKBP7","FLJ14213","FLRT2","FST","GAS7","GLI2","GLIS1","GPR1","GPR32","HMCN1","HS3ST3A1","IGF2AS","IGFBP6","IGFL2","IL13RA1","KCNMB4","KERA","KIAA0574","KIAA1217","KIF26B","KIRREL","L1TD1","LEPRE1","LIPC","LL22NC03-75B3.6","LOC554202","LOXL2","LRRC15","MN1","MYL3","MYO1H","NALCN","NEGR1","NETO1","NPFFR2","NRG1","NSDHL","NUAK1","ODZ4","OR6M1","OSTALPHA","PANX3","PBEF1","PCOLCE","PCSK9","PDLIM2","PEBP4","PPAPDC3","PPP1R2","PPP1R2P3","PROL1","PTHR1","PTPRD","PTPRN","RAB5C","RASGRF2","RBP2","SALL1","SCN2B","SELPLG","SEMA3D","SLAMF9","SLC10A3","SLC16A12","SLC24A2","SLC38A4","SLC38A5","SPARC","ST6GAL2","ST7L","STAT5A","STGC3","THBS2","TLL2","TLOC1","TMEM106A","TNFSF11","TRIM59","UPK3A","WISP1","ZFPM2","ZMAT3","ZNF689"],"vals":[0.180332,0.145189,0.168047,0.13882,0.158224,0.143072,0.145892,0.15365,0.144291,0.157614,0.14744,0.154325,0.147376,0.155081,0.159286,0.25514,0.162077,0.208984,0.15986,0.169436,0.16125,0.153146,0.181141,0.200862,0.137231,0.139624,0.143746,0.165085,0.170691,0.168352,0.18958,0.137049,0.147329,0.145576,0.148437,0.197561,0.163244,0.143887,0.158658,0.141172,0.162165,0.15575,0.141131,0.146965,0.153985,0.173928,0.159943,0.178655,0.138075,0.144719,0.138163,0.183944,0.152835,0.191298,0.143365,0.13743,0.217921,0.206099,0.224969,0.156594,0.137776,0.164921,0.146842,0.141019,0.1566,0.145863,0.172826,0.159286,0.142403,0.146848,0.142655,0.165754,0.136826,0.163144,0.14944,0.199848,0.143898,0.15202,0.164264,0.171155,0.142497,0.137905,0.143324,0.188078,0.144467,0.153205,0.153134,0.162089,0.140169,0.141084,0.182308,0.18585,0.151393,0.144854,0.154917,0.171325,0.145968,0.14204,0.176913,0.139823,0.239401,0.224412,0.15331,0.171594,0.143887,0.207916,0.228734,0.151457,0.170017,0.148021,0.16305,0.139618,0.156758,0.214209,0.156776,0.144239,0.159145,0.137295,0.147036,0.170123,0.154389,0.16196,0.138756,0.140333,0.138627,0.174978,0.154677,0.154548,0.138345,0.147347,0.155644,0.14839,0.144913]},"config":{"aggravate":false,"share":false,"combination":false,"db-version":"latest","searchMethod":"CD"},"meta":[{"key":"Tag","value":"Signature Example"}]})}) 2929 // $http.post('https://maayanlab.cloud/L1000CDS2/queryURLEncoded',{"input":JSON.stringify({"data":{"upGenes":["KDM5A","EGR1","RELB"],"dnGenes":["USP22","PHGDH","HADH"]},"config":{"aggravate":true,"searchMethod":"geneSet","share":true,"combination":true,"db-version":"latest"},"meta":[{"key":"Tag","value":"gene-set python example"},{"key":"Cell","value":"MCF7"}]})}) 2930 // $http.post('https://maayanlab.cloud/L1000CDS2/queryURLEncoded', {input:JSON.stringify(payload)}) 2931 2932 // $http({ 2933 // method: 'POST', 2934 // url: 'https://maayanlab.cloud/L1000CDS2/queryURLEncoded', 2935 // headers: {'Content-Type': 'application/x-www-form-urlencoded'}, 2936 // transformRequest: function(obj) { 2937 // var str = []; 2938 // for(var p in obj) 2939 // str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); 2940 // return str.join("&"); 2941 // }, 2942 // data:{"data": {"upGenes":["KDM5A","EGR1","RELB"],"dnGenes":["USP22","PHGDH","HADH"]},"config":{"aggravate":true,"searchMethod":"geneSet","share":true,"combination":true,"db-version":"latest"},"meta":[{"key":"Tag","value":"gene-set python example"},{"key":"Cell","value":"MCF7"}]} 2943 // }) 2944 2945 // $http({ 2946 // url: myUrl, 2947 // method: 'POST', 2948 // data: $httpParamSerializerJQLike({payload}), 2949 // // data: {input:{"data":{"upGenes":["KIAA1324","HID1","TRIM3","ABCG1","HPX","CREB3L4","BCAM","CXXC5","SPDEF","BCAS1","STARD10","TGFB3","RHOB","ERGIC1","FOXA1","XBP1","DEGS2","CACFD1","TFF3","FAM65C","RHOH","MAGED2","CACNA1D","KCNJ11","ABHD11","CLU","RAB26","GRIN1","SLC9A2","ANXA6","SELENBP1","ALDH3B2","ZG16B","C9orf106","GPD1L","TSTD1","ZNF467","TTC39A","MAN1C1","ERBB3","GPR160","CACNG4","SIDT1","MAGIX","PBX1"],"dnGenes":["GLIPR1","CXCL2","ETS1","FOXL1","COL4A1","B3GNT5","ADAM12","FMNL2","SNAI2","CXCL8","NRP2","MSN","PCOLCE2","RGS20","DSE","PDCD1LG2","CAV2","LYN","C3","FAM171A1","SERPINB7","SAA1","UBASH3B","SERPINB5","ARNTL2","ANXA1","PTX3","PRSS12","LOX","IGF2BP2","TBX20","SERPINE2","INHBA","FOSL1","HDAC9","VIM","PIM1","TNFAIP3","GLIS3","TLR6","CXCL3","VNN1","LAMA2","PLAUR","DZIP1L","KIRREL","IGF2BP3","FERMT1","SLC16A1","F3","CAV1","ADD2","PTRF","COL4A2","INPP1"]},"config":{"aggravate":true,"searchMethod":"geneSet","share":true,"combination":true,"db-version":"latest"},"meta":[{"key":"Tag","value":"Genes from iLincs"}]}}, 2950 // headers: { 2951 // 'Content-Type': 'application/x-www-form-urlencoded' 2952 // } 2953 // }) 2954 2955 $http({ 2956 url: myUrl, 2957 method: 'POST', 2958 data: $httpParamSerializer({input:payload}), 2959 // data: {input:{"data":{"upGenes":["KIAA1324","HID1","TRIM3","ABCG1","HPX","CREB3L4","BCAM","CXXC5","SPDEF","BCAS1","STARD10","TGFB3","RHOB","ERGIC1","FOXA1","XBP1","DEGS2","CACFD1","TFF3","FAM65C","RHOH","MAGED2","CACNA1D","KCNJ11","ABHD11","CLU","RAB26","GRIN1","SLC9A2","ANXA6","SELENBP1","ALDH3B2","ZG16B","C9orf106","GPD1L","TSTD1","ZNF467","TTC39A","MAN1C1","ERBB3","GPR160","CACNG4","SIDT1","MAGIX","PBX1"],"dnGenes":["GLIPR1","CXCL2","ETS1","FOXL1","COL4A1","B3GNT5","ADAM12","FMNL2","SNAI2","CXCL8","NRP2","MSN","PCOLCE2","RGS20","DSE","PDCD1LG2","CAV2","LYN","C3","FAM171A1","SERPINB7","SAA1","UBASH3B","SERPINB5","ARNTL2","ANXA1","PTX3","PRSS12","LOX","IGF2BP2","TBX20","SERPINE2","INHBA","FOSL1","HDAC9","VIM","PIM1","TNFAIP3","GLIS3","TLR6","CXCL3","VNN1","LAMA2","PLAUR","DZIP1L","KIRREL","IGF2BP3","FERMT1","SLC16A1","F3","CAV1","ADD2","PTRF","COL4A2","INPP1"]},"config":{"aggravate":true,"searchMethod":"geneSet","share":true,"combination":true,"db-version":"latest"},"meta":[{"key":"Tag","value":"Genes from iLincs"}]}}, 2960 headers: { 2961 'Content-Type': 'application/x-www-form-urlencoded' 2962 } 2963 }) 2964 2965 // $http.post('https://maayanlab.cloud/L1000CDS2/queryURLEncoded', {
2966 // data: {"upGenes":["KDM5A","EGR1","RELB"],"dnGenes":["USP22","PHGDH","HADH"]},"config":{"aggravate":true,"searchMethod":"geneSet","share":true,"combination":true,"db-version":"latest"},"meta":[{"key":"Tag","value":"gene-set python example"},{"key":"Cell","value":"MCF7"}] 2967 // }, { 2968 // transformRequest: { 2969 // body: function(data, headersGetter) { 2970 // return function(data) { 2971 // var str = []; 2972 // for(var p in obj) 2973 // str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); 2974 // return str.join("&"); 2975 // }; 2976 // }, 2977 // headers: function(data, headersGetter) { 2978 // var headers = headersGetter(); 2979 // headers['Content-Type'] = 'x-www-form-urlencoded'; 2980 // return headers; 2981 // } 2982 // } 2983 // }) 2984 .then(function onSuccess(data) { 2985 // .success(function(data,status) { 2986 // .done(function(result){ 2987 // }) 2988 2989 // $scope.hello = data; 2990 // console.log('Posted Data'); 2991 // console.info('status',data.status); 2992 // console.info('Data',data.data); 2993 $scope.generatingL1000CDS2=false; 2994 2995 if (data.data.err) {alert(data.data.err)} 2996 else { 2997 2998 if (data.data.shareId){ 2999 // window.location.href = "https://maayanlab.cloud/L1000CDS2/#/result/"+data.shareId; 3000 // window.open("https://maayanlab.cloud/L1000CDS2/#/result/"+data.shareId,'_blank'); 3001 var L1000CDS2window = window.open('', '_blank'); 3002 // L1000CDS2window.document.write('Loading L1000CDS2...'); 3003 L1000CDS2window.location.href = "https://maayanlab.cloud/L1000CDS2/#/result/"+data.data.shareId; 3004 } 3005 3006 3007 } 3008 3009 }) 3010 } 3011 3012 $scope.postToL1000FWD = function(upGenes,downGenes){ 3013 // console.log(upGenes); 3014 // console.log(downGenes); 3015 $scope.generatingL1000FWD=true; 3016 3017 // console.log("postToL1000FWD"); 3018 var L1000FWD_URL = 'https://maayanlab.cloud/L1000FWD/' 3019 3020 // upGenes = ['KIAA0907','KDM5A','CDC25A','EGR1','GADD45B','RELB','TERF2IP','SMNDC1','TICAM1','NFKB2','RGS2','NCOA3','ICAM1','TEX10','CNOT4','ARID4B','CLPX','CHIC2','CXCL2','FBXO11','MTF2','CDK2','DNTTIP2','GADD45A','GOLT1B','POLR2K','NFKBIE','GABPB1','ECD','PHKG2','RAD9A','NET1','KIAA0753','EZH2','NRAS','ATP6V0B','CDK7','CCNH','SENP6','TIPARP','FOS','ARPP19','TFAP2A','KDM5B','NPC1','TP53BP2','NUSAP1'] 3021 // downGenes = ['SCCPDH','KIF20A','FZD7','USP22','PIP4K2B','CRYZ','GNB5','EIF4EBP1','PHGDH','RRAGA','SLC25A46','RPA1','HADH','DAG1','RPIA','P4HA2','MACF1','TMEM97','MPZL1','PSMG1','PLK1','SLC37A4','GLRX','CBR3','PRSS23','NUDCD3','CDC20','KIAA0528','NIPSNAP1','TRAM2','STUB1','DERA','MTHFD2','BLVRA','IARS2','LIPA','PGM1','CNDP2','BNIP3','CTSL1','CDC25B','HSPA8','EPRS','PAX8','SACM1L','HOXA5','TLE1','PYGL','TUBB6','LOXL1'] 3022 payload = { 3023 'up_genes': upGenes, 3024 'down_genes': downGenes 3025 } 3026 3027 $http({ 3028 url: L1000FWD_URL + 'sig_search', 3029 method: 'POST', 3030 //data: $httpParamSerializer({input:inputData}), 3031 //data: {input:inputData}, 3032 data: payload, 3033 headers: { 3034 // 'Content-Type': 'application/x-www-form-urlencoded' 3035 'Content-Type': 'text/plain' 3036 }, 3037 dataType:"json" 3038 }) 3039 // .success(function(data,status) { 3040 .then(function onSuccess(response) { 3041 $scope.generatingL1000FWD=false; 3042 // console.log(response); 3043 if (response.data.result_id){ 3044 //open in _blank window 3045 var L1000fwdWindow = window.open('#', '_blank'); 3046 L1000fwdWindow.location.href = L1000FWD_URL + "result/" + response.data.result_id 3047 } 3048 3049 },function onError(response) { 3050 $scope.generatingL1000FWD=false; 3051 console.log(response.status,response.statusText)}) 3052 } 3053 3054 3055 $scope.sendGenesToReactome = function(genes){ 3056 $scope.generatingReactome=true; 3057 var myUrl ="http://www.reactome.org/AnalysisService/identifiers/?interactors=false&pageSize=20&page=1&sortBy=ENTITIES_PVALUE&order=ASC&resource=TOTAL"; 3058 3059 // var myUrl ="http://www.reactome.org/AnalysisService/identifiers/?interactors=false&pageSize=20&page=1&sortBy=ENTITIES_PVALUE&order=ASC&resource=ENSEMBL"; 3060 3061 // PIK3C2A 3062 // PTEN 3063 // UNC5B 3064 3065 // 7165 -2.138 this one not found 3066 // 3006 2.3805 3067 // 55315 1.43525 3068 3069 // var testData="#Genes\nPIK3C2A\nPTEN\nUNC5B"; //only genes 3070 // var testData="#Genes\nZFAND5\nTMEM97\nDNAJB2"; //only genes not found 3071 // var testData="#Genes\t#DiffExp\nPIK3C2A\t1.01\nPTEN\t-2.2\nUNC5B\t3.3"; //signatures 3072 3073 var inputData; 3074 // var inputData = testData; 3075 if (genes) { 3076 inputData = "#Gene names"+"\n"+$scope.volcanoGeneListEnrichr; 3077 } else { 3078 inputData = $scope.expressionReactome; 3079 } 3080 // console.info('Data',inputData); 3081 3082 $http({ 3083 url: myUrl, 3084 method: 'POST', 3085 //data: $httpParamSerializer({input:inputData}), 3086 //data: {input:inputData}, 3087 data: inputData, 3088 // data: {input:{"data":{"upGenes":["KIAA1324","HID1","TRIM3","ABCG1","HPX","CREB3L4","BCAM","CXXC5","SPDEF","BCAS1","STARD10","TGFB3","RHOB","ERGIC1","FOXA1","XBP1","DEGS2","CACFD1","TFF3","FAM65C","RHOH","MAGED2","CACNA1D","KCNJ11","ABHD11","CLU","RAB26","GRIN1","SLC9A2","ANXA6","SELENBP1","ALDH3B2","ZG16B","C9orf106","GPD1L","TSTD1","ZNF467","TTC39A","MAN1C1","ERBB3","GPR160","CACNG4","SIDT1","MAGIX","PBX1"],"dnGenes":["GLIPR1","CXCL2","ETS1","FOXL1","COL4A1","B3GNT5","ADAM12","FMNL2","SNAI2","CXCL8","NRP2","MSN","PCOLCE2","RGS20","DSE","PDCD1LG2","CAV2","LYN","C3","FAM171A1","SERPINB7","SAA1","UBASH3B","SERPINB5","ARNTL2","ANXA1","PTX3","PRSS12","LOX","IGF2BP2","TBX20","SERPINE2","INHBA","FOSL1","HDAC9","VIM","PIM1","TNFAIP3","GLIS3","TLR6","CXCL3","VNN1","LAMA2","PLAUR","DZIP1L","KIRREL","IGF2BP3","FERMT1","SLC16A1","F3","CAV1","ADD2","PTRF","COL4A2","INPP1"]},"config":{"aggravate":true,"searchMethod":"geneSet","share":true,"combination":true,"db-version":"latest"},"meta":[{"key":"Tag","value":"Genes from iLincs"}]}}, 3089 headers: { 3090 // 'Content-Type': 'application/x-www-form-urlencoded' 3091 'Content-Type': 'text/plain' 3092 }, 3093 dataType:"json" 3094 }) 3095 // .success(function(data,status) { 3096 .then(function onSuccess(response) { 3097 $scope.generatingReactome=false; 3098 // .done(function(result){ 3099 // }) 3100 3101 // $scope.hello = data; 3102 // console.log('Posted Data'); 3103 // console.info('status',response.status); 3104 // console.info('Data',response.data); 3105 3106 // if (response.data.err) {alert(response.data.err)} 3107 // else { 3108 3109 if (response.data.summary.token){ 3110 // // window.location.href = "https://maayanlab.cloud/L1000CDS2/#/result/"+data.shareId; 3111 // // window.open("https://maayanlab.cloud/L1000CDS2/#/result/"+data.shareId,'_blank'); 3112 //open in _blank window 3113 var reactomeWindow = window.open('#', '_blank'); 3114 // reactomeWindow.document.write('Loading Reactome...'); 3115 reactomeWindow.location.href = "http://www.reactome.org/PathwayBrowser/#/DTAB=AN&RESOURCE=ENSEMBL&ANALYSIS="+response.data.summary.token; 3116 //open in current window 3117 // window.location.href = "http://www.reactome.org/PathwayBrowser/#/DTAB=AN&RESOURCE=ENSEMBL&ANALYSIS="+response.data.summary.token; 3118 } 3119 3120 3121 // } 3122 3123 // }) 3124 },function onError(response) { 3125 $scope.generatingReactome=false; 3126 console.log(response.status,response.statusText)}) 3127 3128 } 3129 3130 3131 3132 //don't work cause needs straight riderect with POST, done through HTMLform 3133 // $scope.postToEnrichr = function(){ 3134 // console.log("sending data to L1000CDS2"); 3135 // 3136 // 3137 // var myUrl ="https://maayanlab.cloud/Enrichr/enrich"; 3138 // 3139 // 3140 // $http({ 3141 // url: myUrl, 3142 // method: 'POST', 3143 // data: $httpParamSerializer({list:$scope.volcanoGeneListEnrichr}), 3144 // // data: {input:{"data":{"upGenes":["KIAA1324","HID1","TRIM3","ABCG1","HPX","CREB3L4","BCAM","CXXC5","SPDEF","BCAS1","STARD10","TGFB3","RHOB","ERGIC1","FOXA1","XBP1","DEGS2","CACFD1","TFF3","FAM65C","RHOH","MAGED2","CACNA1D","KCNJ11","ABHD11","CLU","RAB26","GRIN1","SLC9A2","ANXA6","SELENBP1","ALDH3B2","ZG16B","C9orf106","GPD1L","TSTD1","ZNF467","TTC39A","MAN1C1","ERBB3","GPR160","CACNG4","SIDT1","MAGIX","PBX1"],"dnGenes":["GLIPR1","CXCL2","ETS1","FOXL1","COL4A1","B3GNT5","ADAM12","FMNL2","SNAI2","CXCL8","NRP2","MSN","PCOLCE2","RGS20","DSE","PDCD1LG2","CAV2","LYN","C3","FAM171A1","SERPINB7","SAA1","UBASH3B","SERPINB5","ARNTL2","ANXA1","PTX3","PRSS12","LOX","IGF2BP2","TBX20","SERPINE2","INHBA","FOSL1","HDAC9","VIM","PIM1","TNFAIP3","GLIS3","TLR6","CXCL3","VNN1","LAMA2","PLAUR","DZIP1L","KIRREL","IGF2BP3","FERMT1","SLC16A1","F3","CAV1","ADD2","PTRF","COL4A2","INPP1"]},"config":{"aggravate":true,"searchMethod":"geneSet","share":true,"combination":true,"db-version":"latest"},"meta":[{"key":"Tag","value":"Genes from iLincs"}]}}, 3145 // headers: { 3146 // 'Content-Type': 'application/x-www-form-urlencoded' 3147 // } 3148 // }) 3149 // 3150 // .success(function(data,status) { 3151 // // .done(function(result){ 3152 // // }) 3153 // 3154 // // $scope.hello = data; 3155 // console.log('Posted Data'); 3156 // console.info('status',status); 3157 // console.info('Data',data); 3158 // 3159 // if (data.err) {alert(data.err)} 3160 // else { 3161 // 3162 // if (data.shareId){ 3163 // // window.location.href = "https://maayanlab.cloud/L1000CDS2/#/result/"+data.shareId; 3164 // // window.open("https://maayanlab.cloud/L1000CDS2/#/result/"+data.shareId,'_blank'); 3165 // var L1000CDS2window = window.open('', '_blank'); 3166 // // L1000CDS2window.document.write('Loading L1000CDS2...'); 3167 // L1000CDS2window.location.href = "https://maayanlab.cloud/L1000CDS2/#/result/"+data.shareId; 3168 // } 3169 // 3170 // 3171 // } 3172 // 3173 // }) 3174 // } 3175 3176 3177 $scope.onClickPie = function(points, evt){ 3178 // console.log("plot clicked"); 3179 // console.log(points, evt); 3180 // console.log(points[0].label); 3181 // console.log(points[0].value); 3182 // console.log(points[0]); 3183 // if (points[0]){ 3184 // switch (points[0].value) { 3185 // case 113735: 3186 // $scope.activeLibs=["LIB_7"]; 3187 // break; 3188 // case 33410: 3189 // $scope.activeLibs=["LIB_6"]; 3190 // break; 3191 // case 68960: 3192 // $scope.activeLibs=["LIB_5"]; 3193 // break; 3194 // case 171: 3195 // $scope.activeLibs=["LIB_8"]; 3196 // break; 3197 // case 9097: 3198 // $scope.activeLibs=["LIB_1"]; 3199 // break; 3200 // case 494: 3201 // $scope.activeLibs=["LIB_3"]; 3202 // break; 3203 // case 519: 3204 // $scope.activeLibs=["LIB_2"]; 3205 // break; 3206 // case 794: 3207 // $scope.activeLibs=["LIB_9"]; 3208 // break; 3209 // // default: 3210 // 3211 // } 3212 3213 SignatureLibraries.findOne({filter:{fields:{libraryID:true},where:{libraryName:points[0].label}}},//{filter:{where:{displayOrder:lib}}}, 3214 function(data){ 3215 // console.log(data);
3216 $scope.activeLibs=data.libraryID; 3217 localStorage.setObj('ActiveLibs', $scope.activeLibs); 3218 // $state.go('signatures.searchInLibs',{term:"testing",libs:$scope.activeLibs}); 3219 // $state.transitionTo('signatures.searchInLibs',{term:$scope.searchTerm,libs:$scope.activeLibs},{reload: true}); 3220 // console.log($scope.searchTerm,$scope.activeLibs); 3221 $state.transitionTo('signatures.searchTerm',{term:null,libs:$scope.activeLibs},{reload: true}); 3222 }, 3223 function(errorResponse){console.log("Signature Library ID not found."),console.log(errorResponse)} 3224 ); 3225 3226 } 3227 3228 3229 3230 3231 // // $scope.PieLabels = ["Download Sales", "In-Store Sales", "Mail-Order Sales"]; 3232 // // $scope.PieData = [300, 500, 100]; 3233 // // $scope.PieLabels = ["LINCS individual shRNA signatures", "LINCS consensus (CGS) gene knockdown signatures", "LINCS chemical perturbagen signatures","Disease Related Signatures","ENCODE Transcription Factor Binding Signatures","Connectivity Map Signatures"]; 3234 // $scope.PieLabels = ["LINCS individual shRNA signatures", "LINCS consensus (CGS) gene knockdown signatures", "LINCS chemical perturbagen signatures","LINCS RNA-Seq signatures","Cancer Therapeutics Response signatures","Disease Related Signatures","ENCODE Transcription Factor Binding Signatures","Connectivity Map Signatures","LINCS targeted protein signatures"]; 3235 // // $scope.PieData = [113735, 33410, 68960,222, 9097, 494, 519]; 3236 // $scope.PieData = [113735, 33410, 68960,253,481, 9097, 494, 519, 725]; 3237 // // $scope.PieData = [Math.log(113735), Math.log(33410), Math.log(68960),Math.log(222), Math.log(9097), Math.log(494), Math.log(519)]; 3238 // $scope.ChartType = 'polarArea'; 3239 // // $scope.PieData = [113, 334, 689, 909, 494, 519]; 3240 // // $scope.PieData = { 3241 // // labels: [ 3242 // // "Red", 3243 // // "Blue", 3244 // // "Yellow" 3245 // // ], 3246 // // datasets: [ 3247 // // { 3248 // // data: [300, 50, 100], 3249 // // backgroundColor: [ 3250 // // "#FF6384", 3251 // // "#36A2EB", 3252 // // "#FFCE56" 3253 // // ], 3254 // // hoverBackgroundColor: [ 3255 // // "#FF6384", 3256 // // "#36A2EB", 3257 // // "#FFCE56" 3258 // // ] 3259 // // }] 3260 // // }; 3261 3262 $scope.setLibrary = function(lib) { 3263 // console.log("setting up library variable"); 3264 $scope.currentLibrary =lib; 3265 } 3266 3267 //from signatures service 3268 $scope.getLibName = function(lib) { 3269 return signatures.getLibName(lib); 3270 } 3271 $scope.getLibIDs = function(lib) { 3272 return signatures.libIDs(); 3273 } 3274 3275 3276 $scope.analyzeWithGenes = function(genes) { 3277 // console.log(genes); 3278 GeneList.create({ content: genes }).$promise 3279 .then(function(data) { 3280 // console.log("GeneList Data"); 3281 // console.log(data); 3282 $scope.GeneListNum = data.id; 3283 historyFactory.saveResultInSessionHistory('geneListHistory',data.id); 3284 // $scope.geneList = data.content; 3285 // $scope.datasets = data.result; 3286 // creatEsetWithInfo($scope.geneListData.content); 3287 // $state.go('analyzeWithGenes.signaturesAnalysisResults',{SignatureListNumber:$scope.SigListNum}); 3288 $state.go('analyzeWithGenes.signatures',{geneListNum:$scope.GeneListNum}); 3289 }); 3290 3291 } 3292 3293 $scope.openIframeModalGenesCb = function(geneId){ 3294 // console.log("successCb"); 3295 $scope.openIframeModal(geneId,'Genes'); 3296 } 3297 3298 $scope.scrubChemCheck = function(pubChemID){ 3299 if (compoundsFactory.scrubChemExist[pubChemID]===undefined){ 3300 compoundsFactory.scrubChemCheck(pubChemID); 3301 return false; 3302 } else { 3303 return compoundsFactory.scrubChemExist[pubChemID]; 3304 } 3305 } 3306 3307 function onSuccessSetGeneList(id){ 3308 3309 //$state.go('pathwayAnalysisSignature',{signatureID:$scope.opened.signatureid,sessionId:$scope.sessionID,geneListId:id}); 3310 var url = $state.href('pathwayAnalysisSignature',{signatureID:$scope.opened.signatureid,sessionId:$scope.sessionID,geneListId:id}); 3311 console.log("in onSuccessSetGeneList"); 3312 window.open(url,'_blank'); 3313 } 3314 3315 function onErrorSetGeneList(err){ 3316 console.log("Error from callback: ",err); 3317 } 3318 3319 $scope.onPathwayAnalysis = function() { 3320 // console.log($scope.volcanoGeneList); 3321 genes.setGeneList($scope.volcanoGeneList,onSuccessSetGeneList,onErrorSetGeneList); 3322 } 3323 3324 function onSuccessKeggPathways(id){ 3325 //$state.transitionTo('keggPathwaysSignature',{signatureID:$scope.opened.signatureid,sessionId:$scope.sessionID,geneListId:id},{reload: true}); 3326 3327 var url = $state.href('keggPathwaysSignature',{signatureID:$scope.opened.signatureid,sessionId:$scope.sessionID,geneListId:id},{reload: true}); 3328 console.log("in onSuccessKeggPathways"); 3329 window.open(url,'_blank'); 3330 3331 } 3332 3333 $scope.onKeggPathways = function() { 3334 // console.log($scope.volcanoGeneList); 3335 genes.setGeneList($scope.volcanoGeneList,onSuccessKeggPathways,onErrorSetGeneList); 3336 } 3337 3338 // $scope.noOfRows=1; 3339 // $scope.$watch('noOfRows', function (newValue, oldValue, scope) { 3340 // //Do anything with $scope.letters 3341 // // console.info("noOfRows watch",oldValue); 3342 // // console.info("noOfRows watch",newValue); 3343 // console.info("noOfRows watch",scope.noOfRows); 3344 // // $scope.dataLength=scope.data.length; 3345 // // scope.rows=scope.resource.rows.length; 3346 // // console.info("type of resource rows",$scope.resource.rows) 3347 // // console.info("no of rows",scope.resource.rows.length) 3348 // }); 3349 3350 $scope.getExSymbols = function(mode){ 3351 if (mode=='signature'){ 3352 $scope.newSignature= {content:'DDR1 0.656282 0.00090283\nRFC2 -0.0307033 0.81855521\nHSPA6 -0.0807417 0.550
3352775065\nPAX8 -2.557 2.20778E-005\nGUCA1A -0.0720556 0.545070543\nUBA7 -1.25986 0.000124866\nTHRA 0.57995 0.198622921\nPTPN21 -0.172433 0.426619573\nCCL5 -2.2593 5.95485E-007\nCYP2E1 -0.102705 0.541813256\nEPHB3 0.36194 0.059704186\nESRRA 0.702305 0.024376289\nCYP2A6 -0.05073 0.321701072\nMMP14 -1.09062 0.015694617\nTRADD -0.0757367 0.564190437\nFNTB 0.746087 0.009585435\nPLD1 0.78648 0.053130761\nBAD 0.782338 0.001259522\nPRPF8 0.68999 0.000127974\nCAPNS1 0.3909 0.036167805\nRPL35 -0.0436667 0.706843514\nRPL28 0.446783 0.063988163\nEIF4G2 0.0291511 0.399923715\nEIF3D -0.31967 0.027215231\nPARK7 0.171533 0.191601577\nSRP14 0.0709667 0.547985596\nGDI2 0.0433167 0.616795925\nRPL11 -0.435033 0.004882385\nARF3 0.901777 0.000260796\nRPL24 0.2429 0.07681522\nHNRNPC 0.372021 0.1757654\nHNRNPA1 0.217742 0.178223317\nRPS27A 0.5201 0.003722247\nRPS13 0.193367 0.106564271\nFAU -0.592467 0.000396905\nTARDBP -0.03982 0.730237452\nCFL1 -0.5614 0.003366163\nRPL18 0.09005 0.448815619\nEIF3F 0.1437 0.17876675\nRPS5 0.233067 0.06800901\nRPL27 0.5104 0.000981438\nRPL34 -0.172433 0.140646338\nNARS -0.398667 0.0093094\nSTARD7 -0.0703233 0.535497436\nRPL19 0.561233 0.000521176\nSLC25A3 0.463867 0.001999137\nRPS11 0.133387 0.469148145\nRPL9 0.1284 0.329358189\nDDX5 0.766142 0.0096662\nRPL6 0.347067 0.010554594\nCTDNEP1 0.15682 0.223378851\nRPL10A 0.165967 0.16269307\nCBX3 -0.297257 0.422090763\nRPL17 -0.372178 0.01044495\nPSMB2 -0.243752 0.338861375\nKHDRBS1 -0.549041 0.309033893\nDDX39B -0.129005 0.545221815\nRTCB -0.0996456 0.347852312\nERH 0.0137333 0.909841851\nSRSF9 0.328272 0.024008349\nABCF1 -0.40016 0.024447319\nDAD1 0.542367 0.001489489\nYY1 0.0188267 0.419781051\nJTB 0.386289 0.010513803\nKAT7 0.8048 0.000144452\nZNF146 0.475302 0.026189068\nSART1 -0.535593 0.004510634\nILF2 0.115953 0.377042686\nSPAG7 0.611477 0.001124804\nZPR1 0.144217 0.260901994\nTAF10 0.333156 0.259883173\nC1D 1.47963 2.44884E-005\nNONO 0.766153 0.000324155\nSNRNP200 -0.0209644 0.616492864\nRHOA 0.00135222 0.7077936\nRNPS1 -0.152395 0.497775191\nRPS24 -0.216618 0.354527684\nRPL30 -0.343233 0.011350347\nNPM1 0.191267 0.407467501\nHSP90AB1 -0.173022 0.366661289\nARF1 0.263278 0.415026755\nIK 0.276603 0.046216556\nSNX3 -0.893781 2.80898E-005\nCANX -0.06689 0.587006594\nSART3 0.25476 0.261043996\nCNPPD1 -0.235878 0.088468915\nSMNDC1 0.310163 0.031542234\nHNRNPM -0.106785 0.439987497\nHNRNPD -0.0722467 0.505336951\nRPL14 0.0139892 0.876486158\nGUK1 -0.428503 0.472455761\nKXD1 -0.52948 0.004755529\nOAZ1 -0.198717 0.182712607\nATP6V0B -0.479563 0.002097676\nKARS -0.222767 0.155414698\nRPS6 0.264198 0.156150314\nRPS7 0.236333 0.06217148\nUSP22 0.109333 0.450429396\nC11orf58 0.132117 0.488886348\nTCEB2 0.238975 0.14763104\nCOX4I1 0.0273244 0.659807971\nTMED2 0.491717 0.012422892\nRPL12 -0.1268 0.296792804\nRPL4 0.703622 0.000128342\nFNTA -0.0745567 0.414551964\nRPS25 0.285733 0.137161683\nRPL37 0.02614 0.297796593\nHINT1 0.0876853 0.575016638\nEEF2 -0.0922167 0.580246049\nRPS10 -0.00616917 0.71693812\nATP6V0E1 -0.0496367 0.449944745\nHNRNPK 0.214033 0.197426508\nANAPC5 0.631953 0.131160127\nHNRNPU 0.0376994 0.173606066\nEIF3A 0.328636 0.066659098\nHSP90B1 0.09062 0.632434765\nMSN 0.148033 0.340240703\nACTN4 0.389493 0.007229386\nAPP -0.883671 0.026821208\nPRKAR1A 1.07905 0.005555538\nDSP 1.26037 6.56017E-006\nRAD21 -0.682083 0.002070014\nWDR1 -0.293501 0.255101753\nNCL 0.590067 0.000422499\nAP2B1 1.22629 0.005562655\nAP2M1 -0.268133 0.033081873\nCLTC 0.568288 0.291953372\nMLEC 0.510022 0.069649302\nLASP1 0.8154 9.63319E-005\nSF3B2 -0.695468 0.014629593\nTMEM59 -0.0724367 0.617963766\nCSRP1 0.952003 0.000095959\nMATR3 0.230686 0.20200754\nCAP1 -1.06304 0.000190313\nPTGES3 0.3652 0.007959154\nWARS -0.461253 0.007031586\nSET -0.123287 0.404811148\nNDRG1 -3.72001 5.57E-009\nPFN1 0.219267 0.081382375\nPTPRF -1.06234 0.035832839\nYWHAZ -0.421408 0.025700511\nSOD1 0.317133 0.017913301\nHDLBP 0.201093 0.209998422\nMARCKSL1 0.647147 0.004688241\nGABARAP 0.222733 0.145848074\nNUCB1 -0.44982 0.037921545\nEIF3C 0.53992 0.007264999\nGLUL -0.186143 0.441918633\nLDHA -0.3643 0.008016141\nGNB2L1 -0.221323 0.17541377\nSSR2 0.155833 0.206185378\nP4HB 0.102844 0.460810058\nSLC25A5 1.18797 1.46646E-006\nPHB 1.09119 5.38242E-006\nS100A11 -0.384033 0.053297831\nCTSA -1.31832 1.80248E-006\nTOMM20 0.665788 0.000858059\nCD63 0.130533 0.277105219\nDNAJB1 -0.319313 0.06627331\nSPARC -7.12574 8.92E-012\nUBE2D3 -0.219397 0.234759421\nXBP1 0.248023 0.058975963\nSPTBN1 0.128562 0.331384532\nLAPTM4A -0.00956667 0.945267442\nRPL32 0.2884 0.04369448\nCD81 -0.600827 0.000448319\nUBE2L3 -0.303133 0.089191732\nPTTG1IP -1.50793 2.40782E-007\nGRN -0.572159 0.001921397\nHMGB1 -0.323129 0.130840018\nGLO1 -0.616 0.000533806\nSRSF11 0.377725 0.205440575\nSF3B3 0.453675 0.42755492\nEEF1G 0.3402 0.010252831\nHSPA9 0.329844 0.078140875\nYWHAQ 0.151511 0.317670372\nDDX24 -0.015895 0.947906314\nPPP2R1A -0.168627 0.164282554\nGSN -0.155319 0.366016471\nHK1 -1.4926 3.83143E-007\nKDELR2 -0.475156 0.051669981\nNPC2 -2.14345 1.18E-008\nDYNLL1 0.285133 0.032426975\nLITAF 0.438753 0.208190233\nEEF1B2 0.8761 2.55533E-005\nPRKCSH -0.6691 0.000764573\nGOT2 1.11055 4.02625E-006\nFKBP1A -0.274925 0.337897072\nACADVL 0.233153 0.099844229\nMAPRE1 0.686903 0.00054694\nOS9 -0.0481833 0.722060662\nRPL13A 0.284813 0.205494864\nRPL7 0.182261 0.325955815\nSKP1 0.324305 0.236357921\nACTR1A 0.00701333 0.41063117\nCAPRIN1 -0.0756775 0.265450691\nRPL10 0.314909 0.266143003\nPPP1CC 0.90948 0.000271345\nACTR2 0.539128 0.259394627\nPTP4A1 1.34412 2.95082E-005\nNACA 0.146933 0.204777375\nGPX1 0.58792 0.000571217\nPGK1 0.077622 0.543975903\nSUMO3 -0.74094 0.000462471\nRPS27 0.156367 0.216613307\nTPP1 -0.190508 0.287396855\nGNB1 -0.775873 0.000614581\nNUMA1 -0.256197 0.207643457\nFTH1 0.638925 0.007875137\nRAN 0.644987 0.002167102\nCAPN1 -0.425 0.039055033\nSRSF2 0.587609 0.00200526\nCALU -0.80959 0.102828495\nNFE2L1 0.379876 0.020575122\nARL6IP5 0.16703 0.269154279\nDPYSL2 1.12386 4.61237E-006\nRPLP1 0.305512 0.071152018\nCTNNA1 -0.346662 0.186656622\nCTSD -0.468024 0.181177802\nFAM120A 0.340408 0.295456567\nMAT2A 0.593022 0.01582377\nLAMC1 -1.3341 1.94946E-005\nPTMA 0.392778 0.082706379\nBZW1 -0.346317 0.02196343\nATF4 -0.9945 8.02291E-005\nGNAS -0.810138 0.20813438\nRPS15A 0.730554 0.1389
335213871\nANXA5 -0.519733 0.001151646\nSTMN1 -0.538073 0.001728681\nLRP1 0.05776 0.185113953\nPSMB7 -0.337301 0.365991959\nPEA15 -2.24142 1.46027E-006\nECH1 1.13856 6.81732E-006\nODC1 0.289067 0.039305388\nIQGAP1 0.177433 0.510863233\nXRCC6 -0.141225 0.516937712\nACO2 -0.0722 0.341954093\nDAZAP2 0.843303 0.071669302\nSPARCL1 -0.0781867 0.587774759\nMCL1 0.39645 0.140852415\nACTB -0.433411 0.005604993\nSARS -0.788127 0.013318383\nTMBIM6 0.48855 0.014478859\nLMAN2 0.004445 0.825075469\nHSPD1 0.0257767 0.466076605\nZYX -1.70651 4.63389E-006\nCIRBP 0.439345 0.161977884\nCCT7 1.10031 0.000009616\nPAFAH1B1 0.194113 0.472039399\nPSME1 -0.379333 0.006966668\nATP5O -0.138578 0.338776605\nRPS15 0.125465 0.356177469\nPSMD8 0.759267 0.000171213\nLAMP2 -0.280383 0.326751432\nTPI1 -0.150951 0.270462633\nGSTP1 0.754467 0.00115234\nHYOU1 -0.289537 0.07099077\nSNRPD2 0.3169 0.023007153\nPLOD1 -1.92146 7.45276E-007\nZNF207 0.635192 0.037931524\nPSMD2 -0.0357 0.805662426\nSCD -0.442617 0.17678248\nRPS21 0.06446 0.590631835\nMAP4 -0.549848 0.171389484\nBCAP31 0.62705 0.000928206\nCTSB -0.435188 0.125664001\nEPRS -0.409111 0.253596521\nPRDX6 -0.144883 0.25633984\nPPP1CA 0.3665 0.015835088\nSARAF 0.77435 0.000470805\nAHCYL1 0.0601117 0.639584093\nIST1 0.513017 0.036898573\nGNB2 -0.38155 0.00855285\nH2AFZ 0.16395 0.194192414\nNCOR1 0.808456 0.130712753\nRPS8 0.0427667 0.72180122\nFLNA -0.771062 0.00026457\nCNOT1 0.743261 0.011715887\nDHCR24 -1.42519 1.28042E-006\nRAB11A 1.35494 3.88214E-006\nPSAP -0.746433 0.000301459\nRNF114 -0.395076 0.046157107\nSTRAP 0.487503 0.084524696\nS100A10 0.745137 0.016233679\nCCT8 -0.141167 0.545218748\nNOP56 -0.01289 0.339654895\nPSMB1 -0.113422 0.309616141\nCCT4 0.496537 0.087336117\nEPAS1 -0.28633 0.129467177\nDNAJA1 0.679792 0.000358307\nPSMD4 0.0691433 0.528819731\nUQCRC2 0.8012 0.018612024\nCKB -0.639037 0.000989962\nPPM1J -0.729897 0.003977337\nPGAM1 -0.817433 4.53074E-005\nSTAT1 -2.68292 2.53382E-006\nRPL23 1.02647 0.001447774\nSSR1 0.143187 0.305467631\nTRA2B 0.335923 0.177056968\nFKBP4 0.613171 0.005215262\nHDGF -0.396933 0.022119929\nPALLD 0.309839 0.09279698\nMGEA5 -0.276661 0.356292221\nM6PR 0.0401617 0.635085257'}; 3353 } else if (mode=='all'){ 3354 // $scope.newGene= {content:'LIMA1,TMPO,KHSRP,CSRP1,AKR1C1,BRAF,CAPN1,CDK1,CLTA,CSRP1,AKR1C1,DYRK1A'}; 3355 $scope.newGene= {content:'ESR1,GREB1,LRRC6,GPR143,CCDC170,SCUBE2,ABAT,ST6GALNAC2,CACNA2D2,RHOH,TFF3,IQSEC1,CLSTN2,REPS2,CACNA1H,MRFAP1L1,ATP7B,CA5B,ARMT1,PRLR,CACNG4,XBP1,CRYL1,SLC9A2,ANXA9,ZMAT4,KIAA1324,KIAA1467,SULT2B1,BCAS1,MED13L,SEPT8,ADD1,ZFYVE21,BCAS3,CYFIP2,CHRD,COX6C,TOB1,MREG,SIAH2,GHR,GATA3,KDM2A,COLQ,HTT,SCGN,CA12,KIF16B,PVALB,SOX2,SIRT4,CBFA2T3,BEX4,GPD1L,SPDEF,TGFB3,KIAA0513,ASTN2,RAB5B,SHROOM2,SUOX,CYP46A1,CLU,EFHD1,ASAH1,SIDT1,SLC22A5,ALDH3B2,RHOB,KDM5B,MAGED2,SLC7A8,GADD45G,NCAM2,ETNK2,PTGER3,MCCC2,SUPT4H1,CTPS2,GRIK4,SLC1A2,TCTN1,CERS4,TTC39A,ELOVL2,IGSF3,C11orf80,SLC35E3,ALDH6A1,ADIRF,CPT1A,KIAA0100,ARSD,UNC13B,LCMT1,SNF8,HOXC4,IGFBP2,ZNF652,SLC35G2,THEMIS2,MED17,CDKL1,CCDC88A,STAC,IFI16,MICAL2,GSTP1,SNRNP40,GNAI1,HOXA7,PRKCDBP,BATF3,ETV4,YEATS2,SNAI2,RASAL2,USB1,ISG15,GART,AKR1C1,BIRC3,SKI,CSRP2,TGFBI,TRIP10,PTX3,FST,MMP14,COLGALT1,HPSE,C1R,FXYD5,MICALL1,PSAT1,CERK,GLIPR1,CAPN2,SPTBN1,GPX1,NASP,PRSS12,SPRY2,EPHA2,DSE,TOMM22,MIEF1,PTK7,BCL11A,IGFBP7,MAP1B,COL4A1,FOSL1,TAP2,CSNK1E,SPCS3,POLR2F,JOSD1,BTG3,MEIS2,PHC2,CAV1,NRP2,MAP7D1,SERPINB7,LUZP1,MDFIC,TINAGL1,ADAM19,EGFR,CXCL3,HDAC9,CAV2,ADCY7,SERPINB8,SLC7A1,GPR3,STX11,SRSF4,CASP4,PLAUR,NABP1,ACSL5,BIN1,FSCN1,MSN,TNFAIP3,PIK3CD,YBX1,ETS1,AGPAT4,PDGFC,CXCL8,CXCL2,COL4A2,HRH1,GADD45A,SDHAF3,CTSC'}; 3356 } else { 3357 // if (direction==='up') 3358 // $scope.upGene= {content:'LIMA1,TMPO,KHSRP,CSRP1,AKR1C1'}; 3359 $scope.upGene= {content:'ESR1,GREB1,LRRC6,GPR143,CCDC170,SCUBE2,ABAT,ST6GALNAC2,CACNA2D2,RHOH,TFF3,IQSEC1,CLSTN2,REPS2,CACNA1H,MRFAP1L1,ATP7B,CA5B,ARMT1,PRLR,CACNG4,XBP1,CRYL1,SLC9A2,ANXA9,ZMAT4,KIAA1324,KIAA1467,SULT2B1,BCAS1,MED13L,SEPT8,ADD1,ZFYVE21,BCAS3,CYFIP2,CHRD,COX6C,TOB1,MREG,SIAH2,GHR,GATA3,KDM2A,COLQ,HTT,SCGN,CA12,KIF16B,PVALB,SOX2,SIRT4,CBFA2T3,BEX4,GPD1L,SPDEF,TGFB3,KIAA0513,ASTN2,RAB5B,SHROOM2,SUOX,CYP46A1,CLU,EFHD1,ASAH1,SIDT1,SLC22A5,ALDH3B2,RHOB,KDM5B,MAGED2,SLC7A8,GADD45G,NCAM2,ETNK2,PTGER3,MCCC2,SUPT4H1,CTPS2,GRIK4,SLC1A2,TCTN1,CERS4,TTC39A,ELOVL2,IGSF3,C11orf80,SLC35E3,ALDH6A1,ADIRF,CPT1A,KIAA0100,ARSD,UNC13B,LCMT1,SNF8,HOXC4,IGFBP2,ZNF652'}; 3360 // else if (direction==='down') 3361 // $scope.downGene= {content:'BRAF,CAPN1,CDK1,CLTA,CSRP1,AKR1C1,DYRK1A'}; 3362 $scope.downGene= {content:'SLC35G2,THEMIS2,MED17,CDKL1,CCDC88A,STAC,IFI16,MICAL2,GSTP1,SNRNP40,GNAI1,HOXA7,PRKCDBP,BATF3,ETV4,YEATS2,SNAI2,RASAL2,USB1,ISG15,GART,AKR1C1,BIRC3,SKI,CSRP2,TGFBI,TRIP10,PTX3,FST,MMP14,COLGALT1,HPSE,C1R,FXYD5,MICALL1,PSAT1,CERK,GLIPR1,CAPN2,SPTBN1,GPX1,NASP,PRSS12,SPRY2,EPHA2,DSE,TOMM22,MIEF1,PTK7,BCL11A,IGFBP7,MAP1B,COL4A1,FOSL1,TAP2,CSNK1E,SPCS3,POLR2F,JOSD1,BTG3,MEIS2,PHC2,CAV1,NRP2,MAP7D1,SERPINB7,LUZP1,MDFIC,TINAGL1,ADAM19,EGFR,CXCL3,HDAC9,CAV2,ADCY7,SERPINB8,SLC7A1,GPR3,STX11,SRSF4,CASP4,PLAUR,NABP1,ACSL5,BIN1,FSCN1,MSN,TNFAIP3,PIK3CD,YBX1,ETS1,AGPAT4,PDGFC,CXCL8,CXCL2,COL4A2,HRH1,GADD45A,SDHAF3,CTSC'}; 3363 } 3364 3365 } 3366 3367 $scope.submitSignature = function(signature){ 3368 $scope.submittingSignature=true; 3369 // console.log(signature); 3370 var fileContent,parsedSignature,firstLine; 3371 3372 parsedSignature=signature; 3373 parsedSignature=parsedSignature.replace( /\t/g, "," ); 3374 // parsedSignature=parsedSignature.replace( /\s/g, "," ); 3375 parsedSignature=parsedSignature.replace( /[;]/g, "," ); 3376 3377 firstLine=parsedSignature.split("\n")[0]; 3378 // console.log(firstLine); 3379 // console.log(firstLine.split(",").length); 3380 // console.log(firstLine.split(",")[0]); 3381 // console.log(!(firstLine.split(",")[0]=="Name_GeneSymbol"||firstLine.split(",")[0]=="ID_geneid")); 3382 if (!(firstLine.split(",")[0]=="Name_GeneSymbol"||firstLine.split(",")[0]=="ID_geneid")) { 3383 if (firstLine.split(",").length==3){ 3384 fileContent="Name_GeneSymbol,Value_LogDiffExp,Significance_pvalue\n"; 3385 } else if (firstLine.split(",").length==4){ 3386 fileContent="ID_geneid,Name_GeneSymbol,Value_LogDiffExp,Significance_pvalue\n"; 3387 } else { 3388 fileContent="Name_GeneSymbol,Value_LogDiffExp\n"; 3389 } 3390 } 3391 3392 3393 // console.log(parsedSignature); 3394 fileContent=fileContent+parsedSignature; 3395 // console.log(fileContent); 3396 var uploadDate=new Date().toJSON().slice(0,19).replace(/:/g,'_').replace(/-/g,'_'); 3397 // console.log(uploadDate); 3398 var fileName ="signatureUploaded"+uploadDate+".txt"; 3399 var file = new File([fileContent],fileName ); 3400 3401 var fd = new FormData(); 3402 // fd.append('distance-type', 'correlation'); 3403 // fd.append('linkage-type', 'complete'); 3404 fd.append('file', file); 3405 $http.post("/api/SignatureUploads/uploadToiLINCS", fd, { 3406 headers: {'Content-Type': undefined} 3407 }) 3408 .then(function onSuccess(resp) { 3409 // console.log(resp.data); 3410 $scope.submittingSignature=false; 3411 // var clustergrammerWindow = window.open('#', '_blank'); 3412 historyFactory.saveResultInSessionHistory('signatureUploadHistory',resp.data.id); 3413 // window.location.href = resp.data.url; 3414 // window.location.href = "http://"+window.location.host+"/ilincs/uploadedSignature/"+resp.data.id; 3415 $state.transitionTo('uploadedSignature',{file:resp.data.id}); 3416 }, function onError(resp) { 3417 console.log(resp.status,resp.statusText); 3418 // $scope.creatingClusterGrammer=false; 3419 }); 3420 } 3421 3422 $scope.submitSignatureUpDown = function(upGenes,downGenes){ 3423 $scope.submittingSignatureUpDown=true; 3424 // console.log(upGenes); 3425 // console.log(downGenes); 3426 // console.log("submitSignatureUpDown"); 3427 var fileContent; 3428 fileContent="Name_GeneSymbol\tValue_LogDiffExp\n"; 3429 // fileContent=fileContent+"LIMA1\t1\n" 3430 // fileContent=fileContent+"TMPO\t1\n" 3431 // fileContent=fileContent+"KHSRP\t1\n" 3432 // fileContent=fileContent+"BRAF\t-1\n" 3433 // fileContent=fileContent+"CAPN1\t-1\n" 3434 // fileContent=fileContent+"CDK1\t-1\n" 3435 var parsedUpGenes=upGenes.replace( /\n/g, "," ); 3436 parsedUpGenes=parsedUpGenes.replace( /\t/g, "," ); 3437 parsedUpGenes=parsedUpGenes.replace( /\s/g, "," ); 3438 parsedUpGenes=parsedUpGenes.replace( /[;]/g, "," ); 3439 // parsedUpGenes=parsedUpGenes.toUpperCase(); 3440 var parsedDownGenes=downGenes.replace( /\n/g, "," ); 3441 parsedDownGenes=parsedDownGenes.replace( /\t/g, "," ); 3442 parsedDownGenes=parsedDownGenes.replace( /\s/g, "," ); 3443 parsedDownGenes=parsedDownGenes.replace( /[;]/g, "," ); 3444 // parsedDownGenes=parsedDownGenes.toUpperCase(); 3445 if (upGenes) var upGenesArr=parsedUpGenes.split(","); 3446 if (downGenes) var downGenesArr=parsedDownGenes.split(","); 3447 angular.forEach(upGenesArr, function(gene) { 3448 fileContent=fileContent+gene+"\t1\n"; 3449 }); 3450 angular.forEach(downGenesArr, function(gene) { 3451 fileContent=fileContent+gene+"\t-1\n"; 3452 }); 3453 3454 // console.log(fileContent); 3455 var fileName ="up"+upGenesArr.length+"Down"+downGenesArr.length+"Genes.txt"; 3456 var file = new File([fileContent],fileName ); 3457 3458 var fd = new FormData(); 3459 // fd.append('distance-type', 'correlation'); 3460 // fd.append('linkage-type', 'complete'); 3461 fd.append('file', file); 3462 $http.post("/api/SignatureUploads/uploadToiLINCS", fd, { 3463 headers: {'Content-Type': undefined} 3464 }) 3465 .then(function onSuccess(resp) { 3466 // console.log(resp.data); 3467 $scope.submittingSignatureUpDown=false; 3468 // var clustergrammerWindow = window.open('#', '_blank'); 3469 historyFactory.saveResultInSessionHistory('signatureUploadHistory',resp.data.id); 3470 // window.location.href = resp.data.url; 3471 // window.location.href = "http://"+window.location.host+"/ilincs/uploadedSignature/"+resp.data.id; 3472 $state.transitionTo('uploadedSignature',{file:resp.data.id,foldchange:[0,0]}); 3473 }, function onError(resp) { 3474 console.log(resp.status,resp.statusText); 3475 // $scope.creatingClusterGrammer=false; 3476 }); 3477 3478 } 3479 3480 $scope.submitSignatureList = function(genes){ 3481 // console.log("submitSignatureList"); 3482 // 3483 // console.log(genes); 3484 var parsedGenes=genes.replace( /\n/g, "," ); 3485 parsedGenes=parsedGenes.replace( /\t/g, "," ); 3486 parsedGenes=parsedGenes.replace( /\s/g, "," ); 3487 parsedGenes=parsedGenes.replace( /[;]/g, "," ); 3488 // console.log(parsedGenes); 3489 GeneInfo.find({filter:{where:{and:[{symbol:{"inq":parsedGenes.split(",")}},{taxid:9606}]},fields:["geneid"]}}, 3490 function(data){ 3491 // console.log(data); 3492 // console.log(data.geneid); 3493 // return data.geneid; 3494 // return onSuccess(data.geneid); 3495 var ids = data.map(function(a) {return a.geneid;}); 3496 // return onSuccess(ids); 3497 // console.log(ids); 3498 GeneList.create({ content: ids }).$promise 3499 .then(function(data) { 3500 // console.log("GeneList Data"); 3501 // console.log(data); 3502 $scope.GeneListNum = data.id; 3503 historyFactory.saveResultInSessionHistory('geneListHistory',data.id); 3504 // $scope.geneList = data.content; 3505 // $scope.datasets = data.result; 3506 // creatEsetWithInfo($scope.geneListData.content); 3507 // $state.go('analyzeWithGenes.signaturesAnalysisResults',{SignatureListNumber:$scope.SigListNum}); 3508 // if (dataset) { 3509 // $state.go('analyzeWithGenes.lincs',{geneListNum:$scope.GeneListNum}); 3510 // } else { 3511 // $state.go('analyzeWithGenes.lincs',{geneListNum:$scope.GeneListNum}); 3512 $state.go('analyzeWithGenes.signatures.enrichment',{geneListNum:$scope.GeneListNum}); 3513 // } 3514 });; 3515 }, 3516 function(errorResponse){ 3517 console.log("Genes not found."); 3518 console.log(errorResponse); 3519 return onError(); 3520 }); 3521 3522 } 3523 3524 $scope.clearSignatureTextbox = function(mode){ 3525 switch (mode) { 3526 case 'signature': 3527 $scope.newSignature.content = ""; 3528 break; 3529 case 'upDn': 3530 $scope.upGene.content = ""; 3531 $scope.downGene.content = ""; 3532 break; 3533 case 'geneList': 3534 $scope.newGene.content = ""; 3535 break; 3536 } 3537 } 3538 3539 // $scope.$watch('signaturesF.signatureLibrariesReady', function(newValue, oldValue) { 3540 // console.log('watch firred on signaturesF.signatureLibrariesReady'); 3541 // // if (newValue !== oldValue) { 3542 // // $log.log('Changed!'); 3543 // // } 3544 // console.log($scope.signaturesF.signatureLibraries);
3545 // console.log($scope.signaturesF.libraryIDs); 3546 // if ($scope.signaturesF.signatureLibrariesReady) { 3547 // $scope.PieLabels = [];//['test']; 3548 // $scope.PieData = [];//[12312]; 3549 // angular.forEach($scope.signaturesF.libraryIDs, function(lib) { 3550 // $scope.PieLabels.push($scope.signaturesF.signatureLibraries[lib].libraryName); 3551 // $scope.PieData.push($scope.signaturesF.signatureLibraries[lib].signatureCount); 3552 // }); 3553 // } 3554 // }); 3555 3556 $scope.getPieData = function(mode){ 3557 3558 // $scope.PieLabels = ["LINCS individual shRNA signatures", "LINCS consensus (CGS) gene knockdown signatures", "LINCS chemical perturbagen signatures","LINCS RNA-Seq signatures","Cancer Therapeutics Response signatures","Disease Related Signatures","ENCODE Transcription Factor Binding Signatures","Connectivity Map Signatures","LINCS targeted protein signatures"]; 3559 // // $scope.PieData = [113735, 33410, 68960,222, 9097, 494, 519]; 3560 // $scope.PieData = [113735, 33410, 68960,253,481, 9097, 494, 519, 725]; 3561 setTimeout(function() { 3562 console.log($scope.signaturesF.signatureLibraries); 3563 console.log($scope.signaturesF.libraryIDs); 3564 $scope.PieLabels = [];//['test']; 3565 $scope.PieData = [];//[12312]; 3566 angular.forEach($scope.signaturesF.libraryIDs, function(lib) { 3567 console.log($scope.signaturesF.signatureLibraries[lib].libraryName); 3568 console.log($scope.signaturesF.signatureLibraries[lib].signatureCount); 3569 $scope.PieLabels.push($scope.signaturesF.signatureLibraries[lib].libraryName); 3570 $scope.PieData.push($scope.signaturesF.signatureLibraries[lib].signatureCount); 3571 }); 3572 // // getEnrichedSignaturesInLib("LIB_1",$scope.geneList); 3573 }, 500); 3574 3575 3576 // if (mode=='data') { 3577 // return [113735, 33410, 68960,253,481, 9097, 494, 519, 725]; 3578 // } else { 3579 // return ["LINCS individual shRNA signatures", "LINCS consensus (CGS) gene knockdown signatures", "LINCS chemical perturbagen signatures","LINCS RNA-Seq signatures","Cancer Therapeutics Response signatures","Disease Related Signatures","ENCODE Transcription Factor Binding Signatures","Connectivity Map Signatures","LINCS targeted protein signatures"]; 3580 // } 3581 // 3582 } 3583 3584 3585 $scope.createLibPieChart = function(){ 3586 $scope.sigLibPlot={}; 3587 // $scope.sigLibPlot.data = [{ 3588 // values: [19, 26, 55], 3589 // labels: ['Residential', 'Non-Residential', 'Utility'], 3590 // type: 'pie' 3591 // }]; 3592 $scope.sigLibPlot.layout = { 3593 margin: {l: 0,r: 0,b: 75,t: 25,pad: 5}, 3594 height: 300 3595 //width: 500 3596 }; 3597 3598 3599 // setTimeout(function() { 3600 // $scope.PieLabels = [];//['test']; 3601 // $scope.PieData = [];//[12312]; 3602 // angular.forEach($scope.signaturesF.libraryIDs, function(lib) { 3603 // $scope.PieLabels.push($scope.signaturesF.signatureLibraries[lib].libraryName); 3604 // $scope.PieData.push($scope.signaturesF.signatureLibraries[lib].signatureCount); 3605 // }); 3606 // $scope.sigLibPlot.data = [{ 3607 // values: $scope.PieData, 3608 // labels: $scope.PieLabels, 3609 // type: 'pie' 3610 // }]; 3611 // $scope.sigLibPlot.ready =true; 3612 // }, 500); 3613 3614 signatures.getSignatureLibrariesStats(function(counts,labels,IDs) { 3615 // console.log("success callback"); 3616 $scope.PieLabels = labels; 3617 $scope.PieData = counts; 3618 console.log($scope.PieLabels); 3619 console.log($scope.PieData); 3620 3621 $scope.sigLibPlot.data = [{ 3622 values: $scope.PieData, 3623 labels: $scope.PieLabels, 3624 ids: IDs, 3625 textinfo: 'value', 3626 type: 'pie' 3627 }]; 3628 $scope.sigLibPlot.ready =true; 3629 },function(error) { 3630 console.log(error); 3631 $scope.errorStats=true; 3632 }); 3633 } 3634 3635 $scope.plotlyEventsPie = function (graph){ 3636 // console.log("plotly event emitted"); 3637 $scope.graphPie=graph; 3638 graph.on('plotly_click', function(data){ 3639 console.log("plotly event: plotly_click emitted"); 3640 3641 var pts = ''; 3642 for(var i=0; i < data.points.length; i++){ 3643 // console.log(data.points[i]); 3644 $scope.activeLibs=data.points[i].id; 3645 localStorage.setObj('ActiveLibs', $scope.activeLibs); 3646 $state.transitionTo('signatures.searchTerm',{term:null,libs:$scope.activeLibs},{reload: true}); 3647 } 3648 $scope.$apply(); 3649 }); 3650 graph.on('plotly_legendclick', function(data){ 3651 console.log("plotly event: plotly_legendclick emitted"); 3652 3653 // var pts = ''; 3654 // for(var i=0; i < data.points.length; i++){ 3655 // console.log(data.points[i]); 3656 // } 3657 $scope.$apply(); 3658 3659 }); 3660 } 3661 3662 $scope.changePageStateParams = function(part,data) { 3663 // console.log("changePageStateParams"); 3664 // window.location.hash = data; 3665 // console.log(part); 3666 // console.log($state.$current.url.pattern); 3667 // $state.go($state.$current.name+'?mainTab=data, null', { location: 'replace'}) 3668 // $state.go($state.$current.name,{[part]:data}, { location: 'replace'}); 3669 $state.go($state.$current.name,{[part]:data}, { location: 'replace'}); 3670 // $state.$current.params.push({[part]:data}); 3671 // $state.$current.params[part]=data; 3672 // console.log($state.$current.params); 3673 3674 3675 3676 // ui-sref="signature({mainTab:2})" ui-sref-opts="{location:'replace'}" 3677 }; 3678 //end of function section 3679 // console.info("current state",$state.$current.name); 3680 // debugger; 3681 // console.log("SignaturesController"); 3682 3683 if (envService.is('production')) { 3684 $scope.environment="production"; 3685 $scope.prodEnv=true; 3686 } 3687 else { 3688 $scope.environment="development"; 3689 $scope.prodEnv=false; 3690 } 3691 // $scope.delay={ show: 500, hide: 100 }; 3692 // $scope.delay=[500,100]; 3693 $scope.delay=500; 3694 // console.log($scope.delay); 3695 $scope.debug =false;//true; 3696 $scope.genesF=genes; 3697 $scope.modalsF=modals; 3698 $scope.signaturesF =signatures; 3699 console.log($scope.signaturesF); 3700 // $scope.libIDs = signatures.libIDs(); 3701 // console.log($state.current.name); 3702 if ($state.current.name=="signatures.search") 3703 { 3704 // console.log($scope.signaturesF.signatureLibrariesReady); 3705 3706 // $scope.getPieData(); 3707 $scope.createLibPieChart(); 3708 // $scope.signatureLibrariesReady=$scope.signaturesF.signatureLibrariesReady; 3709 3710 // $scope.PieLabels = ["LINCS individual shRNA signatures", "LINCS consensus (CGS) gene knockdown signatures", "LINCS chemical perturbagen signatures","LINCS RNA-Seq signatures","Cancer Therapeutics Response signatures","Disease Related Signatures","ENCODE Transcription Factor Binding Signatures","Connectivity Map Signatures","LINCS targeted protein signatures"]; 3711 // // $scope.PieData = [113735, 33410, 68960,222, 9097, 494, 519]; 3712 // $scope.PieData = [113735, 33410, 68960,253,481, 9097, 494, 519, 725]; 3713 // // $scope.PieData = [Math.log(113735), Math.log(33410), Math.log(68960),Math.log(222), Math.log(9097), Math.log(494), Math.log(519)]; 3714 // $scope.ChartType = 'polarArea'; 3715 } 3716 3717 if ($state.current.name=="allsignatures") 3718 { 3719 $scope.allsignatures = []; 3720 $scope.filterSig=[]; 3721 $scope.filterBy={}; 3722 $scope.filterByDown={}; 3723 $scope.dataLoading = true; 3724 $scope.sigDownShow = false;
3725 $scope.sigDownManyShow = false; 3726 getSignatures(); 3727 }; 3728 if ($state.current.name=="concordantTo") 3729 { 3730 $scope.comparedTosignature=$state.params.signature; 3731 getConcordantTo($scope.comparedTosignature); 3732 }; 3733 if ($state.current.name=="lincs.searchFor"||$state.current.name=="analyzeWithGenes.signatures.searchFor"||$state.current.name=="analyzeWithGenes.signatures.searchInLibs"||$state.current.name=="analyzeWithGenes.signatures.enrichment") 3734 { 3735 3736 $scope.allsignatures = []; 3737 $scope.filterSig=[]; 3738 $scope.filterBy={}; 3739 $scope.filterByDown={}; 3740 $scope.dataLoading = true; 3741 $scope.sigDownShow = false; 3742 $scope.sigDownManyShow = false; 3743 $scope.searchTerm=$state.params.term; 3744 3745 if ($state.current.name=="lincs.searchFor"){ 3746 searchSignatures($scope.searchTerm,false); 3747 } 3748 3749 if ($state.current.name=="analyzeWithGenes.signatures.searchFor") 3750 { 3751 console.log("test"); 3752 getGeneList(); 3753 searchSignatures($scope.searchTerm,true); 3754 // console.log("trying to refresh parrent view"); 3755 // $scope.childViewUpdate = function () { 3756 // // do update 3757 // $resolve.resolve($state.$current.parent.resolve) 3758 // } 3759 } 3760 if ($state.current.name=="analyzeWithGenes.signatures.searchInLibs") 3761 { 3762 // console.log($state.params.libs); 3763 // $scope.visibleSigs=""; 3764 $scope.displayedRows=[]; 3765 if ($state.params.libs) $scope.activeLibs=$state.params.libs; 3766 else $scope.activeLibs=["LIB_1","LIB_2","LIB_3","LIB_5","LIB_6","LIB_7","LIB_8"]; 3767 // $scope.activeLibs=["LIB_1","LIB_2"]; 3768 // console.log($scope.activeLibs); 3769 getGeneList(); 3770 angular.forEach($scope.activeLibs, function(lib) { 3771 searchSignaturesInLib($scope.searchTerm,lib,true); 3772 }) 3773 // console.log("trying to refresh parrent view"); 3774 // $scope.childViewUpdate = function () { 3775 // // do update 3776 // $resolve.resolve($state.$current.parent.resolve) 3777 // } 3778 } 3779 3780 if ($state.current.name=="analyzeWithGenes.signatures.enrichment"){ 3781 3782 // angular.forEach($scope.activeLibs, function(lib) { 3783 // searchSignaturesInLib($scope.searchTerm,lib,true); 3784 // }) 3785 // getEnrichedSignaturesInLib("LIB_1",getGeneList()); 3786 $scope.pass={}; 3787 $scope.pass.resolvedE=false; 3788 $scope.pass.rowsE=0; 3789 $scope.uploadedSignatures=true; 3790 // getGeneList(); 3791 $scope.geneList=genes.getGeneList($state.params.geneListNum); 3792 // console.info("genes from service",$scope.geneList); 3793 3794 // if ($scope.geneList) { 3795 // console.log("genes are here"); 3796 // getEnrichedSignaturesInLib("LIB_1",getGeneList()); 3797 // } else { 3798 // console.log("waiting for genes"); 3799 // // console.log($scope.geneList.length); 3800 // setTimeout(function() { 3801 // // console.log($scope.geneList); 3802 // getEnrichedSignaturesInLib("LIB_1",$scope.geneList); 3803 // }, 500); 3804 // } 3805 } 3806 }; 3807 3808 if ($state.current.name=="analyzeWithGenes.signaturesAnalysisResults") { 3809 // debugger; 3810 $scope.stateWithGenes=true; 3811 // getGeneList(); 3812 // $scope.stateName="signaturesAnalysisResults"; 3813 // console.log($state.params.SignatureListNumber); 3814 getSignatureListAndAnalyze($state.params.SignatureListNumber); 3815 } 3816 3817 if ($state.current.name=="signaturesAnalysisResults") { 3818 // getGeneList(); 3819 // $scope.stateName="signaturesAnalysisResults"; 3820 // console.log($state.params.SignatureListNumber); 3821 $scope.noOfGenes=$state.params.noOfGenes; 3822 3823 3824 // console.log($state.params.noOfGenes); 3825 // debugger; 3826 if ($state.params.file) { 3827 $scope.file=$state.params.file; 3828 goGroupAnalyze($state.params.SignatureListNumber,$state.params.noOfGenes,$scope.file); 3829 } else { 3830 goGroupAnalyze($state.params.SignatureListNumber,$state.params.noOfGenes); 3831 } 3832 } 3833 3834 if ($state.current.name=="lincs.searchResult") 3835 { 3836 $scope.allsignatures = []; 3837 $scope.filterSig=[]; 3838 $scope.filterBy={}; 3839 $scope.filterByDown={}; 3840 $scope.dataLoading = true; 3841 $scope.sigDownShow = false;
3842 $scope.sigDownManyShow = false; 3843 getSearchTerm($state.params.id); 3844 }; 3845 3846 3847 if ($state.current.name=="signatures.searchInLibs") 3848 { 3849 // console.log("we're here"); 3850 $scope.allsignatures = []; 3851 $scope.filterSig=[]; 3852 $scope.filterBy={}; 3853 $scope.filterByLib7={}; 3854 $scope.filterByDown={}; 3855 $scope.dataLoading = true; 3856 $scope.sigDownShow = false; 3857 $scope.sigDownManyShow = false; 3858 $scope.searchTerm=$state.params.term; 3859 3860 $scope.searched=true; 3861 3862 // if ($state.current.name=="signatures.searchInLibs") 3863 // { 3864 // console.log($state.params.libs); 3865 // $scope.visibleSigs=""; 3866 $scope.displayedRows=[]; 3867 3868 // try if it works for everything 3869 // if ($state.params.libs) $scope.activeLibs=$state.params.libs; 3870 // else $scope.activeLibs=["LIB_1","LIB_2","LIB_3","LIB_5","LIB_6","LIB_7","LIB_8"]; 3871 3872 // console.log($state.params); 3873 // console.log($state.current); 3874 // console.log($scope.displayedLibrary); 3875 3876 3877 // angular.forEach($scope.activeLibs, function(lib) { 3878 // // if ($scope.searchTerm.length>1){ 3879 // 3880 // searchSignaturesInLib($scope.searchTerm,lib,true); 3881 // // } else { 3882 // // // console.log("empty keyword"); 3883 // // searchSignaturesInLib($scope.searchTerm,lib,true,1000); 3884 // // } 3885 // // console.log($scope.displayedLibrary); 3886 // }); 3887 // debugger; 3888 // console.log($scope.currentLibrary); 3889 if ($scope.currentLibrary) { 3890 // console.log("lib is here"); 3891 searchSignaturesInLib($scope.searchTerm,$scope.currentLibrary,true); 3892 } else { 3893 // console.log("waiting for lib"); 3894 // console.log($scope.foundSignatures.length); 3895 setTimeout(function() { 3896 // console.log($scope.geneList); 3897 searchSignaturesInLib($scope.searchTerm,$scope.currentLibrary,true); 3898 }, 500); 3899 } 3900 // }); 3901 3902 3903 // } 3904 }; 3905 3906 3907 if ($state.current.name=="signatures.searchLincsPertId") 3908 { 3909 // console.log("we're here"); 3910 $scope.allsignatures = []; 3911 $scope.filterSig=[]; 3912 $scope.filterBy={}; 3913 $scope.filterByDown={}; 3914 $scope.dataLoading = true; 3915 $scope.sigDownShow = false; 3916 $scope.sigDownManyShow = false; 3917 $scope.searchTerm=$state.params.term; 3918 3919 $scope.searched=true; 3920 $scope.displayedRows=[]; 3921 3922 // $scope.activeLibs=["LIB_5"]; 3923 3924 // try if it works for everything 3925 // if ($state.params.libs) $scope.activeLibs=$state.params.libs; 3926 // else $scope.activeLibs=["LIB_1","LIB_2","LIB_3","LIB_5","LIB_6","LIB_7","LIB_8"]; 3927 3928 // searchSignaturesInLib($scope.searchTerm,"LIB_5",true); 3929 3930 getLincsPertIdSignatures($scope.searchTerm,"LIB_5"); 3931 3932 }; 3933 3934 if ($state.current.name=="signaturesL1000.searchInLibs") 3935 { 3936 $scope.allsignatures = []; 3937 $scope.filterSig=[]; 3938 $scope.filterBy={}; 3939 $scope.filterByDown={}; 3940 $scope.dataLoading = true; 3941 $scope.sigDownShow = false;
3942 $scope.sigDownManyShow = false; 3943 $scope.searchTerm=$state.params.term; 3944 3945 $scope.searched=true; 3946 3947 3948 $scope.displayedRows=[]; 3949 3950 if ($state.params.libs) $scope.activeLibs=$state.params.libs; 3951 else $scope.activeLibs=["LIB_5"]; 3952 3953 3954 3955 angular.forEach($scope.activeLibs, function(lib) { 3956 searchSignaturesInLib($scope.searchTerm,lib,true); 3957 }) 3958 3959 // } 3960 }; 3961 3962 if ($state.current.name=="concordantSignatures"){ 3963 // debugger; 3964 3965 $scope.pass ={}; 3966 // $scope.pass.count=100; 3967 // $scope.pass.noOfRows =0; 3968 3969 3970 $scope.sigDownShow =false; 3971 $scope.filterSig=[]; 3972 $scope.filterBy={}; 3973 $scope.dataDownLoading =true; 3974 3975 var sigType=$state.params.signatureID.substring(0,3); 3976 if (sigType=="ENC") { 3977 $scope.sigENC=true; 3978 } else { 3979 $scope.sigENC=false; 3980 } 3981 // console.log($state.params.signatureID); 3982 getOneSignature($state.params.signatureID); 3983 getDownloadSignature($state.params.signatureID); 3984 3985 getConcordantSignatures($state.params.signatureID); 3986 // angular.forEach($scope.activeLibs, function(lib) { 3987 // // searchSignaturesInLib($scope.searchTerm,lib,true); 3988 // getConcordantSignatures($state.params.signatureID); 3989 // }) 3990 3991 // $scope.open($state.params.signatureID); 3992 3993 // $scope.legendTooltip = $sce.trustAsHtml(`<div style="display:block;"><ul class="legend"> 3994 // <li><span class="pos05"></span> top positive 0.5%</li> 3995 // <li><span class="pos10"></span> top positive 1.0%</li> 3996 // <li><span class="neg05"></span> top negative 1.0%</li> 3997 // <li><span class="neg10"></span> top negative 0.5%</li> 3998 // </ul></div>`); 3999 4000 // $scope.selectedIcon = "Gear"; 4001 // $scope.selectedIcons = []; 4002 // $scope.icons = [{"value":"Gear","label":"<i class=\"fa fa-gear\"></i> Gear"},{"value":"Globe","label":"<i class=\"fa fa-globe\"></i> Globe"},{"value":"Heart","label":"<i class=\"fa fa-heart\"></i> Heart"},{"value":"Camera","label":"<i class=\"fa fa-camera\"></i> Camera"}]; 4003 // $scope.selectedIcons = []; 4004 // $scope.concordanceDropDown = [{"value":"pos05","label":"<span class=\"legendDrop pos05\"></span> top 0.5%(+)"},{"value":"pos10","label":"<span class=\"legendDrop pos10\"></span> top 1.0%(+)"},{"value":"neg10","label":"<span class=\"legendDrop neg10\"></span> top 1.0%(-)"},{"value":"neg05","label":"<span class=\"legendDrop neg05\"></span> top 0.5%(-)"}]; 4005 } 4006 4007 if ($state.current.name=="signature"){ 4008 // debugger; 4009 // console.log(ngMeta); 4010 // console.log($location.$$path); 4011 $scope.generatingSignature=true; 4012 $scope.foldchange=$state.params.foldchange; 4013 $scope.sigcutoff=$state.params.sigcutoff; 4014 $scope.geneListId=$state.params.geneListId; 4015 ngMeta.setTitle('Signature info page of '+$state.params.signatureID); 4016 ngMeta.setTag('Canonical','/ilincs'+$location.$$path); 4017 // debugger; 4018 $scope.sigDownShow =false; 4019 $scope.filterSig=[]; 4020 $scope.filterBy={}; 4021 $scope.filterByDown={}; 4022 $scope.dataDownLoading =true; 4023 $scope.sigID =$state.params.signatureID; 4024 4025 var sigType=$state.params.signatureID.substring(0,3); 4026 if (sigType=="ENC") { 4027 $scope.sigENC=true; 4028 } else { 4029 $scope.sigENC=false; 4030 if (sigType=="CTR") { 4031 $scope.sigCTRS=true; 4032 } 4033 } 4034 var sigType=$state.params.signatureID.substring(0,7); 4035 // if (sigType=="LINCSTP") { 4036 // $scope.lib9=true; 4037 // } else { 4038 $scope.lib9=false; 4039 // } 4040 // console.log($state.params.signatureID); 4041 // console.log($state.params.sessionID); 4042 getOneSignature($state.params.signatureID); 4043 // console.log($state); 4044 getDownloadSignature($state.params.signatureID,true); 4045 if ($state.params.noOfTopGenes) { 4046 getDownloadSignature($state.params.signatureID,false,$state.params.noOfTopGenes); 4047 } else { 4048 if ($state.params.sessionID&&!($scope.geneListId||$scope.foldchange||$scope.sigcutoff)){ 4049 console.log("volcano mode"); 4050 $scope.fileName="genelist_volcano_"+$state.params.sessionID+".xls";//".csv";// 4051 $scope.signatureFileShort=$scope.fileName; 4052 $scope.fromVolcano=true; 4053 $scope.morpheusJson= encodeURIComponent(JSON.stringify({ 4054 // "dataset" :"http://dev.ilincs.org/tmp/iLincs/volcano/genelist_volcano_"+$state.params.sessionID+".gct", //gimm 6 ver 4055 "dataset" : "http://"+window.location.host+"/tmp/iLincs/volcano/genelist_volcano_"+$state.params.sessionID+".gct", //dev and www ver 4056 // "tools" :[{ name: "Hierarchical Clustering", params: {cluster: "Rows and columns",linkage_method: "Complete"} }], 4057 "colorScheme":{"valueToColorScheme":{"null":{"fractions":[0,0.5,1],"colors":["#0000ff","#000000","#fffe00"],"min":-2,"max":2,"missingColor":"#c0c0c0","scalingMode":1,"stepped":false,"transformValues":0}}}, 4058 "rows" : [ { "field" : "ID_geneid", "display" : ["text"] },{ "field" : "Name_GeneSymbol", "display" : ["text"] }] 4059 })); 4060 // console.log($scope.signatureFileShort); 4061 // console.log($scope.morpheusJson); 4062 downloadVolcanoData($scope.fileName); 4063 } else if ($scope.geneListId||$scope.foldchange||$scope.sigcutoff) { 4064 // console.log("here",$scope.geneListId); 4065 if ($scope.geneListId) { 4066 getGeneListCb($scope.geneListId,function(genes){ 4067 // console.log(genes); 4068 getDownloadSignature($state.params.signatureID,false,undefined,$scope.sigcutoff,$scope.foldchange,genes); 4069 },function(error){console.log(error);}) 4070 } else { 4071 getDownloadSignature($state.params.signatureID,false,undefined,$scope.sigcutoff,$scope.foldchange,undefined); 4072 } 4073 4074 } else { 4075 getDownloadSignature($state.params.signatureID,false,100); 4076 } 4077 4078 } 4079 4080 // getConcordantSignatures($state.params.signatureID); 4081 4082 // $scope.sigDownShow={}; 4083 // $scope.sigDownShow.opened=true; 4084 // $scope.showSignatureTab('full') 4085 // $scope.showSignatureTab('short'); 4086 $scope.showShortSig =false; 4087 $scope.sigDownShow = true; 4088 $scope.tabs={} 4089 // console.log($state.params.mainTab); 4090 var tab=parseInt($state.params.mainTab); 4091 if (tab>3||tab<0) tab=0 4092 $scope.tabs.activeSigTabs = tab||0; 4093 // console.log("activeSigTabs",$scope.tabs.activeSigTabs); 4094 // console.log($state.params.fullSig=="true" ? 0 : 1); 4095 // var whichSig = $state.params.fullSig=="true" ? 0 : 1 4096 // $scope.tabs.SigDataTabs = 0; 4097 // $scope.tabs.connectedSigTabs = 0; 4098 if ($state.params.selected==="true"||$state.params.selected==="t") { 4099 // console.log("showFull"); 4100 $scope.showSignatureTab('short',true) 4101 }// else { 4102 // $scope.showSignatureTab('full') 4103 // } 4104 4105 // console.log($scope.tabs); 4106 // $scope.signatureID=$state.params.signatureID; 4107 // 4108 // $scope.sessionID=$state.params.sessionID; 4109 4110 // $scope.fileName="genelist_volcano_"+$scope.sessionID+".csv"; 4111 4112 // downloadVolcanoData($scope.fileName); 4113 // getEnrichedSignatures(); 4114 // getConcordantSignatures($state.params.signatureID); 4115 4116 4117 // $scope.dataLoading=true; 4118 // getEnrichedSignatures($scope.volcanoGeneList); 4119 4120 } 4121 4122 if ($state.current.name=="analyzeSignature"){ 4123 // debugger; 4124 $scope.sigDownShow =false; 4125 $scope.filterSig=[]; 4126 // $scope.filterBy={}; 4127 $scope.filterByDown={}; 4128 $scope.dataDownLoading =true; 4129 $scope.signatureID=$state.params.signatureID; 4130 // $scope.fileName=$state.params.fileName; 4131 $scope.sessionID=$state.params.sessionID; 4132 // console.log($state.params.sessionID); 4133 $scope.fileName="genelist_volcano_"+$scope.sessionID+".xls";//".csv";// 4134 // console.log($scope.fileName); 4135 // console.log(typeof $scope.fileName); 4136 var sigType=$state.params.signatureID.substring(0,3); 4137 if (sigType=="ENC") { 4138 $scope.sigENC=true; 4139 } else { 4140 $scope.sigENC=false; 4141 if (sigType=="CTR") { 4142 $scope.sigCTRS=true; 4143 } 4144 } 4145 // console.log($state.params.signatureID); 4146 getOneSignature($state.params.signatureID); 4147 getDownloadSignature($state.params.signatureID,true); 4148 4149 // downloadVolcanoData($state.params.fileName); 4150 downloadVolcanoData($scope.fileName); 4151 // getEnrichedSignatures(); 4152 // getConcordantSignatures($state.params.signatureID); 4153 4154 } 4155 4156 4157 if ($state.current.name=="signatures.search"){ 4158 $scope.filterSig=[]; 4159 $scope.filterBy={}; 4160 $scope.showOldSigsLink=true; 4161 // $scope.showPharmActions=false; 4162 // $scope.getPharmActions(); 4163 4164 4165 } 4166 4167 if ($state.current.name=="signatures.search.pharmAction"||$state.current.name=="signatures.search.pharmAction.action"){ 4168 $scope.filterSig=[]; 4169 $scope.filterBy={}; 4170 $scope.uploadPrimary=false; 4171 $scope.pharmAction=true; 4172 $scope.showPharmActions=false; 4173 $scope.getPharmActions(); 4174 4175 4176 } 4177 if ($state.current.name=="signatures.search.moaAction"||$state.current.name=="signatures.search.moaAction.action"){ 4178 $scope.filterSig=[]; 4179 $scope.filterBy={}; 4180 $scope.uploadPrimary=false; 4181 $scope.moaAction=true; 4182 $scope.showMoaActions=false; 4183 $scope.getMOAs(); 4184 4185 } 4186 4187 if ($state.current.name=="signatures.search.knownTargetAction"||$state.current.name=="signatures.search.knownTargetAction.action"){ 4188 $scope.filterSig=[]; 4189 $scope.filterBy={}; 4190 $scope.uploadPrimary=false; 4191 $scope.knownTargetAction=true; 4192 $scope.showKnownTargetActions=false; 4193 $scope.getGeneTargets(); 4194 4195 } 4196 4197 if ($state.current.name=="signatures.search.upload"||$state.current.name=="signaturesUpload"){ 4198 //upload sisganture part 4199 // debugger; 4200 $scope.filterSig=[]; 4201 $scope.filterBy={}; 4202 $scope.upGene={}; 4203 $scope.downGene={}; 4204 $scope.newGene={}; 4205 // $scope.activeUploadLib="LIB_1"; 4206 // $scope.stateName=$state.current.name; 4207 $scope.uploadedSignatures=true; 4208 $scope.uploadPrimary=true; 4209 $scope.pharmAction=false; 4210 $scope.showUpload=false; 4211 $scope.showUploadList=false; 4212 $scope.noEmptyLibs =true; 4213 // create a uploader with options 4214 4215 if ($state.params.fileName) { 4216 $scope.preprocessingFile=true; 4217 // if ($state.params.source=="GRSN") { 4218 signatures.getUploadSignatureCb($state.params.fileName,"",onSuccessUpload,onErrorUpload); 4219 // } 4220 } 4221 4222 var uploader = $scope.uploader = new FileUploader({ 4223 scope: $scope, // to automatically update the html. Default: $rootScope 4224 url: '/api/containers/signatures/upload', 4225 // url: '/api/containers/'+$scope.uploadRecordId+'/upload', 4226 // url: '/api/SignatureMeta/upload', 4227 // url: '/api/SignatureMeta/uploadAndAnalyze', 4228 formData: [ 4229 { key: 'value' } 4230 ] 4231 }); 4232 4233 4234 4235 // ADDING FILTERS 4236 uploader.filters.push({ 4237 name: 'filterName', 4238 fn: function (item, options) { // second user filter 4239 // console.info('filter2'); 4240 // console.info($scope.uploadRecordId); 4241 return true; 4242 } 4243 }); 4244 4245 // REGISTER HANDLERS 4246 // -------------------- 4247 uploader.onAfterAddingFile = function(item) { 4248 // console.info('After adding a file', item); 4249 $scope.showUploadList=true; 4250 $scope.showLibraries=false; 4251 // SignatureUpload.create({fileName:signatures.uploaded[sessionID].orgFileName,sessionId:signatures.uploaded[sessionID].sessionID,entries:signatures.uploaded[sessionID].entries,genesFound:signatures.uploaded[sessionID].foundGenes,pValue:signatures.uploaded[sessionID].Pval}, 4252 SignatureUpload.create({fileName:uploader.queue[0].file.name}, 4253 function(data){ 4254 // console.log(data); 4255 $scope.uploadRecordId=data.id; 4256 // $scope.uploader.url='/api/containers/'+data.id+'/upload', 4257 // console.log($scope.uploader); 4258 // console.log(item); 4259 Container.createContainer({name:data.id}, 4260 function(dataC){ 4261 // console.log(dataC); 4262 item.url='/api/containers/'+data.id+'/upload'; 4263 // console.log(item); 4264 item.upload(); 4265 $scope.uploadedFileName=uploader.queue[0].file.name; 4266 }, 4267 function(errorResponse){console.log("Container creation error",errorResponse)}); 4268 // historyFactory.saveResultInSessionHistory('signatureUploadHistory',data.id); 4269 // $state.transitionTo('uploadedSignature',{file:data.id}); 4270 }, 4271 function(errorResponse){ 4272 console.log("Creating Uploaded Signatures record in database Failed."),console.log(errorResponse) 4273 $scope.wrongFile=true; 4274 $scope.errorMessage=errorResponse; 4275 }); 4276 4277 4278 4279 4280 // item.upload(); 4281 // $scope.uploadedFileName=uploader.queue[0].file.name; 4282 // 4283 4284 // $state.transitionTo('uploadedSignature',{file:$scope.uploadedFileName,libs:$scope.activeUploadLib}); 4285 4286 // console.info('queue', $scope.uploader.queue); 4287 }; 4288 // // -------------------- 4289 // uploader.onAfterAddingAll = function(items) { 4290 // console.info('After adding all files', items); 4291 // }; 4292 // // -------------------- 4293 // uploader.onWhenAddingFileFailed = function(item, filter, options) { 4294 // console.info('When adding a file failed', item); 4295 // }; 4296 // // -------------------- 4297 // uploader.onBeforeUploadItem = function(item) { 4298 // console.info('Before upload', item); 4299 // }; 4300 // // -------------------- 4301 // uploader.onProgressItem = function(item, progress) { 4302 // console.info('Progress: ' + progress, item); 4303 // }; 4304 // // -------------------- 4305 // uploader.onProgressAll = function(progress) { 4306 // console.info('Total progress: ' + pro
4306gress); 4307 // }; 4308 // // -------------------- 4309 // uploader.onSuccessItem = function(item, response, status, headers) { 4310 // console.info('Success', response, status, headers); 4311 // $scope.$broadcast('uploadCompleted', item); 4312 // }; 4313 // // -------------------- 4314 // uploader.onErrorItem = function(item, response, status, headers) { 4315 // console.info('Error', response, status, headers); 4316 // }; 4317 // // -------------------- 4318 // uploader.onCancelItem = function(item, response, status, headers) { 4319 // console.info('Cancel', response, status); 4320 // }; 4321 // // -------------------- 4322 // uploader.onCompleteItem = function(item, response, status, headers) { 4323 // console.info('Complete', response, status, headers); 4324 // }; 4325 // // -------------------- 4326 uploader.onCompleteAll = function() { 4327 // console.info('Complete all'); 4328 $scope.showLibraries=true; 4329 $scope.foundSignatures=undefined; 4330 $scope.resourceLib1=undefined; 4331 $scope.resourceLib2=undefined; 4332 $scope.resourceLib3=undefined; 4333 $scope.resourceLib5=undefined; 4334 $scope.resourceLib6=undefined; 4335 $scope.resourceLib7=undefined; 4336 $scope.resourceLib8=undefined; 4337 4338 if ($state.current.name=="signatures.search.upload"||$state.current.name=="signaturesUpload"){ 4339 //preprocess data new API needed 4340 // $scope.processedSig=signatures.getUploadSignature($scope.uploadedFileName); 4341 $scope.preprocessingFile=true; 4342 // signatures.getUploadSignatureCb($scope.uploadedFileName,"",onSuccessUpload,onErrorUpload); 4343 signatures.getUploadSignatureCb($scope.uploadedFileName,$scope.uploadRecordId,onSuccessUpload,onErrorUpload); 4344 //.then(function(data){console.log(data)}); 4345 // console.log($scope.processedSig); 4346 // $state.transitionTo('uploadedSignature',{file:$scope.uploadedFileName,libs:'LIB_2'}); 4347 } 4348 }; 4349 } 4350 4351 if ($state.current.name=="concordantWithUploaded"){ 4352 // console.info("state",$state); 4353 // $scope.stateParams=$state.params; 4354 $scope.datasetRef=$state.params.datasetID; 4355 $scope.uploadedSignatures=true; 4356 $scope.sigDownShow =false; 4357 $scope.filterSig=[]; 4358 $scope.filterBy={}; 4359 $scope.dataDownLoading =true; 4360 $scope.noEmptyLibs =true; 4361 } 4362 4363 if ($state.current.name=="concordantWithSigGenes"){ 4364 // console.info("state",$state); 4365 // $scope.stateParams=$state.params; 4366 // $scope.datasetRef=$state.params.datasetID; 4367 $scope.signatureID=$state.params.signatureID; 4368 $scope.uploadedSignatures=true; 4369 // $scope.sigDownShow =false; 4370 $scope.filterSig=[]; 4371 $scope.filterBy={}; 4372 $scope.dataDownLoading =true; 4373 $scope.noEmptyLibs =true; 4374 $scope.fromSignatures =true; 4375 } 4376 4377 4378 //modals example 4379 // $scope.items = ['item1', 'item2', 'item3']; 4380 $scope.animationsEnabled = true; 4381 4382 4383 }]); //end from module
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.