66 ElementRef ,
77 inject ,
88 input ,
9+ model ,
910 viewChild ,
1011 ViewChild ,
1112} from '@angular/core' ;
@@ -21,10 +22,12 @@ import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator';
2122import { MatSort , MatSortHeader } from '@angular/material/sort' ;
2223import { MatButton } from '@angular/material/button' ;
2324import { MatTooltip } from '@angular/material/tooltip' ;
25+ import { MatSliderModule } from '@angular/material/slider' ;
26+ import { FormsModule } from '@angular/forms' ;
27+ import { DecimalPipe } from '@angular/common' ;
2428import { BrowseService } from '../../services/browse.service' ;
2529import { capitalize } from 'lodash' ;
2630import { InfoComponent } from '../info/info.component' ;
27- import katex from 'katex' ;
2831import { ModalsService } from '../modals-service/modals.service' ;
2932import { InfoService } from '../../services/info.service' ;
3033
@@ -38,6 +41,9 @@ import { InfoService } from '../../services/info.service';
3841 MatButton ,
3942 MatTooltip ,
4043 InfoComponent ,
44+ MatSliderModule ,
45+ FormsModule ,
46+ DecimalPipe ,
4147 ] ,
4248 templateUrl : './interactions-table.component.html' ,
4349 styleUrl : './interactions-table.component.scss' ,
@@ -54,9 +60,46 @@ export class InteractionsTableComponent implements AfterViewInit {
5460 mscorEquation$ = viewChild < ElementRef < HTMLSpanElement > > ( 'mscorEquation' ) ;
5561 infoService = inject ( InfoService ) ;
5662 columns = [ 'name_1' , 'name_2' , 'mirna' , 'correlation' , 'mscor' , 'padj' ] ;
63+
64+ minPValue = model ( 0 ) ;
65+ maxPValue = model ( 1 ) ;
66+ minMscor = model ( 0 ) ;
67+ maxMscor = model ( 1 ) ;
68+
69+ // Compute data limits
70+ pValueLimits = computed ( ( ) => {
71+ const interactions = this . interactions$ ( ) || [ ] ;
72+ const pValues = interactions . map ( i => i . p_value ) ;
73+ return {
74+ min : Math . min ( ...pValues ) ,
75+ max : Math . max ( ...pValues ) ,
76+ step : Math . pow ( 10 , Math . floor ( Math . log10 ( Math . min ( ...pValues ) ) ) ) / 10 // One decimal place smaller than smallest value
77+ } ;
78+ } ) ;
79+
80+ mscorLimits = computed ( ( ) => {
81+ const interactions = this . interactions$ ( ) || [ ] ;
82+ const mscors = interactions . map ( i => i . mscor ) ;
83+ return {
84+ min : Math . min ( ...mscors ) ,
85+ max : Math . max ( ...mscors ) ,
86+ step : 0.001 // Fixed small step for mscor
87+ } ;
88+ } ) ;
89+
5790 dataSource$ = computed ( ( ) => {
91+ const interactions = this . interactions$ ( ) || [ ] ;
92+ const filteredInteractions = interactions . filter ( interaction => {
93+ const pValue = interaction . p_value ;
94+ const mscor = interaction . mscor ;
95+ return pValue >= this . minPValue ( ) &&
96+ pValue <= this . maxPValue ( ) &&
97+ mscor >= this . minMscor ( ) &&
98+ mscor <= this . maxMscor ( ) ;
99+ } ) ;
100+
58101 return new MatTableDataSource (
59- ( this . interactions$ ( ) || [ ] ) . map ( ( interaction ) => {
102+ filteredInteractions . map ( ( interaction ) => {
60103 const names = BrowseService . getInteractionFullNames ( interaction ) ;
61104 return {
62105 name_1 : names [ 0 ] ,
@@ -83,6 +126,17 @@ export class InteractionsTableComponent implements AfterViewInit {
83126 effect ( ( ) => {
84127 this . infoService . renderMscorEquation ( this . mscorEquation$ ( ) ! ) ;
85128 } ) ;
129+
130+ // Initialize slider values to data limits
131+ effect ( ( ) => {
132+ const pLimits = this . pValueLimits ( ) ;
133+ const mLimits = this . mscorLimits ( ) ;
134+
135+ this . minPValue . set ( pLimits . min ) ;
136+ this . maxPValue . set ( pLimits . max ) ;
137+ this . minMscor . set ( mLimits . min ) ;
138+ this . maxMscor . set ( mLimits . max ) ;
139+ } ) ;
86140 }
87141
88142 ngAfterViewInit ( ) : void {
0 commit comments