mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-30 19:58:13 +08:00
* immutable crossfilter * first cut at reducer refactor with cascade model * add initial redo/undo implementation * small optimization * integrate expression with history * add tests for new reducers and fix a couple of small initialization bugs * treat tiny lasso selections as a clear * better function name for clarity * fix undo for differential expression * remove logging * fix regression due to bad merge * cleanup and comments for clarity * improve undoable configuration for flexibility * fix stale comments * remove debugging code from production build * rename categoricalSelectionState * rename file * improve comments
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
import _ from "lodash";
|
|
|
|
import { ControlsHelpers } from "../util/stateManager";
|
|
|
|
const Universe = (state = null, action, nextSharedState, prevSharedState) => {
|
|
switch (action.type) {
|
|
case "initial data load complete (universe exists)": {
|
|
const { universe } = action;
|
|
return universe;
|
|
}
|
|
|
|
case "expression load success": {
|
|
let { varData } = state;
|
|
|
|
// Load new expression data into the varData dataframes, if
|
|
// not already present.
|
|
_.forEach(action.expressionData, (val, key) => {
|
|
// If not already in universe.varData, save entire expression column
|
|
if (!varData.hasCol(key)) {
|
|
varData = varData.withCol(key, val);
|
|
}
|
|
});
|
|
|
|
// Prune size of varData "cache" if getting out of hand....
|
|
const { userDefinedGenes, diffexpGenes } = prevSharedState;
|
|
const allTheGenesWeNeed = _.uniq(
|
|
[].concat(
|
|
userDefinedGenes,
|
|
diffexpGenes,
|
|
Object.keys(action.expressionData)
|
|
)
|
|
);
|
|
varData = ControlsHelpers.pruneVarDataCache(varData, allTheGenesWeNeed);
|
|
|
|
return {
|
|
...state,
|
|
varData
|
|
};
|
|
}
|
|
|
|
default: {
|
|
return state;
|
|
}
|
|
}
|
|
};
|
|
|
|
export default Universe;
|