GMOD / JBrowseR

R interface to the JBrowse 2 Linear Genome View.
https://gmod.github.io/JBrowseR/
Apache License 2.0
35 stars 3 forks source link

change tracks display by using functions or config file #41

Open mgabriel01 opened 6 months ago

mgabriel01 commented 6 months ago

Hello, Thank you for this nice tool.

Is there a way to change the display of the tracks by using the functions assembly(), track_feature(), track_alignments(), default_session(), or at least a config file? For example, by default we have the genome in forward and reverse, and the corresponding translation in 3 frames, is there an easy way to reduce this ?

Thank you in advance for your answer !

Best,

Marc G.

BELKHIR commented 2 months ago

Hello,

This is my solution to disable reverse sequence and translation for genome (assembly) track. I wrote a function "mydefault_session()" that replace default_session by adding the showXX to the display section.

This new function is then used this way :

set up the default session for the browser using the new function

default_session <- mydefault_session( assembly, c(annotations_track) )

mydefault_session <- function(assembly, displayed_tracks, display_assembly = TRUE) { assembly_name <- JBrowseR:::get_assembly_name(assembly)

configuration <- stringr::str_c(assembly_name, "-ReferenceSequenceTrack")

if (display_assembly) { reference_track= as.character( stringr::str_glue( "{{ ", '"type": "ReferenceSequenceTrack", ', '"configuration": "{configuration}", ', '"displays": [ ', "{{ ", '"type": "LinearReferenceSequenceDisplay", ', '"configuration": "{stringr::str_c(configuration, "-LinearReferenceSequenceDisplay")}",', '"showForward": true,', '"showReverse": false,', '"showTranslation": false', "}}", "]", "}}" ) ) } else { reference_track = "" }

tracks <- JBrowseR:::get_tracks(assembly, displayed_tracks, display_assembly)

as.character( stringr::str_glue( "{{ ", '"name": "My Session", ', '"view": {{ ', '"id": "LinearGenomeView", ', '"type": "LinearGenomeView", ', '"tracks": [ ', "{reference_track} ", "{tracks} ", "] ", "}} ", "}}" ) ) }