mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-24 02:38:12 +08:00
Improve label picking (#1179)
* add simple error message helper * port all label name pickers to use the new LabelInput component * use pure components where possible * cleanup * more cleanup * lint * change new label prompt
This commit is contained in:
@@ -10,7 +10,6 @@ TL;DR: sort order is:
|
||||
|
||||
import isNumber from "is-number";
|
||||
import * as globals from "../globals";
|
||||
import { memoize } from "./dataframe/util";
|
||||
|
||||
function caseInsensitiveCompare(a, b) {
|
||||
const textA = String(a).toUpperCase();
|
||||
|
||||
@@ -58,18 +58,18 @@ function topNCategories(colSchema, summary, N) {
|
||||
);
|
||||
const topNindices = new Set(sortIndex.slice(0, N));
|
||||
|
||||
const topNCategories = [];
|
||||
const _topNCategories = [];
|
||||
const topNCounts = [];
|
||||
for (let i = 0; i < categories.length; i += 1) {
|
||||
if (topNindices.has(i)) {
|
||||
topNCategories.push(categories[i]);
|
||||
_topNCategories.push(categories[i]);
|
||||
topNCounts.push(counts[i]);
|
||||
}
|
||||
}
|
||||
return [topNCategories, topNCounts];
|
||||
return [_topNCategories, topNCounts];
|
||||
}
|
||||
|
||||
export function selectableCategoryNames(schema, maxCategoryItems, names) {
|
||||
export function selectableCategoryNames(schema, maxCatItems, names) {
|
||||
/*
|
||||
return all obs annotation names that are categorical AND have a
|
||||
"reasonably" small number of categories AND are not the index column.
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import _ from "lodash";
|
||||
|
||||
import { unassignedCategoryLabel } from "../../globals";
|
||||
import { decodeMatrixFBS } from "./matrix";
|
||||
import * as Dataframe from "../dataframe";
|
||||
import { isFpTypedArray } from "../typeHelpers";
|
||||
import { indexEntireSchema } from "./schemaHelpers";
|
||||
import { isCategoricalAnnotation } from "./annotationsHelpers";
|
||||
import catLabelSort from "../catLabelSort";
|
||||
|
||||
/*
|
||||
@@ -96,7 +93,7 @@ export function matrixFBSToDataframe(arrayBuffers) {
|
||||
|
||||
const fbs = arrayBuffers.map(ab => decodeMatrixFBS(ab, true)); // leave in place
|
||||
/* check that all FBS have same row dimensionality */
|
||||
const nRows = fbs[0].nRows;
|
||||
const { nRows } = fbs[0];
|
||||
fbs.forEach(b => {
|
||||
if (b.nRows !== nRows)
|
||||
throw new Error("FBS with inconsistent dimensionality");
|
||||
@@ -181,7 +178,7 @@ export function addObsAnnotations(universe, df) {
|
||||
|
||||
// for all of the new data, reconcile with schema and sort categories.
|
||||
const dfs = Array.isArray(df) ? df : [df];
|
||||
const keys = dfs.map(df => df.colIndex.keys()).flat();
|
||||
const keys = dfs.map(d => d.colIndex.keys()).flat();
|
||||
const { schema } = universe;
|
||||
keys.forEach(k => {
|
||||
const colSchema = schema.annotations.obsByName[k];
|
||||
|
||||
@@ -292,7 +292,7 @@ export function createObsDimensions(crossfilter, world, XYdimNames) {
|
||||
for which we have a supported type, *except* for the index column, indicated
|
||||
by schema.annotations.obs.index.
|
||||
*/
|
||||
const { schema, obsLayout, obsAnnotations } = world;
|
||||
const { schema, obsLayout } = world;
|
||||
const indexName = schema.annotations.obs.index;
|
||||
const annoList = schema.annotations.obs.columns.filter(
|
||||
anno => anno.name !== indexName
|
||||
|
||||
Reference in New Issue
Block a user