mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-30 19:38:11 +08:00
binary wire format with flatbuffers (#509)
* first flatbuffer schema * do not lint auto-generated files * add flatbuffers package * add flatbuffer module * wire up /data/X/T route * use flatbuffers for matrix data fetc * clarity and comments * add flatbuffer layout route * clean up obsolete code * fix tests * move flake8 config to setup.cfg * add comments * lint * rework layout routes for fbs * add more type support to fbs * lint * add flatbuffer support for annotations * function name improvements * fix botched merge with master * remove unused import * route cleanup for flatbuffers * rename function for clarity * add missing globals to Jest tests * fix client JS tests * fix routes for Python tests * comments for clarity * non-finite floating point hardening * more non-finite number handling * lint * fix tests for summarizeAnnotations * harden diffexp calculation against FP errors * cleanup unused code * lint * add encoding tests for flatbuffers * application type specified as strings * fix spelling error * improve variable names * add note about documentation gap * rename FBS DataFrame to Matrix
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
import _ from "lodash";
|
||||
import * as d3 from "d3";
|
||||
import { interpolateRainbow, interpolateCool } from "d3-scale-chromatic";
|
||||
import * as globals from "../globals";
|
||||
import parseRGB from "../util/parseRGB";
|
||||
import finiteExtent from "../util/finiteExtent";
|
||||
|
||||
/*
|
||||
https://medium.com/@jacobp100/you-arent-using-redux-middleware-enough-94ffe991e6
|
||||
@@ -93,10 +95,15 @@ const updateCellColorsMiddleware = store => next => action => {
|
||||
}
|
||||
|
||||
const key = action.colorAccessor;
|
||||
const nonFiniteColor = parseRGB(globals.nonFiniteCellColor);
|
||||
for (let i = 0, len = obsAnnotations.length; i < len; i += 1) {
|
||||
const obs = obsAnnotations[i];
|
||||
const c = colorScale(obs[key]);
|
||||
colorsByRGB[i] = colors[c];
|
||||
const val = obsAnnotations[i][key];
|
||||
if (Number.isFinite(val)) {
|
||||
const c = colorScale(val);
|
||||
colorsByRGB[i] = colors[c];
|
||||
} else {
|
||||
colorsByRGB[i] = nonFiniteColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,8 +111,7 @@ const updateCellColorsMiddleware = store => next => action => {
|
||||
const { gene, data } = action;
|
||||
const expression = data[gene]; // Float32Array
|
||||
const colorBins = 100;
|
||||
// XXX TODO - replace _.min/_.max with the much faster finiteExtent
|
||||
const [min, max] = [_.min(expression), _.max(expression)];
|
||||
const [min, max] = finiteExtent(expression);
|
||||
colorScale = d3
|
||||
.scaleQuantile()
|
||||
.domain([min, max])
|
||||
@@ -116,10 +122,16 @@ const updateCellColorsMiddleware = store => next => action => {
|
||||
for (let i = 0; i < colorBins; i += 1) {
|
||||
colors[i] = parseRGB(interpolateCool(i / colorBins));
|
||||
}
|
||||
const nonFiniteColor = parseRGB(globals.nonFiniteCellColor);
|
||||
|
||||
for (let i = 0, len = expression.length; i < len; i += 1) {
|
||||
const c = colorScale(expression[i]);
|
||||
colorsByRGB[i] = colors[c];
|
||||
const e = expression[i];
|
||||
if (Number.isFinite(e)) {
|
||||
const c = colorScale(e);
|
||||
colorsByRGB[i] = colors[c];
|
||||
} else {
|
||||
colorsByRGB[i] = nonFiniteColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user