UNPKG

bakana

Version:

Backend for kana's single-cell analyses. This supports single or multiple samples, execution in Node.js or the browser, in-memory caching of results for iterative analyses, and serialization to/from file for redistribution.

47 lines (39 loc) 1.14 kB
import * as scran from "scran.js"; export function chooseDelay(animate) { if (animate) { // TODO: using 75 for now // in the future the user can choose a bar for speed on the UI // options would be 1x, 2x, 3x return 75; } else { return 1000000; // effectively no delay. } }; export function recreateNeighbors(neighbors) { var output = null; var rbuf = null; var ibuf = null; var dbuf = null; try { var num_obs = neighbors.num_obs; var size = neighbors.size; rbuf = scran.createInt32WasmArray(num_obs); rbuf.set(neighbors.runs); ibuf = scran.createInt32WasmArray(size); ibuf.set(neighbors.indices); dbuf = scran.createFloat64WasmArray(size); dbuf.set(neighbors.distances); output = scran.FindNearestNeighborsResults.unserialize(rbuf, ibuf, dbuf); } finally { if (rbuf !== null) { rbuf.free(); } if (ibuf !== null) { ibuf.free(); } if (dbuf !== null) { dbuf.free(); } } return output; };