diff --git a/packages/libs/eda/src/lib/core/components/computations/plugins/differentialabundance.tsx b/packages/libs/eda/src/lib/core/components/computations/plugins/differentialabundance.tsx index bcd1e6a418..e022caaf28 100644 --- a/packages/libs/eda/src/lib/core/components/computations/plugins/differentialabundance.tsx +++ b/packages/libs/eda/src/lib/core/components/computations/plugins/differentialabundance.tsx @@ -35,6 +35,7 @@ import { GetBinRangesProps, getBinRanges, } from '../../../../map/analysis/utils/defaultOverlayConfig'; +import { config } from 'process'; const cx = makeClassNameHelper('AppStepConfigurationContainer'); @@ -154,16 +155,6 @@ function DifferentialAbundanceConfigDescriptionComponent({ )} -

- Method:{' '} - - {differentialAbundanceMethod ? ( - differentialAbundanceMethod - ) : ( - Not selected - )} - -

); } @@ -225,7 +216,6 @@ export function DifferentialAbundanceConfiguration( })); }, [collections]); - // TODO presumably to keep the saved analyses from breaking, we need to maintain support for a variableId const selectedCollectionVar = useMemo(() => { if (configuration && 'collectionVariable' in configuration) { const selectedItem = collectionVarItems.find((item) => @@ -299,10 +289,29 @@ export function DifferentialAbundanceConfiguration( ); const differentialAbundanceMethod = useMemo(() => { - if (configuration && 'differentialAbundanceMethod' in configuration) { - return configuration.differentialAbundanceMethod; + if (configuration && 'collectionVariable' in configuration) { + // First find the collection in our collections array so that we can access its annotations + const selectedCollection = collections.find( + (collection) => + collection.entityId === configuration.collectionVariable.entityId && + collection.id === configuration.collectionVariable.collectionId + ); + + // Now determine the appropriate method based on the collection's normalization method + const method = + selectedCollection?.normalizationMethod && + selectedCollection.normalizationMethod === 'NULL' + ? DIFFERENTIAL_ABUNDANCE_METHODS[0] + : DIFFERENTIAL_ABUNDANCE_METHODS[1]; + changeConfigHandler('differentialAbundanceMethod', method); + return method; } - }, [configuration]); + }, [ + selectedCollectionVar, + collections, + configuration?.collectionVariable, + changeConfigHandler, + ]); return ( - -
- Method - ({ - value: method, - display: method, - }))} - /> -
);