diff --git a/src/components/expression/expression.js b/src/components/expression/expression.js index 1b472030..0484d92a 100644 --- a/src/components/expression/expression.js +++ b/src/components/expression/expression.js @@ -12,40 +12,130 @@ import actions from "../../actions"; } }) class DiffExp extends React.Component { + handleGeneColorScaleClick(gene) { + return () => { + this.props.dispatch(actions.requestSingleGeneExpressionCountsForColoringPOST(gene)) + } + } render() { if (!this.props.differential.diffExp) return null - const topGenesForCellSet1 = this.props.differential.diffExp.data.celllist1; const topGenesForCellSet2 = this.props.differential.diffExp.data.celllist2; const rectSide = 10; const rightMargin = 0; + const extent = d3.extent( + _.union( + topGenesForCellSet1.mean_expression_cellset1, + topGenesForCellSet1.mean_expression_cellset2, + topGenesForCellSet2.mean_expression_cellset1, + topGenesForCellSet2.mean_expression_cellset2 + ) + ) + + console.log('diffexp', this.props) + console.log('extent', extent) + + const greyColorScale = d3.scaleSequential() + .domain(extent) + .interpolator(d3.interpolateGreys); + return (
-

Top genes expressed by cellset 1

-

Gene {"............"} Exp in set 1 {"............"} Exp in set 2

+
+

Gene

+

Set 1 exp

+

Set 2 exp

+
{ topGenesForCellSet1.topgenes.map((gene, i) => { return ( -

- {gene} {"...................... "} - {Math.floor(topGenesForCellSet1.mean_expression_cellset1[i])} {" ................... "} - {Math.floor(topGenesForCellSet1.mean_expression_cellset2[i])} -

+
+
+ 🎨 + {gene} +
+

+ {Math.floor(topGenesForCellSet1.mean_expression_cellset1[i])} +

+

+ {Math.floor(topGenesForCellSet1.mean_expression_cellset2[i])} +

+
) }) } -

Top genes expressed by cellset 2

-

Gene {"............"} Exp in set 1 {"............"} Exp in set 2

{ topGenesForCellSet2.topgenes.map((gene, i) => { return ( -

- {gene} {"...................... "} - {Math.floor(topGenesForCellSet2.mean_expression_cellset1[i])} {" ................... "} - {Math.floor(topGenesForCellSet2.mean_expression_cellset2[i])} -

+
+
+ 🎨 + {gene} +
+

+ {Math.floor(topGenesForCellSet2.mean_expression_cellset1[i])} +

+

+ {Math.floor(topGenesForCellSet2.mean_expression_cellset2[i])} +

+
) }) } @@ -54,6 +144,9 @@ class DiffExp extends React.Component { } } +//

Top genes expressed by cellset 2

+//

Gene {"............"} Exp in set 1 {"............"} Exp in set 2

+ @connect((state) => { return { @@ -120,46 +213,74 @@ class Expression extends React.Component { ) { return null } - - console.log('expression render sees', this.props.differential) return ( -
- -
- - -
+
+ - Gene count: -
- - { - _.map(this.props.expression.genes, (gene) => { - return ( - - ) - }) - }
) } @@ -168,6 +289,25 @@ class Expression extends React.Component { export default Expression; +// +// +// { +// _.map(this.props.expression.genes, (gene) => { +// return ( +// +// ) +// }) +// } + + +// Gene count: +// + // // // { diff --git a/src/middleware/updateCellColors.js b/src/middleware/updateCellColors.js index d1f3735d..b10997f4 100644 --- a/src/middleware/updateCellColors.js +++ b/src/middleware/updateCellColors.js @@ -79,10 +79,9 @@ const updateCellSelectionMiddleware = (store) => { } if (action.type === "color by expression") { - /* we assume if they clicked the control we must have loaded something, that could change though. */ - /* this bit could be sped up and could be on the server, but it's drawn once on click, not at 60fps */ - const indexOfGene = s.expression.data.genes.indexOf(action.gene); + + const indexOfGene = 0 /* we only get one, this comes from server as needed now */ const expressionMap = {} /* @@ -93,34 +92,33 @@ const updateCellSelectionMiddleware = (store) => { cell789: [0, 8] } */ - _.each(s.expression.data.cells, (cell) => { + _.each(action.data.data.cells, (cell) => { /* this action is coming directly from the server */ expressionMap[cell.cellname] = cell.e }) - const minExpressionCell = _.minBy(s.expression.data.cells, (cell) => { + const minExpressionCell = _.minBy(action.data.data.cells, (cell) => { return cell.e[indexOfGene] }) - const maxExpressionCell = _.maxBy(s.expression.data.cells, (cell) => { + const maxExpressionCell = _.maxBy(action.data.data.cells, (cell) => { return cell.e[indexOfGene] }) + + console.log('middle', action, expressionMap, minExpressionCell) + + colorScale = d3.scaleLinear() .domain([minExpressionCell.e[indexOfGene], maxExpressionCell.e[indexOfGene]]) .range([1,0]) /* invert viridis... probably pass this scale through to others */ - - _.each(currentSelectionWithUpdatedColors, (cell, i) => { - currentSelectionWithUpdatedColors[i]["__color__"] = d3.interpolateViridis( colorScale( expressionMap[cell.CellName][indexOfGene] ) ) }) - - } /*