user defined gene

This commit is contained in:
Colin Megill
2018-10-15 11:20:52 -07:00
parent 2b77f8146b
commit 8e08534d42
3 changed files with 55 additions and 16 deletions
+20 -1
View File
@@ -204,6 +204,24 @@ const requestGeneExpressionCountsPOST = genes => async (dispatch, getState) => {
} }
}; };
const requestUserDefinedGene = gene => async dispatch => {
dispatch({ type: "request user defined gene started" });
try {
const data = await dispatch(requestGeneExpressionCountsPOST([gene]));
/* then send the success case action through */
return dispatch({
type: "request user defined gene success",
data
});
} catch (error) {
return dispatch({
type: "request user defined gene error",
error
});
}
};
const requestDifferentialExpression = (set1, set2, num_genes = 10) => async ( const requestDifferentialExpression = (set1, set2, num_genes = 10) => async (
dispatch, dispatch,
getState getState
@@ -244,7 +262,7 @@ const requestDifferentialExpression = (set1, set2, num_genes = 10) => async (
Kick off secondary action to fetch all of the expression data for the Kick off secondary action to fetch all of the expression data for the
topN expressed genes. topN expressed genes.
*/ */
dispatch(requestGeneExpressionCountsPOST(topNGenes)); await dispatch(requestGeneExpressionCountsPOST(topNGenes));
/* then send the success case action through */ /* then send the success case action through */
return dispatch({ return dispatch({
@@ -265,5 +283,6 @@ export default {
requestSingleGeneExpressionCountsForColoringPOST, requestSingleGeneExpressionCountsForColoringPOST,
requestGeneExpressionCountsPOST, requestGeneExpressionCountsPOST,
requestDifferentialExpression, requestDifferentialExpression,
requestUserDefinedGene,
doInitialDataLoad doInitialDataLoad
}; };
@@ -54,7 +54,7 @@ class GeneExpression extends React.Component {
} else if (!_.find(world.varAnnotations, { name: gene })) { } else if (!_.find(world.varAnnotations, { name: gene })) {
console.log("That doesn't appear to be a valid gene name."); console.log("That doesn't appear to be a valid gene name.");
} else { } else {
dispatch(actions.requestGeneExpressionCountsPOST([gene])); dispatch(actions.requestUserDefinedGene(gene));
dispatch({ dispatch({
type: "user defined gene", type: "user defined gene",
data: gene data: gene
+34 -14
View File
@@ -203,8 +203,7 @@ const Controls = (
}; };
} }
case "expression load success": { case "expression load success": {
console.log("expression load success", action); const { world, universe } = state;
const { world, universe, crossfilter, dimensionMap } = state;
let universeVarDataCache = universe.varDataCache; let universeVarDataCache = universe.varDataCache;
let worldVarDataCache = world.varDataCache; let worldVarDataCache = world.varDataCache;
_.forEach(action.expressionData, (val, key) => { _.forEach(action.expressionData, (val, key) => {
@@ -218,16 +217,6 @@ const Controls = (
} }
}); });
_.forEach(action.expressionData, (val, key) => {
dimensionMap[key] = World.createVarDimension(
/* "__var__" + */
world,
worldVarDataCache,
crossfilter,
key
);
});
return { return {
...state, ...state,
universe: { universe: {
@@ -240,17 +229,48 @@ const Controls = (
} }
}; };
} }
case "request user defined gene success": {
const { world, crossfilter, dimensionMap, userDefinedGenes } = state;
const worldVarDataCache = world.varDataCache;
const _userDefinedGenes = userDefinedGenes.slice();
const gene = action.data.genes[0];
dimensionMap[userDefinedDimensionName(gene)] = World.createVarDimension(
/* "__var__" + */
world,
worldVarDataCache,
crossfilter,
gene
);
return {
...state,
dimensionMap,
userDefinedGenes: _userDefinedGenes
};
}
case "request differential expression success": { case "request differential expression success": {
console.log("request diff success", action); const { world, crossfilter, dimensionMap } = state;
const { world } = state; const worldVarDataCache = world.varDataCache;
const _diffexpGenes = []; const _diffexpGenes = [];
action.data.forEach(d => { action.data.forEach(d => {
_diffexpGenes.push(world.varAnnotations[d[0]].name); _diffexpGenes.push(world.varAnnotations[d[0]].name);
}); });
_.forEach(_diffexpGenes, gene => {
dimensionMap[diffexpDimensionName(gene)] = World.createVarDimension(
/* "__var__" + */
world,
worldVarDataCache,
crossfilter,
gene
);
});
return { return {
...state, ...state,
dimensionMap,
diffexpGenes: _diffexpGenes diffexpGenes: _diffexpGenes
}; };
} }