gladkia / igvShiny

An htmlwidget version of igv, for RStudio and Shiny apps
https://gladkia.github.io/igvShiny/
Other
36 stars 24 forks source link

loadBedGraphTrackFromURL rewrites the config vars including url #35

Open malcook opened 1 year ago

malcook commented 1 year ago

There appears to be some debugging/testing code left in Shiny.addCustomMessageHandler("fubar", which is responsible for rewriting the url to a hardcoded value, as can be seen in the javascript console:

(text version copied below) image

Perhaps I should not be working off master?

FWIW: I am trying to suss out how to load a bigbed file by URL and could use some guidance...

=== loadBedGraphTrackFromURL
igvShiny.js:7 
{elementID: 'igvShiny_0', trackName: 'meme.ame.all.shuffle', url: 'http://webfs/Sci/SCI-003911-GPFGRIZ/sequenceanalysis/run8/PRLT/meme/ame/shuffle/all.shuffle.bb', color: 'gray', trackHeight: 30, …}
igvShiny.js:521 --- loading bedGraphTrackFromURL
igvShiny.js:522 
{url: 'https://www.encodeproject.org/files/ENCFF000ASF/@@download/ENCFF000ASF.bigWig', name: 'GM12878 H3K4me3', color: 'rgb(200,0,0)', autoscaleGroup: '1'}
autoscaleGroup
: 
"1"
color
: 
"rgb(200,0,0)"
format
: 
"bigwig"
name
: 
"GM12878 H3K4me3"
type
: 
"wig"
url
: 
"https://www.encodeproject.org/files/ENCFF000ASF/@@download/ENCFF000ASF.bigWig"
[[Prototype]]
: 
Object
paul-shannon commented 1 year ago

Malcolm,

I will try to borrow a laptop over the weekend here in Weimar, work on the issues you raise.

If you attach a -small- bigbed file, gzipped, to a new issue on GitHub I will give that a try also.

On Oct 7, 2022, at 8:03 AM, Malcolm Cook @.***> wrote:

 There appears to be some debugging/testing code left in Shiny.addCustomMessageHandler("fubar", which is responsible for rewriting the url to a hardcoded value, as can be seen in the javascript console:

(text version copied below)

Perhaps I should not be working off master?

FWIW: I am trying to suss out how to load a bigbed file by URL and could use some guidance...

=== loadBedGraphTrackFromURL igvShiny.js:7 {elementID: 'igvShiny_0', trackName: 'meme.ame.all.shuffle', url: 'http://webfs/Sci/SCI-003911-GPFGRIZ/sequenceanalysis/run8/PRLT/meme/ame/shuffle/all.shuffle.bb', color: 'gray', trackHeight: 30, …} igvShiny.js:521 --- loading bedGraphTrackFromURL igvShiny.js:522 {url: 'https://www.encodeproject.org/files/ENCFF000ASF/@@download/ENCFF000ASF.bigWig', name: 'GM12878 H3K4me3', color: 'rgb(200,0,0)', autoscaleGroup: '1'} autoscaleGroup : "1" color : "rgb(200,0,0)" format : "bigwig" name : "GM12878 H3K4me3" type : "wig" url : "https://www.encodeproject.org/files/ENCFF000ASF/@@download/ENCFF000ASF.bigWig" [[Prototype]] : Object — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

malcook commented 1 year ago

Paul,

I have placed a smallish bigbed at https://research.stowers.org/mec/A.distal.all.bb

Bigbeds are already compressed so I sill not gzip it.

I can load into IGV desktop using "File > Load From URL"

But, there is no hurry at all since I have figured out how to define my own generic loadTrack function which formats ... as JSON payload to config any igv.js compatible track.

Like this:

loadTrack<-function (session, id, trackName,
                     deleteTracksOfSameName = TRUE, quiet = TRUE,...)
{
    if (!quiet) {
        log("--- igvShiny::loadTrack")
    }
    if (deleteTracksOfSameName) {
        removeTracksByName(session, id, trackName)
    }
    configJSON<-rjson::toJSON(rlang::dots_list(...))
    state[["userAddedTracks"]] <- unique(c(state[["userAddedTracks"]],         trackName))
    msg.to.igv <- list(elementID = id, trackName=trackName,configJSON=configJSON)
    session$sendCustomMessage("loadTrack", msg.to.igv )
}

Here is the corresponding javascript message handler:

Shiny.addCustomMessageHandler("loadTrack",
   function(message){
       igvshiny_log("=== loadTrack");
       igvshiny_log(message);
       var elementID = message.elementID;
       var configJSON = message.configJSON
       var igvBrowser = document.getElementById(elementID).igvBrowser;
      igvBrowser.loadTrack(configJSON);
      }
);

I am in this way able to load my bigBed files with success as:

    loadTrack(session, id="igvShiny_0"
              ,trackName='meme.ame.all.shuffle'
              ,url='https://research.stowers.org/mec/A.distal.all.bb'
              ,type='annotation'
              ,displayMode="expanded"
              ,height=300
              ,visibilityWindow=1000000)

but only after disabling CORS security in my browser by running it as

chrome.exe --user-data-dir="C://Chrome dev session" --disable-web-security

since that webserver enforces CORS.

I rather like this approach and may use it across the board. You may like to consider adding it to igvShiny, possibly after renaming it, perhaps to loadIGVTrack or something.

So, again, no hurry on this issue.

However, if you can address #34 I would be much obliged.

Enjoy your travels.

gladkia commented 8 months ago

Hi @malcook,

What's the status of this issue? Is it still valid? Thanks for your help.

malcook commented 8 months ago

Hi -

The issue still holds, namely that "There appears to be some debugging/testing code left in Shiny.addCustomMessageHandler("fubar", which is responsible for rewriting the url to a hardcoded value"

Also, I have been using my proposed addition and still think this project should consider adopting it. What do you think?