Skip to content
Snippets Groups Projects
Commit 70666c37 authored by Hartung, Michael's avatar Hartung, Michael
Browse files

auto network layout until stabilization or 1000 iterations

parent 1b329d85
No related branches found
No related tags found
No related merge requests found
...@@ -197,6 +197,12 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit ...@@ -197,6 +197,12 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit
this.networkHandler.activeNetwork.networkInternal = new vis.Network(container, this.nodeData, options); this.networkHandler.activeNetwork.networkInternal = new vis.Network(container, this.nodeData, options);
this.networkHandler.activeNetwork.networkInternal.on('stabilizationIterationsDone', () => {
if (!this.drugstoneConfig.config.physicsOn) {
this.networkHandler.activeNetwork.updatePhysicsEnabled(false);
}
});
this.tableDrugs = nodes.filter(e => e.drugstoneId && e.drugstoneId.startsWith('d')); this.tableDrugs = nodes.filter(e => e.drugstoneId && e.drugstoneId.startsWith('d'));
this.tableDrugs.forEach((r) => { this.tableDrugs.forEach((r) => {
r.rawScore = r.score; r.rawScore = r.score;
...@@ -400,80 +406,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit ...@@ -400,80 +406,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit
} }
} }
// public saveAddNodes(nodeList: Node[]) {
// const existing = this.nodeData.nodes.get().map(n => n.id);
// const toAdd = nodeList.filter(n => existing.indexOf(n.id) === -1)
// this.nodeData.nodes.add(toAdd);
// }
// public saveRemoveDisorders(nodeList: Node[]) {
// const other = this.adjacentDrugDisorderList === nodeList ? this.adjacentProteinDisorderList : this.adjacentDrugDisorderList
// if (other == null)
// this.nodeData.nodes.remove(nodeList);
// else {
// const otherIds = other.map(d => d.id);
// const rest = nodeList.filter(d => otherIds.indexOf(d.id) === -1)
// this.nodeData.nodes.remove(rest)
// }
// }
// public updateAdjacentProteinDisorders(bool: boolean) {
// this.adjacentDisordersProtein = bool;
// if (this.adjacentDisordersProtein) {
// this.netex.adjacentDisorders(this.nodeData.nodes, 'proteins').subscribe(response => {
// for (const interaction of response.edges) {
// const edge = {from: interaction.protein, to: interaction.disorder};
// this.adjacentProteinDisorderEdgesList.push(mapCustomEdge(edge, this.myConfig));
// }
// for (const disorder of response.disorders) {
// disorder.group = 'defaultDisorder';
// disorder.id = disorder.drugstoneId;
// this.adjacentProteinDisorderList.push(mapCustomNode(disorder, this.myConfig))
// }
// this.saveAddNodes(this.adjacentProteinDisorderList);
// this.nodeData.edges.add(this.adjacentProteinDisorderEdgesList);
// this.emitVisibleItems(true);
// });
// this.legendContext = this.adjacentDrugs ? 'adjacentDrugsAndDisorders' : 'adjacentDisorders';
// } else {
// this.saveRemoveDisorders(this.adjacentProteinDisorderList);
// this.nodeData.edges.remove(this.adjacentProteinDisorderEdgesList);
// this.adjacentProteinDisorderList = [];
// this.adjacentProteinDisorderEdgesList = [];
// this.legendContext = this.adjacentDisordersDrug ? this.legendContext : this.adjacentDrugs ? 'adjacentDrugs' : 'explorer';
// this.emitVisibleItems(true);
// }
// }
// public updateAdjacentDrugDisorders(bool: boolean) {
// this.adjacentDisordersDrug = bool;
// if (this.adjacentDisordersDrug) {
// this.netex.adjacentDisorders(this.nodeData.nodes, 'drugs').subscribe(response => {
// for (const interaction of response.edges) {
// const edge = {from: interaction.drug, to: interaction.disorder};
// this.adjacentDrugDisorderEdgesList.push(mapCustomEdge(edge, this.myConfig));
// }
// for (const disorder of response.disorders) {
// disorder.group = 'defaultDisorder';
// disorder.id = disorder.drugstoneId;
// this.adjacentDrugDisorderList.push(mapCustomNode(disorder, this.myConfig));
// }
// this.saveAddNodes(this.adjacentDrugDisorderList);
// this.nodeData.edges.add(this.adjacentDrugDisorderEdgesList);
// this.emitVisibleItems(true);
// });
// this.legendContext = this.adjacentDrugs ? 'adjacentDrugsAndDisorders' : 'adjacentDisorders';
// } else {
// this.saveRemoveDisorders(this.adjacentDrugDisorderList);
// this.nodeData.edges.remove(this.adjacentDrugDisorderEdgesList);
// this.adjacentDrugDisorderList = [];
// this.adjacentDrugDisorderEdgesList = [];
// this.legendContext = this.adjacentDisordersProtein ? this.legendContext : this.adjacentDrugs ? 'adjacentDrugs' : 'explorer';
// this.emitVisibleItems(true);
// }
// }
public downloadLink(view: string): string { public downloadLink(view: string): string {
return `${environment.backend}task_result/?token=${this.token}&view=${view}&fmt=csv`; return `${environment.backend}task_result/?token=${this.token}&view=${view}&fmt=csv`;
} }
...@@ -589,72 +521,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit ...@@ -589,72 +521,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit
}; };
} }
// hasDrugsLoaded(): boolean {
// if (this.nodeData == null || this.nodeData.nodes == null)
// return false;
// return this.nodeData.nodes.get().filter((node: Node) => node.drugId && node.drugstoneId.startsWith('dr')).length > 0;
// }
// public updateAdjacentDrugs(bool: boolean) {
// this.adjacentDrugs = bool;
// if (this.adjacentDrugs) {
// this.netex.adjacentDrugs(this.myConfig.interactionDrugProtein, this.nodeData.nodes).subscribe(response => {
// for (const interaction of response.pdis) {
// const edge = {from: interaction.protein, to: interaction.drug};
// this.adjacentDrugEdgesList.push(mapCustomEdge(edge, this.myConfig));
// }
// for (const drug of response.drugs) {
// drug.group = 'foundDrug';
// drug.id = getDrugNodeId(drug)
// this.adjacentDrugList.push(mapCustomNode(drug, this.myConfig))
// }
// this.nodeData.nodes.add(this.adjacentDrugList);
// this.nodeData.edges.add(this.adjacentDrugEdgesList);
// this.emitVisibleItems(true);
// })
// this.legendContext = this.adjacentDisordersDrug || this.adjacentDisordersProtein ? 'adjacentDrugsAndDisorders' : 'adjacentDrugs';
// } else {
// this.nodeData.nodes.remove(this.adjacentDrugList);
// this.nodeData.edges.remove(this.adjacentDrugEdgesList);
// this.adjacentDrugList = [];
// this.adjacentDrugEdgesList = [];
// this.legendContext = this.adjacentDisordersDrug || this.adjacentDisordersProtein ? 'adjacentDisorders' : 'explorer';
// this.emitVisibleItems(true);
// }
// }
// public updatePhysicsEnabled(bool: boolean) {
// this.drugstoneConfig.config.physicsOn = bool;
// this.networkHandler.activeNetwork.networkInternal.setOptions({
// physics: {
// enabled: this.drugstoneConfig.config.physicsOn,
// stabilization: {
// enabled: false,
// },
// }
// });
// }
// public toImage() {
// this.downloadDom(this.networkWithLegendEl.nativeElement).catch(error => {
// console.error("Falling back to network only screenshot. Some components seem to be inaccessable, most likely the legend is a custom image with CORS access problems on the host server side.")
// this.downloadDom(this.networkHandler.activeNetwork.networkEl.nativeElement).catch(e => {
// console.error("Some network content seems to be inaccessable for saving as a screenshot. This can happen due to custom images used as nodes. Please ensure correct CORS accessability on the images host server.")
// console.error(e)
// });
// });
// }
// public downloadDom(dom: object) {
// return domtoimage.toPng(dom, {bgcolor: '#ffffff'}).then((generatedImage) => {
// const a = document.createElement('a');
// a.href = generatedImage;
// a.download = `Network.png`;
// a.click();
// });
// }
public tableProteinSelection = (e): void => { public tableProteinSelection = (e): void => {
const oldSelection = [...this.tableSelectedProteins]; const oldSelection = [...this.tableSelectedProteins];
this.tableSelectedProteins = e; this.tableSelectedProteins = e;
......
...@@ -56,7 +56,8 @@ export class NetworkSettings { ...@@ -56,7 +56,8 @@ export class NetworkSettings {
length: 250 length: 250
}; };
private static mainPhysics = { private static mainPhysics = {
enabled: false enabled: true,
stabilization: true
}; };
static getOptions(network: 'main' | 'analysis' | 'analysis-big', physicsOn) { static getOptions(network: 'main' | 'analysis' | 'analysis-big', physicsOn) {
......
...@@ -282,6 +282,12 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { ...@@ -282,6 +282,12 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit {
this.networkHandler.activeNetwork.networkInternal = new vis.Network(container, this.nodeData, options); this.networkHandler.activeNetwork.networkInternal = new vis.Network(container, this.nodeData, options);
this.networkHandler.activeNetwork.networkInternal.on('stabilizationIterationsDone', () => {
if (!this.drugstoneConfig.config.physicsOn) {
this.networkHandler.activeNetwork.updatePhysicsEnabled(false);
}
});
if (!this.drugstoneConfig.config.showSidebar) { if (!this.drugstoneConfig.config.showSidebar) {
// skip network options for selecting nodes when there are no options to use it // skip network options for selecting nodes when there are no options to use it
return return
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<drugst-one id="netexp1" <drugst-one id="netexp1"
pluginId="2" pluginId="2"
groups='{"nodeGroups":{"patient":{"type":"patient","color":"#000000","font":{"color":"#000000"},"groupName":"Patient","shape":"image","image":"https://static.thenounproject.com/png/22780-200.png"},"condition":{"type":"condition","color":"#000000","font":{"color":"#000000"},"groupName":"Condition","shape":"text"},"important":{"type":"gene","color":"#ff881f","font":{"color":"#000000"},"groupName":"Important Gene","shape":"star"},"gene":{"type":"gene","color":"#4da300","font":{"color":"#f0f0f0"},"groupName":"Gene","shape":"circle"},"foundDrug":{"type":"drug","color":"#F12590","font":{"color":"#000000"},"groupName":"Drug","shape":"diamond"}},"edgeGroups":{"genotype":{"color":"#000000","groupName":"Relevant Gene"},"has-condition":{"color":"#000000","groupName":"Has Condition","dashes":[2,2]},"default":{"color":"#000000","groupName":"default edge"},"ggi":{"color":"#000000","groupName":"Interaction","dashes":[3,2]}}}' groups='{"nodeGroups":{"patient":{"type":"patient","color":"#000000","font":{"color":"#000000"},"groupName":"Patient","shape":"image","image":"https://static.thenounproject.com/png/22780-200.png"},"condition":{"type":"condition","color":"#000000","font":{"color":"#000000"},"groupName":"Condition","shape":"text"},"important":{"type":"gene","color":"#ff881f","font":{"color":"#000000"},"groupName":"Important Gene","shape":"star"},"gene":{"type":"gene","color":"#4da300","font":{"color":"#f0f0f0"},"groupName":"Gene","shape":"circle"},"foundDrug":{"type":"drug","color":"#F12590","font":{"color":"#000000"},"groupName":"Drug","shape":"diamond"}},"edgeGroups":{"genotype":{"color":"#000000","groupName":"Relevant Gene"},"has-condition":{"color":"#000000","groupName":"Has Condition","dashes":[2,2]},"default":{"color":"#000000","groupName":"default edge"},"ggi":{"color":"#000000","groupName":"Interaction","dashes":[3,2]}}}'
config='{"identifier":"symbol","title":"Breast cancer example network","nodeShadow":true,"edgeShadow":false,"autofillEdges":false,"showLegend":true}' config='{"physicsOn":false,"identifier":"symbol","title":"Breast cancer example network","nodeShadow":true,"edgeShadow":false,"autofillEdges":false,"showLegend":true}'
network='{"nodes":[{"id":"patient-1","group":"patient","x":592,"y":446},{"id":"patient-2","group":"patient","x":235,"y":87},{"id":"patient-3","group":"patient","x":105,"y":369},{"id":"ATM","label":"ATM","group":"gene","x":289,"y":242},{"id":"BARD1","label":"BARD1","group":"gene","x":44,"y":250},{"id":"BRCA1","label":"BRCA1","group":"gene","x":466,"y":576},{"id":"BRCA2","label":"BRCA2","group":"gene","x":507,"y":285},{"id":"BRIP1","label":"BRIP1","group":"gene","x":54,"y":474},{"id":"CHEK2","label":"CHEK2","group":"gene","x":216,"y":590},{"id":"CDH1","label":"CDH1","group":"gene","x":320,"y":-57},{"id":"NF1","label":"NF1","group":"gene","x":481,"y":111},{"id":"NBN","label":"NBN","group":"gene","x":-57,"y":314},{"id":"PALB2","label":"PALB2","group":"gene","x":450,"y":190},{"id":"PTEN","label":"PTEN","group":"important","x":305,"y":494},{"id":"RAD51C","label":"RAD51C","group":"gene","x":182,"y":-90},{"id":"RAD51D","label":"RAD51D","group":"gene","x":368,"y":73},{"id":"STK11","label":"STK11","group":"gene","x":686,"y":330},{"id":"TP53","label":"TP53","group":"important","x":333,"y":316},{"id":"subtype-1","label":"Subtype 1","group":"condition","x":556,"y":171},{"id":"subtype-2","label":"Subtype 2","group":"condition","x":-87,"y":221}],"edges":[{"from":"BRCA1","to":"BRCA2","group":"ggi"},{"from":"ATM","to":"BARD1","group":"ggi"},{"from":"BRCA1","to":"CHEK2","group":"ggi"},{"from":"RAD51C","to":"RAD51D","group":"ggi"},{"from":"STK11","to":"TP53","group":"ggi"},{"from":"TP53","to":"PALB2","group":"ggi"},{"from":"TP53","to":"RAD51D","group":"ggi"},{"from":"TP53","to":"NF1","group":"ggi"},{"from":"TP53","to":"BRCA1","group":"ggi"},{"from":"TP53","to":"BRCA2","group":"ggi"},{"from":"PTEN","to":"BRCA1","group":"ggi"},{"from":"PTEN","to":"BRCA2","group":"ggi"},{"from":"TP53","to":"PTEN","group":"ggi"},{"from":"ATM","to":"PTEN","group":"ggi"},{"from":"CDH1","to":"RAD51D","group":"ggi"},{"from":"CDH1","to":"PALB2","group":"ggi"},{"from":"NBN","to":"BRIP1","group":"ggi"},{"from":"BRIP1","to":"PTEN","group":"ggi"},{"from":"patient-1","to":"BRCA1","group":"genotype"},{"from":"patient-1","to":"TP53","group":"genotype"},{"from":"patient-1","to":"BRCA2","group":"genotype"},{"from":"patient-1","to":"PTEN","group":"genotype"},{"from":"patient-2","to":"TP53","group":"genotype"},{"from":"patient-2","to":"NF1","group":"genotype"},{"from":"patient-2","to":"BARD1","group":"genotype"},{"from":"patient-3","to":"TP53","group":"genotype"},{"from":"patient-3","to":"PTEN","group":"genotype"},{"from":"patient-3","to":"NBN","group":"genotype"},{"from":"patient-1","to":"subtype-1","group":"has-condition"},{"from":"patient-2","to":"subtype-1","group":"has-condition"},{"from":"patient-3","to":"subtype-2","group":"has-condition"}]}' network='{"nodes":[{"id":"patient-1","group":"patient","x":592,"y":446},{"id":"patient-2","group":"patient","x":235,"y":87},{"id":"patient-3","group":"patient","x":105,"y":369},{"id":"ATM","label":"ATM","group":"gene","x":289,"y":242},{"id":"BARD1","label":"BARD1","group":"gene","x":44,"y":250},{"id":"BRCA1","label":"BRCA1","group":"gene","x":466,"y":576},{"id":"BRCA2","label":"BRCA2","group":"gene","x":507,"y":285},{"id":"BRIP1","label":"BRIP1","group":"gene","x":54,"y":474},{"id":"CHEK2","label":"CHEK2","group":"gene","x":216,"y":590},{"id":"CDH1","label":"CDH1","group":"gene","x":320,"y":-57},{"id":"NF1","label":"NF1","group":"gene","x":481,"y":111},{"id":"NBN","label":"NBN","group":"gene","x":-57,"y":314},{"id":"PALB2","label":"PALB2","group":"gene","x":450,"y":190},{"id":"PTEN","label":"PTEN","group":"important","x":305,"y":494},{"id":"RAD51C","label":"RAD51C","group":"gene","x":182,"y":-90},{"id":"RAD51D","label":"RAD51D","group":"gene","x":368,"y":73},{"id":"STK11","label":"STK11","group":"gene","x":686,"y":330},{"id":"TP53","label":"TP53","group":"important","x":333,"y":316},{"id":"subtype-1","label":"Subtype 1","group":"condition","x":556,"y":171},{"id":"subtype-2","label":"Subtype 2","group":"condition","x":-87,"y":221}],"edges":[{"from":"BRCA1","to":"BRCA2","group":"ggi"},{"from":"ATM","to":"BARD1","group":"ggi"},{"from":"BRCA1","to":"CHEK2","group":"ggi"},{"from":"RAD51C","to":"RAD51D","group":"ggi"},{"from":"STK11","to":"TP53","group":"ggi"},{"from":"TP53","to":"PALB2","group":"ggi"},{"from":"TP53","to":"RAD51D","group":"ggi"},{"from":"TP53","to":"NF1","group":"ggi"},{"from":"TP53","to":"BRCA1","group":"ggi"},{"from":"TP53","to":"BRCA2","group":"ggi"},{"from":"PTEN","to":"BRCA1","group":"ggi"},{"from":"PTEN","to":"BRCA2","group":"ggi"},{"from":"TP53","to":"PTEN","group":"ggi"},{"from":"ATM","to":"PTEN","group":"ggi"},{"from":"CDH1","to":"RAD51D","group":"ggi"},{"from":"CDH1","to":"PALB2","group":"ggi"},{"from":"NBN","to":"BRIP1","group":"ggi"},{"from":"BRIP1","to":"PTEN","group":"ggi"},{"from":"patient-1","to":"BRCA1","group":"genotype"},{"from":"patient-1","to":"TP53","group":"genotype"},{"from":"patient-1","to":"BRCA2","group":"genotype"},{"from":"patient-1","to":"PTEN","group":"genotype"},{"from":"patient-2","to":"TP53","group":"genotype"},{"from":"patient-2","to":"NF1","group":"genotype"},{"from":"patient-2","to":"BARD1","group":"genotype"},{"from":"patient-3","to":"TP53","group":"genotype"},{"from":"patient-3","to":"PTEN","group":"genotype"},{"from":"patient-3","to":"NBN","group":"genotype"},{"from":"patient-1","to":"subtype-1","group":"has-condition"},{"from":"patient-2","to":"subtype-1","group":"has-condition"},{"from":"patient-3","to":"subtype-2","group":"has-condition"}]}'
> >
</drugst-one> </drugst-one>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment