diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2d98fee..1b2fa80 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,13 +5,12 @@ name: Node.js CI on: push: - branches: [ "master", "development" ] + branches: ['master', 'development'] pull_request: - branches: [ "master", "development" ] + branches: ['master', 'development'] jobs: build: - runs-on: ubuntu-latest strategy: @@ -20,14 +19,14 @@ jobs: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - run: npm i -g @angular/cli - - run: npm i -g nx - - run: npm ci - - run: ng lint - - run: ng run-many --all --target=test -- --no-watch --no-progress --browsers=ChromeHeadlessCI + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm i -g @angular/cli + - run: npm i -g nx + - run: npm i + - run: ng lint + - run: ng run-many --all --target=test -- --no-watch --no-progress --browsers=ChromeHeadlessCI diff --git a/apps/ramp-client/src/styles.scss b/apps/ramp-client/src/styles.scss index 2ca0e00..b6a4a73 100644 --- a/apps/ramp-client/src/styles.scss +++ b/apps/ramp-client/src/styles.scss @@ -179,6 +179,7 @@ a { @include utils.width(70); @include utils.width(66); @include utils.width(60); +@include utils.width(55); @include utils.width(50); @include utils.width(45); @include utils.width(40); @@ -203,6 +204,11 @@ a { top: calc(60px + 17vh) !important; } +.banner-title { + font-size: 1.5rem; + font-weight: bold; +} + @media only screen and (max-width: 1024px) { .navigation-menu-panel { width: 50%; diff --git a/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.html b/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.html index ceae677..7f09719 100644 --- a/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.html +++ b/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.html @@ -140,7 +140,7 @@

[position]="'right'" > -
+

Filter Results

diff --git a/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.ts b/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.ts index 4d9817a..f53d874 100644 --- a/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.ts +++ b/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.ts @@ -14,6 +14,7 @@ import { select } from '@ngrx/store'; import { ChemicalEnrichment, Classes, + RampChemicalEnrichmentResponse, RampResponse, } from '@ramp/models/ramp-models'; import { InputRowComponent } from '@ramp/shared/ramp/input-row'; @@ -25,7 +26,6 @@ import { FeedbackPanelComponent } from '@ramp/shared/ui/feedback-panel'; import { LoadingComponent } from '@ramp/shared/ui/loading-spinner'; import { DataProperty } from '@ramp/shared/ui/ncats-datatable'; import { - ClassesFromMetabolitesActions, MetaboliteEnrichmentsActions, RampSelectors, } from '@ramp/stores/ramp-store'; @@ -192,51 +192,48 @@ export class ChemicalEnrichmentComponent .pipe( select(RampSelectors.getChemicalEnrichment), takeUntilDestroyed(this.destroyRef), - map( - ( - res: - | { data: ChemicalEnrichment[]; openModal?: boolean } - | undefined, - ) => { - if (res && res.data) { - this.dataAsDataProperty = res.data.map( - (enrichment: ChemicalEnrichment) => { - const newObj: { [key: string]: DataProperty } = {}; - Object.entries(enrichment).map((value: any) => { - newObj[value[0]] = new DataProperty({ - name: value[0], - label: value[0], - value: value[1], - }); + map((res: RampChemicalEnrichmentResponse | undefined) => { + console.log(res); + if (res && res.enriched_chemical_class_list) { + this.dataAsDataProperty = res.enriched_chemical_class_list.map( + (enrichment: ChemicalEnrichment) => { + const newObj: { [key: string]: DataProperty } = {}; + Object.entries(enrichment).map((value: any) => { + newObj[value[0]] = new DataProperty({ + name: value[0], + label: value[0], + value: value[1], }); - return newObj; - }, - ); - this.enrichmentLoading = false; + }); + return newObj; + }, + ); + this.enrichmentLoading = false; - if (res.openModal) { - const ref: MatDialogRef = - this.dialog.open(CompleteDialogComponent, { - data: { - title: 'Chemical Class', - tabs: ['Chemical Classes', 'Enriched Chemical Classes'], - }, - }); + // if (res.openModal) { + const ref: MatDialogRef = this.dialog.open( + CompleteDialogComponent, + { + data: { + title: 'Chemical Class', + tabs: ['Chemical Classes', 'Enriched Chemical Classes'], + }, + }, + ); - ref.afterClosed().subscribe((res) => { - if (res) { - this.resultsTabs.selectedIndex = res; - this.ref.markForCheck(); - } - }); + ref.afterClosed().subscribe((res) => { + if (res) { + this.resultsTabs.selectedIndex = res; + this.ref.markForCheck(); } - this.ref.markForCheck(); - } - /*if (res && res.dataframe) { + }); + // } + this.ref.markForCheck(); + } + /*if (res && res.dataframe) { this.enrichmentDataFrame = res.dataframe; }*/ - }, - ), + }), ) .subscribe(); @@ -275,7 +272,7 @@ export class ChemicalEnrichmentComponent this.enrichmentLoading = true; if (this.file) { this.store.dispatch( - ClassesFromMetabolitesActions.fetchClassesFromMetabolites({ + MetaboliteEnrichmentsActions.fetchClassesFromMetabolites({ metabolites: event, biospecimen: this.biospecimenCtrl.value, background: this.file, @@ -290,7 +287,7 @@ export class ChemicalEnrichmentComponent ); } else { this.store.dispatch( - ClassesFromMetabolitesActions.fetchClassesFromMetabolites({ + MetaboliteEnrichmentsActions.fetchClassesFromMetabolites({ metabolites: event, biospecimen: this.biospecimenCtrl.value, }), diff --git a/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.html b/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.html index 72fd865..9b47913 100644 --- a/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.html +++ b/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.html @@ -149,7 +149,7 @@

Filter Results

-
+
Filter Results

Cluster Results

- {{ analyteType }}
- Analysis Complete - close -
-
- @if (!data.message) { -

- {{ data.title }} analysis is now complete. Click on the tabs or below - buttons to view the data. -

- } - @if (data.message) { -

{{ data.message }}

- } +
+
+ + close +
+
+ @if (!data.message) { +

+ {{ data.title }} analysis is now complete. Click on the tabs or below + buttons to view the data. +

+ } + @if (data.message) { +

{{ data.message }}

+ } +
+
+
+
+ @for (tab of data.tabs; track tab; let i = $index) { +
+ +
+ } +


-
- @for (tab of data.tabs; track tab; let i = $index) { - - } -
-
-
diff --git a/libs/shared/ui/complete-dialog/src/lib/complete-dialog/complete-dialog.component.scss b/libs/shared/ui/complete-dialog/src/lib/complete-dialog/complete-dialog.component.scss index 7b943b9..c2011b5 100644 --- a/libs/shared/ui/complete-dialog/src/lib/complete-dialog/complete-dialog.component.scss +++ b/libs/shared/ui/complete-dialog/src/lib/complete-dialog/complete-dialog.component.scss @@ -1,3 +1,7 @@ +.dialog-content { + padding: 1rem; +} + .close-button { cursor: pointer; } diff --git a/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.html b/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.html index 22d36b3..8db5daf 100644 --- a/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.html +++ b/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.html @@ -1,8 +1,5 @@ @if (showPaginator && pageData) { -
+
(), + fetchClassesFromMetabolitesSuccess: props<{ + data: Classes[]; + query: RampQuery; + dataframe?: FishersDataframe; + }>(), + fetchClassesFromMetabolitesFailure: props<{ error: any }>(), fetchEnrichmentFromMetabolites: props<{ metabolites: string[]; biospecimen?: string; @@ -216,11 +228,9 @@ export const MetaboliteEnrichmentsActions = createActionGroup({ }>(), fetchEnrichmentFromMetabolitesFile: emptyProps(), fetchEnrichmentFromMetabolitesSuccess: props<{ - data: ChemicalEnrichment[]; - enriched_chemical_class?: any; + data: RampChemicalEnrichmentResponse; pval_type?: string; pval_cutoff?: number; - dataframe?: FishersDataframe; }>(), fetchEnrichmentFromMetabolitesFailure: props<{ error: any }>(), filterEnrichmentFromMetabolites: props<{ @@ -228,9 +238,7 @@ export const MetaboliteEnrichmentsActions = createActionGroup({ pval_cutoff: number; }>(), filterEnrichmentFromMetabolitesSuccess: props<{ - data: ChemicalEnrichment[]; - enriched_chemical_class?: any; - openModal?: boolean; + data: RampChemicalEnrichmentResponse; }>(), filterEnrichmentFromMetabolitesFailure: props<{ error: any }>(), }, diff --git a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.ts b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.ts index 1dc98b0..647242a 100644 --- a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.ts +++ b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.ts @@ -11,6 +11,7 @@ import { Pathway, Properties, RampAPIResponse, + RampChemicalEnrichmentResponse, RampPathwayEnrichmentResponse, RampResponse, Reaction, @@ -32,9 +33,10 @@ import { RampService } from '../ramp.service'; import { exhaustMap, mergeMap, of, tap } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; import { + getChemicalEnrichment, getClusterPlot, getCombinedFishersDataframe, - getEnrichedChemicalClass, + // getEnrichedChemicalClass, getFilteredFishersDataframe, } from './ramp.selectors'; @@ -242,7 +244,10 @@ export const fetchMetabolitesFromOntologiesFile = createEffect( export const fetchClassesFromMetabolites = createEffect( (actions$ = inject(Actions), rampService = inject(RampService)) => { return actions$.pipe( - ofType(ClassesFromMetabolitesActions.fetchClassesFromMetabolites), + ofType( + ClassesFromMetabolitesActions.fetchClassesFromMetabolites, + MetaboliteEnrichmentsActions.fetchClassesFromMetabolites, + ), exhaustMap((action) => { return rampService .fetchChemicalClass( @@ -530,32 +535,40 @@ export const filterEnrichedChemicalClasses = createEffect( MetaboliteEnrichmentsActions.fetchEnrichmentFromMetabolitesSuccess, MetaboliteEnrichmentsActions.filterEnrichmentFromMetabolites, ), - concatLatestFrom((action) => store.select(getEnrichedChemicalClass)), + concatLatestFrom((action) => store.select(getChemicalEnrichment)), mergeMap(([action, dataframe]) => { - return rampService - .filterMetaboliteEnrichment( - dataframe as FishersDataframe, - action.pval_type, - action.pval_cutoff, - ) - .pipe( - map( - (ret: any) => { - return MetaboliteEnrichmentsActions.filterEnrichmentFromMetabolitesSuccess( - { - ...ret, - }, - ); - }, - catchError((error: ErrorEvent) => - of( - MetaboliteEnrichmentsActions.filterEnrichmentFromMetabolitesFailure( - { error }, + console.log(dataframe); + if (dataframe) { + return rampService + .filterMetaboliteEnrichment( + dataframe, + action.pval_type, + action.pval_cutoff, + ) + .pipe( + map( + (ret: RampChemicalEnrichmentResponse) => { + console.log(ret); + return MetaboliteEnrichmentsActions.filterEnrichmentFromMetabolitesSuccess( + { data: ret }, + ); + }, + catchError((error: ErrorEvent) => + of( + MetaboliteEnrichmentsActions.filterEnrichmentFromMetabolitesFailure( + { error }, + ), ), ), ), + ); + } else { + return of( + MetaboliteEnrichmentsActions.filterEnrichmentFromMetabolitesFailure( + { error: 'No dataframe available' }, ), ); + } }), ); }, @@ -570,10 +583,12 @@ export const fetchEnrichmentFromMetabolitesFile = createEffect( ) => { return actions$.pipe( ofType(MetaboliteEnrichmentsActions.fetchEnrichmentFromMetabolitesFile), - concatLatestFrom((action) => store.select(getEnrichedChemicalClass)), + concatLatestFrom((action) => store.select(getChemicalEnrichment)), tap(([action, dataframe]) => { if (dataframe) { - rampService.fetchEnrichmentFromMetabolitesFile(dataframe); + rampService.fetchEnrichmentFromMetabolitesFile( + dataframe.enriched_chemical_class_list, + ); } }), ); diff --git a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.reducer.ts b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.reducer.ts index 75cb4e3..8cabadd 100644 --- a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.reducer.ts +++ b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.reducer.ts @@ -2,7 +2,6 @@ import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity'; import { createReducer, on, Action } from '@ngrx/store'; import { Analyte, - ChemicalEnrichment, Classes, EntityCount, FisherResult, @@ -16,6 +15,7 @@ import { RampQuery, Reaction, SourceVersion, + RampChemicalEnrichmentResponse, } from '@ramp/models/ramp-models'; import { AnalyteFromPathwayActions, @@ -55,10 +55,7 @@ export interface State extends EntityState { properties?: RampResponse; - chemicalEnrichments?: { - data: ChemicalEnrichment[]; - openModal?: boolean; - }; + chemicalEnrichments?: RampChemicalEnrichmentResponse; pathwayEnrichments?: { data: FisherResult[]; @@ -68,8 +65,6 @@ export interface State extends EntityState { openModal?: boolean; }; - enriched_chemical_class?: { [key: string]: string[] }; - filteredFishersDataframe?: FishersDataframe; combinedFishersDataframe?: FishersDataframe; @@ -212,6 +207,7 @@ export const rampReducer = createReducer( on( ClassesFromMetabolitesActions.fetchClassesFromMetabolitesSuccess, + MetaboliteEnrichmentsActions.fetchClassesFromMetabolitesSuccess, (state, { data, query, dataframe }) => ({ ...state, loading: false, @@ -228,23 +224,18 @@ export const rampReducer = createReducer( }), ), - on( - MetaboliteEnrichmentsActions.fetchEnrichmentFromMetabolitesSuccess, - (state, { data, enriched_chemical_class }) => ({ - ...state, - loading: false, - chemicalEnrichments: { data, enriched_chemical_class }, - enriched_chemical_class: enriched_chemical_class, - }), - ), on( MetaboliteEnrichmentsActions.filterEnrichmentFromMetabolitesSuccess, - (state, { data, enriched_chemical_class }) => ({ - ...state, - loading: false, - chemicalEnrichments: { data, enriched_chemical_class, openModal: true }, - enriched_chemical_class: enriched_chemical_class, - }), + MetaboliteEnrichmentsActions.fetchEnrichmentFromMetabolitesSuccess, + (state, { data }) => { + console.log(data); + return { + ...state, + loading: false, + chemicalEnrichments: data, + openModal: true, + }; + }, ), on( diff --git a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.selectors.ts b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.selectors.ts index 13b1d82..dfaffa3 100644 --- a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.selectors.ts +++ b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.selectors.ts @@ -126,10 +126,10 @@ export const getFilteredFishersDataframe = createSelector( (state: State) => state.filteredFishersDataframe, ); -export const getEnrichedChemicalClass = createSelector( +/*export const getEnrichedChemicalClass = createSelector( getRampState, - (state: State) => state.enriched_chemical_class, -); + // (state: State) => state.chemicalEnrichments, +);*/ export const getClusterPlot = createSelector( getRampState, diff --git a/libs/stores/ramp-store/src/lib/+state/ramp.service.ts b/libs/stores/ramp-store/src/lib/+state/ramp.service.ts index a9ec3ed..9f612b6 100644 --- a/libs/stores/ramp-store/src/lib/+state/ramp.service.ts +++ b/libs/stores/ramp-store/src/lib/+state/ramp.service.ts @@ -389,18 +389,18 @@ export class RampService { ) // ,{responseType: 'text'}) .pipe( map((response: RampChemicalEnrichmentAPIResponse) => { - console.log(response.data); + console.log(response); const retList: ChemicalEnrichment[] = []; const responseClone = response.data; - delete responseClone.result_type; + // delete responseClone.result_type; [...Object.values(responseClone)].forEach((val: any) => val.forEach((cc: { [key: string]: unknown }) => { retList.push(new ChemicalEnrichment(cc)); }), ); return { - data: retList, - enriched_chemical_class: response.data, + data: response, + enriched_chemical_class_list: retList, } as RampChemicalEnrichmentResponse; }), // catchError(this.handleError('chemical enrichment', [])), @@ -408,13 +408,14 @@ export class RampService { } filterMetaboliteEnrichment( - dataframe: FishersDataframe, + dataframe: RampChemicalEnrichmentResponse, pval_type?: string, pval_cutoff?: number, ) { + console.log(dataframe); return this.http .post(`${this.url}filter-fisher-test-results`, { - fishers_results: dataframe, + fishers_results: dataframe.data, pval_type: pval_type, pval_cutoff: pval_cutoff, }) @@ -428,21 +429,21 @@ export class RampService { }), ); return { - data: retList, - enriched_chemical_class: response.data, + data: response.data, + enriched_chemical_class_list: retList, }; }), ); } - fetchEnrichmentFromMetabolitesFile(data: { [key: string]: string[] }) { - const enrichments: string[] = []; - Object.values(data).forEach((val: string[]) => { + fetchEnrichmentFromMetabolitesFile(data: ChemicalEnrichment[]) { + /* const enrichments: string[] = []; + data.forEach((val: ChemicalEnrichment[]) => { val.forEach((v: string) => enrichments.push(v)); }); - enrichments.pop(); + enrichments.pop();*/ this._downloadFile( - this._makeBlob(this._toTSV(enrichments)), + this._makeBlob(this._toTSV(data)), 'fetchEnrichmentFromMetabolites-download.tsv', ); }