Skip to content
Snippets Groups Projects
Commit eb5b9447 authored by Maiykol's avatar Maiykol
Browse files

display drugs and nodes in analysis network; display custom nodes like...

display drugs and nodes in analysis network; display custom nodes like patients; TODO: node type is not passed on from group AND node style in analysis is not loaded correctly, falls back to default.+
parent 3b76f4fe
Branches
No related tags found
No related merge requests found
Pipeline #11026 failed
...@@ -256,9 +256,9 @@ ...@@ -256,9 +256,9 @@
ID ID
<p-sortIcon [field]="'drugId'"></p-sortIcon> <p-sortIcon [field]="'drugId'"></p-sortIcon>
</th> </th>
<th [pSortableColumn]="'name'"> <th [pSortableColumn]="'label'">
Name Label
<p-sortIcon [field]="'name'"></p-sortIcon> <p-sortIcon [field]="'label'"></p-sortIcon>
</th> </th>
<th [pSortableColumn]="'status'"> <th [pSortableColumn]="'status'">
Approved Approved
...@@ -285,7 +285,7 @@ ...@@ -285,7 +285,7 @@
<ng-template pTemplate="body" let-e> <ng-template pTemplate="body" let-e>
<tr> <tr>
<td><a href="https://www.drugbank.ca/drugs/{{ e.drugId }}" target="_blank">{{ e.drugId }}</a></td> <td><a href="https://www.drugbank.ca/drugs/{{ e.drugId }}" target="_blank">{{ e.drugId }}</a></td>
<td>{{e.name}}</td> <td>{{e.label}}</td>
<td> <td>
<span *ngIf="e.status === 'approved'"> <span *ngIf="e.status === 'approved'">
<i class="fa fa-check"></i> <i class="fa fa-check"></i>
...@@ -340,9 +340,9 @@ ...@@ -340,9 +340,9 @@
UniProt Code UniProt Code
<p-sortIcon [field]="'uniprotAc'"></p-sortIcon> <p-sortIcon [field]="'uniprotAc'"></p-sortIcon>
</th> </th>
<th [pSortableColumn]="'name'"> <th [pSortableColumn]="'symbol'">
Gene Symbol
<p-sortIcon [field]="'name'"></p-sortIcon> <p-sortIcon [field]="'symbol'"></p-sortIcon>
</th> </th>
<th [pSortableColumn]="'proteinName'"> <th [pSortableColumn]="'proteinName'">
Name Name
...@@ -368,7 +368,7 @@ ...@@ -368,7 +368,7 @@
<p-tableCheckbox [value]="e"></p-tableCheckbox> <p-tableCheckbox [value]="e"></p-tableCheckbox>
</td> </td>
<td><a href="https://www.uniprot.org/uniprot/{{ e.uniprotAc }}" target="_blank">{{ e.uniprotAc }}</a></td> <td><a href="https://www.uniprot.org/uniprot/{{ e.uniprotAc }}" target="_blank">{{ e.uniprotAc }}</a></td>
<td>{{e.name}}</td> <td>{{e.symbol}}</td>
<td>{{e.proteinName}}</td> <td>{{e.proteinName}}</td>
<td *ngIf="tableHasScores">{{e.score | number}}</td> <td *ngIf="tableHasScores">{{e.score | number}}</td>
<td> <td>
......
...@@ -33,6 +33,7 @@ import {NetworkSettings} from '../../network-settings'; ...@@ -33,6 +33,7 @@ import {NetworkSettings} from '../../network-settings';
import { NetexControllerService } from 'src/app/services/netex-controller/netex-controller.service'; import { NetexControllerService } from 'src/app/services/netex-controller/netex-controller.service';
import { IConfig } from 'src/app/config'; import { IConfig } from 'src/app/config';
import { config } from 'rxjs'; import { config } from 'rxjs';
import { wrapReference } from '@angular/compiler/src/render3/util';
declare var vis: any; declare var vis: any;
...@@ -387,6 +388,26 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { ...@@ -387,6 +388,26 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
} }
} }
public inferNodeLabel(config: IConfig, wrapper: Wrapper): string {
if (wrapper.data.label) {
return wrapper.data.label;
}
const identifier = config.identifier;
if (identifier === 'uniprot'){
return wrapper.data.uniprotAc;
} else if (identifier === 'symbol') {
return wrapper.data.symbol;
} else if (identifier === 'ensg') {
// heuristc to find most important ensg is to look for smallest id
// parse ensg numbers to integers
const ensg_numbers = wrapper.data.ensg.map(x => parseInt(x));
// get index of smalles number
const i = ensg_numbers.reduce((iMin, x, i, arr) => x < arr[iMin] ? i : iMin, 0);
// return ensg-ID
return wrapper.data.ensg[i];
}
}
/** /**
* Maps analysis result returned from database to valid Vis.js network input * Maps analysis result returned from database to valid Vis.js network input
...@@ -411,6 +432,7 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { ...@@ -411,6 +432,7 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
const scores = attributes.scores || {}; const scores = attributes.scores || {};
const details = attributes.details || {}; const details = attributes.details || {};
const wrappers: { [key: string]: Wrapper } = {}; const wrappers: { [key: string]: Wrapper } = {};
for (const node of network.nodes) { for (const node of network.nodes) {
// backend converts object keys to PascalCase: p_123 --> p123 // backend converts object keys to PascalCase: p_123 --> p123
const nodeObjectKey = node.split('_').join(''); const nodeObjectKey = node.split('_').join('');
...@@ -438,6 +460,14 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { ...@@ -438,6 +460,14 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
}; };
} }
/**
* maps node object returned from backend to frontend node, i.e. input to vis.js
* @param config
* @param wrapper
* @param isSeed
* @param score
* @returns
*/
private mapNode(config: IConfig, wrapper: Wrapper, isSeed?: boolean, score?: number): any { private mapNode(config: IConfig, wrapper: Wrapper, isSeed?: boolean, score?: number): any {
// const node = NetworkSettings.getNodeStyle(nodeType, isSeed, this.analysis.inSelection(wrapper)); // const node = NetworkSettings.getNodeStyle(nodeType, isSeed, this.analysis.inSelection(wrapper));
let group = this.inferNodeGroup(wrapper); let group = this.inferNodeGroup(wrapper);
...@@ -446,7 +476,7 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { ...@@ -446,7 +476,7 @@ export class AnalysisPanelComponent implements OnInit, OnChanges {
} }
const node = JSON.parse(JSON.stringify(config.nodeGroups[group])); const node = JSON.parse(JSON.stringify(config.nodeGroups[group]));
node.id = wrapper.id; node.id = wrapper.id;
node.label = wrapper.data.symbol; node.label = this.inferNodeLabel(config, wrapper);
node.nodeType = group; node.nodeType = group;
node.isSeed = isSeed; node.isSeed = isSeed;
node.wrapper = wrapper; node.wrapper = wrapper;
......
...@@ -19,7 +19,7 @@ export interface EdgeGroup { ...@@ -19,7 +19,7 @@ export interface EdgeGroup {
color: string; color: string;
} }
export type Identifier = 'hugo'|'uniprot'|'ensg'; export type Identifier = 'symbol'|'uniprot'|'ensg';
export type InteractionDrugProteinDB = 'DrugBank'|'Chembl'|'DGIdb'; export type InteractionDrugProteinDB = 'DrugBank'|'Chembl'|'DGIdb';
export type InteractionProteinProteinDB = 'STRING'|'BioGRID'|'APID'; export type InteractionProteinProteinDB = 'STRING'|'BioGRID'|'APID';
...@@ -70,7 +70,7 @@ export const defaultConfig: IConfig = { ...@@ -70,7 +70,7 @@ export const defaultConfig: IConfig = {
showTasks: true, showTasks: true,
showFooter: true, showFooter: true,
showLegend: true, showLegend: true,
identifier: 'hugo', identifier: 'symbol',
interactionDrugProtein: 'DrugBank', interactionDrugProtein: 'DrugBank',
interactionProteinProtein: 'STRING', interactionProteinProtein: 'STRING',
nodeGroups: { nodeGroups: {
......
...@@ -102,8 +102,14 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges { ...@@ -102,8 +102,14 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges {
} }
public async startTask() { public async startTask() {
// filter out all seed nodes that do not have a netex_Id, hence do not
// exist in the backend
const seeds = this.analysis.getSelection().map((item) => item.data.netexId)
const seedsFiltered = seeds.filter(function (el) {
return el != null;
});
const parameters: any = { const parameters: any = {
seeds: this.analysis.getSelection().map((item) => item.data.netexId), seeds: seedsFiltered,
config: this.config, config: this.config,
input_network: this.inputNetwork input_network: this.inputNetwork
}; };
...@@ -117,7 +123,6 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges { ...@@ -117,7 +123,6 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges {
this.inputNetwork.nodes.forEach(node => { this.inputNetwork.nodes.forEach(node => {
delete node.interactions delete node.interactions
}); });
console.log(this.inputNetwork)
if (this.algorithm === 'trustrank') { if (this.algorithm === 'trustrank') {
parameters.damping_factor = this.trustrankDampingFactor; parameters.damping_factor = this.trustrankDampingFactor;
...@@ -170,7 +175,9 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges { ...@@ -170,7 +175,9 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges {
} }
parameters.hub_penalty = this.multisteinerHubPenalty; parameters.hub_penalty = this.multisteinerHubPenalty;
} }
console.log('parameters')
console.log(parameters)
await this.analysis.startAnalysis(this.algorithm, this.target, parameters); await this.analysis.startAnalysis(this.algorithm, this.target, parameters);
} }
......
import {AlgorithmType, QuickAlgorithmType} from './services/analysis/analysis.service'; import {AlgorithmType, QuickAlgorithmType} from './services/analysis/analysis.service';
export interface Node { export interface Node {
name: string; label: string;
symbol: string; symbol: string;
id: string; id: string;
netexId?: string; netexId?: string;
...@@ -14,7 +14,6 @@ export interface Node { ...@@ -14,7 +14,6 @@ export interface Node {
x?: number; x?: number;
y?: number; y?: number;
expressionLevel?: number; expressionLevel?: number;
label?: string;
} }
export interface Tissue { export interface Tissue {
...@@ -121,6 +120,8 @@ export function getWrapperFromCustom(gene: Node): Wrapper { ...@@ -121,6 +120,8 @@ export function getWrapperFromCustom(gene: Node): Wrapper {
/** /**
* Constructs wrapper interface for gene * Constructs wrapper interface for gene
*/ */
// if gene.label is undefined, set it to id
gene.label = gene.label ? gene.label : gene.id
return { return {
id: getNodeId(gene), id: getNodeId(gene),
nodeId: getNodeId(gene), nodeId: getNodeId(gene),
...@@ -163,7 +164,7 @@ export interface Wrapper { ...@@ -163,7 +164,7 @@ export interface Wrapper {
type: WrapperType; type: WrapperType;
data: { data: {
id: string; id: string;
name: string; label: string;
symbol?: string; symbol?: string;
netexId?: string; netexId?: string;
ensg?: Array<string>; ensg?: Array<string>;
...@@ -172,7 +173,6 @@ export interface Wrapper { ...@@ -172,7 +173,6 @@ export interface Wrapper {
interactions?: any; interactions?: any;
group?: string; group?: string;
uniprotAc?: string; uniprotAc?: string;
label?: string;
expressionLevel?: number; expressionLevel?: number;
x?: number; x?: number;
y?: number; y?: number;
...@@ -186,7 +186,7 @@ export interface Wrapper { ...@@ -186,7 +186,7 @@ export interface Wrapper {
export interface Drug { export interface Drug {
id: string; id: string;
name: string; label: string;
status: 'approved' | 'investigational'; status: 'approved' | 'investigational';
inTrial: boolean; inTrial: boolean;
inLiterature: boolean; inLiterature: boolean;
......
...@@ -34,7 +34,7 @@ export class OmnipathControllerService { ...@@ -34,7 +34,7 @@ export class OmnipathControllerService {
// entry 1 is always source uniprot ID, entry 2 always target uniprot ID // entry 1 is always source uniprot ID, entry 2 always target uniprot ID
source = lineValues[0]; source = lineValues[0];
target = lineValues[1]; target = lineValues[1];
} else if (identifier === 'hugo') { } else if (identifier === 'symbol') {
// entry 3 is always source name, entry 4 always target name // entry 3 is always source name, entry 4 always target name
source = lineValues[2]; source = lineValues[2];
target = lineValues[3]; target = lineValues[3];
......
...@@ -38,13 +38,13 @@ ...@@ -38,13 +38,13 @@
<network-expander id="netexp1" <network-expander id="netexp1"
config='{ config='{
"nodeGroups": {"0.5": {"type": "gene", "color": "rgb(204, 255, 51)", "name": "0.5", "shape": "circle"}, "1.5": {"type": "gene", "color": "rgb(102, 255, 51)", "name": "1.5", "shape": "circle"}, "2.0": {"type": "gene", "color": "rgb(51, 204, 51)", "name": "2.0", "shape": "circle"}, "-2.0": {"type": "gene", "color": "rgb(255, 0, 0)", "name": "-2.0", "shape": "circle"}}, "nodeGroups": {"0.5": {"type": "gene", "color": "rgb(204, 255, 51)", "name": "0.5", "shape": "circle"}, "patient_group": {"type": "patient", "color": "red", "name": "patient group", "shape": "circle"}, "2.0": {"type": "gene", "color": "rgb(51, 204, 51)", "name": "2.0", "shape": "circle"}, "-2.0": {"type": "gene", "color": "rgb(255, 0, 0)", "name": "-2.0", "shape": "circle"}},
"edgeGroups": {"custom": {"color": "black", "name": "Custom Group"}}, "edgeGroups": {"custom": {"color": "black", "name": "Custom Group"}},
"identifier": "ensg", "identifier": "symbol",
"legendUrl": "https://exbio.wzw.tum.de/covex/assets/leg1.png" "legendUrl": "https://exbio.wzw.tum.de/covex/assets/leg1.png"
}' }'
network='{ network='{
"nodes": [{"id": "ENSG00000171862", "group": "0.5"}, {"label": "ENSG00000284792", "id": "ENSG00000284792", "group": 0.5}], "nodes": [{"id": "TP53", "group": "0.5"}, {"id": "C5", "group": "0.5"}, {"id": "Patient", "group": "patient_group"}, {"label": "PTEN", "id": "PTEN", "group": 0.5}],
"edges": [] "edges": []
}' }'
style="height: 100%; width: 100vw; display: block;" style="height: 100%; width: 100vw; display: block;"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment