Skip to content

Commit 0676ebd

Browse files
authored
Merge pull request #117 from daisybio/dev
Fix several minor issues
2 parents 103a721 + 5a6b7d2 commit 0676ebd

File tree

4 files changed

+68
-9
lines changed

4 files changed

+68
-9
lines changed

src/app/components/transcript-modal/transcript-modal.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ <h1 mat-dialog-title>{{ BrowseService.getFullName(transcript) }}</h1>
5353
</ng-container>
5454

5555
<ng-container matColumnDef="psi">
56-
<th *matHeaderCellDef mat-header-cell>Psivec</th>
56+
<th *matHeaderCellDef mat-header-cell>Psi value</th>
5757
<td *matCellDef="let asEntry" mat-cell>
5858
{{ asEntry.psi | async }}
5959
</td>

src/app/routes/browse/network/network.component.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<app-info title="What do I see?">
88
<p>What you see is a subset of a large ceRNA network obtained by applying SPONGE to data from TCGA. The entire
99
network is too large to visualize here. You can adjust the filter criteria using the controls on the left.</p>
10+
<p>The size of the nodes is proportional to the degree of the node. The thickness of the edges is proportional to
11+
the mscor value of the interaction.</p>
1012
<h3>Shapes</h3>
1113
<table>
1214
<tr>
@@ -29,4 +31,8 @@ <h3>Shapes</h3>
2931
<mat-icon>open_in_new</mat-icon>
3032
Functional enrichment analysis using g:Profiler
3133
</a>
34+
<button (click)="setAllNodesState(!allNodesSelected$())" mat-stroked-button>{{allNodesSelected$() ? 'Deselect' :
35+
'Select'}} all visible nodes</button>
36+
<button (click)="setAllEdgesState(!allEdgesSelected$())" mat-stroked-button>{{allEdgesSelected$() ? 'Deselect' :
37+
'Select'}} all visible edges</button>
3238
</div>

src/app/routes/browse/network/network.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ export class NetworkComponent implements AfterViewInit, OnDestroy {
9292
graph$ = new ReplaySubject<Graph>();
9393
sigma?: Sigma;
9494
level$ = this.browseService.level$;
95+
allNodesSelected$ = this.browseService.allNodesSelected$;
96+
allEdgesSelected$ = this.browseService.allEdgesSelected$;
9597

9698
circleExplanation$: Signal<string> = computed(() => {
9799
switch (this.level$()) {
@@ -283,4 +285,12 @@ export class NetworkComponent implements AfterViewInit, OnDestroy {
283285
this.setNodeState(node, this.determineState(state));
284286
});
285287
}
288+
289+
setAllNodesState(state: boolean) {
290+
this.browseService.setAllNodesState(state);
291+
}
292+
293+
setAllEdgesState(state: boolean) {
294+
this.browseService.setAllEdgesState(state);
295+
}
286296
}

src/app/services/browse.service.ts

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -451,12 +451,14 @@ export class BrowseService {
451451
const graph = new Graph();
452452

453453
// Find max node degree for normalization
454-
const maxNodeDegree = Math.max(...nodes.map(node => node.node_degree));
454+
const maxNodeDegree = Math.max(...nodes.map((node) => node.node_degree));
455455

456456
// Find max mscor for normalization
457-
const maxMscor = Math.max(...interactions.map(interaction =>
458-
'gene1' in interaction ? interaction.mscor : interaction.mscor
459-
));
457+
const maxMscor = Math.max(
458+
...interactions.map((interaction) =>
459+
'gene1' in interaction ? interaction.mscor : interaction.mscor
460+
)
461+
);
460462

461463
nodes.forEach((node) => {
462464
const gene = BrowseService.getNodeGeneName(node);
@@ -465,7 +467,7 @@ export class BrowseService {
465467
);
466468

467469
// Calculate normalized node size based on degree (range: 5-20)
468-
const normalizedSize = 5 + (15 * (node.node_degree / maxNodeDegree));
470+
const normalizedSize = 5 + 15 * (node.node_degree / maxNodeDegree);
469471

470472
graph.addNode(BrowseService.getNodeID(node), {
471473
label: BrowseService.getNodeFullName(node),
@@ -484,14 +486,55 @@ export class BrowseService {
484486
}
485487

486488
// Calculate normalized edge size based on mscor (range: 1-5)
487-
const mscor = 'gene1' in interaction ? interaction.mscor : interaction.mscor;
488-
const normalizedSize = 1 + (6 * (mscor / maxMscor));
489+
const mscor =
490+
'gene1' in interaction ? interaction.mscor : interaction.mscor;
491+
const normalizedSize = 1 + 6 * (mscor / maxMscor);
489492

490493
graph.addEdge(ids[0], ids[1], {
491-
size: normalizedSize
494+
size: normalizedSize,
492495
});
493496
});
494497

495498
return graph;
496499
}
500+
501+
setAllNodesState(state: boolean) {
502+
this._nodeStates$.update((entityStates) => {
503+
return Object.fromEntries(
504+
Object.keys(entityStates).map((key) => [
505+
key,
506+
{
507+
...entityStates[key],
508+
[State.Active]: state,
509+
},
510+
])
511+
);
512+
});
513+
}
514+
515+
allNodesSelected$ = computed(() => {
516+
return Object.values(this._nodeStates$()).every(
517+
(state) => state[State.Active]
518+
);
519+
});
520+
521+
setAllEdgesState(state: boolean) {
522+
this._edgeStates$.update((entityStates) => {
523+
return Object.fromEntries(
524+
Object.keys(entityStates).map((key) => [
525+
key,
526+
{
527+
...entityStates[key],
528+
[State.Active]: state,
529+
},
530+
])
531+
);
532+
});
533+
}
534+
535+
allEdgesSelected$ = computed(() => {
536+
return Object.values(this._edgeStates$()).every(
537+
(state) => state[State.Active]
538+
);
539+
});
497540
}

0 commit comments

Comments
 (0)