From 22d51ab1748df55ab16ede194bccdb16a236799c Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Tue, 20 Apr 2021 00:19:46 -0700 Subject: [PATCH] add genesets as an argument --- client/src/components/categorical/category/index.js | 9 ++++++++- client/src/components/continuousLegend/index.js | 11 +++++++++-- .../src/components/graph/overlays/centroidLabels.js | 5 +++-- client/src/components/scatterplot/scatterplot.js | 5 +++-- client/src/util/stateManager/colorHelpers.js | 2 +- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/client/src/components/categorical/category/index.js b/client/src/components/categorical/category/index.js index a9649660..a08f8f7a 100644 --- a/client/src/components/categorical/category/index.js +++ b/client/src/components/categorical/category/index.js @@ -44,6 +44,7 @@ const LABEL_WIDTH_ANNO = LABEL_WIDTH - ANNO_BUTTON_WIDTH; schema, crossfilter: state.obsCrossfilter, isUserAnno, + genesets: state.genesets.genesets, }; }) class Category extends React.PureComponent { @@ -142,9 +143,15 @@ class Category extends React.PureComponent { */ const { schema } = annoMatrix; const { colorAccessor, colorMode } = colors; + const { genesets } = this.props; let colorDataPromise = Promise.resolve(null); if (colorAccessor) { - const query = createColorQuery(colorMode, colorAccessor, schema); + const query = createColorQuery( + colorMode, + colorAccessor, + schema, + genesets + ); if (query) colorDataPromise = annoMatrix.fetch(...query); } const [categoryData, colorData] = await Promise.all([ diff --git a/client/src/components/continuousLegend/index.js b/client/src/components/continuousLegend/index.js index 5087ab59..b0a58d28 100644 --- a/client/src/components/continuousLegend/index.js +++ b/client/src/components/continuousLegend/index.js @@ -106,16 +106,23 @@ const continuous = (selectorId, colorScale, colorAccessor) => { @connect((state) => ({ annoMatrix: state.annoMatrix, colors: state.colors, + genesets: state.genesets.genesets, })) class ContinuousLegend extends React.Component { async componentDidUpdate(prevProps) { - const { annoMatrix, colors } = this.props; + const { annoMatrix, colors, genesets } = this.props; if (!colors || !annoMatrix) return; if (colors !== prevProps?.colors || annoMatrix !== prevProps?.annoMatrix) { const { schema } = annoMatrix; const { colorMode, colorAccessor, userColors } = colors; - const colorQuery = createColorQuery(colorMode, colorAccessor, schema); + const colorQuery = createColorQuery( + colorMode, + colorAccessor, + schema, + genesets + ); + const colorDf = colorQuery ? await annoMatrix.fetch(...colorQuery) : null; const colorTable = createColorTable( colorMode, diff --git a/client/src/components/graph/overlays/centroidLabels.js b/client/src/components/graph/overlays/centroidLabels.js index 65f22215..3f4d19aa 100644 --- a/client/src/components/graph/overlays/centroidLabels.js +++ b/client/src/components/graph/overlays/centroidLabels.js @@ -14,6 +14,7 @@ export default dilatedValue: state.pointDilation.categoryField, categoricalSelection: state.categoricalSelection, showLabels: state.centroidLabels?.showLabels, + genesets: state.genesets.genesets, })) class CentroidLabels extends PureComponent { static watchAsync(props, prevProps) { @@ -74,10 +75,10 @@ class CentroidLabels extends PureComponent { }; colorByQuery() { - const { annoMatrix, colors } = this.props; + const { annoMatrix, colors, genesets } = this.props; const { schema } = annoMatrix; const { colorMode, colorAccessor } = colors; - return createColorQuery(colorMode, colorAccessor, schema); + return createColorQuery(colorMode, colorAccessor, schema, genesets); } async fetchData() { diff --git a/client/src/components/scatterplot/scatterplot.js b/client/src/components/scatterplot/scatterplot.js index b70fd4ae..91c12ac1 100644 --- a/client/src/components/scatterplot/scatterplot.js +++ b/client/src/components/scatterplot/scatterplot.js @@ -53,6 +53,7 @@ const getYScale = memoize(getScale); differential: state.differential, crossfilter, + genesets: state.genesets.genesets, }; }) class Scatterplot extends React.PureComponent { @@ -313,10 +314,10 @@ class Scatterplot extends React.PureComponent { } createColorByQuery(colors) { - const { annoMatrix } = this.props; + const { annoMatrix, genesets } = this.props; const { schema } = annoMatrix; const { colorMode, colorAccessor } = colors; - return createColorQuery(colorMode, colorAccessor, schema); + return createColorQuery(colorMode, colorAccessor, schema, genesets); } updateColorTable(colors, colorDf) { diff --git a/client/src/util/stateManager/colorHelpers.js b/client/src/util/stateManager/colorHelpers.js index 2271ea2d..d5cd4885 100644 --- a/client/src/util/stateManager/colorHelpers.js +++ b/client/src/util/stateManager/colorHelpers.js @@ -13,7 +13,7 @@ given a color mode & accessor, generate an annoMatrix query that will fulfill it */ export function createColorQuery(colorMode, colorByAccessor, schema, genesets) { - if (!colorMode || !colorByAccessor || !schema) return null; + if (!colorMode || !colorByAccessor || !schema || !genesets) return null; switch (colorMode) { case "color by categorical metadata": case "color by continuous metadata": {