From 2130a8b1ea79ca29dad3023bec47479f2146e89b Mon Sep 17 00:00:00 2001
From: Julian Matschinske <ge93nar@mytum.de>
Date: Wed, 15 Apr 2020 12:13:51 +0200
Subject: [PATCH] Add max deg and hub penalty

---
 .../analysis-window.component.html            |  16 +-
 .../launch-analysis.component.html            | 288 ++++++++++++++----
 .../launch-analysis.component.scss            |   7 +-
 .../launch-analysis.component.ts              |  14 +
 4 files changed, 264 insertions(+), 61 deletions(-)

diff --git a/src/app/components/analysis-window/analysis-window.component.html b/src/app/components/analysis-window/analysis-window.component.html
index 6c42eac0..13bf6025 100644
--- a/src/app/components/analysis-window/analysis-window.component.html
+++ b/src/app/components/analysis-window/analysis-window.component.html
@@ -29,6 +29,10 @@
           <div>
             <table class="table is-narrow">
               <tbody>
+              <tr *ngIf="task.info.parameters.resultSize">
+                <td>Result Size</td>
+                <td>{{task.info.parameters.resultSize}}</td>
+              </tr>
               <tr *ngIf="task.info.parameters.k">
                 <td>K</td>
                 <td>{{task.info.parameters.k}}</td>
@@ -45,6 +49,14 @@
                 <td>Damping Factor</td>
                 <td>{{task.info.parameters.dampingFactor}}</td>
               </tr>
+              <tr *ngIf="task.info.parameters.maxDeg !== undefined">
+                <td>Maximum Degree</td>
+                <td>{{task.info.parameters.maxDeg}}</td>
+              </tr>
+              <tr *ngIf="task.info.parameters.hubPenalty !== undefined">
+                <td>Hub Penality</td>
+                <td>{{task.info.parameters.hubPenalty}}</td>
+              </tr>
               <tr *ngIf="task.info.parameters.includeIndirectDrugs !== undefined && task.info.target === 'drug'">
                 <td>Include indirect drugs</td>
                 <td>
@@ -66,10 +78,6 @@
                   <i *ngIf="task.info.parameters.ignoreNonSeedBaits" class="fa fa-times"></i>
                 </td>
               </tr>
-              <tr *ngIf="task.info.parameters.resultSize">
-                <td>Result Size</td>
-                <td>{{task.info.parameters.resultSize}}</td>
-              </tr>
               </tbody>
             </table>
           </div>
diff --git a/src/app/components/launch-analysis/launch-analysis.component.html b/src/app/components/launch-analysis/launch-analysis.component.html
index 036a7041..77ab252a 100644
--- a/src/app/components/launch-analysis/launch-analysis.component.html
+++ b/src/app/components/launch-analysis/launch-analysis.component.html
@@ -27,13 +27,6 @@
         </div>
       </div>
 
-      <div *ngIf="algorithm === 'keypathwayminer' && hasBaits">
-        <div class="notification is-warning warning">
-          You have selected <i class="fa fa-virus"></i> viral proteins.
-          If you want to use KeyPathwayMiner, please remove them because it cannot process them.
-        </div>
-      </div>
-
       <div class="tabs is-toggle is-small is-fullwidth is-rounded has-tooltip">
         <ul>
           <li [class.is-active]="algorithm === algo.slug" *ngFor="let algo of algorithms">
@@ -43,67 +36,147 @@
       </div>
 
       <div *ngIf="algorithm==='trustrank'">
-        <p class="help info">
-          <span class="icon"><i class="fa fa-info"></i></span>
-          <a href="https://en.wikipedia.org/wiki/TrustRank" target="_blank">TrustRank</a>
-          is a node centrality measure that ranks nodes in a network based on how well they are connected to a
-          (trusted) set of seed nodes (Gyöngyi, Garcia-Molina, and Pedersen 2004).
-        </p>
+
+        <div class="field">
+          <label class="label" for="trustrank-rs">Result Size</label>
+          <div class="control">
+            <input [(ngModel)]="trustrankResultSize" id="trustrank-rs" class="input" type="number"
+                   placeholder="Result size" required>
+          </div>
+        </div>
+
         <div class="field" *ngIf="target === 'drug'">
           <label class="label">Indirect Drugs</label>
           <app-toggle textOn="Include" textOff="Ignore" tooltipOn="Include indirect drugs."
                       tooltipOff="Exclude indirect drugs from the result."
-                      [(value)]="trustrankIncludeIndirectDrugs"></app-toggle>
+                      [(value)]="trustrankIncludeIndirectDrugs">
+          </app-toggle>
+          <p class="help">
+            Specifies whether also drugs targeting interactors of the seed nodes should be considered.
+          </p>
         </div>
+
         <div class="field" *ngIf="target === 'drug'">
           <label class="label">Non-approved Drugs</label>
           <app-toggle textOn="Include" textOff="Ignore" tooltipOn="Include non-approved drugs."
                       tooltipOff="Exclude non-approved drugs from the result."
-                      [(value)]="trustrankIncludeNonApprovedDrugs"></app-toggle>
+                      [(value)]="trustrankIncludeNonApprovedDrugs">
+          </app-toggle>
         </div>
+
         <div class="field">
           <label class="label" for="trustrank-df">Damping Factor</label>
           <div class="control">
             <input [(ngModel)]="trustrankDampingFactor" id="trustrank-df" class="input" type="number"
-                   placeholder="Damping factor"
-                   min="0" max="1"
-                   required>
+                   placeholder="Damping factor" min="0" max="1" required>
+          </div>
+          <p class="help">
+            The larger the damping factor, the faster the trust is propagated through the network.
+          </p>
+        </div>
+
+        <div class="field">
+          <label class="label" for="trustrank-md">Maximum degree</label>
+          <div class="control">
+            <input [(ngModel)]="trustrankMaxDeg" id="trustrank-md" class="input" type="number"
+                   placeholder="Maximum degree" min="0" max="1" required>
           </div>
+          <p class="help">
+            All nodes with degree greater than this value times number of vertices will be ignored.
+          </p>
         </div>
+
+        <div class="field">
+          <label class="label" for="trustrank-hp">Hub penalty</label>
+          <div class="control">
+            <input [(ngModel)]="trustrankHubPenalty" id="trustrank-hp" class="input" type="number"
+                   placeholder="Maximum degree" min="0" max="1" required>
+          </div>
+          <p class="help">
+            Penalty parameter for hubs.
+          </p>
+        </div>
+
         <div class="field" *ngIf="target === 'drug-target'">
           <label class="label">Include non-seed viral proteins</label>
           <app-toggle textOn="Include" textOff="Ignore"
                       tooltipOn="Include viral proteins that are not seeds."
                       tooltipOff="Exclude viral proteins that are not seeds."
-                      [(value)]="trustrankIncludeViralNonSeeds"></app-toggle>
+                      [(value)]="trustrankIncludeViralNonSeeds">
+          </app-toggle>
+        </div>
+
+        <div class="box">
+          <article class="media">
+            <div class="media-left">
+              <span class="icon"><i class="fa fa-info"></i></span>
+            </div>
+            <div class="media-content">
+              <div class="content">
+                <h6 class="is-6">About TrustRank</h6>
+                <p>
+                  <a href="https://en.wikipedia.org/wiki/TrustRank" target="_blank">TrustRank</a>
+                  is a node centrality measure that ranks nodes in a network based on how well they are connected to a
+                  (trusted) set of seed nodes (Gyöngyi, Garcia-Molina, and Pedersen 2004).
+                </p>
+              </div>
+            </div>
+          </article>
         </div>
+
+      </div>
+
+      <div *ngIf="algorithm==='closeness'">
+
         <div class="field">
-          <label class="label" for="trustrank-rs">Result Size</label>
+          <label class="label" for="closeness-rs">Result Size</label>
           <div class="control">
-            <input [(ngModel)]="trustrankResultSize" id="trustrank-rs" class="input" type="number"
+            <input [(ngModel)]="closenessResultSize" id="closeness-rs" class="input" type="number"
                    placeholder="Result size" required>
           </div>
         </div>
-      </div>
 
-      <div *ngIf="algorithm==='closeness'">
-        <p class="help info"><span class="icon"><i class="fa fa-info"></i></span>
-          <a href="https://en.wikipedia.org/wiki/Closeness_centrality" target="_blank">Closeness Centrality</a>
-          is a node centrality measure that ranks the nodes in a network based on the lengths of their shortest paths
-          to all other nodes in the network (Kaczprowski, Doncheva, and Albrecht 2013).
-        </p>
         <div class="field" *ngIf="target === 'drug'">
           <label class="label">Indirect Drugs</label>
           <app-toggle textOn="Include" textOff="Ignore" tooltipOn="Include indirect drugs."
                       tooltipOff="Exclude indirect drugs from the result."
-                      [(value)]="closenessIncludeIndirectDrugs"></app-toggle>
+                      [(value)]="closenessIncludeIndirectDrugs">
+          </app-toggle>
+          <p class="help">
+            Specifies whether also drugs targeting interactors of the seed nodes should be considered.
+          </p>
         </div>
+
         <div class="field" *ngIf="target === 'drug'">
           <label class="label">Non-approved Drugs</label>
           <app-toggle textOn="Include" textOff="Ignore" tooltipOn="Include non-approved drugs."
                       tooltipOff="Exclude non-approved drugs from the result."
-                      [(value)]="closenessIncludeNonApprovedDrugs"></app-toggle>
+                      [(value)]="closenessIncludeNonApprovedDrugs">
+          </app-toggle>
+        </div>
+
+        <div class="field">
+          <label class="label" for="closeness-md">Maximum degree</label>
+          <div class="control">
+            <input [(ngModel)]="closenessMaxDeg" id="closeness-md" class="input" type="number"
+                   placeholder="Maximum degree" min="0" max="1" required>
+          </div>
+          <p class="help">
+            All nodes with degree greater than this value times number of vertices will be ignored.
+          </p>
+        </div>
+
+        <div class="field">
+          <label class="label" for="closeness-hp">Hub penalty</label>
+          <div class="control">
+            <input [(ngModel)]="closenessHubPenalty" id="closeness-hp" class="input" type="number"
+                   placeholder="Maximum degree" min="0" max="1" required>
+          </div>
+          <p class="help">
+            Penalty parameter for hubs.
+          </p>
         </div>
+
         <div class="field" *ngIf="target === 'drug-target'">
           <label class="label">Include non-seed viral proteins</label>
           <app-toggle textOn="Include" textOff="Ignore"
@@ -111,27 +184,55 @@
                       tooltipOff="Exclude viral proteins that are not seeds."
                       [(value)]="closenessIncludeViralNonSeeds"></app-toggle>
         </div>
+
+        <div class="box">
+          <article class="media">
+            <div class="media-left">
+              <span class="icon"><i class="fa fa-info"></i></span>
+            </div>
+            <div class="media-content">
+              <div class="content">
+                <h6 class="is-6">About Closeness Centrality</h6>
+                <p>
+                  <a href="https://en.wikipedia.org/wiki/Closeness_centrality" target="_blank">Closeness Centrality</a>
+                  is a node centrality measure that ranks the nodes in a network based on the lengths of their shortest
+                  paths to all other nodes in the network (Kaczprowski, Doncheva, and Albrecht 2013).
+                </p>
+              </div>
+            </div>
+          </article>
+        </div>
+
+      </div>
+
+      <div *ngIf="algorithm==='degree'">
+
         <div class="field">
-          <label class="label" for="closeness-rs">Result Size</label>
+          <label class="label" for="degree-rs">Result Size</label>
           <div class="control">
-            <input [(ngModel)]="closenessResultSize" id="closeness-rs" class="input" type="number"
+            <input [(ngModel)]="degreeResultSize" id="degree-rs" class="input" type="number"
                    placeholder="Result size" required>
           </div>
         </div>
-      </div>
 
-      <div *ngIf="algorithm==='degree'">
-        <p class="help info"><span class="icon"><i class="fa fa-info"></i></span>
-          <a href="https://en.wikipedia.org/wiki/Centrality#Degree_centrality" target="_blank">Degree Centrality</a>
-          assigns an importance score based simply on the number of links held by each node. In CoVex, we use a modified
-          version which does not consider all links but only the neighbouring seeds.
-        </p>
         <div class="field" *ngIf="target === 'drug'">
           <label class="label">Non-approved Drugs</label>
           <app-toggle textOn="Include" textOff="Ignore" tooltipOn="Include non-approved drugs."
                       tooltipOff="Exclude non-approved drugs from the result."
                       [(value)]="degreeIncludeNonApprovedDrugs"></app-toggle>
         </div>
+
+        <div class="field">
+          <label class="label" for="degree-md">Maximum degree</label>
+          <div class="control">
+            <input [(ngModel)]="degreeMaxDeg" id="degree-md" class="input" type="number"
+                   placeholder="Maximum degree" min="0" max="1" required>
+          </div>
+          <p class="help">
+            All nodes with degree greater than this value times number of vertices will be ignored.
+          </p>
+        </div>
+
         <div class="field" *ngIf="target === 'drug-target'">
           <label class="label">Include non-seed viral proteins</label>
           <app-toggle textOn="Include" textOff="Ignore"
@@ -139,21 +240,38 @@
                       tooltipOff="Exclude viral proteins that are not seeds."
                       [(value)]="degreeIncludeViralNonSeeds"></app-toggle>
         </div>
-        <div class="field">
-          <label class="label" for="degree-rs">Result Size</label>
-          <div class="control">
-            <input [(ngModel)]="degreeResultSize" id="degree-rs" class="input" type="number"
-                   placeholder="Result size" required>
-          </div>
+
+        <div class="box">
+          <article class="media">
+            <div class="media-left">
+              <span class="icon"><i class="fa fa-info"></i></span>
+            </div>
+            <div class="media-content">
+              <div class="content">
+                <h6 class="is-6">About Degree Centrality</h6>
+                <p>
+                  <a href="https://en.wikipedia.org/wiki/Centrality#Degree_centrality" target="_blank">
+                    Degree Centrality
+                  </a>
+                  assigns an importance score based simply on the number of links held by each node. In CoVex, we use
+                  a modified version which does not consider all links but only the neighbouring seeds.
+                </p>
+              </div>
+            </div>
+          </article>
         </div>
+
       </div>
 
       <div *ngIf="algorithm==='keypathwayminer'">
-        <p class="help info"><span class="icon"><i class="fa fa-info"></i></span>
-          <a href="https://keypathwayminer.compbio.sdu.dk/keypathwayminer/">KeyPathwayMiner</a>
-          is a network enrichment tool that identifies condition-specific sub-networks (key pathways)
-          (Alcaraz et al. 2016).
-        </p>
+
+        <div *ngIf="hasBaits">
+          <div class="notification is-warning warning">
+            You have selected <i class="fa fa-virus"></i> viral proteins.
+            If you want to use KeyPathwayMiner, please remove them because it cannot process them.
+          </div>
+        </div>
+
         <div class="field">
           <label class="label" for="keypathwayminer-k">K</label>
           <div class="control">
@@ -168,15 +286,29 @@
             </div>
           </div>
         </div>
+
+        <div class="box">
+          <article class="media">
+            <div class="media-left">
+              <span class="icon"><i class="fa fa-info"></i></span>
+            </div>
+            <div class="media-content">
+              <div class="content">
+                <h6 class="is-6">About KeyPathwayMiner</h6>
+                <p>
+                  <a href="https://keypathwayminer.compbio.sdu.dk/keypathwayminer/">KeyPathwayMiner</a>
+                  is a network enrichment tool that identifies condition-specific sub-networks (key pathways)
+                  (Alcaraz et al. 2016).
+                </p>
+              </div>
+            </div>
+          </article>
+        </div>
+
       </div>
 
       <div *ngIf="algorithm==='multisteiner'">
-        <p class="help info"><span class="icon"><i class="fa fa-info"></i></span>
-          The <a href="https://en.wikipedia.org/wiki/Steiner_tree_problem">Steiner tree</a>
-          problem is a classical combinatorial optimization problem. It asks to find a sub-graph
-          of minimum size connecting a given set of seed nodes.
-          This implementation behaves non-deterministically, so results can differ between multiple runs.
-        </p>
+
         <div class="field">
           <label class="label" for="multisteiner-numtrees">Number of Steiner trees to return</label>
           <div class="control">
@@ -194,6 +326,7 @@
             </div>
           </div>
         </div>
+
         <div class="field">
           <label class="label" for="multisteiner-numtrees">Tolerance for trees</label>
           <div class="control">
@@ -211,6 +344,29 @@
             </div>
           </div>
         </div>
+
+        <div class="field">
+          <label class="label" for="multisteiner-md">Maximum degree</label>
+          <div class="control">
+            <input [(ngModel)]="multisteinerMaxDeg" id="multisteiner-md" class="input" type="number"
+                   placeholder="Maximum degree" min="0" max="1" required>
+          </div>
+          <p class="help">
+            All nodes with degree greater than this value times number of vertices will be ignored.
+          </p>
+        </div>
+
+        <div class="field">
+          <label class="label" for="multisteiner-hp">Hub penalty</label>
+          <div class="control">
+            <input [(ngModel)]="multisteinerHubPenalty" id="multisteiner-hp" class="input" type="number"
+                   placeholder="Maximum degree" min="0" max="1" required>
+          </div>
+          <p class="help">
+            Penalty parameter for hubs.
+          </p>
+        </div>
+
         <div class="field" *ngIf="target === 'drug-target'">
           <label class="label">Include non-seed viral proteins</label>
           <app-toggle textOn="Include" textOff="Ignore"
@@ -218,6 +374,26 @@
                       tooltipOff="Exclude viral proteins that are not seeds."
                       [(value)]="multisteinerIncludeViralNonSeeds"></app-toggle>
         </div>
+
+        <div class="box">
+          <article class="media">
+            <div class="media-left">
+              <span class="icon"><i class="fa fa-info"></i></span>
+            </div>
+            <div class="media-content">
+              <div class="content">
+                <h6 class="is-6">About Multi-Steiner</h6>
+                <p>
+                  The <a href="https://en.wikipedia.org/wiki/Steiner_tree_problem">Steiner tree</a>
+                  problem is a classical combinatorial optimization problem. It asks to find a sub-graph
+                  of minimum size connecting a given set of seed nodes.
+                  This implementation behaves non-deterministically, so results can differ between multiple runs.
+                </p>
+              </div>
+            </div>
+          </article>
+        </div>
+
       </div>
     </section>
 
diff --git a/src/app/components/launch-analysis/launch-analysis.component.scss b/src/app/components/launch-analysis/launch-analysis.component.scss
index 7bf0ee27..07fa0d31 100644
--- a/src/app/components/launch-analysis/launch-analysis.component.scss
+++ b/src/app/components/launch-analysis/launch-analysis.component.scss
@@ -1,5 +1,6 @@
 .modal-card {
-  height: 600px;
+  height: 800px;
+  max-height: 80vh;
 }
 
 .modal-card-body {
@@ -13,4 +14,8 @@
 
 .help.info {
   margin-bottom: 20px;
+
+  .icon {
+    background-color: blue;
+  }
 }
diff --git a/src/app/components/launch-analysis/launch-analysis.component.ts b/src/app/components/launch-analysis/launch-analysis.component.ts
index c3575198..0d106c18 100644
--- a/src/app/components/launch-analysis/launch-analysis.component.ts
+++ b/src/app/components/launch-analysis/launch-analysis.component.ts
@@ -35,17 +35,22 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges {
   public trustrankIncludeNonApprovedDrugs = false;
   public trustrankIncludeViralNonSeeds = true;
   public trustrankDampingFactor = 0.85;
+  public trustrankMaxDeg = 1.0;
+  public trustrankHubPenalty = 0.0;
   public trustrankResultSize = 20;
 
   // Closeness Parameters
   public closenessIncludeIndirectDrugs = false;
   public closenessIncludeNonApprovedDrugs = false;
   public closenessIncludeViralNonSeeds = true;
+  public closenessMaxDeg = 1.0;
+  public closenessHubPenalty = 0.0;
   public closenessResultSize = 20;
 
   // Degree Parameters
   public degreeIncludeNonApprovedDrugs = false;
   public degreeIncludeViralNonSeeds = true;
+  public degreeMaxDeg = 1.0;
   public degreeResultSize = 20;
 
   // Keypathwayminer Parameters
@@ -55,6 +60,8 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges {
   public multisteinerNumTrees = 5;
   public multisteinerTolerance = 10;
   public multisteinerIncludeViralNonSeeds = true;
+  public multisteinerMaxDeg = 1.0;
+  public multisteinerHubPenalty = 0.0;
 
   public hasBaits;
 
@@ -96,17 +103,22 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges {
       parameters.include_indirect_drugs = this.trustrankIncludeIndirectDrugs;
       parameters.include_non_approved_drugs = this.trustrankIncludeNonApprovedDrugs;
       parameters.ignore_non_seed_baits = !this.trustrankIncludeViralNonSeeds;
+      parameters.max_deg = this.trustrankMaxDeg;
+      parameters.hub_penalty = this.trustrankHubPenalty;
       parameters.result_size = this.trustrankResultSize;
     } else if (this.algorithm === 'closeness') {
       parameters.strain_or_drugs = this.target === 'drug' ? 'drugs' : this.dataset;
       parameters.include_indirect_drugs = this.closenessIncludeIndirectDrugs;
       parameters.include_non_approved_drugs = this.closenessIncludeNonApprovedDrugs;
       parameters.ignore_non_seed_baits = !this.closenessIncludeViralNonSeeds;
+      parameters.max_deg = this.closenessMaxDeg;
+      parameters.hub_penalty = this.closenessHubPenalty;
       parameters.result_size = this.closenessResultSize;
     } else if (this.algorithm === 'degree') {
       parameters.strain_or_drugs = this.target === 'drug' ? 'drugs' : this.dataset;
       parameters.include_non_approved_drugs = this.degreeIncludeNonApprovedDrugs;
       parameters.ignore_non_seed_baits = !this.degreeIncludeViralNonSeeds;
+      parameters.max_deg = this.degreeMaxDeg;
       parameters.result_size = this.closenessResultSize;
     } else if (this.algorithm === 'keypathwayminer') {
       parameters.k = this.keypathwayminerK;
@@ -115,6 +127,8 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges {
       parameters.num_trees = this.multisteinerNumTrees;
       parameters.tolerance = this.multisteinerTolerance;
       parameters.ignore_non_seed_baits = !this.multisteinerIncludeViralNonSeeds;
+      parameters.max_deg = this.multisteinerMaxDeg;
+      parameters.hub_penalty = this.multisteinerHubPenalty;
     }
 
     await this.analysis.startAnalysis(this.algorithm, this.target, parameters);
-- 
GitLab