From ae3f64f8134e3f226fe836e7aa096557659f87b4 Mon Sep 17 00:00:00 2001 From: Trevor Manz Date: Sat, 30 Mar 2024 14:11:14 -0400 Subject: [PATCH] Bump Gosling.js to `v0.16.0` (#143) Co-authored-by: manzt --- gosling/display.py | 124 ++-- gosling/schema/__init__.py | 4 +- gosling/schema/core.py | 229 +++++-- gosling/schema/gosling-schema.json | 921 +++++++++++++++++++++-------- gosling/sphinxext/plot.py | 57 +- 5 files changed, 906 insertions(+), 429 deletions(-) diff --git a/gosling/display.py b/gosling/display.py index 644b41f4..cc06ef26 100644 --- a/gosling/display.py +++ b/gosling/display.py @@ -1,79 +1,39 @@ +from __future__ import annotations + import json import uuid -from dataclasses import dataclass -from typing import Any, Dict, Optional +from typing import Any, Dict import jinja2 from gosling.plugin_registry import PluginRegistry from gosling.schema import SCHEMA_VERSION, THEMES -# TODO: This is kind of a mess. Gosling.js can be very finky with its -# peer dependencies in various Jupyter-like environments. This is a -# hacky way to get things working in JupyterLab, Jupyter Notebook, -# VSCode, and Colab consistently. +# TODO: Ideally we could use a single import but this seems to work ok. HTML_TEMPLATE = jinja2.Template( """ -
@@ -83,54 +43,40 @@ GoslingSpec = Dict[str, Any] -@dataclass -class GoslingBundle: - react: str - react_dom: str - pixijs: str - higlass_js: str - higlass_css: str - gosling: str - - -def get_display_dependencies( +def get_gosling_import_map( gosling_version: str = SCHEMA_VERSION.lstrip("v"), - higlass_version: str = "~1.12", - react_version: str = "17", + higlass_version: str = "1.13", + react_version: str = "18", pixijs_version: str = "6", - base_url: str = "https://unpkg.com", -) -> GoslingBundle: - return GoslingBundle( - react=f"{ base_url }/react@{ react_version }/umd/react.production.min.js", - react_dom=f"{ base_url }/react-dom@{ react_version }/umd/react-dom.production.min.js", - pixijs=f"{ base_url }/pixi.js@{ pixijs_version }/dist/browser/pixi.min.js", - higlass_js=f"{ base_url }/higlass@{ higlass_version }/dist/hglib.js", - higlass_css=f"{ base_url }/higlass@{ higlass_version }/dist/hglib.css", - gosling=f"{ base_url }/gosling.js@{ gosling_version }/dist/gosling.js", - ) +) -> dict: + return { + "imports": { + "react": f"https://esm.sh/react@{react_version}", + "react-dom": f"https://esm.sh/react-dom@{react_version}", + "pixi": f"https://esm.sh/pixi.js@{pixijs_version}", + "higlass": f"https://esm.sh/higlass@{higlass_version}?external=react,react-dom,pixi", + "gosling.js": f"https://esm.sh/gosling.js@{gosling_version}?external=react,react-dom,pixi,higlass", + } + } def spec_to_html( spec: GoslingSpec, output_div: str = "vis", - embed_options: Optional[Dict[str, Any]] = None, + embed_options: Dict[str, Any] | None = None, **kwargs, ): embed_options = embed_options or dict(padding=0, theme=themes.get()) - deps = get_display_dependencies(**kwargs) + deps = get_gosling_import_map(**kwargs) return HTML_TEMPLATE.render( spec=json.dumps(spec), embed_options=json.dumps(embed_options), output_div=output_div, - react_url=deps.react, - react_dom_url=deps.react_dom, - pixijs_url=deps.pixijs, - higlass_js_url=deps.higlass_js, - higlass_css_url=deps.higlass_css, - gosling_url=deps.gosling, + import_map=json.dumps(deps), ) + class Renderer: def __init__(self, output_div: str = "jupyter-gosling-{}", **kwargs: Any): self._output_div = output_div diff --git a/gosling/schema/__init__.py b/gosling/schema/__init__.py index 81eb3a04..c6f24ab7 100644 --- a/gosling/schema/__init__.py +++ b/gosling/schema/__init__.py @@ -1,6 +1,6 @@ # flake8: noqa from .core import * from .channels import * -SCHEMA_VERSION = 'v0.9.31' -SCHEMA_URL = 'https://raw.githubusercontent.com/gosling-lang/gosling.js/v0.9.31/schema/gosling.schema.json' +SCHEMA_VERSION = 'v0.16.0' +SCHEMA_URL = 'https://raw.githubusercontent.com/gosling-lang/gosling.js/v0.16.0/src/gosling-schema/gosling.schema.json' THEMES = {'dark', 'ensembl', 'excel', 'ggplot', 'google', 'igv', 'jbrowse', 'light', 'ucsc', 'warm', 'washu'} diff --git a/gosling/schema/core.py b/gosling/schema/core.py index 12343392..7e824e8b 100644 --- a/gosling/schema/core.py +++ b/gosling/schema/core.py @@ -176,7 +176,7 @@ class DataDeep(GoslingSchema): anyOf(:class:`JsonData`, :class:`CsvData`, :class:`BedData`, :class:`BigWigData`, :class:`MultivecData`, :class:`BeddbData`, :class:`VectorData`, :class:`MatrixData`, - :class:`BamData`, :class:`VcfData`) + :class:`BamData`, :class:`VcfData`, :class:`GffData`) """ _schema = {'$ref': '#/definitions/DataDeep'} _rootschema = GoslingSchema._rootschema @@ -490,6 +490,38 @@ def __init__(self, *args): super(DisplacementType, self).__init__(*args) +class DummyTrackStyle(GoslingSchema): + """DummyTrackStyle schema wrapper + + Mapping(required=[]) + + Attributes + ---------- + + background : string + Background color of the track + outline : string + Color of the outline of the track + textFontSize : float + Specify the font size of the title + textFontWeight : enum('bold', 'normal') + Specify the font weight of the title. + textStroke : string + Specify the stroke color of title. + textStrokeWidth : float + Specify the stroke width of the title. + """ + _schema = {'$ref': '#/definitions/DummyTrackStyle'} + _rootschema = GoslingSchema._rootschema + + def __init__(self, background=Undefined, outline=Undefined, textFontSize=Undefined, + textFontWeight=Undefined, textStroke=Undefined, textStrokeWidth=Undefined, **kwds): + super(DummyTrackStyle, self).__init__(background=background, outline=outline, + textFontSize=textFontSize, textFontWeight=textFontWeight, + textStroke=textStroke, textStrokeWidth=textStrokeWidth, + **kwds) + + class EventStyle(GoslingSchema): """EventStyle schema wrapper @@ -666,6 +698,48 @@ def __init__(self, endField=Undefined, newField=Undefined, startField=Undefined, startField=startField, type=type, **kwds) +class GffData(DataDeep): + """GffData schema wrapper + + Mapping(required=[type, url, indexUrl]) + Generic Feature Format Version 3 (GFF3) format data. It parses files that follow the [GFF3 + specification](https://github.com/The-Sequence-Ontology/Specifications/blob/master/gff3.md). + + Attributes + ---------- + + indexUrl : string + URL link to the tabix index file + type : string + + url : string + URL link to the GFF file + attributesToFields : List(Mapping(required=[attribute, defaultValue])) + Specifies which attributes to include as a fields. GFF files have an "attributes" + column which contains a list of attributes which are each tag-value pairs + (`tag=value`). This option allows for specific attributes to be accessible as a + field. For example, if you have an attribute called "gene_name" and you want label + features on your track using those values, you can use this option so that you can + use `"field": "gene_name"` in the schema. + + If there is a single `value` corresponding to the `tag`, Gosling will parse that + value as a string. If there are multiple `value`s corresponding to a `tag`, Gosling + will parse it as a comma-separated list string. If a feature does not have a + particular attribute, then the attribute value will be set to the `defaultValue`. + sampleLength : float + The maximum number of samples to be shown on the track. Samples are uniformly + randomly selected so that this threshold is not exceeded. __Default:__ `1000` + """ + _schema = {'$ref': '#/definitions/GffData'} + _rootschema = GoslingSchema._rootschema + + def __init__(self, indexUrl=Undefined, type=Undefined, url=Undefined, attributesToFields=Undefined, + sampleLength=Undefined, **kwds): + super(GffData, self).__init__(indexUrl=indexUrl, type=type, url=url, + attributesToFields=attributesToFields, sampleLength=sampleLength, + **kwds) + + class GoslingSpec(GoslingSchema): """GoslingSpec schema wrapper @@ -935,6 +1009,9 @@ class MultipleViews(GoslingSchema): Proportion of the radius of the center white space. __Default:__ `0.3` + id : string + The ID of a view that is maintained for the use of JS API functions, e.g., positions + of a view layout : :class:`Layout` Specify the layout type of all tracks. linkingId : string @@ -975,14 +1052,14 @@ class MultipleViews(GoslingSchema): _rootschema = GoslingSchema._rootschema def __init__(self, views=Undefined, _assignedHeight=Undefined, _assignedWidth=Undefined, - arrangement=Undefined, assembly=Undefined, centerRadius=Undefined, layout=Undefined, - linkingId=Undefined, orientation=Undefined, spacing=Undefined, static=Undefined, - style=Undefined, xAxis=Undefined, xDomain=Undefined, xOffset=Undefined, - yDomain=Undefined, yOffset=Undefined, zoomLimits=Undefined, **kwds): + arrangement=Undefined, assembly=Undefined, centerRadius=Undefined, id=Undefined, + layout=Undefined, linkingId=Undefined, orientation=Undefined, spacing=Undefined, + static=Undefined, style=Undefined, xAxis=Undefined, xDomain=Undefined, + xOffset=Undefined, yDomain=Undefined, yOffset=Undefined, zoomLimits=Undefined, **kwds): super(MultipleViews, self).__init__(views=views, _assignedHeight=_assignedHeight, _assignedWidth=_assignedWidth, arrangement=arrangement, - assembly=assembly, centerRadius=centerRadius, layout=layout, - linkingId=linkingId, orientation=orientation, + assembly=assembly, centerRadius=centerRadius, id=id, + layout=layout, linkingId=linkingId, orientation=orientation, spacing=spacing, static=static, style=style, xAxis=xAxis, xDomain=xDomain, xOffset=xOffset, yDomain=yDomain, yOffset=yOffset, zoomLimits=zoomLimits, **kwds) @@ -1147,7 +1224,8 @@ class OverlaidTracks(GoslingSchema): height : float Specify the track height in pixels. id : string - + The ID of a view that is maintained for the use of JS API functions, e.g., positions + of a view innerRadius : float Specify the inner radius of tracks when (`{"layout": "circular"}`). layout : :class:`Layout` @@ -1294,9 +1372,11 @@ class PartialTrack(GoslingSchema): Internal: Used for responsive spec _invalidTrack : boolean internal + _overlay : List(Mapping(required=[])) + _renderingId : string internal - assembly : :class:`Assembly` + assembly : anyOf(:class:`Assembly`, string) A string that specifies the genome builds to use. Currently support `"hg38"`, `"hg19"`, `"hg18"`, `"hg17"`, `"hg16"`, `"mm10"`, `"mm9"`, and `"unknown"`. @@ -1327,10 +1407,10 @@ class PartialTrack(GoslingSchema): height : float Specify the track height in pixels. id : string - + Assigned to `uid` in a HiGlass view config, used for API and caching. innerRadius : float Specify the inner radius of tracks when (`{"layout": "circular"}`). - layout : :class:`Layout` + layout : anyOf(:class:`Layout`, string) Specify the layout type of all tracks. linkingId : string Specify an ID for [linking multiple @@ -1343,8 +1423,6 @@ class PartialTrack(GoslingSchema): Specify the orientation. outerRadius : float Specify the outer radius of tracks when `{"layout": "circular"}`. - overlay : List(Mapping(required=[])) - overlayOnPreviousTrack : boolean overrideTemplate : boolean @@ -1365,7 +1443,7 @@ class PartialTrack(GoslingSchema): startAngle : float Specify the start angle (in the range of [0, 360]) of circular tracks (`{"layout": "circular"}`). - static : boolean + static : anyOf(boolean, boolean) Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`. @@ -1375,7 +1453,7 @@ class PartialTrack(GoslingSchema): strokeWidth : anyOf(:class:`StrokeWidth`, :class:`ChannelValue`) - style : :class:`Style` + style : anyOf(:class:`Style`, :class:`DummyTrackStyle`) Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, @@ -1390,6 +1468,8 @@ class PartialTrack(GoslingSchema): If defined, will show the textual label on the left-top corner of a track. tooltip : List(:class:`Tooltip`) + type : string + Used to specify the dummy track visibility : List(:class:`VisibilityCondition`) width : float @@ -1420,48 +1500,48 @@ class PartialTrack(GoslingSchema): Specify the y offset of views in the unit of pixels ye : anyOf(:class:`Y`, :class:`ChannelValue`) - zoomLimits : :class:`ZoomLimits` + zoomLimits : anyOf(:class:`ZoomLimits`, List(None)) """ _schema = {'$ref': '#/definitions/PartialTrack'} _rootschema = GoslingSchema._rootschema def __init__(self, _assignedHeight=Undefined, _assignedWidth=Undefined, _invalidTrack=Undefined, - _renderingId=Undefined, assembly=Undefined, baselineY=Undefined, + _overlay=Undefined, _renderingId=Undefined, assembly=Undefined, baselineY=Undefined, centerRadius=Undefined, color=Undefined, data=Undefined, dataTransform=Undefined, displacement=Undefined, encoding=Undefined, endAngle=Undefined, experimental=Undefined, flipY=Undefined, height=Undefined, id=Undefined, innerRadius=Undefined, layout=Undefined, linkingId=Undefined, mark=Undefined, opacity=Undefined, - orientation=Undefined, outerRadius=Undefined, overlay=Undefined, - overlayOnPreviousTrack=Undefined, overrideTemplate=Undefined, prerelease=Undefined, - row=Undefined, size=Undefined, spacing=Undefined, startAngle=Undefined, - static=Undefined, stretch=Undefined, stroke=Undefined, strokeWidth=Undefined, - style=Undefined, subtitle=Undefined, template=Undefined, text=Undefined, - title=Undefined, tooltip=Undefined, visibility=Undefined, width=Undefined, x=Undefined, - x1=Undefined, x1e=Undefined, xAxis=Undefined, xDomain=Undefined, xOffset=Undefined, - xe=Undefined, y=Undefined, y1=Undefined, y1e=Undefined, yDomain=Undefined, - yOffset=Undefined, ye=Undefined, zoomLimits=Undefined, **kwds): + orientation=Undefined, outerRadius=Undefined, overlayOnPreviousTrack=Undefined, + overrideTemplate=Undefined, prerelease=Undefined, row=Undefined, size=Undefined, + spacing=Undefined, startAngle=Undefined, static=Undefined, stretch=Undefined, + stroke=Undefined, strokeWidth=Undefined, style=Undefined, subtitle=Undefined, + template=Undefined, text=Undefined, title=Undefined, tooltip=Undefined, type=Undefined, + visibility=Undefined, width=Undefined, x=Undefined, x1=Undefined, x1e=Undefined, + xAxis=Undefined, xDomain=Undefined, xOffset=Undefined, xe=Undefined, y=Undefined, + y1=Undefined, y1e=Undefined, yDomain=Undefined, yOffset=Undefined, ye=Undefined, + zoomLimits=Undefined, **kwds): super(PartialTrack, self).__init__(_assignedHeight=_assignedHeight, _assignedWidth=_assignedWidth, _invalidTrack=_invalidTrack, - _renderingId=_renderingId, assembly=assembly, - baselineY=baselineY, centerRadius=centerRadius, color=color, - data=data, dataTransform=dataTransform, - displacement=displacement, encoding=encoding, - endAngle=endAngle, experimental=experimental, flipY=flipY, - height=height, id=id, innerRadius=innerRadius, layout=layout, - linkingId=linkingId, mark=mark, opacity=opacity, - orientation=orientation, outerRadius=outerRadius, - overlay=overlay, + _overlay=_overlay, _renderingId=_renderingId, + assembly=assembly, baselineY=baselineY, + centerRadius=centerRadius, color=color, data=data, + dataTransform=dataTransform, displacement=displacement, + encoding=encoding, endAngle=endAngle, + experimental=experimental, flipY=flipY, height=height, id=id, + innerRadius=innerRadius, layout=layout, linkingId=linkingId, + mark=mark, opacity=opacity, orientation=orientation, + outerRadius=outerRadius, overlayOnPreviousTrack=overlayOnPreviousTrack, overrideTemplate=overrideTemplate, prerelease=prerelease, row=row, size=size, spacing=spacing, startAngle=startAngle, static=static, stretch=stretch, stroke=stroke, strokeWidth=strokeWidth, style=style, subtitle=subtitle, template=template, text=text, title=title, tooltip=tooltip, - visibility=visibility, width=width, x=x, x1=x1, x1e=x1e, - xAxis=xAxis, xDomain=xDomain, xOffset=xOffset, xe=xe, y=y, - y1=y1, y1e=y1e, yDomain=yDomain, yOffset=yOffset, ye=ye, - zoomLimits=zoomLimits, **kwds) + type=type, visibility=visibility, width=width, x=x, x1=x1, + x1e=x1e, xAxis=xAxis, xDomain=xDomain, xOffset=xOffset, + xe=xe, y=y, y1=y1, y1e=y1e, yDomain=yDomain, yOffset=yOffset, + ye=ye, zoomLimits=zoomLimits, **kwds) class Range(GoslingSchema): @@ -1917,7 +1997,7 @@ class Track(GoslingSchema): """Track schema wrapper anyOf(:class:`SingleTrack`, :class:`OverlaidTrack`, :class:`DataTrack`, - :class:`TemplateTrack`) + :class:`TemplateTrack`, :class:`DummyTrack`) """ _schema = {'$ref': '#/definitions/Track'} _rootschema = GoslingSchema._rootschema @@ -1961,7 +2041,7 @@ class DataTrack(Track): height : float Specify the track height in pixels. id : string - + Assigned to `uid` in a HiGlass view config, used for API and caching. innerRadius : float Specify the inner radius of tracks when (`{"layout": "circular"}`). layout : :class:`Layout` @@ -2041,16 +2121,69 @@ def __init__(self, data=Undefined, _assignedHeight=Undefined, _assignedWidth=Und yDomain=yDomain, yOffset=yOffset, zoomLimits=zoomLimits, **kwds) +class DummyTrack(Track): + """DummyTrack schema wrapper + + Mapping(required=[type]) + A placeholder track. In contrast to other tracks, this track does not display any data. + Instead it provides empty space for third party tools to display their data on top of. + + Attributes + ---------- + + type : string + Used to specify the dummy track + _invalidTrack : boolean + internal + assembly : string + No assemblies can be associated with a dummy track + height : float + Specify the track height in pixels. + id : string + Assigned to `uid` in a HiGlass view config, used for API and caching. + layout : string + Only linear layout are supported at this time + orientation : :class:`Orientation` + Specify the orientation. + overlayOnPreviousTrack : boolean + + static : boolean + Whether to disable [Zooming and + Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), + __Default:__ `false`. + style : :class:`DummyTrackStyle` + Defines how the track is styled + title : string + Text that gets shown on the DummyTrack + width : float + Specify the track width in pixels. + zoomLimits : List(None) + Unused property for DummyTrack + """ + _schema = {'$ref': '#/definitions/DummyTrack'} + _rootschema = GoslingSchema._rootschema + + def __init__(self, type=Undefined, _invalidTrack=Undefined, assembly=Undefined, height=Undefined, + id=Undefined, layout=Undefined, orientation=Undefined, + overlayOnPreviousTrack=Undefined, static=Undefined, style=Undefined, title=Undefined, + width=Undefined, zoomLimits=Undefined, **kwds): + super(DummyTrack, self).__init__(type=type, _invalidTrack=_invalidTrack, assembly=assembly, + height=height, id=id, layout=layout, orientation=orientation, + overlayOnPreviousTrack=overlayOnPreviousTrack, static=static, + style=style, title=title, width=width, zoomLimits=zoomLimits, + **kwds) + + class OverlaidTrack(Track): """OverlaidTrack schema wrapper - Mapping(required=[overlay]) + Mapping(required=[_overlay]) Superposing multiple tracks. Attributes ---------- - overlay : List(Mapping(required=[])) + _overlay : List(Mapping(required=[])) _assignedHeight : float @@ -2089,7 +2222,7 @@ class OverlaidTrack(Track): height : float Specify the track height in pixels. id : string - + Assigned to `uid` in a HiGlass view config, used for API and caching. innerRadius : float Specify the inner radius of tracks when (`{"layout": "circular"}`). layout : :class:`Layout` @@ -2184,7 +2317,7 @@ class OverlaidTrack(Track): _schema = {'$ref': '#/definitions/OverlaidTrack'} _rootschema = GoslingSchema._rootschema - def __init__(self, overlay=Undefined, _assignedHeight=Undefined, _assignedWidth=Undefined, + def __init__(self, _overlay=Undefined, _assignedHeight=Undefined, _assignedWidth=Undefined, _invalidTrack=Undefined, _renderingId=Undefined, assembly=Undefined, baselineY=Undefined, centerRadius=Undefined, color=Undefined, data=Undefined, dataTransform=Undefined, displacement=Undefined, endAngle=Undefined, @@ -2199,7 +2332,7 @@ def __init__(self, overlay=Undefined, _assignedHeight=Undefined, _assignedWidth= x1e=Undefined, xAxis=Undefined, xDomain=Undefined, xOffset=Undefined, xe=Undefined, y=Undefined, y1=Undefined, y1e=Undefined, yDomain=Undefined, yOffset=Undefined, ye=Undefined, zoomLimits=Undefined, **kwds): - super(OverlaidTrack, self).__init__(overlay=overlay, _assignedHeight=_assignedHeight, + super(OverlaidTrack, self).__init__(_overlay=_overlay, _assignedHeight=_assignedHeight, _assignedWidth=_assignedWidth, _invalidTrack=_invalidTrack, _renderingId=_renderingId, assembly=assembly, baselineY=baselineY, centerRadius=centerRadius, color=color, @@ -2268,7 +2401,7 @@ class SingleTrack(Track): height : float Specify the track height in pixels. id : string - + Assigned to `uid` in a HiGlass view config, used for API and caching. innerRadius : float Specify the inner radius of tracks when (`{"layout": "circular"}`). layout : :class:`Layout` @@ -2435,7 +2568,7 @@ class TemplateTrack(Track): height : float Specify the track height in pixels. id : string - + Assigned to `uid` in a HiGlass view config, used for API and caching. innerRadius : float Specify the inner radius of tracks when (`{"layout": "circular"}`). layout : :class:`Layout` diff --git a/gosling/schema/gosling-schema.json b/gosling/schema/gosling-schema.json index cb352d85..4a1c1eba 100644 --- a/gosling/schema/gosling-schema.json +++ b/gosling/schema/gosling-schema.json @@ -553,6 +553,9 @@ }, { "$ref": "#/definitions/VcfData" + }, + { + "$ref": "#/definitions/GffData" } ] }, @@ -595,6 +598,7 @@ "type": "number" }, "id": { + "description": "Assigned to `uid` in a HiGlass view config, used for API and caching.", "type": "string" }, "innerRadius": { @@ -876,6 +880,110 @@ ], "type": "object" }, + "DummyTrack": { + "additionalProperties": false, + "description": "A placeholder track. In contrast to other tracks, this track does not display any data. Instead it provides empty space for third party tools to display their data on top of.", + "properties": { + "_invalidTrack": { + "description": "internal", + "type": "boolean" + }, + "assembly": { + "const": "unknown", + "description": "No assemblies can be associated with a dummy track", + "type": "string" + }, + "height": { + "description": "Specify the track height in pixels.", + "type": "number" + }, + "id": { + "description": "Assigned to `uid` in a HiGlass view config, used for API and caching.", + "type": "string" + }, + "layout": { + "const": "linear", + "description": "Only linear layout are supported at this time", + "type": "string" + }, + "orientation": { + "$ref": "#/definitions/Orientation", + "description": "Specify the orientation." + }, + "overlayOnPreviousTrack": { + "type": "boolean" + }, + "static": { + "const": true, + "description": "Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.", + "type": "boolean" + }, + "style": { + "$ref": "#/definitions/DummyTrackStyle", + "description": "Defines how the track is styled" + }, + "title": { + "description": "Text that gets shown on the DummyTrack", + "type": "string" + }, + "type": { + "const": "dummy-track", + "description": "Used to specify the dummy track", + "type": "string" + }, + "width": { + "description": "Specify the track width in pixels.", + "type": "number" + }, + "zoomLimits": { + "description": "Unused property for DummyTrack", + "items": { + "type": "null" + }, + "maxItems": 2, + "minItems": 2, + "type": "array" + } + }, + "required": [ + "type" + ], + "type": "object" + }, + "DummyTrackStyle": { + "additionalProperties": false, + "properties": { + "background": { + "description": "Background color of the track", + "type": "string" + }, + "outline": { + "description": "Color of the outline of the track", + "type": "string" + }, + "textFontSize": { + "description": "Specify the font size of the title", + "type": "number" + }, + "textFontWeight": { + "description": "Specify the font weight of the title.", + "enum": [ + "bold", + "normal" + ], + "type": "string" + }, + "textStroke": { + "description": "Specify the stroke color of title.", + "type": "string" + }, + "textStrokeWidth": { + "description": "Specify the stroke width of the title.", + "type": "number" + } + }, + "type": "object" + }, "EventStyle": { "additionalProperties": false, "description": "The styles defined here will be applied to the target marks of mouse events, such as a point mark after the user clicks on it.", @@ -1035,6 +1143,54 @@ ], "type": "object" }, + "GffData": { + "additionalProperties": false, + "description": "Generic Feature Format Version 3 (GFF3) format data. It parses files that follow the [GFF3 specification](https://github.com/The-Sequence-Ontology/Specifications/blob/master/gff3.md).", + "properties": { + "attributesToFields": { + "description": "Specifies which attributes to include as a fields. GFF files have an \"attributes\" column which contains a list of attributes which are each tag-value pairs (`tag=value`). This option allows for specific attributes to be accessible as a field. For example, if you have an attribute called \"gene_name\" and you want label features on your track using those values, you can use this option so that you can use `\"field\": \"gene_name\"` in the schema.\n\nIf there is a single `value` corresponding to the `tag`, Gosling will parse that value as a string. If there are multiple `value`s corresponding to a `tag`, Gosling will parse it as a comma-separated list string. If a feature does not have a particular attribute, then the attribute value will be set to the `defaultValue`.", + "items": { + "additionalProperties": false, + "properties": { + "attribute": { + "type": "string" + }, + "defaultValue": { + "type": "string" + } + }, + "required": [ + "attribute", + "defaultValue" + ], + "type": "object" + }, + "type": "array" + }, + "indexUrl": { + "description": "URL link to the tabix index file", + "type": "string" + }, + "sampleLength": { + "description": "The maximum number of samples to be shown on the track. Samples are uniformly randomly selected so that this threshold is not exceeded. __Default:__ `1000`", + "type": "number" + }, + "type": { + "const": "gff", + "type": "string" + }, + "url": { + "description": "URL link to the GFF file", + "type": "string" + } + }, + "required": [ + "type", + "url", + "indexUrl" + ], + "type": "object" + }, "GoslingSpec": { "anyOf": [ { @@ -1116,6 +1272,15 @@ "default": false, "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" } }, "type": "object" @@ -1128,6 +1293,7 @@ "type": "number" }, "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", "type": "string" }, "innerRadius": { @@ -1267,6 +1433,15 @@ "default": false, "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" } }, "type": "object" @@ -1279,6 +1454,7 @@ "type": "number" }, "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", "type": "string" }, "innerRadius": { @@ -1882,6 +2058,15 @@ "default": false, "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" } }, "type": "object" @@ -1894,6 +2079,7 @@ "type": "number" }, "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", "type": "string" }, "innerRadius": { @@ -2033,6 +2219,15 @@ "default": false, "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" } }, "type": "object" @@ -2045,6 +2240,7 @@ "type": "number" }, "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", "type": "string" }, "innerRadius": { @@ -2596,6 +2792,10 @@ "description": { "type": "string" }, + "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", + "type": "string" + }, "layout": { "$ref": "#/definitions/Layout", "description": "Specify the layout type of all tracks." @@ -2701,6 +2901,15 @@ "default": false, "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" } }, "type": "object" @@ -2713,6 +2922,7 @@ "type": "number" }, "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", "type": "string" }, "innerRadius": { @@ -3113,6 +3323,10 @@ "description": { "type": "string" }, + "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", + "type": "string" + }, "layout": { "$ref": "#/definitions/Layout", "description": "Specify the layout type of all tracks." @@ -3167,6 +3381,10 @@ "description": "Proportion of the radius of the center white space.\n\n__Default:__ `0.3`", "type": "number" }, + "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", + "type": "string" + }, "layout": { "$ref": "#/definitions/Layout", "description": "Specify the layout type of all tracks." @@ -3633,6 +3851,10 @@ "description": "Proportion of the radius of the center white space.\n\n__Default:__ `0.3`", "type": "number" }, + "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", + "type": "string" + }, "layout": { "$ref": "#/definitions/Layout", "description": "Specify the layout type of all tracks." @@ -3856,112 +4078,7 @@ "description": "internal", "type": "boolean" }, - "_renderingId": { - "description": "internal", - "type": "string" - }, - "assembly": { - "$ref": "#/definitions/Assembly", - "description": "A string that specifies the genome builds to use. Currently support `\"hg38\"`, `\"hg19\"`, `\"hg18\"`, `\"hg17\"`, `\"hg16\"`, `\"mm10\"`, `\"mm9\"`, and `\"unknown\"`.\n\n__Note:__: with `\"unknown\"` assembly, genomic axes do not show chrN: in labels." - }, - "baselineY": { - "type": "number" - }, - "centerRadius": { - "description": "Proportion of the radius of the center white space.\n\n__Default:__ `0.3`", - "type": "number" - }, - "color": { - "anyOf": [ - { - "$ref": "#/definitions/Color" - }, - { - "$ref": "#/definitions/ChannelValue" - } - ] - }, - "data": { - "$ref": "#/definitions/DataDeep" - }, - "dataTransform": { - "items": { - "$ref": "#/definitions/DataTransform" - }, - "type": "array" - }, - "displacement": { - "$ref": "#/definitions/Displacement" - }, - "endAngle": { - "description": "Specify the end angle (in the range of [0, 360]) of circular tracks (`{\"layout\": \"circular\"}`).", - "type": "number" - }, - "experimental": { - "additionalProperties": false, - "properties": { - "mouseEvents": { - "anyOf": [ - { - "type": "boolean" - }, - { - "$ref": "#/definitions/MouseEventsDeep" - } - ] - }, - "performanceMode": { - "default": false, - "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", - "type": "boolean" - } - }, - "type": "object" - }, - "flipY": { - "type": "boolean" - }, - "height": { - "description": "Specify the track height in pixels.", - "type": "number" - }, - "id": { - "type": "string" - }, - "innerRadius": { - "description": "Specify the inner radius of tracks when (`{\"layout\": \"circular\"}`).", - "type": "number" - }, - "layout": { - "$ref": "#/definitions/Layout", - "description": "Specify the layout type of all tracks." - }, - "linkingId": { - "description": "Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)", - "type": "string" - }, - "mark": { - "$ref": "#/definitions/Mark" - }, - "opacity": { - "anyOf": [ - { - "$ref": "#/definitions/Opacity" - }, - { - "$ref": "#/definitions/ChannelValue" - } - ] - }, - "orientation": { - "$ref": "#/definitions/Orientation", - "description": "Specify the orientation." - }, - "outerRadius": { - "description": "Specify the outer radius of tracks when `{\"layout\": \"circular\"}`.", - "type": "number" - }, - "overlay": { + "_overlay": { "items": { "additionalProperties": false, "properties": { @@ -4034,6 +4151,15 @@ "default": false, "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" } }, "type": "object" @@ -4042,6 +4168,7 @@ "type": "boolean" }, "id": { + "description": "Assigned to `uid` in a HiGlass view config, used for API and caching.", "type": "string" }, "innerRadius": { @@ -4293,6 +4420,121 @@ }, "type": "array" }, + "_renderingId": { + "description": "internal", + "type": "string" + }, + "assembly": { + "$ref": "#/definitions/Assembly", + "description": "A string that specifies the genome builds to use. Currently support `\"hg38\"`, `\"hg19\"`, `\"hg18\"`, `\"hg17\"`, `\"hg16\"`, `\"mm10\"`, `\"mm9\"`, and `\"unknown\"`.\n\n__Note:__: with `\"unknown\"` assembly, genomic axes do not show chrN: in labels." + }, + "baselineY": { + "type": "number" + }, + "centerRadius": { + "description": "Proportion of the radius of the center white space.\n\n__Default:__ `0.3`", + "type": "number" + }, + "color": { + "anyOf": [ + { + "$ref": "#/definitions/Color" + }, + { + "$ref": "#/definitions/ChannelValue" + } + ] + }, + "data": { + "$ref": "#/definitions/DataDeep" + }, + "dataTransform": { + "items": { + "$ref": "#/definitions/DataTransform" + }, + "type": "array" + }, + "displacement": { + "$ref": "#/definitions/Displacement" + }, + "endAngle": { + "description": "Specify the end angle (in the range of [0, 360]) of circular tracks (`{\"layout\": \"circular\"}`).", + "type": "number" + }, + "experimental": { + "additionalProperties": false, + "properties": { + "mouseEvents": { + "anyOf": [ + { + "type": "boolean" + }, + { + "$ref": "#/definitions/MouseEventsDeep" + } + ] + }, + "performanceMode": { + "default": false, + "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", + "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" + } + }, + "type": "object" + }, + "flipY": { + "type": "boolean" + }, + "height": { + "description": "Specify the track height in pixels.", + "type": "number" + }, + "id": { + "description": "Assigned to `uid` in a HiGlass view config, used for API and caching.", + "type": "string" + }, + "innerRadius": { + "description": "Specify the inner radius of tracks when (`{\"layout\": \"circular\"}`).", + "type": "number" + }, + "layout": { + "$ref": "#/definitions/Layout", + "description": "Specify the layout type of all tracks." + }, + "linkingId": { + "description": "Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)", + "type": "string" + }, + "mark": { + "$ref": "#/definitions/Mark" + }, + "opacity": { + "anyOf": [ + { + "$ref": "#/definitions/Opacity" + }, + { + "$ref": "#/definitions/ChannelValue" + } + ] + }, + "orientation": { + "$ref": "#/definitions/Orientation", + "description": "Specify the orientation." + }, + "outerRadius": { + "description": "Specify the outer radius of tracks when `{\"layout\": \"circular\"}`.", + "type": "number" + }, "overlayOnPreviousTrack": { "type": "boolean" }, @@ -4521,7 +4763,7 @@ } }, "required": [ - "overlay" + "_overlay" ], "type": "object" }, @@ -4601,6 +4843,15 @@ "default": false, "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" } }, "type": "object" @@ -4613,6 +4864,7 @@ "type": "number" }, "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", "type": "string" }, "innerRadius": { @@ -4847,172 +5099,61 @@ { "$ref": "#/definitions/ChannelValue" } - ] - }, - "yDomain": { - "anyOf": [ - { - "$ref": "#/definitions/DomainInterval" - }, - { - "$ref": "#/definitions/DomainChrInterval" - }, - { - "$ref": "#/definitions/DomainChr" - } - ], - "description": "Specify the visible region of genomic y-axis" - }, - "yOffset": { - "description": "Specify the y offset of views in the unit of pixels", - "type": "number" - }, - "ye": { - "anyOf": [ - { - "$ref": "#/definitions/Y" - }, - { - "$ref": "#/definitions/ChannelValue" - } - ] - }, - "zoomLimits": { - "$ref": "#/definitions/ZoomLimits" - } - }, - "required": [ - "alignment", - "tracks" - ], - "type": "object" - }, - "PartialTrack": { - "additionalProperties": false, - "properties": { - "_assignedHeight": { - "type": "number" - }, - "_assignedWidth": { - "description": "Internal: Used for responsive spec", - "type": "number" - }, - "_invalidTrack": { - "description": "internal", - "type": "boolean" - }, - "_renderingId": { - "description": "internal", - "type": "string" - }, - "assembly": { - "$ref": "#/definitions/Assembly", - "description": "A string that specifies the genome builds to use. Currently support `\"hg38\"`, `\"hg19\"`, `\"hg18\"`, `\"hg17\"`, `\"hg16\"`, `\"mm10\"`, `\"mm9\"`, and `\"unknown\"`.\n\n__Note:__: with `\"unknown\"` assembly, genomic axes do not show chrN: in labels." - }, - "baselineY": { - "type": "number" - }, - "centerRadius": { - "description": "Proportion of the radius of the center white space.\n\n__Default:__ `0.3`", - "type": "number" - }, - "color": { - "anyOf": [ - { - "$ref": "#/definitions/Color" - }, - { - "$ref": "#/definitions/ChannelValue" - } - ] - }, - "data": { - "$ref": "#/definitions/DataDeep" - }, - "dataTransform": { - "items": { - "$ref": "#/definitions/DataTransform" - }, - "type": "array" - }, - "displacement": { - "$ref": "#/definitions/Displacement" - }, - "encoding": { - "additionalProperties": { - "$ref": "#/definitions/Channel" - }, - "type": "object" - }, - "endAngle": { - "description": "Specify the end angle (in the range of [0, 360]) of circular tracks (`{\"layout\": \"circular\"}`).", - "type": "number" - }, - "experimental": { - "additionalProperties": false, - "properties": { - "mouseEvents": { - "anyOf": [ - { - "type": "boolean" - }, - { - "$ref": "#/definitions/MouseEventsDeep" - } - ] - }, - "performanceMode": { - "default": false, - "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", - "type": "boolean" - } - }, - "type": "object" - }, - "flipY": { - "type": "boolean" - }, - "height": { - "description": "Specify the track height in pixels.", - "type": "number" + ] }, - "id": { - "type": "string" + "yDomain": { + "anyOf": [ + { + "$ref": "#/definitions/DomainInterval" + }, + { + "$ref": "#/definitions/DomainChrInterval" + }, + { + "$ref": "#/definitions/DomainChr" + } + ], + "description": "Specify the visible region of genomic y-axis" }, - "innerRadius": { - "description": "Specify the inner radius of tracks when (`{\"layout\": \"circular\"}`).", + "yOffset": { + "description": "Specify the y offset of views in the unit of pixels", "type": "number" }, - "layout": { - "$ref": "#/definitions/Layout", - "description": "Specify the layout type of all tracks." - }, - "linkingId": { - "description": "Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)", - "type": "string" - }, - "mark": { - "$ref": "#/definitions/Mark" - }, - "opacity": { + "ye": { "anyOf": [ { - "$ref": "#/definitions/Opacity" + "$ref": "#/definitions/Y" }, { "$ref": "#/definitions/ChannelValue" } ] }, - "orientation": { - "$ref": "#/definitions/Orientation", - "description": "Specify the orientation." + "zoomLimits": { + "$ref": "#/definitions/ZoomLimits" + } + }, + "required": [ + "alignment", + "tracks" + ], + "type": "object" + }, + "PartialTrack": { + "additionalProperties": false, + "properties": { + "_assignedHeight": { + "type": "number" }, - "outerRadius": { - "description": "Specify the outer radius of tracks when `{\"layout\": \"circular\"}`.", + "_assignedWidth": { + "description": "Internal: Used for responsive spec", "type": "number" }, - "overlay": { + "_invalidTrack": { + "description": "internal", + "type": "boolean" + }, + "_overlay": { "items": { "additionalProperties": false, "properties": { @@ -5085,6 +5226,15 @@ "default": false, "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" } }, "type": "object" @@ -5093,6 +5243,7 @@ "type": "boolean" }, "id": { + "description": "Assigned to `uid` in a HiGlass view config, used for API and caching.", "type": "string" }, "innerRadius": { @@ -5344,6 +5495,147 @@ }, "type": "array" }, + "_renderingId": { + "description": "internal", + "type": "string" + }, + "assembly": { + "anyOf": [ + { + "$ref": "#/definitions/Assembly", + "description": "A string that specifies the genome builds to use. Currently support `\"hg38\"`, `\"hg19\"`, `\"hg18\"`, `\"hg17\"`, `\"hg16\"`, `\"mm10\"`, `\"mm9\"`, and `\"unknown\"`.\n\n__Note:__: with `\"unknown\"` assembly, genomic axes do not show chrN: in labels." + }, + { + "const": "unknown", + "description": "No assemblies can be associated with a dummy track", + "type": "string" + } + ], + "description": "A string that specifies the genome builds to use. Currently support `\"hg38\"`, `\"hg19\"`, `\"hg18\"`, `\"hg17\"`, `\"hg16\"`, `\"mm10\"`, `\"mm9\"`, and `\"unknown\"`.\n\n__Note:__: with `\"unknown\"` assembly, genomic axes do not show chrN: in labels." + }, + "baselineY": { + "type": "number" + }, + "centerRadius": { + "description": "Proportion of the radius of the center white space.\n\n__Default:__ `0.3`", + "type": "number" + }, + "color": { + "anyOf": [ + { + "$ref": "#/definitions/Color" + }, + { + "$ref": "#/definitions/ChannelValue" + } + ] + }, + "data": { + "$ref": "#/definitions/DataDeep" + }, + "dataTransform": { + "items": { + "$ref": "#/definitions/DataTransform" + }, + "type": "array" + }, + "displacement": { + "$ref": "#/definitions/Displacement" + }, + "encoding": { + "additionalProperties": { + "$ref": "#/definitions/Channel" + }, + "type": "object" + }, + "endAngle": { + "description": "Specify the end angle (in the range of [0, 360]) of circular tracks (`{\"layout\": \"circular\"}`).", + "type": "number" + }, + "experimental": { + "additionalProperties": false, + "properties": { + "mouseEvents": { + "anyOf": [ + { + "type": "boolean" + }, + { + "$ref": "#/definitions/MouseEventsDeep" + } + ] + }, + "performanceMode": { + "default": false, + "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", + "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" + } + }, + "type": "object" + }, + "flipY": { + "type": "boolean" + }, + "height": { + "description": "Specify the track height in pixels.", + "type": "number" + }, + "id": { + "description": "Assigned to `uid` in a HiGlass view config, used for API and caching.", + "type": "string" + }, + "innerRadius": { + "description": "Specify the inner radius of tracks when (`{\"layout\": \"circular\"}`).", + "type": "number" + }, + "layout": { + "anyOf": [ + { + "$ref": "#/definitions/Layout", + "description": "Specify the layout type of all tracks." + }, + { + "const": "linear", + "description": "Only linear layout are supported at this time", + "type": "string" + } + ], + "description": "Specify the layout type of all tracks." + }, + "linkingId": { + "description": "Specify an ID for [linking multiple views](http://gosling-lang.org/docs/user-interaction#linking-views)", + "type": "string" + }, + "mark": { + "$ref": "#/definitions/Mark" + }, + "opacity": { + "anyOf": [ + { + "$ref": "#/definitions/Opacity" + }, + { + "$ref": "#/definitions/ChannelValue" + } + ] + }, + "orientation": { + "$ref": "#/definitions/Orientation", + "description": "Specify the orientation." + }, + "outerRadius": { + "description": "Specify the outer radius of tracks when `{\"layout\": \"circular\"}`.", + "type": "number" + }, "overlayOnPreviousTrack": { "type": "boolean" }, @@ -5384,8 +5676,18 @@ "type": "number" }, "static": { - "description": "Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.", - "type": "boolean" + "anyOf": [ + { + "description": "Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.", + "type": "boolean" + }, + { + "const": true, + "description": "Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`.", + "type": "boolean" + } + ], + "description": "Whether to disable [Zooming and Panning](http://gosling-lang.org/docs/user-interaction#zooming-and-panning), __Default:__ `false`." }, "stretch": { "type": "boolean" @@ -5411,7 +5713,16 @@ ] }, "style": { - "$ref": "#/definitions/Style", + "anyOf": [ + { + "$ref": "#/definitions/Style", + "description": "Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)." + }, + { + "$ref": "#/definitions/DummyTrackStyle", + "description": "Defines how the track is styled" + } + ], "description": "Define the [style](http://gosling-lang.org/docs/visual-channel#style-related-properties) of multive views. Will be overwritten by the style of children elements (e.g., view, track)." }, "subtitle": { @@ -5440,6 +5751,11 @@ }, "type": "array" }, + "type": { + "const": "dummy-track", + "description": "Used to specify the dummy track", + "type": "string" + }, "visibility": { "items": { "$ref": "#/definitions/VisibilityCondition" @@ -5571,7 +5887,20 @@ ] }, "zoomLimits": { - "$ref": "#/definitions/ZoomLimits" + "anyOf": [ + { + "$ref": "#/definitions/ZoomLimits" + }, + { + "description": "Unused property for DummyTrack", + "items": { + "type": "null" + }, + "maxItems": 2, + "minItems": 2, + "type": "array" + } + ] } }, "type": "object" @@ -5794,6 +6123,15 @@ "default": false, "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" } }, "type": "object" @@ -5806,6 +6144,7 @@ "type": "number" }, "id": { + "description": "Assigned to `uid` in a HiGlass view config, used for API and caching.", "type": "string" }, "innerRadius": { @@ -6152,6 +6491,15 @@ "default": false, "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" } }, "type": "object" @@ -6164,6 +6512,7 @@ "type": "number" }, "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", "type": "string" }, "innerRadius": { @@ -6299,6 +6648,15 @@ "default": false, "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" } }, "type": "object" @@ -6311,6 +6669,7 @@ "type": "number" }, "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", "type": "string" }, "innerRadius": { @@ -6911,6 +7270,15 @@ "default": false, "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" } }, "type": "object" @@ -6923,6 +7291,7 @@ "type": "number" }, "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", "type": "string" }, "innerRadius": { @@ -7058,6 +7427,15 @@ "default": false, "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" } }, "type": "object" @@ -7070,6 +7448,7 @@ "type": "number" }, "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", "type": "string" }, "innerRadius": { @@ -7618,6 +7997,10 @@ "description": "Proportion of the radius of the center white space.\n\n__Default:__ `0.3`", "type": "number" }, + "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", + "type": "string" + }, "layout": { "$ref": "#/definitions/Layout", "description": "Specify the layout type of all tracks." @@ -7719,6 +8102,15 @@ "default": false, "description": "Render visual marks with less smooth curves to increase rendering performance. Only supported for `elliptical` `linkStyle` `withinLink` currently.", "type": "boolean" + }, + "stretchGraphics": { + "description": "Performance rendering option. By default, certain marks ('bar', 'line', 'rect', 'area') are stretched when zooming in/out to improve rendering performance. No marks will be stretched in circular layouts.\n\nWhen this option is set to true, all marks will be stretched when zooming in/out. When this option is set to false, all marks will be rerendered when zooming in/out.", + "type": "boolean" + }, + "stretchGraphicsThreshold": { + "default": 1.5, + "description": "Threshold for stretching graphics. If the graphics are scaled larger than the threshold, then the graphic will be rerendered. If the graphics are scaled smaller than 1/threshold (e.g., 1/2), then the graphic will be rerendered. This is to prevent the graphics from being stretched too much.", + "type": "number" } }, "type": "object" @@ -7731,6 +8123,7 @@ "type": "number" }, "id": { + "description": "The ID of a view that is maintained for the use of JS API functions, e.g., positions of a view", "type": "string" }, "innerRadius": { @@ -8606,6 +8999,7 @@ "type": "number" }, "id": { + "description": "Assigned to `uid` in a HiGlass view config, used for API and caching.", "type": "string" }, "innerRadius": { @@ -8787,6 +9181,9 @@ }, { "$ref": "#/definitions/TemplateTrack" + }, + { + "$ref": "#/definitions/DummyTrack" } ] }, diff --git a/gosling/sphinxext/plot.py b/gosling/sphinxext/plot.py index 66de31f2..77e05671 100644 --- a/gosling/sphinxext/plot.py +++ b/gosling/sphinxext/plot.py @@ -1,24 +1,32 @@ +from __future__ import annotations + +import json import pathlib import warnings +import typing import jinja2 from docutils import nodes from docutils.parsers.rst import Directive from docutils.parsers.rst.directives import flag -from gosling.display import get_display_dependencies +from gosling.display import get_gosling_import_map from gosling.schemapi import SchemaValidationError from gosling.utils.execeval import eval_block +if typing.TYPE_CHECKING: + from sphinx.application import Sphinx + TEMPLATE = jinja2.Template( """
- @@ -84,14 +92,25 @@ def run(self): return result +def add_custom_head( + app: Sphinx, pagename: str, templatename: str, context: dict, doctree +): + custom_html = ( + f'' + ) + if context.get("metatags, None"): + context["metatags"] += custom_html + else: + context["metatags"] = custom_html + + def html_visit_gosling_plot(self, node): # Execute the code, saving output and namespace try: chart = eval_block(node["code"]) except Exception as e: warnings.warn( - "gosling-plot: {}:{} Code Execution failed:" - "{}: {}".format( + "gosling-plot: {}:{} Code Execution failed:" "{}: {}".format( node["rst_source"], node["rst_lineno"], e.__class__.__name__, str(e) ) ) @@ -112,26 +131,8 @@ def depart_gosling_plot(self, node): return -def builder_inited(app): - app.add_css_file(app.config.higlass_css_url) - app.add_js_file(app.config.react_url) - app.add_js_file(app.config.reactdom_url) - app.add_js_file(app.config.pixi_url) - app.add_js_file(app.config.higlass_js_url) - app.add_js_file(app.config.gosling_url) - - -def setup(app): - deps = get_display_dependencies() - app.add_config_value("react_url", deps.react, "html") - app.add_config_value("reactdom_url", deps.react_dom, "html") - app.add_config_value("pixi_url", deps.pixijs, "html") - app.add_config_value("higlass_js_url", deps.higlass_js, "html") - app.add_config_value("higlass_css_url", deps.higlass_css, "html") - app.add_config_value("gosling_url", deps.gosling, "html") - +def setup(app: Sphinx): + app.connect("html-page-context", add_custom_head) app.add_directive("gosling-plot", GoslingPlotDirective) app.add_node(gosling_plot, html=(html_visit_gosling_plot, depart_gosling_plot)) - - app.connect("builder-inited", builder_inited) return {"version": "0.1"}