TnT Genome is built on top of TnT Board and exposes the same methods explained in TnT Board's API. TnT Genome also offers a few elements explained below. The most important are: three new displays for genes, transcripts and genomic sequences, a modified location display that includes the species and the chromosome being displayed in the board, a layout that avoids overlaps in genes and transcripts and integration with the Ensembl REST API to fetch genomic data through TnT Rest.
In the example above a new genome board is createdand configured using the two new methods species and gene. Then two tracks are created using the new data endpoints and displays: the first one is a gene track and the second one a sequence track. Although no location or axis tracks are set in the board explicitely they are included by default in the genome board. min and max are set automatically to 0 and the chromosome length respectively by default. The rest of the elements are the same explained before for TnT Board.
The genome board is a special type of tnt.board that inherits all its elements. A new genome board can be created using tnt.board.genome. An example of use looks like:
# tnt.board.genome ()
Creates a new genome board that can be configured using the methods explained below. The returned genome is a function itself that can be called passing a DOM element as its argument. This DOM element is used as a container for the visualization.
# genome.species (<string>)
Sets the species for the genome board. Only species included in Ensembl are supported. Both scientific names (ie, "homo_sapiens") and common names ("human") are allowed. When called without arguments returns the current species. By default the species is "human".
# genome.chr (<integer>)
Sets the chromosome for the visualisation. When called without arguments returns the current chromosome.
# genome.gene (<string>)
Sets the gene to show in the genome visualisation. This gene can be a gene name (for example, "BRCA2") or an ensembl ID ("ENSG00000139618"). If the former is provided it is also needed to specify the species since the gene name may not be unique among species. When called without arguments returns the current gene.
# genome.min_coord (<Promise>)
Sets the minimum allowed genome coordinate in the visualisation. It accepts a Promise. It defaults to a promise resolving to 0
# genome.max_coord (<Promise>)
Sets the maximum allowed genome coordinate in the visualisation. It accepts a Promise. It defaults to a promise resolving to the max coordinate for the chromosome.
# genome.expand (<integer>)
Sets extra space in the visualisation when the genome is centered to a given gene. Instead of starting the visualisation exactly on the specified gene some extra five and 3 prime space is given. The argument to the function is the the percentage of the extent and it is added to both ends (5' and 3') of the genome board.
TnT Genome provides 3 new data displays for genes, transcripts and genomic sequences. They understand the data elements fetched by their corresponding data retrievers explained below.
# tnt.board.track.feature.genome.gene ()
Creates a new gene display. This has the same methods and properties as any other TnT Board display. It understands the elements retrieved by the gene data retriever.
# tnt.board.track.feature.genome.transcript ()
Creates a new transcript display. This has the same methods and properties as any other TnT Board display. It understands the elements retrieved by the transcript data retriever.
# tnt.board.track.feature.genome.sequence ()
Creates a new sequence display. This has the same methods and properties as any other TnT Board display. It understands the elements retrieved by the sequence data retriever.
TnT Genome provides an interface to the Ensembl REST API to fetch genomic data. This interface uses tnt.board.track.data.async under the hood, which means that uses ES2015 promises that can be chained with user-defined functions.
# tnt.board.track.data.genome.gene ()
Creates a new gene retriever using the Ensembl REST API. Returns a promise that can be chained with other user-defined functions.
# tnt.board.track.data.genome.transcript ()
Creates a new transcript retriever using the Ensembl REST API. Returns a promise that can be chained with other user-defined functions.
# tnt.board.track.data.sequence.sequence ()
Creates a new sequence retriever using the Ensembl REST API. Returns a promise that can be chained with other user-defined functions.
# sequence.limit (<integer>)
Sets a limit for returning the genomic sequence. If the length of the sequence to retrieve is greater than the limit, nothing is returned or displayed. By default, this limit is set to 150. If called without arguments returns the current limit
The layout analyses all the genes, transcripts and labels in a track and distributes them vertically to avoid overlaps. It is set as a property of the board's display. It is run after the data is retrieved and before the elements are displayed. It also supports several configuration methods explained below. The layout normally doesn't need to be set up by the library user.
# display.layout (<tnt.board.track.layout>)
Sets a layout for the elements of a track. It accepts a tnt.board.track.layout as its argument. When called without arguments returns the current layout. In TnT Genome the layout is set to tnt.board.track.layout.genome, that avoids overlaps between elements to display (and their labels). This method is specially useful to configure this default layout.
# tnt.board.track.layout.genome ()
Default layout for genes and transcripts. It avoids overlaps between genes or transcript (including their labels). The layout distributes the elements (genes or transcripts) into slots. The elements are placed in the different slots available (based on the height of the track) avoiding overlaps using a _expanded_ display. When there are too many elements to ensure that the overlaps are avoided the layout notifies that and the display uses a _collapsed_ display in which the labels are not shown and the element's height is reduced.
# genome.fixed_slot_type (<string>)
Specifies if the layout should always keep the slot type. By default the layout shows genes expanded (see above) if they all fit in the current board and collapsed if they don't. Setting this option to "expanded" the genes will always be shown in the former form. Using "collapsed" as its argument uses always the latter.
# genome.keep_slots (<boolean>)
Specifies if the elements should keep their assigned slot between updates. By default this is set to true which means that elements (genes or transcripts) that are in display between two updates will keep their vertical position to reduce the amount of transitions. Once they go out of sight, they are removed from the track. If this option is set to false the layout recomputes the positions of the elements (genes or transcripts) on every data update.
# genome.on_layout_run (<callback>)
Sets a callback to be run after the layout has finished positioning elements. That callback is called with the an object containing the two slot types described above and the name of the one currently used.