mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-25 18:58:12 +08:00
add multi-layout support to back-end (#766)
* add multi-layout support to back-end * remove obsolete code * temporary code to apply heuristic choice of default layout * fix tests * update python tests * more py lint * PR review changes * more PR lint * PR lint
This commit is contained in:
@@ -78,6 +78,7 @@ function AnnotationsFBSToDataframe(arrayBuffer) {
|
||||
The application has strong assumptions that all scalar data will be
|
||||
stored as a float32 or float64 (regardless of underlying data types).
|
||||
For example, clipping of value ranges (eg, user-selected percentiles)
|
||||
depends on the ability to use NaN in any numeric type.
|
||||
|
||||
All float data from the server is left as is. All non-float is promoted
|
||||
to an appropriate float.
|
||||
@@ -98,13 +99,30 @@ function AnnotationsFBSToDataframe(arrayBuffer) {
|
||||
|
||||
function LayoutFBSToDataframe(arrayBuffer) {
|
||||
const fbs = decodeMatrixFBS(arrayBuffer, true);
|
||||
if (fbs.columns.length !== 2 || !fbs.columns.every(isFpTypedArray)) {
|
||||
if (fbs.columns.length < 2 || !fbs.columns.every(isFpTypedArray)) {
|
||||
// We have strong assumptions about the shape & type of layout data.
|
||||
throw new Error("Unexpected layout data type returned from server");
|
||||
}
|
||||
|
||||
/*
|
||||
TODO: XXX
|
||||
|
||||
TEMPORARY CODE AND COMMENT to support the progressive implementation
|
||||
of multi-layout support. For now, we search for one of the following
|
||||
in the layouts and use it if we find it: umap, then tsne, then pca,
|
||||
then whatever is first in the list.
|
||||
*/
|
||||
let layoutIndex = 0;
|
||||
["umap", "tsne", "pca"].some(name => {
|
||||
const idx = fbs.colIdx.indexOf(`${name}_0`);
|
||||
if (idx !== -1) {
|
||||
layoutIndex = idx;
|
||||
}
|
||||
return idx !== -1;
|
||||
});
|
||||
const df = new Dataframe.Dataframe(
|
||||
[fbs.nRows, fbs.nCols],
|
||||
fbs.columns,
|
||||
[fbs.nRows, 2],
|
||||
[fbs.columns[layoutIndex], fbs.columns[layoutIndex + 1]],
|
||||
null,
|
||||
new Dataframe.KeyIndex(["X", "Y"])
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user