mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-04 04:28:12 +08:00
regraph
This commit is contained in:
+33
-27
@@ -1,5 +1,6 @@
|
|||||||
import * as globals from "../globals";
|
import * as globals from "../globals";
|
||||||
import URI from "urijs";
|
import URI from "urijs";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
const requestCells = (query = "") => {
|
const requestCells = (query = "") => {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
@@ -19,40 +20,46 @@ const requestCells = (query = "") => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* SELECT */
|
/* SELECT */
|
||||||
const attemptCategoricalMetadataSelection = (metadataField, value) => {
|
const regraph = () => {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch({type: "categorical metadata filter selected start"})
|
dispatch({type: "regraph started"})
|
||||||
|
|
||||||
|
const state = getState()
|
||||||
|
const selectedMetadata = {};
|
||||||
|
|
||||||
|
_.each(state.controls.categoricalAsBooleansMap, (options, field) => {
|
||||||
|
let atLeastOneOptionDeselected = false;
|
||||||
|
|
||||||
|
_.each(options, (isActive, option) => {
|
||||||
|
if (!isActive) {
|
||||||
|
atLeastOneOptionDeselected = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (atLeastOneOptionDeselected) {
|
||||||
|
_.each(options, (isActive, option) => {
|
||||||
|
if (isActive) {
|
||||||
|
if (selectedMetadata[field]) {
|
||||||
|
selectedMetadata[field].push(option)
|
||||||
|
} else if (!selectedMetadata[field]) {
|
||||||
|
selectedMetadata[field] = [option]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
let uri = new URI()
|
let uri = new URI()
|
||||||
uri.setSearch(getState().selectedMetadata)
|
uri.setSearch(selectedMetadata)
|
||||||
uri.addSearch({[metadataField]: [value]})
|
console.log(uri.search(), selectedMetadata)
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
requestCells(uri.search())
|
requestCells(uri.search())
|
||||||
).then((res) => {
|
).then((res) => {
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
dispatch({type: "categorical metadata filter selected error"})
|
dispatch({type: "regraph success"})
|
||||||
} else {
|
} else {
|
||||||
dispatch({type: "categorical metadata filter selected success", metadataField, value})
|
dispatch({type: "regraph error"})
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* DESELECT */
|
|
||||||
const attemptCategoricalMetadataDeselection = (metadataField, value) => {
|
|
||||||
return (dispatch, getState) => {
|
|
||||||
dispatch({type: "categorical metadata filter deselected start"})
|
|
||||||
|
|
||||||
let uri = new URI()
|
|
||||||
uri.setSearch(getState().selectedMetadata)
|
|
||||||
uri.removeSearch({[metadataField]: [value]})
|
|
||||||
|
|
||||||
dispatch(requestCells(uri.search())).then((res) => {
|
|
||||||
if (res.error) {
|
|
||||||
dispatch({type: "categorical metadata filter deselected error"})
|
|
||||||
} else {
|
|
||||||
dispatch({type: "categorical metadata filter deselected success", metadataField, value})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -168,10 +175,9 @@ const requestDifferentialExpression = (celllist1, celllist2, num_genes = 7) => {
|
|||||||
export default {
|
export default {
|
||||||
initialize,
|
initialize,
|
||||||
requestCells,
|
requestCells,
|
||||||
|
regraph,
|
||||||
requestGeneExpressionCounts,
|
requestGeneExpressionCounts,
|
||||||
___hardcoded___requestGeneExpressionCountsPOST,
|
___hardcoded___requestGeneExpressionCountsPOST,
|
||||||
requestSingleGeneExpressionCountsForColoringPOST,
|
requestSingleGeneExpressionCountsForColoringPOST,
|
||||||
attemptCategoricalMetadataSelection,
|
|
||||||
attemptCategoricalMetadataDeselection,
|
|
||||||
requestDifferentialExpression
|
requestDifferentialExpression
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ class App extends React.Component {
|
|||||||
<div>
|
<div>
|
||||||
<Graph/>
|
<Graph/>
|
||||||
<button
|
<button
|
||||||
|
onClick={() => { this.props.dispatch(actions.regraph()) }}
|
||||||
style={{
|
style={{
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: 400,
|
fontWeight: 400,
|
||||||
@@ -82,7 +83,7 @@ class App extends React.Component {
|
|||||||
}}
|
}}
|
||||||
|
|
||||||
>
|
>
|
||||||
Reproject
|
Regraph
|
||||||
</button>
|
</button>
|
||||||
<Continuous/>
|
<Continuous/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -116,9 +116,12 @@ class Categories extends React.Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{
|
<div style={{
|
||||||
width: 320,
|
width: 310,
|
||||||
marginRight: 40,
|
marginRight: 40,
|
||||||
flexShrink: 0
|
paddingRight: 20,
|
||||||
|
flexShrink: 0,
|
||||||
|
height: 700,
|
||||||
|
overflow: "auto",
|
||||||
}}>
|
}}>
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user