mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-24 00:58:12 +08:00
correctly handle categoricals that are not strings (#1346)
This commit is contained in:
@@ -101,7 +101,7 @@ class Occupancy extends React.PureComponent {
|
||||
const groupBy = world.obsAnnotations.col(metadataField);
|
||||
const occupancyMap = world.obsAnnotations
|
||||
.col(colorAccessor)
|
||||
.histogram(groupBy);
|
||||
.histogramCategorical(groupBy);
|
||||
|
||||
const occupancy = occupancyMap.get(category.categoryValues[categoryIndex]);
|
||||
|
||||
@@ -117,7 +117,7 @@ class Occupancy extends React.PureComponent {
|
||||
|
||||
let currentOffset = 0;
|
||||
const dfColumn = world.obsAnnotations.col(colorAccessor);
|
||||
const categoryValues = dfColumn.summarize().categories;
|
||||
const categoryValues = dfColumn.summarizeCategorical().categories;
|
||||
|
||||
let o;
|
||||
let scaledValue;
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
summarizeCategorical as _summarizeCategorical
|
||||
} from "./summarize";
|
||||
import {
|
||||
histogramCategorical,
|
||||
histogramCategorical as _histogramCategorical,
|
||||
hashCategorical,
|
||||
histogramContinuous,
|
||||
hashContinuous
|
||||
@@ -260,16 +260,20 @@ class Dataframe {
|
||||
/*
|
||||
Create histogram bins for this column. Memoized.
|
||||
*/
|
||||
const _memoHistoCat = memoize(_histogramCategorical, hashCategorical);
|
||||
const histogramCategorical = by => _memoHistoCat(get, by);
|
||||
let histogram = null;
|
||||
if (isTypedArray(column)) {
|
||||
const mFn = memoize(histogramContinuous, hashContinuous);
|
||||
get.histogram = (bins, domain, by) => mFn(get, bins, domain, by);
|
||||
histogram = (bins, domain, by) => mFn(get, bins, domain, by);
|
||||
} else {
|
||||
const mFn = memoize(histogramCategorical, hashCategorical);
|
||||
get.histogram = by => mFn(get, by);
|
||||
histogram = histogramCategorical;
|
||||
}
|
||||
|
||||
get.summarize = summarize;
|
||||
get.summarizeCategorical = summarizeCategorical;
|
||||
get.histogram = histogram;
|
||||
get.histogramCategorical = histogramCategorical;
|
||||
get.asArray = asArray;
|
||||
get.has = has;
|
||||
get.ihas = ihas;
|
||||
|
||||
Reference in New Issue
Block a user