mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-28 11:58:12 +08:00
Improved summary counts of annotation values (#478)
* convert annotation summary to a Map * add 2d annotation count summary * add memoization on 2D annotation counting * add tests for annotation summarization * fix import/exports * rename WorldOps to WorldUtil * rename WorldOps to WorldUtil * add comment
This commit is contained in:
@@ -25,24 +25,22 @@ class Category extends React.Component {
|
||||
const { categoricalSelectionState, metadataField } = this.props;
|
||||
const cat = categoricalSelectionState[metadataField];
|
||||
const categoryCount = {
|
||||
// total number of options in this category
|
||||
totalOptionCount: cat.numOptions,
|
||||
// total number of categories in this dimension
|
||||
totalCatCount: cat.numCategories,
|
||||
// number of selected options in this category
|
||||
selectedOptionCount: _.reduce(
|
||||
cat.optionSelected,
|
||||
selectedCatCount: _.reduce(
|
||||
cat.categorySelected,
|
||||
(res, cond) => (cond ? res + 1 : res),
|
||||
0
|
||||
)
|
||||
};
|
||||
if (categoryCount.selectedOptionCount === categoryCount.totalOptionCount) {
|
||||
if (categoryCount.selectedCatCount === categoryCount.totalCatCount) {
|
||||
/* everything is on, so not indeterminate */
|
||||
this.checkbox.indeterminate = false;
|
||||
} else if (categoryCount.selectedOptionCount === 0) {
|
||||
} else if (categoryCount.selectedCatCount === 0) {
|
||||
/* nothing is on, so no */
|
||||
this.checkbox.indeterminate = false;
|
||||
} else if (
|
||||
categoryCount.selectedOptionCount < categoryCount.totalOptionCount
|
||||
) {
|
||||
} else if (categoryCount.selectedCatCount < categoryCount.totalCatCount) {
|
||||
/* to be explicit... */
|
||||
this.checkbox.indeterminate = true;
|
||||
}
|
||||
@@ -88,12 +86,12 @@ class Category extends React.Component {
|
||||
const { categoricalSelectionState, metadataField } = this.props;
|
||||
|
||||
const cat = categoricalSelectionState[metadataField];
|
||||
const optTuples = alphabeticallySortedValues([...cat.optionIndex]);
|
||||
const optTuples = alphabeticallySortedValues([...cat.categoryIndices]);
|
||||
return _.map(optTuples, (tuple, i) => (
|
||||
<Value
|
||||
key={tuple[1]}
|
||||
metadataField={metadataField}
|
||||
optionIndex={tuple[1]}
|
||||
categoryIndex={tuple[1]}
|
||||
i={i}
|
||||
/>
|
||||
));
|
||||
|
||||
@@ -11,20 +11,20 @@ import _ from "lodash";
|
||||
}))
|
||||
class CategoryValue extends React.Component {
|
||||
toggleOff() {
|
||||
const { dispatch, metadataField, optionIndex } = this.props;
|
||||
const { dispatch, metadataField, categoryIndex } = this.props;
|
||||
dispatch({
|
||||
type: "categorical metadata filter deselect",
|
||||
metadataField,
|
||||
optionIndex
|
||||
categoryIndex
|
||||
});
|
||||
}
|
||||
|
||||
toggleOn() {
|
||||
const { dispatch, metadataField, optionIndex } = this.props;
|
||||
const { dispatch, metadataField, categoryIndex } = this.props;
|
||||
dispatch({
|
||||
type: "categorical metadata filter select",
|
||||
metadataField,
|
||||
optionIndex
|
||||
categoryIndex
|
||||
});
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class CategoryValue extends React.Component {
|
||||
const {
|
||||
categoricalSelectionState,
|
||||
metadataField,
|
||||
optionIndex,
|
||||
categoryIndex,
|
||||
colorAccessor,
|
||||
colorScale,
|
||||
i,
|
||||
@@ -42,10 +42,12 @@ class CategoryValue extends React.Component {
|
||||
if (!categoricalSelectionState) return null;
|
||||
|
||||
const category = categoricalSelectionState[metadataField];
|
||||
const selected = category.optionSelected[optionIndex];
|
||||
const count = category.optionCount[optionIndex];
|
||||
const value = category.optionValue[optionIndex];
|
||||
const displayString = String(category.optionValue[optionIndex]).valueOf();
|
||||
const selected = category.categorySelected[categoryIndex];
|
||||
const count = category.categoryCounts[categoryIndex];
|
||||
const value = category.categoryValues[categoryIndex];
|
||||
const displayString = String(
|
||||
category.categoryValues[categoryIndex]
|
||||
).valueOf();
|
||||
|
||||
/* this is the color scale, so add swatches below */
|
||||
const c = metadataField === colorAccessor;
|
||||
|
||||
Reference in New Issue
Block a user