mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-05 00:28:11 +08:00
break out differential genes from user defined
This commit is contained in:
@@ -20,10 +20,12 @@ import actions from "../../actions/";
|
|||||||
ranges,
|
ranges,
|
||||||
metadata,
|
metadata,
|
||||||
initializeRanges,
|
initializeRanges,
|
||||||
userDefinedGenes: state.userDefinedGenes,
|
userDefinedGenes: state.controls.userDefinedGenes,
|
||||||
world: state.controls.world,
|
world: state.controls.world,
|
||||||
|
dimensionMap: state.controls.dimensionMap,
|
||||||
colorAccessor: state.controls.colorAccessor,
|
colorAccessor: state.controls.colorAccessor,
|
||||||
allGeneNames: state.controls.allGeneNames
|
allGeneNames: state.controls.allGeneNames,
|
||||||
|
differential: state.differential
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
class GeneExpression extends React.Component {
|
class GeneExpression extends React.Component {
|
||||||
@@ -38,51 +40,8 @@ class GeneExpression extends React.Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {}
|
|
||||||
handleBrushAction(selection) {
|
|
||||||
this.props.dispatch({
|
|
||||||
type: "continuous selection using parallel coords brushing",
|
|
||||||
data: selection
|
|
||||||
});
|
|
||||||
}
|
|
||||||
handleColorAction(key) {
|
|
||||||
return () => {};
|
|
||||||
const indexOfGene = 0; /* we only get one, this comes from server as needed now */
|
|
||||||
|
|
||||||
const expressionMap = {};
|
|
||||||
/*
|
|
||||||
converts [{cellname: cell123, e}, ...]
|
|
||||||
|
|
||||||
expressionMap = {
|
|
||||||
cell123: [123, 2],
|
|
||||||
cell789: [0, 8]
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// _.each(data.data.cells, cell => {
|
|
||||||
// /* this action is coming directly from the server */
|
|
||||||
// expressionMap[cell.cellname] = cell.e;
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// const minExpressionCell = _.minBy(data.data.cells, cell => {
|
|
||||||
// return cell.e[indexOfGene];
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// const maxExpressionCell = _.maxBy(data.data.cells, cell => {
|
|
||||||
// return cell.e[indexOfGene];
|
|
||||||
// });
|
|
||||||
// dispatch({
|
|
||||||
// type: "color by expression"
|
|
||||||
// gene: gene,
|
|
||||||
// colorAccessor: gene,
|
|
||||||
// data,
|
|
||||||
// expressionMap,
|
|
||||||
// minExpressionCell,
|
|
||||||
// maxExpressionCell,
|
|
||||||
// indexOfGene
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { world, userDefinedGenes } = this.props;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<input
|
<input
|
||||||
@@ -101,9 +60,21 @@ class GeneExpression extends React.Component {
|
|||||||
padding: 0
|
padding: 0
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
this.props.dispatch(
|
if (userDefinedGenes.indexOf(this.state.gene) !== -1) {
|
||||||
actions.requestGeneExpressionCountsPOST([this.state.gene])
|
console.log("That gene already exists");
|
||||||
);
|
} else if (userDefinedGenes.length > 15) {
|
||||||
|
console.log(
|
||||||
|
"That's too many genes, you can have at most 15 user defined genes"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.props.dispatch(
|
||||||
|
actions.requestGeneExpressionCountsPOST([this.state.gene])
|
||||||
|
);
|
||||||
|
this.props.dispatch({
|
||||||
|
type: "user defined gene",
|
||||||
|
data: this.state.gene
|
||||||
|
});
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CirclePlus
|
<CirclePlus
|
||||||
@@ -116,17 +87,42 @@ class GeneExpression extends React.Component {
|
|||||||
/>{" "}
|
/>{" "}
|
||||||
add gene{" "}
|
add gene{" "}
|
||||||
</button>
|
</button>
|
||||||
{this.props.world
|
{world && userDefinedGenes.length > 0 ? (
|
||||||
? _.map(this.props.world.varDataCache, (value, key) => {
|
<p>User defined genes</p>
|
||||||
if (key[0] === "_" /* private */) {
|
) : null}
|
||||||
return;
|
{world && userDefinedGenes.length > 0
|
||||||
|
? _.map(userDefinedGenes, (geneName, index) => {
|
||||||
|
if (!world.varDataCache[geneName]) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
const values = world.varDataCache[geneName];
|
||||||
|
return (
|
||||||
|
<HistogramBrush
|
||||||
|
key={geneName}
|
||||||
|
field={geneName}
|
||||||
|
ranges={d3.extent(values)}
|
||||||
|
isUserSelected
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
: null}
|
||||||
|
{this.props.differential.diffExp ? (
|
||||||
|
<p> Differentially Expressed Genes </p>
|
||||||
|
) : null}
|
||||||
|
{this.props.differential.diffExp
|
||||||
|
? _.map(this.props.differential.diffExp, (value, key) => {
|
||||||
|
const name = world.varAnnotations[value[0]].name;
|
||||||
|
const values = world.varDataCache[name];
|
||||||
|
if (!world.varDataCache[world.varAnnotations[value[0]].name]) {
|
||||||
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<HistogramBrush
|
<HistogramBrush
|
||||||
key={key}
|
key={name}
|
||||||
field={key}
|
field={name}
|
||||||
ranges={d3.extent(value)}
|
ranges={d3.extent(values)}
|
||||||
handleColorAction={this.handleColorAction(key).bind(this)}
|
isDiffExp
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user