mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-26 18:48:11 +08:00
* revert all commits to before Typescript migration * update compat workflow to match latest deps (#2335) * update compat workflow to match latest deps * attempt to debug * attempt to debug * remove debugging code * typo * update deps to match desktop (#2340) * fix: don't run lint with `--fix` on push tests (#2273) * fix: don't run lint with `--fix` on push tests * npx Co-authored-by: maniarathi <mani.arathi@gmail.com> Co-authored-by: Madison Dunitz <madison.dunitz@chanzuckerberg.com> * rename X_approx_distribution to X_approximate_distribution (#2337) * Correctly handle non-finite numbers in heuristic determination of X distribution (#2342) * handle non-finites explicitly * improve and test edge case handling for distribution estimation * revert debugging changes * code readability * clean up type inferencing (#2332) * unit tests for 64 bit conversion * clean up type handling * type inference tests * more type inference fixes * use schema to determine user intent for data typing * stop using deprecated API * fbs type encoding test * add missing test * add more tests * correctly infer X type for CXG adaptor * lint * fix typo * ts migration * cleanup from PR review * lint * PR review changes * remove unused packages from client (#2359) * remove unused packages from client * add missing peer dep * fix: disable FE auth testing on compatibility tests (#2377) * update: release process (#2277) Co-authored-by: maniarathi <mani.arathi@gmail.com> * fix: remove spaces in param setup (#2380) * delete deploy workflow (#2396) * undo reformatting which now does not pass lint * fix snapshots which changed due to npm dep changes * add missing quoting to snapshot * another snapshot typo fix * TS Revert (2) - replay PR #2347 and #2354 (#2403) * replay edits from PR 2347 * TS Revert (3) - replay edits in PR #2327 (#2404) * replay edits in PR 2327 * TS Revert (4) - replay PR #2355 (#2405) * replay edits in PR 2355 * add additional babel config * reformat with new prettier config Co-authored-by: Severiano Badajoz <sbadajoz@chanzuckerberg.com> Co-authored-by: maniarathi <mani.arathi@gmail.com> Co-authored-by: Madison Dunitz <madison.dunitz@chanzuckerberg.com>
193 lines
4.8 KiB
JavaScript
193 lines
4.8 KiB
JavaScript
/*
|
|
Action creators for selection
|
|
*/
|
|
export const selectContinuousMetadataAction =
|
|
(type, query, range, oldProps = {}) =>
|
|
async (dispatch, getState) => {
|
|
const { obsCrossfilter: prevObsCrossfilter } = getState();
|
|
|
|
const selection = range
|
|
? {
|
|
mode: "range",
|
|
lo: range[0],
|
|
hi: range[1],
|
|
inclusive: true, // [lo, hi] incluisve selection
|
|
}
|
|
: { mode: "all" };
|
|
|
|
const obsCrossfilter = await prevObsCrossfilter.select(...query, selection);
|
|
|
|
dispatch({
|
|
type,
|
|
obsCrossfilter,
|
|
range,
|
|
...oldProps,
|
|
});
|
|
};
|
|
|
|
export const selectCategoricalMetadataAction =
|
|
(
|
|
type, // action type
|
|
metadataField, // annotation category name
|
|
labels,
|
|
label, // the label being selected/deselected
|
|
isSelected, // bool
|
|
oldProps = {}
|
|
) =>
|
|
async (dispatch, getState) => {
|
|
const { obsCrossfilter: prevObsCrossfilter, categoricalSelection } =
|
|
getState();
|
|
|
|
const labelSelectionState = new Map(categoricalSelection[metadataField]);
|
|
labels.forEach(
|
|
(l) => labelSelectionState.has(l) || labelSelectionState.set(l, true)
|
|
);
|
|
labelSelectionState.set(label, isSelected);
|
|
|
|
const values = Array.from(labelSelectionState.keys()).filter((k) =>
|
|
labelSelectionState.get(k)
|
|
);
|
|
const selection = {
|
|
mode: "exact",
|
|
values,
|
|
};
|
|
const obsCrossfilter = await prevObsCrossfilter.select(
|
|
"obs",
|
|
metadataField,
|
|
selection
|
|
);
|
|
|
|
dispatch({
|
|
type,
|
|
obsCrossfilter,
|
|
metadataField,
|
|
labelSelectionState,
|
|
...oldProps,
|
|
});
|
|
};
|
|
|
|
export const selectCategoricalAllMetadataAction =
|
|
(
|
|
type, // action type
|
|
metadataField, // annotation category name
|
|
labels,
|
|
isSelected, // bool, select all or none
|
|
oldProps = {}
|
|
) =>
|
|
async (dispatch, getState) => {
|
|
const { obsCrossfilter: prevObsCrossfilter, categoricalSelection } =
|
|
getState();
|
|
|
|
const labelSelectionState = new Map(categoricalSelection[metadataField]);
|
|
labels.forEach((label) => labelSelectionState.set(label, isSelected));
|
|
|
|
const selection = { mode: isSelected ? "all" : "none" };
|
|
const obsCrossfilter = await prevObsCrossfilter.select(
|
|
"obs",
|
|
metadataField,
|
|
selection
|
|
);
|
|
|
|
dispatch({
|
|
type,
|
|
obsCrossfilter,
|
|
metadataField,
|
|
labelSelectionState,
|
|
...oldProps,
|
|
});
|
|
};
|
|
|
|
/**
|
|
** Graph selection-related actions
|
|
**/
|
|
|
|
export const graphBrushStartAction = () =>
|
|
/* no change to crossfilter until a change fires */
|
|
({ type: "graph brush start" });
|
|
|
|
const _graphBrushWithinRectAction =
|
|
(type, embName, brushCoords) => async (dispatch, getState) => {
|
|
const { obsCrossfilter: prevObsCrossfilter } = getState();
|
|
|
|
const selection = { mode: "within-rect", ...brushCoords };
|
|
const obsCrossfilter = await prevObsCrossfilter.select(
|
|
"emb",
|
|
embName,
|
|
selection
|
|
);
|
|
|
|
dispatch({
|
|
type,
|
|
obsCrossfilter,
|
|
brushCoords,
|
|
});
|
|
};
|
|
|
|
const _graphAllAction = (type, embName) => async (dispatch, getState) => {
|
|
const { obsCrossfilter: prevObsCrossfilter } = getState();
|
|
|
|
const obsCrossfilter = await prevObsCrossfilter.select("emb", embName, {
|
|
mode: "all",
|
|
});
|
|
|
|
dispatch({
|
|
type,
|
|
obsCrossfilter,
|
|
});
|
|
};
|
|
|
|
export const graphBrushChangeAction = (embName, brushCoords) =>
|
|
_graphBrushWithinRectAction("graph brush change", embName, brushCoords);
|
|
|
|
export const graphBrushEndAction = (embName, brushCoords) =>
|
|
_graphBrushWithinRectAction("graph brush end", embName, brushCoords);
|
|
|
|
export const graphBrushCancelAction = (embName) =>
|
|
_graphAllAction("graph brush cancel", embName);
|
|
export const graphBrushDeselectAction = (embName) =>
|
|
_graphAllAction("graph brush deselect", embName);
|
|
|
|
export const graphLassoStartAction = () =>
|
|
/* no change to crossfilter until a change fires */
|
|
({ type: "graph lasso start" });
|
|
|
|
export const graphLassoCancelAction = (embName) =>
|
|
_graphAllAction("graph lasso cancel", embName);
|
|
|
|
export const graphLassoDeselectAction = (embName) =>
|
|
_graphAllAction("graph lasso cancel", embName);
|
|
|
|
export const graphLassoEndAction =
|
|
(embName, polygon) => async (dispatch, getState) => {
|
|
const { obsCrossfilter: prevObsCrossfilter } = getState();
|
|
|
|
const selection = {
|
|
mode: "within-polygon",
|
|
polygon,
|
|
};
|
|
const obsCrossfilter = await prevObsCrossfilter.select(
|
|
"emb",
|
|
embName,
|
|
selection
|
|
);
|
|
|
|
dispatch({
|
|
type: "graph lasso end",
|
|
obsCrossfilter,
|
|
polygon,
|
|
});
|
|
};
|
|
|
|
/*
|
|
Differential expression set selection
|
|
*/
|
|
export const setCellSetFromSelection = (cellSetId) => (dispatch, getState) => {
|
|
const { obsCrossfilter } = getState();
|
|
const selected = obsCrossfilter.allSelectedLabels();
|
|
|
|
dispatch({
|
|
type: `store current cell selection as differential set ${cellSetId}`,
|
|
data: selected.length > 0 ? selected : null,
|
|
});
|
|
};
|