oncoprintjs
Version:
A data visualization for cancer genomic data.
177 lines (176 loc) • 6.47 kB
TypeScript
import { ComputedShapeParams, ShapeParams } from './oncoprintshape';
import { Omit } from './utils';
import { ActiveRules, ColumnProp, Datum, RuleSetId } from './oncoprintmodel';
export declare type RuleSetParams = ILinearInterpRuleSetParams | ICategoricalRuleSetParams | IGradientRuleSetParams | IBarRuleSetParams | IStackedBarRuleSetParams | IGradientAndCategoricalRuleSetParams | IGeneticAlterationRuleSetParams;
interface IGeneralRuleSetParams {
type?: RuleSetType;
legend_label?: string;
legend_base_color?: RGBAColor;
exclude_from_legend?: boolean;
na_z?: number;
na_legend_label?: string;
na_shapes?: ShapeParams[];
}
interface ILinearInterpRuleSetParams extends IGeneralRuleSetParams {
log_scale?: boolean;
value_key: string;
value_range: [number, number];
}
export interface ICategoricalRuleSetParams extends IGeneralRuleSetParams {
type: RuleSetType.CATEGORICAL;
category_key: string;
category_to_color?: {
[category: string]: RGBAColor;
};
universal_rule_categories?: {
[category: string]: any;
};
}
export interface IGradientRuleSetParams extends ILinearInterpRuleSetParams {
type: RuleSetType.GRADIENT;
colors?: RGBAColor[];
colormap_name?: string;
value_stop_points: number[];
null_color?: RGBAColor;
null_legend_label?: string;
}
export interface IGradientAndCategoricalRuleSetParams extends IGeneralRuleSetParams {
type: RuleSetType.GRADIENT_AND_CATEGORICAL;
colors?: RGBAColor[];
colormap_name?: string;
value_stop_points: number[];
null_color?: RGBAColor;
log_scale?: boolean;
value_key: string;
value_range: [number, number];
category_key: string;
category_to_color?: {
[category: string]: RGBAColor;
};
}
export interface IBarRuleSetParams extends ILinearInterpRuleSetParams {
type: RuleSetType.BAR;
fill?: RGBAColor;
negative_fill?: RGBAColor;
}
export interface IStackedBarRuleSetParams extends IGeneralRuleSetParams {
type: RuleSetType.STACKED_BAR;
value_key: string;
categories: string[];
fills?: RGBAColor[];
}
export interface IGeneticAlterationRuleSetParams extends IGeneralRuleSetParams {
type: RuleSetType.GENE;
rule_params: GeneticAlterationRuleParams;
}
declare type GeneticAlterationSingleRuleParams = {
shapes: ShapeParams[];
legend_label: string;
exclude_from_legend?: boolean;
legend_order?: number;
};
export declare type GeneticAlterationRuleParams = {
always?: GeneticAlterationSingleRuleParams;
conditional: {
[datumKey: string]: {
[commaSeparatedDatumValues: string]: GeneticAlterationSingleRuleParams;
};
};
};
export declare type RGBAColor = [number, number, number, number];
declare type RuleParams = {
shapes: ShapeParams[];
legend_label?: string;
exclude_from_legend?: boolean;
legend_config?: RuleLegendConfig;
legend_order?: number;
legend_base_color?: RGBAColor;
};
declare type RuleLegendConfig = {
type: 'rule';
target: any;
} | {
type: 'number';
range: [number, number];
range_type: LinearInterpRangeType;
positive_color: RGBAColor;
negative_color: RGBAColor;
interpFn: (val: number) => number;
} | {
type: 'gradient';
range: [number, number];
colorFn: (val: number) => RGBAColor;
};
export declare enum RuleSetType {
CATEGORICAL = "categorical",
GRADIENT = "gradient",
GRADIENT_AND_CATEGORICAL = "gradient+categorical",
BAR = "bar",
STACKED_BAR = "stacked_bar",
GENE = "gene"
}
export declare type RuleId = number;
export declare type RuleWithId = {
id: RuleId;
rule: Rule;
};
export declare class RuleSet {
static getRuleSetId: () => number;
static getRuleId: () => number;
rule_set_id: RuleSetId;
legend_label?: string;
protected legend_base_color?: RGBAColor;
exclude_from_legend?: boolean;
protected active_rule_ids: ActiveRules;
protected rules_with_id: RuleWithId[];
protected universal_rule?: RuleWithId;
constructor(params: Omit<RuleSetParams, 'type'>);
getLegendLabel(): string;
getRuleSetId(): number;
addRules(list_of_params: RuleParams[]): number[];
_addRule(params: RuleParams, rule_id?: RuleId): number;
setUniversalRule(r: RuleWithId): void;
removeRule(rule_id: RuleId): void;
getRuleWithId(rule_id: RuleId): RuleWithId;
isExcludedFromLegend(): boolean;
getRule(rule_id: RuleId): Rule;
getRecentlyUsedRules(): Rule[];
applyRulesToDatum(rules_with_id: RuleWithId[], datum: Datum, cell_width: number, cell_height: number): ComputedShapeParams[];
getSpecificRulesForDatum(datum?: Datum): RuleWithId[];
getUniversalRule(): RuleWithId;
getUniversalShapes(cell_width: number, cell_height: number): ComputedShapeParams[];
getSpecificShapesForDatum(data: Datum[], cell_width: number, cell_height: number, out_active_rules?: ActiveRules | undefined, data_id_key?: string & keyof Datum, important_ids?: ColumnProp<boolean>): ComputedShapeParams[][];
}
declare class LookupRuleSet extends RuleSet {
private lookup_map_by_key_and_value;
private lookup_map_by_key;
private rule_id_to_conditions;
getSpecificRulesForDatum(datum?: Datum): RuleWithId[];
private indexRuleForLookup;
addRule(condition_key: string, condition_value: any, params: RuleParams): number;
linkExistingRule(condition_key: string, condition_value: string, existing_rule_id: RuleId): void;
removeRule(rule_id: RuleId): void;
}
export declare enum LinearInterpRangeType {
ALL = "ALL",
NON_NEGATIVE = "NON_NEGATIVE",
NON_POSITIVE = "NON_POSITIVE"
}
export declare class GeneticAlterationRuleSet extends LookupRuleSet {
constructor(params: IGeneticAlterationRuleSetParams);
private addRulesFromParams;
}
export declare class Rule {
private shapes;
legend_label: string;
legend_base_color?: RGBAColor;
exclude_from_legend?: boolean;
private legend_config?;
legend_order?: number;
constructor(params: RuleParams);
getLegendConfig(): RuleLegendConfig;
apply(d: Datum, cell_width: number, cell_height: number): ComputedShapeParams[];
isExcludedFromLegend(): boolean;
}
export default function (params: RuleSetParams): RuleSet;
export {};