From c32876f69256b1d49812474a5f29dc7429588a1c Mon Sep 17 00:00:00 2001 From: asizemore Date: Mon, 9 Oct 2023 14:42:35 -0400 Subject: [PATCH 1/5] auto-select diff abund method based on data --- .../plugins/differentialabundance.tsx | 55 ++++++++----------- 1 file changed, 23 insertions(+), 32 deletions(-) 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, - }))} - /> -
); From 6f86d508329ff3c358d715e29dcf093b26f9a145 Mon Sep 17 00:00:00 2001 From: asizemore Date: Mon, 9 Oct 2023 15:12:02 -0400 Subject: [PATCH 2/5] show method in volcano subtitle --- .../plugins/differentialabundance.tsx | 9 +++++++-- .../implementations/VolcanoPlotVisualization.tsx | 16 +++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) 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 e022caaf28..8dedad88af 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,7 +35,6 @@ import { GetBinRangesProps, getBinRanges, } from '../../../../map/analysis/utils/defaultOverlayConfig'; -import { config } from 'process'; const cx = makeClassNameHelper('AppStepConfigurationContainer'); @@ -91,7 +90,13 @@ export const plugin: ComputationPlugin = { createDefaultConfiguration: () => undefined, isConfigurationValid: isCompleteDifferentialAbundanceConfig, visualizationPlugins: { - volcanoplot: volcanoPlotVisualization, // Must match name in data service and in visualization.tsx + volcanoplot: volcanoPlotVisualization.withOptions({ + getPlotSubtitle(config) { + if (DifferentialAbundanceConfig.is(config)) { + return `Differential abundance computed using ${config.differentialAbundanceMethod} with default parameters.`; + } + }, + }), // Must match name in data service and in visualization.tsx }, }; diff --git a/packages/libs/eda/src/lib/core/components/visualizations/implementations/VolcanoPlotVisualization.tsx b/packages/libs/eda/src/lib/core/components/visualizations/implementations/VolcanoPlotVisualization.tsx index a093726e0b..429a0c3279 100755 --- a/packages/libs/eda/src/lib/core/components/visualizations/implementations/VolcanoPlotVisualization.tsx +++ b/packages/libs/eda/src/lib/core/components/visualizations/implementations/VolcanoPlotVisualization.tsx @@ -25,7 +25,7 @@ import { createVisualizationPlugin } from '../VisualizationPlugin'; import LabelledGroup from '@veupathdb/components/lib/components/widgets/LabelledGroup'; import { NumberInput } from '@veupathdb/components/lib/components/widgets/NumberAndDateInputs'; -import { LayoutOptions } from '../../layouts/types'; +import { LayoutOptions, TitleOptions } from '../../layouts/types'; import { RequestOptions } from '../options/types'; // Volcano plot imports @@ -54,6 +54,7 @@ import SliderWidget, { import { ResetButtonCoreUI } from '../../ResetButton'; import AxisRangeControl from '@veupathdb/components/lib/components/plotControls/AxisRangeControl'; import { fixVarIdLabel } from '../../../utils/visualization'; +import { OutputEntityTitle } from '../OutputEntityTitle'; // end imports const DEFAULT_SIG_THRESHOLD = 0.05; @@ -106,6 +107,7 @@ export const VolcanoPlotConfig = t.partial({ interface Options extends LayoutOptions, + TitleOptions, RequestOptions {} // Volcano Plot Visualization @@ -384,6 +386,11 @@ function VolcanoPlotViz(props: VisualizationProps) { ] ); + // plot subtitle + const plotSubtitle = options?.getPlotSubtitle?.( + computation.descriptor.configuration + ); + // Add labels to the extremes of the x axis. These may change in the future based on the type // of data. For example, for genes we may want to say Up regulated in... const comparisonLabels = @@ -627,12 +634,7 @@ function VolcanoPlotViz(props: VisualizationProps) { /> - {/* This should be populated with info from the colections var. So like "Showing 1000 taxa blah". Waiting on collections annotations. */} - {/* */} + Date: Tue, 10 Oct 2023 05:40:35 -0400 Subject: [PATCH 3/5] replace auto-select with maaslin only --- .../plugins/differentialabundance.tsx | 47 +++++-------------- 1 file changed, 12 insertions(+), 35 deletions(-) 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 8dedad88af..daab200812 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 @@ -123,10 +123,6 @@ function DifferentialAbundanceConfigDescriptionComponent({ 'comparator' in configuration ? findEntityAndVariable(configuration.comparator.variable) : undefined; - const differentialAbundanceMethod = - 'differentialAbundanceMethod' in configuration - ? configuration.differentialAbundanceMethod - : undefined; const updatedCollectionVariable = collections.find((collectionVar) => isEqual( @@ -165,7 +161,9 @@ function DifferentialAbundanceConfigDescriptionComponent({ } // Include available methods in this array. -const DIFFERENTIAL_ABUNDANCE_METHODS = ['DESeq', 'Maaslin']; +// 10/10/23 - decided to only release Maaslin for the first roll-out. DESeq is still available +// and we're poised to release it in the future. +const DIFFERENTIAL_ABUNDANCE_METHODS = ['Maaslin']; // + 'DESeq' in the future export function DifferentialAbundanceConfiguration( props: ComputationConfigProps @@ -185,6 +183,11 @@ export function DifferentialAbundanceConfiguration( const filters = analysisState.analysis?.descriptor.subset.descriptor; const findEntityAndVariable = useFindEntityAndVariable(filters); + // Only releasing Maaslin for b66 + if (configuration) + configuration.differentialAbundanceMethod = + DIFFERENTIAL_ABUNDANCE_METHODS[0]; + // Include known collection variables in this array. const collections = useCollectionVariables(studyMetadata.rootEntity); if (collections.length === 0) @@ -205,11 +208,10 @@ export function DifferentialAbundanceConfiguration( const collectionVarItems = useMemo(() => { return collections .filter((collectionVar) => { - return collectionVar.normalizationMethod // i guess diy stuff doesnt have this prop? - ? // !collectionVar.isProportion && - // collectionVar.normalizationMethod === 'NULL' && - !collectionVar.displayName?.includes('pathway') - : true; + return collectionVar.normalizationMethod + ? collectionVar.normalizationMethod !== 'NULL' && + !collectionVar.displayName?.includes('pathway') + : true; // DIY may not have the normalizationMethod annotations, but we still want those datasets to pass. }) .map((collectionVar) => ({ value: { @@ -293,31 +295,6 @@ export function DifferentialAbundanceConfiguration( } ); - const differentialAbundanceMethod = useMemo(() => { - 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; - } - }, [ - selectedCollectionVar, - collections, - configuration?.collectionVariable, - changeConfigHandler, - ]); - return ( Date: Tue, 10 Oct 2023 05:57:05 -0400 Subject: [PATCH 4/5] remove unused imports --- .../visualizations/implementations/VolcanoPlotVisualization.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/libs/eda/src/lib/core/components/visualizations/implementations/VolcanoPlotVisualization.tsx b/packages/libs/eda/src/lib/core/components/visualizations/implementations/VolcanoPlotVisualization.tsx index 429a0c3279..fabe9ccda7 100755 --- a/packages/libs/eda/src/lib/core/components/visualizations/implementations/VolcanoPlotVisualization.tsx +++ b/packages/libs/eda/src/lib/core/components/visualizations/implementations/VolcanoPlotVisualization.tsx @@ -34,7 +34,6 @@ import DataClient, { VolcanoPlotResponse, } from '../../../api/DataClient'; import { - VolcanoPlotData, VolcanoPlotDataPoint, VolcanoPlotStats, } from '@veupathdb/components/lib/types/plots/volcanoplot'; From fc04d5a4b57b50ae1d2100760c341119489d7e4a Mon Sep 17 00:00:00 2001 From: asizemore Date: Tue, 10 Oct 2023 07:01:50 -0400 Subject: [PATCH 5/5] clean and clarify --- .../computations/plugins/differentialabundance.tsx | 6 ++++-- .../implementations/VolcanoPlotVisualization.tsx | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) 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 daab200812..2601fad52b 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 @@ -206,11 +206,13 @@ export function DifferentialAbundanceConfiguration( ); const collectionVarItems = useMemo(() => { + // Show all collections except for absolute abundance. Eventually this will be performed by + // the backend, similar to how we do visualization input var constraints. return collections .filter((collectionVar) => { return collectionVar.normalizationMethod - ? collectionVar.normalizationMethod !== 'NULL' && - !collectionVar.displayName?.includes('pathway') + ? collectionVar.normalizationMethod !== 'NULL' || + collectionVar.displayName?.includes('pathway') : true; // DIY may not have the normalizationMethod annotations, but we still want those datasets to pass. }) .map((collectionVar) => ({ diff --git a/packages/libs/eda/src/lib/core/components/visualizations/implementations/VolcanoPlotVisualization.tsx b/packages/libs/eda/src/lib/core/components/visualizations/implementations/VolcanoPlotVisualization.tsx index fabe9ccda7..f1e7c46ed9 100755 --- a/packages/libs/eda/src/lib/core/components/visualizations/implementations/VolcanoPlotVisualization.tsx +++ b/packages/libs/eda/src/lib/core/components/visualizations/implementations/VolcanoPlotVisualization.tsx @@ -121,8 +121,6 @@ function VolcanoPlotViz(props: VisualizationProps) { updateConfiguration, updateThumbnail, filters, - dataElementConstraints, - dataElementDependencyOrder, filteredCounts, computeJobStatus, } = props;