componetize buttons on diffexp to generalize

This commit is contained in:
Colin Megill
2018-02-28 09:49:58 -08:00
parent 56f6aca981
commit bafd2827fe
3 changed files with 80 additions and 88 deletions
@@ -0,0 +1,63 @@
import React from "react";
import _ from "lodash";
import { connect } from "react-redux";
import * as globals from "../../globals";
import styles from "../framework/buttons.css";
import actions from "../../actions";
@connect()
class CellSetButton extends React.Component {
set() {
const set = [];
_.each(this.props.currentCellSelection, (cell) => {
if (cell["__selected__"]) {
set.push(cell.CellName)
}
})
this.props.dispatch({
type: "store current cell selection as differential set " + this.props.eitherCellSetOneOrTwo,
data: set
})
}
render() {
return (
<span style={{marginRight: 20}}>
<button
style={{
color: "#FFF",
padding: "0px 10px",
height: 30,
backgroundColor: globals.brightBlue,
border: "none",
cursor: "pointer",
}}
onClick={this.set.bind(this)}>
<span style={{fontSize: 24, fontWeight: 700}}> {this.props.eitherCellSetOneOrTwo} </span>
<span style={{fontFamily: "Georgia", fontStyle: "italic", marginLeft: 8, position: "relative", top: -3}}>
{
this.props.differential["celllist" + this.props.eitherCellSetOneOrTwo] ?
this.props.differential["celllist" + this.props.eitherCellSetOneOrTwo].length + " cells" :
0 + " cells"
}
</span>
</button>
<button style={{
marginLeft: 3,
color: "#FFF",
padding: "0px 10px",
height: 30,
backgroundColor: globals.brightBlue,
border: "none",
cursor: "pointer",
}}>
<span style={{fontSize: 24, fontWeight: 700}}> X </span>
</button>
</span>
)
}
}
export default CellSetButton;
+2 -2
View File
@@ -46,7 +46,7 @@ class HeatmapSquare extends React.Component {
*********************************** ***********************************
**********************************/ **********************************/
@connect((state) => { @connect((state) => {
return { return {
scatterplotXXaccessor: state.controls.scatterplotXXaccessor, scatterplotXXaccessor: state.controls.scatterplotXXaccessor,
scatterplotYYaccessor: state.controls.scatterplotYYaccessor, scatterplotYYaccessor: state.controls.scatterplotYYaccessor,
@@ -166,7 +166,7 @@ class Heatmap extends React.Component {
} }
} }
render() { render() {
if (!this.props.differential.diffExp) return null if (!this.props.differential.diffExp) return <p>Select cells & compute differential to see heatmap</p>
const topGenesForCellSet1 = this.props.differential.diffExp.data.celllist1; const topGenesForCellSet1 = this.props.differential.diffExp.data.celllist1;
const topGenesForCellSet2 = this.props.differential.diffExp.data.celllist2; const topGenesForCellSet2 = this.props.differential.diffExp.data.celllist2;
+15 -86
View File
@@ -2,11 +2,8 @@ import React from "react";
import _ from "lodash"; import _ from "lodash";
import { connect } from "react-redux"; import { connect } from "react-redux";
import * as globals from "../../globals"; import * as globals from "../../globals";
import styles from "./expression.css";
import actions from "../../actions"; import actions from "../../actions";
import Heatmap from "./diffExpHeatmap"; import CellSetButton from "./cellSetButtons";
// <p> Top genes expressed by cellset 2 </p>
// <p> Gene {"............"} Exp in set 1 {"............"} Exp in set 2 </p>
@connect((state) => { @connect((state) => {
return { return {
@@ -29,34 +26,6 @@ class Expression extends React.Component {
}); });
} }
} }
set1() {
const set = [];
_.each(this.props.currentCellSelection, (cell) => {
if (cell["__selected__"]) {
set.push(cell.CellName)
}
})
this.props.dispatch({
type: "store current cell selection as differential set 1",
data: set
})
}
set2() {
const set = [];
_.each(this.props.currentCellSelection, (cell) => {
if (cell["__selected__"]) {
set.push(cell.CellName)
}
})
this.props.dispatch({
type: "store current cell selection as differential set 2",
data: set
})
}
computeDiffExp() { computeDiffExp() {
this.props.dispatch( this.props.dispatch(
actions.requestDifferentialExpression( actions.requestDifferentialExpression(
@@ -73,70 +42,30 @@ class Expression extends React.Component {
} }
return ( return (
<div> <div>
<div style={{ <div style={{margin: 10}}>
marginBottom: 20, <CellSetButton
width: 500, {...this.props}
}}> eitherCellSetOneOrTwo={1}/>
<button <CellSetButton
style={{ {...this.props}
width: 200, eitherCellSetOneOrTwo={2}/>
fontSize: 14, </div>
margin: 5,
fontWeight: 400,
color: "#5A5F63",
padding: "10px 20px",
backgroundColor: "#C5D1D8",
border: "none",
borderRadius: 3,
cursor: "pointer",
}}
onClick={this.set1.bind(this)}>
{
this.props.differential.celllist1 ?
this.props.differential.celllist1.length + " cells selected" :
"Store current cell selection as 'set 1'"
}
</button>
<button
style={{
width: 200,
fontSize: 14,
margin: 5,
fontWeight: 400,
color: "#5A5F63",
padding: "10px 20px",
backgroundColor: "#C5D1D8",
border: "none",
borderRadius: 3,
cursor: "pointer",
}}
onClick={this.set2.bind(this)}>
{
this.props.differential.celllist2 ?
this.props.differential.celllist2.length + " cells selected" :
"Store current cell selection as 'set 2'"
}
</button>
</div>
<div> <div>
<button <button
style={{ style={{
fontSize: 14, fontSize: 18,
margin: 5, margin: 10,
fontWeight: 400, fontWeight: 700,
color: "#41633C", color: "#FFF",
padding: "10px 20px", padding: "12px 20px",
backgroundColor: "#B9D1B5", backgroundColor: "#448C4D",
border: "none", border: "none",
borderRadius: 3,
cursor: "pointer", cursor: "pointer",
}} }}
onClick={this.computeDiffExp.bind(this)}> onClick={this.computeDiffExp.bind(this)}>
Compute differential expression Compute differential expression
</button> </button>
</div> </div>
<Heatmap/>
</div> </div>
) )
} }