Documentation ¶
Overview ¶
Package rings implements a number of graphical representations of genomic features and feature associations using the idioms developed in the Circos distribution.
The rings package borrows significantly from the ideas of Circos and shares some implementation details in order to run as a work-a-like. Circos is available from http://circos.ca/.
Index ¶
- func Rectangular(theta Angle, r vg.Length) vg.Point
- type Angle
- type Arc
- type ArcOfer
- type Arcer
- type Arcs
- type Axis
- type AxisLabel
- type Bezier
- type Blocks
- type ColorFunc
- type Conformation
- type Conformationer
- type FactorDist
- type Feature
- type FillColorer
- type Heat
- type Highlight
- type Label
- type Labeler
- type Labels
- type LengthDist
- type LineStyleFunc
- type LineStyler
- type Links
- type Orientation
- type Orienter
- type Pair
- type Ribbons
- type Sail
- type Scale
- type ScaleGrid
- type ScoreRenderer
- type Scorer
- type Scores
- type Spokes
- type TextPlacement
- type TextStyler
- type TickConfig
- type Trace
- type TraceJoiner
- type Twist
- type XYer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Angle ¶
type Angle float64
Angle represents an angle in radians. Angles increase in the counter clockwise direction.
type Arc ¶
type Arc struct { Theta Angle // Initial angle of an arc in radians. Phi Angle // The sweep of the arc in radians. }
Arc represents an arc of a circle.
type ArcOfer ¶
type ArcOfer interface { Arcer // ArcOf must return a non-nil error if the Feature is not found by // the receiver or the query is nil, unless the receiver is an Arc. When // the receiver is an Arc the error returned is always nil. ArcOf(loc, f Feature) (Arc, error) }
ArcOfer is an Arcer that contains a collection of features mapped to its span.
type Arcs ¶
type Arcs struct { Base Arc // Base represents the complete span of the Arcs. Arcs map[Feature]Arc // Arcs provides a lookup for features within the span. }
Arcs is the base ArcOfer implementation provided by the rings package.
func NewGappedArcs ¶
NewGappedArcs returns an Arcs that maps the provided features to the base arc with a fractional gap between each feature.
func (Arcs) ArcOf ¶
ArcOf returns the arc of a feature in the context of the provided location.
The behaviour of ArcOf depends on the nil status of loc and f:
- if both loc and f are non-nil, f must have a sub-feature relationship with loc, and the returned arc will be the arc of f.
- if either of loc or f are nil, then the arc of the non-nil parameter will be returned.
- if both loc and f are nil, and no nil feature is found in the Arcs, the base arc will be returned.
If no matching feature is found a non-nil error is returned.
type Axis ¶
type Axis struct { // Angle specifies the angular location of the axis. Angle Angle // Label describes the axis label configuration. Label AxisLabel // LineStyle is the style of the axis line. LineStyle draw.LineStyle // Tick describes the scale's tick configuration. Tick TickConfig // Grid is the style of the grid lines. Grid draw.LineStyle }
Axis represents the radial axis of ring, usually a Scores.
type AxisLabel ¶
type AxisLabel struct { // Text is the axis label string. Text string // TextStyle is the style of the axis label text. draw.TextStyle // Placement determines the text rotation and alignment. // If Placement is nil, DefaultPlacement is used. Placement TextPlacement }
AxisLabel describes an axis label format and text.
type Bezier ¶
type Bezier struct { // Segments defines the number of segments to draw when rendering the curve. Segments int // Radius, Crest and Purity define aspects of Bézier geometry. // // See http://circos.ca/documentation/tutorials/links/geometry/images for a detailed explanation // of radius, crest and purity. // // Radius specifies the Bézier radius of a curve generated by the Bezier. Radius LengthDist // Crest and Purity specify the crest and purity behaviour of a curve generated by the Bezier. // If nil, these values are not used. Crest *FactorDist Purity *FactorDist }
Bezier defines Bézier control points for a link between features represented by Links and Ribbons.
type Blocks ¶
type Blocks struct { // Set holds a collection of features to render. Set []Feature // Base defines the targets of the rendered blocks. Base ArcOfer // Color determines the fill color of each block. If Color is not nil each block is rendered // filled with the specified color, otherwise no fill is performed. This behaviour is // over-ridden if the feature describing the block is a FillColorer. Color color.Color // LineStyle determines the line style of each block. LineStyle behaviour // is over-ridden if the feature describing a block is a LineStyler. LineStyle draw.LineStyle // Inner and Outer define the inner and outer radii of the blocks. Inner, Outer vg.Length // X and Y specify rendering location when Plot is called. X, Y float64 }
Blocks implements rendering of Features as radial blocks.
func NewBlocks ¶
NewBlocks returns a Blocks based on the parameters, first checking that the provided features are able to be rendered. An error is returned if the features are not renderable.
func NewGappedBlocks ¶
func NewGappedBlocks(fs []Feature, base Arcer, inner, outer vg.Length, gap float64) (*Blocks, error)
NewGappedBlocks is a convenience wrapper of NewBlocks that guarantees to provide a valid ArcOfer based of the provided Arcer. If the provided Arcer is an ArcOfer it is tested for validity and a new ArcOfer is created only if needed.
func (*Blocks) ArcOf ¶
ArcOf returns the Arc location of the parameter. If the location is not found in the Blocks, an error is returned.
func (*Blocks) DrawAt ¶
DrawAt renders the feature of a Blocks at cen in the specified drawing area, according to the Blocks configuration.
func (*Blocks) GlyphBoxes ¶
GlyphBoxes returns a liberal glyphbox for the blocks rendering.
type ColorFunc ¶
ColorFunc allows dynamic assignment of color to objects based on passed parameters.
type Conformation ¶
type Conformation int8
Conformation describes whether a feature is linear or circular.
const ( UndefinedConformation Conformation = iota - 1 Linear Circular )
func (Conformation) String ¶
func (c Conformation) String() string
type Conformationer ¶
type Conformationer interface {
Conformation() Conformation
}
Conformationer wraps the Conformation method.
type FactorDist ¶
FactorDist generates a random value in the range [Length*Min, Length*Max), depending on a provided random factor.
func (*FactorDist) Perturb ¶
func (p *FactorDist) Perturb(f float64) float64
Perturb returns a perturbed float value. Calling Perturb on a nil FactorDist will panic.
type Feature ¶
type Feature interface { // Start and End indicate the position of the feature within the // containing Parent's coordinate system. Start() float64 End() float64 // Name returns the name of the feature. Name() string // Parent returns the reference feature on which the feature is located. Parent() Feature }
Feature is a Range whose coordinates are defined relative to a feature location/parent. Start and End return the coordinates of the feature relative to its parent which can be nil. In the latter case callers should make no assumptions whether coordinates of such features are comparable.
type FillColorer ¶
FillColorer is a type that can define its fill color. For the purposes of the rings package a FillColoer that returns a nil Color is not rendered filled.
type Heat ¶
type Heat struct { Palette []color.Color Underflow color.Color Overflow color.Color DrawArea draw.Canvas Center vg.Point Inner, Outer vg.Length Min, Max float64 }
Heat is a ScoreRenderer that represents feature scores as a color block.
type Highlight ¶
type Highlight struct { // Base describes the arc through which the highlight should be drawn. Base Arc // Color determines the fill color of the highlight. Color color.Color // LineStyle determines the line style of the highlight. LineStyle draw.LineStyle // Inner and Outer define the inner and outer radii of the blocks. Inner, Outer vg.Length // X and Y specify rendering location when Plot is called. X, Y float64 }
Highlight implements rendering a colored arc.
func NewHighlight ¶
NewHighlight returns a Highlight based on the parameters, first checking that the provided features are able to be rendered. An error is returned if the features are not renderable.
func (*Highlight) DrawAt ¶
DrawAt renders the feature of a Highlight at cen in the specified drawing area, according to the Highlight configuration.
func (*Highlight) GlyphBoxes ¶
GlyphBoxes returns a liberal glyphbox for the highlight rendering.
type Label ¶
type Label string
Label is a string that satisfies the Labeler interface. A Label may be used to label an Arc or a Highlight.
type Labeler ¶
type Labeler interface {
Label() string
}
Labeler is a type that can be used to label a block in a ring.
func NameLabels ¶
NameLabels returns a Labeler slice built from the provided slice of features. The labels returned are generated from the features' Name() values.
type Labels ¶
type Labels struct { // Labels contains the set of labels. Labelers that are Features and are found // in the Base ArcOfer will label the identified block with the string returned // by their Name method. Labels []Labeler // Base describes the ring holding the features to be labeled. Base ArcOfer // TextStyle determines the text style of each label. TextStyle behaviour // is over-ridden if the Label describing a block is a TextStyler. TextStyle draw.TextStyle // Radius defines the inner radius of the labels. Radius vg.Length // Placement determines the text rotation and alignment. If Placement is // nil, DefaultPlacement is used. Placement TextPlacement // X and Y specify rendering location when Plot is called. X, Y float64 }
Labels implements rendering of radial labels.
func NewLabels ¶
NewLabels returns a Labels based on the parameters, first checking that the provided set of labels are able to be rendered; an Arc or Highlight may only take a single label, otherwise the labels must be a Feature that can be found in the base ring. An error is returned if the labels are not renderable. If base is an XYer, the returned base XY values are used to populate the Labels' X and Y fields.
func (*Labels) DrawAt ¶
DrawAt renders the text of a Labels at cen in the specified drawing area, according to the Labels configuration.
func (*Labels) GlyphBoxes ¶
GlyphBoxes returns a liberal glyphbox for the label rendering.
type LengthDist ¶
LengthDist generates a random value in the range [Length*Min, Length*Max), depending on a provided random factor.
type LineStyleFunc ¶
LineStyleFunc allows dynamic assignment of line styles to objects based on passed parameters.
type LineStyler ¶
LineStyler is a type that can define its drawing line style. For the purposes of the rings package the lines of a LineStyler that returns a nil Color or a LineStyle with width 0 are not rendered.
type Links ¶
type Links struct { // Set holds a collection of feature pairs to render. Set []Pair // Ends holds the elements that define the end targets of the rendered ribbons. Ends [2]ArcOfer // Radii indicates the distance of the ribbon end points from the center of the plot. Radii [2]vg.Length // Bezier describes the Bézier configuration for link rendering. Bezier *Bezier // LineStyle determines the line style of each link Bézier curve. LineStyle behaviour // is over-ridden if the Pair describing features is a LineStyler. LineStyle draw.LineStyle // X and Y specify rendering location when Plot is called. X, Y float64 }
Links implements rendering of Feature associations as Bézier curves.
func NewLinks ¶
NewLinks returns a Links based on the parameters, first checking that the provided features are able to be rendered. An error is returned if the features are not renderable. The ends of a Links ring cannot be an Arc or a Highlight.
func (*Links) DrawAt ¶
DrawAt renders the feature pairs of a Links at cen in the specified drawing area, according to the Links configuration.
func (*Links) GlyphBoxes ¶
GlyphBoxes returns a liberal glyphbox for the links rendering.
type Orientation ¶
type Orientation int8
Orientation describes whether a feature is oriented forwards or backwards.
const ( Backward Orientation = iota - 1 NotOriented Forward )
func (Orientation) String ¶
func (o Orientation) String() string
type Orienter ¶
type Orienter interface {
Orientation() Orientation
}
Orienter wraps the Orientation method.
type Pair ¶
type Pair interface {
Features() [2]Feature
}
Pair represents a pair of associated features.
type Ribbons ¶
type Ribbons struct { // Set holds a collection of feature pairs to render. // If the features are both Orienters this is taken into account according to Twist. Set []Pair // Ends holds the elements that define the end targets of the rendered ribbons. Ends [2]ArcOfer // Radii indicates the distance of the ribbon end points from the center of the plot. Radii [2]vg.Length // Twist indicates how feature orientation should be rendered. // // None indicates no explicit twist; ribbons are drawn so that the start // and end positions of each feature are connected by Bézier curves. // // f₀.Start -arc-> f₀.End -Bézier-> f₁.End -arc-> f₁.Start -Bézier-> f₀.Start // // Flat indicates ribbons should be rendered so that ribbons do not twist; paths are // drawn in angle sort order with each feature's end points joined by arcs. // // Individual allows a feature pair to define its ribbon twist; feature pairs where // both features satisfy Orienter are rendered according to the product of their // orientations: // // +1 - as if the Twist flag were set, ignoring all other flags except Reverse. // 0 - according to the states of all other Twist flags. // -1 - as if the Flat flag were set, ignoring all other flags except Reverse. // // Twisted indicates ribbons should be rendered so that ribbons twist; paths of the // first feature are drawn in angle sort order and paths of the second are drawn in // reverse angle sort order, with each feature's end points joined by arcs. // // Reverse inverts all twist behaviour. // // If Twist has both Flat and Twisted flags set, DrawAt and Plot will panic. Twist Twist // Bezier describes the Bézier configuration for ribbon rendering. Bezier *Bezier // Color determines the fill color of each ribbon. If Color is not nil each ribbon is // rendered filled with the specified color, otherwise no fill is performed. This // behaviour is over-ridden if the feature describing the block is a FillColorer. Color color.Color // LineStyle determines the line style of each ribbon. LineStyle behaviour is over-ridden // for end point arcs if the feature describing an end point is a LineStyler and for // Bézier curves if the Pair is a LineStyler. LineStyle draw.LineStyle // X and Y specify rendering location when Plot is called. X, Y float64 }
Ribbons implements rendering of Feature associations as ribbons.
func NewRibbons ¶
NewRibbons returns a Ribbons based on the parameters, first checking that the provided features are able to be rendered. An error is returned if the features are not renderable. The ends of a Ribbons ring cannot be an Arc or a Highlight.
func (*Ribbons) DrawAt ¶
DrawAt renders the feature pairs of a Ribbons at cen in the specified drawing area, according to the Ribbons configuration. DrawAt will panic if the feature pairs being linked both satisfy Orienter and the product of orientations is not in {Forward,NotOriented,Backward}.
func (*Ribbons) GlyphBoxes ¶
GlyphBoxes returns a liberal glyphbox for the ribbons rendering.
type Sail ¶
type Sail struct { // Set holds a collection of connected features to render. // If the features are Orienters this is taken into account according to Twist. Set []Feature // Base holds the element that defines the end targets of the rendered sail. Base ArcOfer // Radius indicates the distance of the sail end points from the center of the plot. Radius vg.Length // Twist indicates how feature orientation should be rendered. // // None indicates no explicit twist; sail ends are drawn so that the start // and end positions of each feature are connected by Bézier curves. // Thus if features are numbered in order of their appearance along an arc: // // f₀.Start -arc-> f₀.End -Bézier-> f₁.End -arc-> f₁.Start -Bézier-> ... f₀.Start // // Flat indicates sails should be rendered so that sail ends do not twist; paths are // drawn in angle sort order with each feature's end points joined by arcs. // // Individual allows a feature to define the twist of its sail end depending on its // orientation: // // -1 - as if the Twist flag were set, ignoring all other flags except Reverse. // 0 - according to the states of all other Twist flags. // +1 - as if the Flat flag were set, ignoring all other flags except Reverse. // // Twisted indicates sails should be rendered so that sail ends twist; the overall // progression is in angle sort order with Bézier paths drawn in angle sort order // and each feature's end points joined by arcs in reverse angle sort order. // // Reverse inverts all twist behaviour. // // If Twist has both Flat and Twisted flags set, DrawAt and Plot will panic. Twist Twist // Bezier describes the Bézier configuration for sail rendering. Bezier *Bezier // Color determines the fill color of each sail. If Color is not nil each sail is // rendered filled with the specified color, otherwise no fill is performed. Color color.Color // LineStyle determines the line style of each sail. LineStyle behaviour is over-ridden // for end point arcs if the feature describing an end point is a LineStyler. LineStyle draw.LineStyle // X and Y specify rendering location when Plot is called. X, Y float64 }
Sail implements rendering of Feature associations as sails. A sail is conceptually a hyper edge connecting a number of features.
func NewSail ¶
NewSail returns a Sail based on the parameters, first checking that the provided features are able to be rendered. An error is returned if the features are not renderable. The base of a Sail ring cannot be an Arc or a Highlight.
func (*Sail) DrawAt ¶
DrawAt renders the features of a Sail at cen in the specified drawing area, according to the Sail configuration. DrawAt will panic if the feature pairs being linked both satisfy Orienter and the product of orientations is not in {Forward,NotOriented,Backward}.
func (*Sail) GlyphBoxes ¶
GlyphBoxes returns a liberal glyphbox for the ribbons rendering.
type Scale ¶
type Scale struct { // Set holds a collection of features to render scales for. Set []Feature // Base defines the targets of the rendered blocks. Base ArcOfer // Radius defines the radius of the axis. Radius vg.Length // LineStyle is the style of the axis line. LineStyle draw.LineStyle // Tick describes the scale's tick configuration. Tick TickConfig // Grid describes the scales grid configuration. Grid ScaleGrid X, Y float64 }
Scale represents the circular axis of ring.
func NewScale ¶
NewScale returns a Scale based on the parameters, first checking that the provided feature scales are able to be rendered. An error is returned if the scales are not renderable.
func (*Scale) DrawAt ¶
DrawAt renders the scales at cen in the specified drawing area, according to the Scale configuration.
func (*Scale) GlyphBoxes ¶
GlyphBoxes returns a liberal glyphbox for the label rendering.
type ScoreRenderer ¶
type ScoreRenderer interface { // Configure sets up the ScoreRenderer for set-wide values. // The min and max parameters may be ignored by an implementation. Configure(ca draw.Canvas, cen vg.Point, base ArcOfer, inner, outer vg.Length, min, max float64) // Render renders scores across the specified arc. Rendering may be // performed lazily. Render(Arc, Scorer) // Close finalises the rendering. For ScoreRenderers that do not // render lazily, this is a no-op. Close() }
ScoreRenderer is a type that produces a graphical representation of a score series for a Scores ring.
type Scores ¶
type Scores struct { // Set holds a collection of features to render. Scores does not // make any check for Scorer overlap in Set. Set []Scorer // Base defines the targets of the rendered scores. Base ArcOfer // Renderer is the rendering implementation used to represent the // feature sets score data. Renderer ScoreRenderer // Min and Max hold the score range. Min, Max float64 // Inner and Outer define the inner and outer radii of the blocks. Inner, Outer vg.Length // X and Y specify rendering location when Plot is called. X, Y float64 }
Scores implements rendering of Features as radial blocks.
func NewScores ¶
func NewScores(fs []Scorer, base ArcOfer, inner, outer vg.Length, renderer ScoreRenderer) (*Scores, error)
NewScores returns a Scores based on the parameters, first checking that the provided features are able to be rendered. An error is returned if the features are not renderable.
func (*Scores) DrawAt ¶
DrawAt renders the feature of a Scores at cen in the specified drawing area, according to the Scores configuration.
func (*Scores) GlyphBoxes ¶
GlyphBoxes returns a liberal glyphbox for the score rendering.
type Spokes ¶
type Spokes struct { // Set holds a collection of features to render. Set []Feature // Base holds the elements that define the targets of the rendered spokes. Base ArcOfer // LineStyle determines the line style of each spoke. LineStyle is over-ridden // for each spoke if the feature describing the spoke is a LineStyler. LineStyle draw.LineStyle // Inner and Outer define the inner and outer radii of the spokes. Inner, Outer vg.Length // X and Y specify rendering location when Plot is called. X, Y float64 }
Spokes implements rendering of Features representing 0 or 1 length features as radial lines.
func NewSpokes ¶
NewSpokes returns a Spokes based on the parameters, first checking that the provided features are able to be rendered. An error is returned if the features are not renderable. The base of a Spokes ring cannot be an Arc or a Highlight.
func (*Spokes) ArcOf ¶
ArcOf returns the Arc location of the parameter. If the location is not found in the Spokes, an error is returned.
func (*Spokes) DrawAt ¶
DrawAt renders the feature of a Spokes at cen in the specified drawing area, according to the Spokes configuration.
func (*Spokes) GlyphBoxes ¶
GlyphBoxes returns a liberal glyphbox for the blocks rendering.
type TextPlacement ¶
TextPlacement is used to determine text rotation and alignment by a Labels ring.
var ( DefaultPlacement TextPlacement = tangential Horizontal TextPlacement = horizontal Radial TextPlacement = radial Tangential TextPlacement = tangential )
type TextStyler ¶
TextStyler is a type that can define its text style. For the purposes of the rings package the lines of a LineStyler that returns a nil Color or a TextStyle with Font.Size of 0 are not rendered.
type TickConfig ¶
type TickConfig struct { // Label is the TextStyle on the tick labels. Label draw.TextStyle // LineStyle is the LineStyle of the tick lines. LineStyle draw.LineStyle // Placement determines the text rotation and alignment. // If Placement is nil, DefaultPlacement is used. Placement TextPlacement // Length is the length of a major tick mark. // Minor tick marks are half of the length of major // tick marks. Length vg.Length // Marker returns the tick marks. Any tick marks // returned by the Marker function that are not in // range of the axis are not drawn. Marker plot.Ticker }
TickConfig describes an axis tick configuration.
type Trace ¶
type Trace struct { // LineStyles determines the lines style for each trace. LineStyles []draw.LineStyle // Join specifies whether adjacent features should be joined with radial lines. // It is overridden by the returned value of JoinTrace if the Scorer is a TraceJoiner. Join bool Base ArcOfer DrawArea draw.Canvas Center vg.Point Inner, Outer vg.Length Min, Max float64 // Axis represents a radial axis configuration Axis *Axis // contains filtered or unexported fields }
Trace is a ScoreRenderer that represents feature scores as a trace line.
type TraceJoiner ¶
type TraceJoiner interface { // JoinTrace returns whether the ith score value should be part of a joined trace. JoinTrace(i int) bool }
TraceJoiner is a type that can specify whether the traces for its scores should be joined when adjacent.
type Twist ¶
type Twist uint
Twist is a flag type used to specify Ribbon and Sail twist behaviour. Specific interpretation of Twist flags is documented in the relevant types.
const ( None Twist = 0 // None indicates no explicit twist. Flat Twist = 1 << iota // Render feature connections without twist. Individual // Individual allows a feature or feature pair to define its ribbon twist. Twisted // Twisted specifies that feature connections render with twist. Invert // Invert inverts all twist behaviour. )