mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-25 06:08:12 +08:00
* initial dataframe commit * initial dataframe port of core app * rename variables for clarity * remove unused import * comment out unused code * fix array handling bug in crossfilter dimension creation * allow creation of empty dataframes * handle non-existent columns * handle non-existent columns * revise tests for new dataframe * comments for clarity * comments for clarity * generate bulk add placeholder with real gene names * fix bug in gene name adding * more dataframe unit tests * fix bug - subset from current world, not universe * put cut and pasted code into a single function * improve caching of crossfilter * remove cascading update bug from graph * more performance work * improve state handling for scatterplot * performance optimization of critical path * add column summarization * dataframe utils * add callOnceLazy * fix tests * minor updates found during review * fix misspelling * remove RESTv02 from function names * comment cleanup * cut/icut col parameter defaults to null * break up large test * improve tests and comments on dataframe at/has functions * add Dataframe withCol/dropCol * expression varData now stored in a dataframe * dead code cleanup * use dataframe.summarize() * test cases for Dataframe.col.summarize * update test cases for new dataframe summarize * improve naming * use new hasCol API * add comments * add more Dataframe.withCol tests * add ability to specify row index in cut operation * retire subsetVarData function * correctly handle expression subsetting * lint and improve comments * rename cut to subset * changes based on PR review
67 lines
1.9 KiB
JavaScript
67 lines
1.9 KiB
JavaScript
import * as Universe from "../../../src/util/stateManager/universe";
|
|
import * as Dataframe from "../../../src/util/dataframe";
|
|
import * as REST from "./sampleResponses";
|
|
|
|
describe("createUniverseFromResponse", () => {
|
|
/*
|
|
test createUniverseFromResponse - this function converts
|
|
a set of REST 0.2 responses into a "new" Universe.
|
|
|
|
createUniverseFromResponse(
|
|
configResponse,
|
|
schemaResponse,
|
|
annotationsObsResponse,
|
|
annotationsVarResponse,
|
|
layoutObsResponse
|
|
) --> Universe
|
|
|
|
where:
|
|
configResponse: GET /.../config
|
|
schemaResponse: GET /.../schema
|
|
annotationsObsResponse: GET /.../annotations/obs
|
|
annotationsVarResponse: GET /.../annotations/var
|
|
layoutObsResponse: GET /.../layout/obs
|
|
|
|
See spec in docs/REST_API.md.
|
|
*/
|
|
|
|
test("create from test data", () => {
|
|
/*
|
|
create a universe from sample data nad validate its shape & contents
|
|
*/
|
|
const { nObs, nVar } = REST.schema.schema.dataframe;
|
|
const universe = Universe.createUniverseFromResponse(
|
|
REST.config,
|
|
REST.schema,
|
|
REST.annotationsObs,
|
|
REST.annotationsVar,
|
|
REST.layoutObs
|
|
);
|
|
|
|
expect(universe).toBeDefined();
|
|
expect(universe).toMatchObject(
|
|
expect.objectContaining({
|
|
nObs,
|
|
nVar,
|
|
schema: REST.schema.schema,
|
|
obsAnnotations: expect.any(Dataframe.Dataframe),
|
|
varAnnotations: expect.any(Dataframe.Dataframe),
|
|
obsLayout: expect.any(Dataframe.Dataframe),
|
|
varData: expect.any(Dataframe.Dataframe)
|
|
})
|
|
);
|
|
|
|
expect(universe.obsAnnotations.dims).toEqual([
|
|
nObs,
|
|
REST.schema.schema.annotations.obs.length
|
|
]);
|
|
expect(universe.obsLayout.dims).toEqual([nObs, 2]);
|
|
expect(universe.obsLayout.colIndex.keys()).toEqual(["X", "Y"]);
|
|
expect(universe.varAnnotations.dims).toEqual([
|
|
nVar,
|
|
REST.schema.schema.annotations.var.length
|
|
]);
|
|
expect(universe.varData.isEmpty()).toBeTruthy();
|
|
});
|
|
});
|