Skip to content
Snippets Groups Projects
Commit d5a83f31 authored by AndiMajore's avatar AndiMajore
Browse files

fixed drug existence check and node groups

parent f5e8bcc4
Branches
Tags
No related merge requests found
...@@ -200,10 +200,11 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit ...@@ -200,10 +200,11 @@ 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.tableDrugs = nodes.filter(e => e.drugstoneId && e.drugstoneId.drugstoneType === 'drug'); this.tableDrugs = nodes.filter(e => e.drugstoneId && e.drugstoneType === 'drug');
this.tableDrugs.forEach((r) => { this.tableDrugs.forEach((r) => {
r.rawScore = r.score; r.rawScore = r.score;
}); });
console.log(this.tableDrugs)
this.tableProteins = nodes.filter(e => e.drugstoneId && e.drugstoneType === 'protein'); this.tableProteins = nodes.filter(e => e.drugstoneId && e.drugstoneType === 'protein');
this.tableSelectedProteins = []; this.tableSelectedProteins = [];
...@@ -411,7 +412,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit ...@@ -411,7 +412,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit
public createNetwork(result: any): { edges: any[], nodes: any[] } { public createNetwork(result: any): { edges: any[], nodes: any[] } {
const config = result.parameters.config; const config = result.parameters.config;
this.myConfig = config; this.myConfig = config;
const identifier = this.myConfig.identifier; const identifier = this.myConfig.identifier;
// add drugGroup and foundNodesGroup for added nodes // add drugGroup and foundNodesGroup for added nodes
...@@ -424,24 +424,14 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit ...@@ -424,24 +424,14 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit
this.effects = []; this.effects = [];
const network = result.network; const network = result.network;
// const nodeTypes = attributes.nodeTypes || {};
// const isSeed = attributes.isSeed || {};
// const scores = attributes.scores || {};
const details = attributes.details || {}; const details = attributes.details || {};
const nodeIdMap = {} const nodeIdMap = {}
// const reverseNodeIdMap = {}
// @ts-ignore // @ts-ignore
Object.entries(details).filter(e => e[1].drugstoneType === 'protein').forEach(e => { Object.entries(details).filter(e => e[1].drugstoneType === 'protein').forEach(e => {
// let id =
// @ts-ignore // @ts-ignore
e[1].drugstoneId.forEach(id => { e[1].drugstoneId.forEach(id => {
nodeIdMap[id] = e[1][identifier][0] nodeIdMap[id] = e[1][identifier][0]
}) })
// if (!nodeIdMap[id])
// nodeIdMap[id] = [e[0]]
// else
// nodeIdMap[id].push(e[0])
}) })
for (const nodeId of Object.keys(details)) { for (const nodeId of Object.keys(details)) {
const nodeDetails = details[nodeId] const nodeDetails = details[nodeId]
...@@ -449,7 +439,9 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit ...@@ -449,7 +439,9 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit
if (nodeDetails.drugstoneId && nodeDetails.drugstoneType === 'protein') { if (nodeDetails.drugstoneId && nodeDetails.drugstoneType === 'protein') {
// node is protein from database, has been mapped on init to backend protein from backend // node is protein from database, has been mapped on init to backend protein from backend
// or was found during analysis // or was found during analysis
nodeDetails.group = result.targetNodes && result.targetNodes.indexOf(nodeId) !== -1 ? 'foundNode' : (nodeDetails.group ? nodeDetails.group : 'default' ); // FIXME connectorNodes are not visualized correctly
nodeDetails.group = result.targetNodes && result.targetNodes.indexOf(nodeId) !== -1 ? 'foundNode' : (nodeDetails.group ? nodeDetails.group : 'connectorNode');
console.log(nodeDetails)
nodeDetails.label = nodeDetails.label ? nodeDetails.label : nodeDetails[identifier]; nodeDetails.label = nodeDetails.label ? nodeDetails.label : nodeDetails[identifier];
nodeDetails.id = nodeDetails[identifier][0] ? nodeDetails[identifier][0] : nodeDetails.id; nodeDetails.id = nodeDetails[identifier][0] ? nodeDetails[identifier][0] : nodeDetails.id;
this.proteins.push(nodeDetails); this.proteins.push(nodeDetails);
...@@ -464,18 +456,22 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit ...@@ -464,18 +456,22 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit
} }
// further analysis and the button function can be used to highlight seeds // further analysis and the button function can be used to highlight seeds
// option to use scores[node] as gradient, but sccores are very small // option to use scores[node] as gradient, but sccores are very small
console.log(nodeDetails)
nodes.push(NetworkSettings.getNodeStyle(nodeDetails as Node, config, false, false, 1)) nodes.push(NetworkSettings.getNodeStyle(nodeDetails as Node, config, false, false, 1))
} }
const edges = []; const edges = [];
let uniqEdges = []
for (const edge of network.edges) { for (const edge of network.edges) {
const e = mapCustomEdge(edge, this.myConfig) const e = mapCustomEdge(edge, this.myConfig)
e.from = e.from[0] === 'p' ? nodeIdMap[e.from] : e.from e.from = e.from[0] === 'p' ? nodeIdMap[e.from] : e.from
e.to = e.to[0] === 'p' ? nodeIdMap[e.to] : e.to e.to = e.to[0] === 'p' ? nodeIdMap[e.to] : e.to
const hash = e.from + "_" + e.to;
if (uniqEdges.indexOf(hash) === -1) {
uniqEdges.push(hash);
edges.push(e); edges.push(e);
} }
}
return { return {
nodes, nodes,
edges, edges,
......
...@@ -426,9 +426,11 @@ export class NetworkComponent implements OnInit { ...@@ -426,9 +426,11 @@ export class NetworkComponent implements OnInit {
} }
public hasDrugsLoaded(): boolean { public hasDrugsLoaded(): boolean {
if (this.nodeData == null || this.nodeData.nodes == null) if(this.nodeData && this.nodeData.nodes)
for(const node of this.nodeData.nodes.get())
if(node.drugstoneType && node.drugstoneId === 'drug')
return true;
return false; return false;
return this.nodeData.nodes.get().filter((node: Node) => node.drugId).map(node => node.drugstoneId).filter(id => id.startsWith('dr')).length > 0;
} }
public setLegendContext() { public setLegendContext() {
...@@ -442,9 +444,10 @@ export class NetworkComponent implements OnInit { ...@@ -442,9 +444,10 @@ export class NetworkComponent implements OnInit {
if (this.highlightSeeds) { if (this.highlightSeeds) {
this.legendContext = "drugTargetAndSeeds"; this.legendContext = "drugTargetAndSeeds";
} else { } else {
this.legendContext = 'drugTarget' this.legendContext = 'drugTarget';
} }
} }
console.log(this.legendContext)
} }
/** /**
......
...@@ -79,6 +79,42 @@ export interface IConfig { ...@@ -79,6 +79,42 @@ export interface IConfig {
edgeShadow?: boolean; edgeShadow?: boolean;
} }
const defaultNodeGroup: NodeGroup = {
// this default group is used for default node group values
// and is fallback in case user does not provide any nodeGroup
groupName: 'Default Node Group',
color: {
border: '#FFFF00',
background: '#FFFF00',
highlight: {
border: '#FF0000',
background: '#FF0000'
},
},
shape: 'triangle',
type: 'default type',
detailShowLabel: false,
font: {
color: '#000000',
size: 14,
face: 'arial',
background: undefined,
strokeWidth: 0,
strokeColor: '#ffffff',
align: 'center',
bold: false,
ital: false,
boldital: false,
mono: false,
},
borderWidth: 1,
borderWidthSelected: 2
};
const connectorNodeGroup: NodeGroup = JSON.parse(JSON.stringify(defaultNodeGroup));
connectorNodeGroup.groupName = 'Connector Node';
// @ts-ignore
/** /**
* Provide default values * Provide default values
*/ */
...@@ -126,37 +162,7 @@ export const defaultConfig: IConfig = { ...@@ -126,37 +162,7 @@ export const defaultConfig: IConfig = {
nodeGroups: { nodeGroups: {
// all NodeGroups but the default group must be set, if not provided by the user, they will be taken from here // all NodeGroups but the default group must be set, if not provided by the user, they will be taken from here
// IMPORTANT: node color must be hexacode! // IMPORTANT: node color must be hexacode!
default: { default: defaultNodeGroup,
// this default group is used for default node group values
// and is fallback in case user does not provide any nodeGroup
groupName: 'Default Node Group',
color: {
border: '#FFFF00',
background: '#FFFF00',
highlight: {
border: '#FF0000',
background: '#FF0000'
},
},
shape: 'triangle',
type: 'default type',
detailShowLabel: false,
font: {
color: '#000000',
size: 14,
face: 'arial',
background: undefined,
strokeWidth: 0,
strokeColor: '#ffffff',
align: 'center',
bold: false,
ital: false,
boldital: false,
mono: false,
},
borderWidth: 1,
borderWidthSelected: 2
},
foundNode: { foundNode: {
groupName: 'Found Nodes', groupName: 'Found Nodes',
color: { color: {
...@@ -170,6 +176,7 @@ export const defaultConfig: IConfig = { ...@@ -170,6 +176,7 @@ export const defaultConfig: IConfig = {
shape: 'circle', shape: 'circle',
type: 'default node type', type: 'default node type',
}, },
connectorNode: connectorNodeGroup,
foundDrug: { foundDrug: {
groupName: 'Drugs', groupName: 'Drugs',
color: { color: {
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<drugst-one id="netexp1" <drugst-one id="netexp1"
pluginId="2" pluginId="2"
config='{"identifier":"symbol","licencedDatasets": false, "interactionDrugProtein":"NeDRex", "physicsOn":true, "showLeftSidebar": true, "showSimpleAnalysis":true, "nodeGroups":{"patient":{"type":"patient","color":"black","font":{"color":"#ffffff"},"groupName":"Patient","shape":"image","image":"https://static.thenounproject.com/png/22780-200.png"},"condition":{"type":"condition","color":"black","font":{"color":"black"},"groupName":"Condition","shape":"text"},"important":{"type":"gene","color":"#ff881f","font":{"color":"#000000"},"groupName":"Important Gene","shape":"star"},"gene":{"type":"gene","color":"#4da300","font":{"color":"#ffffff"},"groupName":"Gene","shape":"circle"},"foundDrug":{"type":"drug","color":{"border":"#F12590","background":"#F12590"},"font":{"color":"#000000"},"groupName":"Drug","shape":"diamond"}},"edgeGroups":{"genotype":{"color":"black","groupName":"Relevant Gene"},"has-condition":{"color":"#ffffff","groupName":"Has Condition","dashes":[2,2]},"default":{"color":"#000000","groupName":"default edge"},"ggi":{"color":"#000000","groupName":"Interaction","dashes":[3,2]}},"title":"Breast cancer example network","nodeShadow":true,"edgeShadow":false,"autofillEdges":true,"showLegend":true}' config='{"identifier":"symbol","licencedDatasets": false, "interactionDrugProtein":"NeDRex", "physicsOn":true, "showLeftSidebar": true, "showSimpleAnalysis":true, "nodeGroups":{"patient":{"type":"patient","color":"black","font":{"color":"#ffffff"},"groupName":"Patient","shape":"image","image":"https://static.thenounproject.com/png/22780-200.png"},"condition":{"type":"condition","color":"black","font":{"color":"black"},"groupName":"Condition","shape":"text"},"important":{"type":"gene","color":"#ff881f","font":{"color":"#000000"},"groupName":"Important Gene","shape":"star"},"gene":{"type":"gene","color":"#4da300","font":{"color":"#ffffff"},"groupName":"Gene","shape":"circle"},"foundDrug":{"type":"drug","color":{"border":"#F12590","background":"#F12590"},"font":{"color":"#000000"},"groupName":"Drug","shape":"diamond"}},"edgeGroups":{"genotype":{"color":"black","groupName":"Relevant Gene"},"has-condition":{"color":"#ffffff","groupName":"Has Condition","dashes":[2,2]},"default":{"color":"#000000","groupName":"default edge"},"ggi":{"color":"#000000","groupName":"Interaction","dashes":[3,2]}},"title":"Breast cancer example network","nodeShadow":true,"edgeShadow":false,"autofillEdges":true,"showLegend":true}'
network='{"nodes":[{"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}],"edges":[]}'> network='{"nodes":[{"id":"ATM","label":"ATM","group":"gene","x":289,"y":242},{"id":"FOXP2","label":"FOXP2","group":"gene"},{"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}],"edges":[]}'>
</drugst-one> </drugst-one>
<!-- ENSEMBL test--> <!-- ENSEMBL test-->
<!-- <drugst-one id="netexp1"--> <!-- <drugst-one id="netexp1"-->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment