DECIPHER-genomics / Genoverse

HTML5 scrollable genome browser
https://genoverse.org/
Other
106 stars 44 forks source link

Track for Coverage 2018 #52

Closed MrKevinDC closed 6 years ago

MrKevinDC commented 6 years ago

Hello Simon. I´m new to Javascript and programming in general but have been working for several weeks on Genoverse trying to add a read coverage track. This issue has a similar one from 2016 but in August 2017 you added WIG and BIGWIG support to Genoverse so I believe things have changed. The WIG display is spot on what we need, I just added some code so it could discard headers and read in several times "fixedStep..." in case they were any gaps in the WIG, as it only reads this statement at the start of the file.

I was making WIGs from small BAMs to test it all out, but everything came crashing down when my "employers" asked me to load up a transcript.bam of a whole chromosome. To start off they are not budging to any explanations that they can just as easily make a genomic bam adding another option to their command (they are using rsem-calculate-expression which by default can give either a transcript or a genomic bam, but they just want the transcript bam now, unless I convince them otherwise) so I must work with that. The transcript start and end positions would be extracted from an accompanying gff3 supposedly.

I also observed you have coping mechanisms for large files (bam works with a bai and dalliance, vcf works with tbi and tabix) but it doesn´t seem there is such a thing for the WIGs right?

Therefore my questions are: 1- Any tips on how to work with a large WIG file? 2- Any tips on sending data from one filereader to another filereader (or something similar)?

PD: Sorry for the rant, this public version of Genoverse is very well organised but if I find out anything you could also find useful I´ll share if you want

simonbrent commented 6 years ago

Hi,

I don't entirely follow your description, but it sounds like you want the BIGWIG track. Rather than using a large WIG file, you can create a BIGWIG file using a conversion tool:

https://genome.ucsc.edu/goldenpath/help/bigWig.html https://www.encodeproject.org/software/wigtobigwig/

Sorry, I can't help you with actually using the tool, as I have no experience of it.

With regard to question 2, I don't know if that is possible. What are you trying to achieve?

MrKevinDC commented 6 years ago

Hi again Simon, Well it seems now that indeed BIGWIG will be all we need as they have now provided us with genomic bams. However another track still requires accessing data from another file:

-We have a .gff with transcript IDs and positions, and on the other hand we have a .txt with transcript IDs and gene expression values (all calculated with RSEM). We have to fetch the transcript positions from the .gff so that we can plot the values of the .txt in the browser. We thought that maybe we could load both files at once similar to how the bam/bai and vcf/tbi is done, but maybe we require a more expert insight on this. Kind regards Kevin

simonbrent commented 6 years ago

Yes, you can load both files at once. You will have modify the fileDrop plugin a bit (currently it treats the second file as an index, e.g. bam/bai), and create a new Track.Model.File extension, which has a getData function whose promise resolves once both files' data has been read. The following is untested code which should do what you want there.

getData: function (chr) {
  var model = this;

  if (this.isLocal && this.dataFiles) {
    return Promise.all(this.dataFiles.map(function (file) {
      return new Promise(function (resolve) {
        var reader = new FileReader();

        reader.onload = function (e) {
          resolve(e.target.result);
        };

        reader.readAsText(file);
      });    
    })).then(function (filesData) {
      // filesData is an array whose elements contain the contents of each file
      var combinedData = [ do something with filesData to turn it into an array of Genoverse-compatible features ]
      model.receiveData(combinedData, chr, 1, model.browser.getChromosomeSize(chr));
    });
  } else {
    return this.base.apply(this, arguments);
  }
},
MrKevinDC commented 6 years ago

Thank you so much Simon this is what we were struggling with now but you have painted a great picture of what we have to do. You are doing a great job supporting Genoverse, thank you. Kind regards