UNPKG

higlass

Version:

HiGlass Hi-C / genomic / large data viewer

370 lines (369 loc) 14.3 kB
/** @import * as t from './types' */ /** * Get a valueScale for a heatmap. * * If the scalingType isn't specified, then default to the defaultScaling. * * @param {string} scalingType: The type of the (e.g. 'linear', or 'log') * @param {number} minValue: The minimum data value to which this scale will apply * @param {number} pseudocountIn: A value to add to all numbers to prevent taking the log of 0 * @param {number} maxValue: The maximum data value to which this scale will apply * @param {string} defaultScaling: The default scaling type to use in case * 'scalingType' is null (e.g. 'linear' or 'log') * * @returns {[string, import('d3-scale').ScaleLogarithmic<number, number> | import('d3-scale').ScaleLinear<number, number>]} * An array of [string, scale] containing the scale type and a scale with an appropriately set domain and range */ export function getValueScale(scalingType: string, minValue: number, pseudocountIn: number, maxValue: number, defaultScaling: string): [string, import("d3-scale").ScaleLogarithmic<number, number> | import("d3-scale").ScaleLinear<number, number>]; export default TiledPixiTrack; export type Scale = { minValue?: number | null | undefined; maxValue?: number | null | undefined; maxRawValue?: number | null | undefined; minRawValue?: number | null | undefined; }; /** * An alternative to Tile. Perhaps the worst data type. An array of numbers with some extra properties. */ export type TilePositionArrayObject = Array<number> & Pick<Tile, "mirrored" | "tilePositionId">; export type Tile = { tileId: string; tileData: TileData; remoteId: string; mirrored: unknown; tilePositionId: string; graphics: import("pixi.js").Graphics; }; export type TileData = { tilesetUid: string; zoomLevel: number; tilePos: Array<number>; error: string; dense: Float32Array; minNonZero: number; maxNonZero: number; /** * - Optional 1D or 2D array dimensions */ shape?: number[] | undefined; }; export type TiledPixiTrackContextBase = { dataFetcher: DataFetcher; dataConfig: t.DataConfig; /** * A function to redraw this track. Typically called when an * asynchronous event occurs (i.e. tiles loaded) */ animate: Function; /** * The range of values has changed so we need to inform * the higher ups that the value scale has changed. Only occurs on tracks with ``dense`` data. */ onValueScaleChanged: () => void; /** * A callback to do something once once the tileset * info is received. Usually it registers some information about the tileset with its definition */ handleTilesetInfoReceived?: ((t: t.TilesetInfo) => void) | undefined; }; export type TiledPixiTrackContext = import("./PixiTrack").ExtendedPixiContext<TiledPixiTrackContextBase>; export type TiledPixiTrackOptions = { /** * - If the label is to be drawn, where should it be drawn? */ labelPosition: string; /** * - What should be drawn in the label. */ labelText: string; maxZoom: number; name: string; }; export type ExtendedTiledPixiTrackOptions<T> = T & TiledPixiTrackOptions; /** * @typedef Scale * @property {number | null} [minValue] * @property {number | null} [maxValue] * @property {number | null} [maxRawValue] * @property {number | null} [minRawValue] */ /** * An alternative to Tile. Perhaps the worst data type. An array of numbers with some extra properties. * @typedef {Array<number> & Pick<Tile, 'mirrored' | 'tilePositionId'>} TilePositionArrayObject */ /** * @typedef Tile * @property {string} tileId * @property {TileData} tileData * @property {string} remoteId * @property {unknown} mirrored * @property {string} tilePositionId * @property {import("pixi.js").Graphics} graphics */ /** * @typedef TileData * @property {string} tilesetUid * @property {number} zoomLevel * @property {Array<number>} tilePos * @property {string} error * @property {Float32Array} dense * @property {number} minNonZero * @property {number} maxNonZero * @property {Array<number>} [shape] - Optional 1D or 2D array dimensions */ /** * @typedef TiledPixiTrackContextBase * @property {DataFetcher} dataFetcher * @property {t.DataConfig} dataConfig * @property {function} animate A function to redraw this track. Typically called when an * asynchronous event occurs (i.e. tiles loaded) * @property {() => void} onValueScaleChanged The range of values has changed so we need to inform * the higher ups that the value scale has changed. Only occurs on tracks with ``dense`` data. * @property {(t: t.TilesetInfo) => void} [handleTilesetInfoReceived] A callback to do something once once the tileset * info is received. Usually it registers some information about the tileset with its definition */ /** * @typedef {import('./PixiTrack').ExtendedPixiContext<TiledPixiTrackContextBase>} TiledPixiTrackContext */ /** * @typedef TiledPixiTrackOptions * @property {string} labelPosition - If the label is to be drawn, where should it be drawn? * @property {string} labelText - What should be drawn in the label. * @property {number} maxZoom * @property {string} name */ /** * @template T * @typedef {T & TiledPixiTrackOptions} ExtendedTiledPixiTrackOptions */ /** * The TiledPixiTrack requires an options parameter, which should be an object containing properties specified in * TiledPixiTrackOptions. It is capable of accepting any property defined in any of its superclasses. * @template {ExtendedTiledPixiTrackOptions<{[key: string]: any}>} Options * @extends {PixiTrack<Options>} * */ declare class TiledPixiTrack<Options extends ExtendedTiledPixiTrackOptions<{ [key: string]: any; }>> extends PixiTrack<Options> { /** * * @param {TiledPixiTrackContext} context * @param {Options} options */ constructor(context: TiledPixiTrackContext, options: Options); /** @type {number} */ renderVersion: number; /** @type {Array<Pick<Tile, 'tileId' |'remoteId' | 'mirrored'>>} */ visibleTiles: Array<Pick<Tile, "tileId" | "remoteId" | "mirrored">>; /** @type {Set<string>} */ visibleTileIds: Set<string>; renderingTiles: Set<any>; fetching: Set<any>; /** @type {Scale} */ scale: Scale; /** @type {{[id: string]: Tile}} */ fetchedTiles: { [id: string]: Tile; }; /** @type {Object.<string, import('pixi.js').DisplayObject>} */ tileGraphics: { [x: string]: import("pixi.js").DisplayObject; }; /** @type {number} */ maxZoom: number; medianVisibleValue: number | null | undefined; backgroundTaskScheduler: { taskList: import("./utils/background-task-scheduler").Task[]; taskHandle: number | null; requestIdleCallbackTimeout: number; /** * @template T * @overload * @param {(data: T) => void} taskHandler * @param {T} taskData * @param {string | null=} trackId * @return {void} */ enqueueTask<T>(taskHandler: (data: T) => void, taskData: T, trackId?: (string | null) | undefined): void; /** * If `taskData` is `null` the `taskHandler` will eventaully be called without any arguments. * * @overload * @param {() => void} taskHandler * @param {null} taskData * @param {string | null=} trackId * @return {void} */ enqueueTask(taskHandler: () => void, taskData: null, trackId?: (string | null) | undefined): void; runTaskQueue(deadline: { timeRemaining(): number; didTimeout: boolean; }): void; }; continuousScaling: boolean; valueScaleMin: number | null; fixedValueScaleMin: number | null; valueScaleMax: number | null; fixedValueScaleMax: number | null; /** @type {Record<string, Array<Function>>} */ listeners: Record<string, Array<Function>>; animate: Function; onValueScaleChanged: () => void; prevValueScale: any; dataFetcher: DataFetcher; /** @type {null | string} */ tilesetInfoError: null | string; uuid: string; trackNotFoundText: import("pixi.js").Text; refreshTilesDebounced: (request: unknown) => void; chromInfo: import("./utils/parse-chromsizes-rows.js").ParsedChromsizes; tilesetUid: string | undefined; server: string; /** @param {number | string} value */ setFixedValueScaleMin(value: number | string): void; /** @param {number | string} value */ setFixedValueScaleMax(value: number | string): void; checkValueScaleLimits(): void; /** * Register an event listener for track events. Currently, the only supported * event is ``dataChanged``. * * @param {string} event The event to listen for * @param {function} callback The callback to call when the event occurs. The * parameters for the event depend on the event called. * * @example * * trackObj.on('dataChanged', (newData) => { * console.log('newData:', newData) * }); */ on(event: string, callback: Function): void; /** * @param {string} event The event to listen for * @param {function} callback The callback to call when the event occurs. The * parameters for the event depend on the event called. */ off(event: string, callback: Function): void; /** Called when tileset info is received. The actual tileset info * can be found in this.tilesetInfo. * * Child tracks can implement this method. */ tilesetInfoReceived(): void; /** * Return the set of ids of all tiles which are both visible and fetched. */ visibleAndFetchedIds(): string[]; visibleAndFetchedTiles(): Tile[]; /** * Set which tiles are visible right now. * * @param {Array<TilePositionArrayObject>} tilePositions - A set of tiles which will be considered the currently visible tile positions. */ setVisibleTiles(tilePositions: Array<TilePositionArrayObject>): void; removeOldTiles(): void; refreshTiles(): void; /** @param {Tile} tile */ parentInFetched(tile: Tile): boolean; /** @param {Tile} tile */ parentTileId(tile: Tile): string; /** * Remove obsolete tiles * * @param {Array<string>} toRemoveIds: An array of tile ids to remove from the list of fetched tiles. */ removeTiles(toRemoveIds: Array<string>): void; /** * @param {t.Scale} newXScale * @param {t.Scale} newYScale */ zoomed(newXScale: t.Scale, newYScale: t.Scale, k?: number, tx?: number, ty?: number): void; /** * Check to see if all the visible tiles are loaded. * * If they are, remove all other tiles. */ areAllVisibleTilesLoaded(): boolean; /** * Function is called when all tiles that should be visible have * been received. */ allTilesLoaded(): void; /** @param {number} [_] - Optional value to set */ minValue(_?: number): number | this | null | undefined; /** @param {number} [_] - Optional value to set */ maxValue(_?: number): number | this | null | undefined; minRawValue(): number | null | undefined; maxRawValue(): number | null | undefined; /** @param {Tile} tile */ initTile(tile: Tile): void; /** @param {Tile} tile */ updateTile(tile: Tile): void; /** @param {Tile} tile */ destroyTile(tile: Tile): void; addMissingGraphics(): void; /** * Change the graphics for existing tiles */ updateExistingGraphics(): void; synchronizeTilesAndGraphics(): void; /** * @typedef TiledAreaTile * @property {string} tileId * @property {string} type * @property {unknown} data */ /** * * @param {TiledAreaTile} tile A tile returned by a TiledArea. * @param {function} dataLoader A function for extracting drawable data from a tile. This * usually means differentiating the between dense and sparse tiles and putting the data into an array. * @returns */ loadTileData(tile: { tileId: string; type: string; data: unknown; }, dataLoader: Function): any; /** @param {Pick<Tile,'remoteId'>[]} toFetch */ fetchNewTiles(toFetch: Pick<Tile, "remoteId">[]): void; /** * We've gotten a bunch of tiles from the server in * response to a request from fetchTiles. * @param {Object<string, import('./data-fetchers/DataFetcher').DividedTile | Tile | TilePositionArrayObject>} loadedTiles */ receivedTiles(loadedTiles: { [x: string]: import("./data-fetchers/DataFetcher").DividedTile | Tile | TilePositionArrayObject; }): void; _checkForErrors(): string[]; /** * Draw a tile on some graphics * @param {Tile} tile */ drawTile(tile: Tile): void; calculateMedianVisibleValue(): number | undefined; allVisibleValues(): number[]; minVisibleValue(ignoreFixedScale?: boolean): number | null; minVisibleValueInTiles(ignoreFixedScale?: boolean): number | null; maxVisibleValue(ignoreFixedScale?: boolean): number | null; maxVisibleValueInTiles(ignoreFixedScale?: boolean): number | null; /** @typedef {import('d3-scale').ScaleQuantile<number, never> & { ticks?: (count: number) => number[] }} ScaleQuantile */ /** * Create a value scale that will be used to position values * along the y axis. * @param {number} minValue The minimum value of the data * @param {number} medianValue The median value of the data. Potentially used for adding a pseudocount * @param {number} maxValue The maximum value of the data * @param {number} [inMargin] A number of pixels to be left free on the top and bottom * of the track. For example if the glyphs have a certain * width and we want all of them to fit into the space * @returns {[t.Scale | ScaleQuantile, number]} */ makeValueScale(minValue: number, medianValue: number, maxValue: number, inMargin?: number): [t.Scale | (import("d3-scale").ScaleQuantile<number, never> & { ticks?: (count: number) => number[]; }), number]; } import { DataFetcher } from './data-fetchers'; import type * as t from './types'; import PixiTrack from './PixiTrack';