Skip to content
Simon Brent edited this page Mar 25, 2022 · 3 revisions

In Genoverse, a "feature" is anything to be drawn by a track - genes, variants, etc.

By default, features are drawn as rectangles, but the use of subFeatures or custom Genoverse.Track.View extensions can change this.

A feature is represented by a JavaScript object with the following properties:

Mandatory properties

start

The genomic position for the start of the feature

end

The genomic position for the end of the feature

Recommended properties

chr

The chromosome for the feature. If missing, the current value of genoverse.chr will be used.

id

A unique string or number identifying the feature. If missing, one will be generated as a hash of JSON.stringify(feature).

Displaying text for a feature

label

A string which will be displayed along (depending on track setting) with the feature, depending on the track's labels setting. New line (\n) characters in the string will be respected when the track is drawn.

legend

A string which will be displayed in a legend, if the track's legend setting is enabled.

Coloring a feature

color

An HTML color code to be used when drawing the feature, using CanvasRenderingContext2D.fillRect(). Defaults to track.color.

If false, fillRect will not be used to draw the feature.

borderColor

An HTML color code to be used when drawing the feature's border, using CanvasRenderingContext2D.strokeRect() By default, features do not have borders.

clear

If true, CanvasRenderingContext2D.clearRect() is used while drawing features, between fillRect() and strokeRect()

labelColor

An HTML color code to be used when drawing the feature's label. Defaults to the first truthy value of track.fontColor, feature.color, or track.color.

Positioning a feature within the track

height

A number of pixels for the height of the feature's rectangle. Defaults to track.featureHeight

marginTop

A number of pixels to be left as space between the top of the feature and bottom of the vertical alignment above that feature. Defaults to track.featureMargin.top.

For example, if a track has bumping enabled, and all its features have height of 10 and marginTop of 5, features will be drawn with y positions starting at 5, 20 ((bump level 1 = 5 + 10) + 5), 35 ((bump level 2 = 2 * (5 + 10)) + 5), etc.

y

Can be used to fix the vertical position of a feature within a track.

If this property is used, it is recommended that track.bump is set to false, that every feature for the track has a y property, and that every feature for the track is the same height. If any of these things is not true, it is highly likely that the features will be drawn poorly, e.g. overlapping each other or with big unnecessary vertical gaps.

Other properties used in drawing a feature

subFeatures

A feature can be split into sub features, for example exons in a transcript. If this is the case, feature.subFeatures should be an array of feature-like objects (i.e. using the properties documented on this page) whose start and end are within the bounds of the feature's start and end. feature.subFeatures gets sorted from lowest to highest start.

Sub features should not have a height greater than their feature's height, but can have one which is smaller.

Sub features are drawn within the bounds of the feature, vertically-aligned on its midpoint (i.e. if feature.height = 10 and subFeature.height = 6, the sub feature will be drawn from 2px below the top of the feature to 2px above its bottom: the middle 6px), and are visually are joined together according to the track.subFeatureJoinStyle setting.

Note that sub features do not get bumped within a feature.

joinColor

An HTML color code to be used when drawing the feature's sub feature joins, if it has subFeatures, and track.subFeatureJoinStyle is not false. Defaults to track.color.

strand

Affects the way track.subFeatureJoinStyle draws joins.

If a track is stranded, features of strand = -1 and strand = 1 will be split into two separate tracks.

decorations

If truthy, track.view.decorateFeature() is called for the feature.