jbrowse icon indicating copy to clipboard operation
jbrowse copied to clipboard

feature densities calculated incorrectly

Open Tom-Shorter opened this issue 5 years ago • 9 comments

  • JBrowse version = 1.15.4
  • Web browser being used latest google chrome
  • Operating system if relevant - macOS mojave

I believe there is a bug in how the feature density histograms are generated.

image

All of these tracks are formed with the same original data and show 50kbp per bin, the top 3 are 3 different REST API implementations I have been creating to test speed etc., the bottom is the default import using bin/flatfile-to-json.pl --gff /Users/tom/Desktop/gff_files/HGVRS1.gff --tracklabel HGVRS1.gff

The bottom track bins seem to be offset by 1.

Below is an image of the individual datapoints in the same region as where the histogram bar directly beneath the Y scale should be displaying:

image

There are 9 features between 9,500,000 and 9,550,000 which is reflected within the first 3 tracks but the 4th shows there being 4 features and the 50k bases before has 4 features.

Tom

Tom-Shorter avatar Jan 15 '19 16:01 Tom-Shorter

Does look perhaps like an off by one. I guess that would be an issue with the perl code generating the histograms

If you want to try and check out what fixes are needed for this and #1249 I would be happy to help guide you!

cmdcolin avatar Jan 17 '19 19:01 cmdcolin

Hi Colin,

If it is in the perl code I should be able to handle it. Do you know the location of the perl file which handles the histograms?

On Thu, Jan 17, 2019 at 7:41 PM Colin Diesh [email protected] wrote:

Does look perhaps like an off by one. I guess that would be an issue with the perl code generating the histograms

If you want to try and check out what fixes are needed for this and #1249 https://github.com/GMOD/jbrowse/issues/1249 I would be happy to help guide you!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/GMOD/jbrowse/issues/1303#issuecomment-455305439, or mute the thread https://github.com/notifications/unsubscribe-auth/AX8mQzC8V_f-Sq8N-RomSurPxSqNI52Vks5vENIFgaJpZM4aBYqK .

Tom-Shorter avatar Jan 18 '19 12:01 Tom-Shorter

This is the perl code that handles histograms https://github.com/GMOD/jbrowse/blob/master/src/perl5/FeatureTrack.pm#L157-L249

It writes to files such as "data/tracks/yourtrack/hist-20-0.json"

cmdcolin avatar Jan 18 '19 12:01 cmdcolin

You should be able to directly modify the file like this in your local installation without any additional compilation steps, just simple edit of the perl and re-run flatfile-to-json as needed

cmdcolin avatar Jan 18 '19 12:01 cmdcolin

I've had a quick look through and the perl code should work as expected.

The histbins which contain the feature are calculated using int(feature[start]/histBinBases) and int(feature[end]/histBinBases) and every hist bin between which is how I calculate it in my rest API as well. It could be something to do with how the histbin data is stored or read by jbrowse when being displayed.

I also did a quick check by setting line 203 - $curHist->[$bin] += 1; to $curHist->[$bin-1] += 1; but this results in an error indicating the loop is correct and does do $bin = 0 ... $bin = n.

On Fri, Jan 18, 2019 at 12:50 PM Colin Diesh [email protected] wrote:

You should be able to directly modify the file like this in your local installation without any additional compilation steps, just simple edit of the perl and re-run flatfile-to-json as needed

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/GMOD/jbrowse/issues/1303#issuecomment-455535583, or mute the thread https://github.com/notifications/unsubscribe-auth/AX8mQ-fTh0_FA-Vl1RvzYmt8hyKEBRPfks5vEcL_gaJpZM4aBYqK .

Tom-Shorter avatar Jan 18 '19 13:01 Tom-Shorter

If you are strongly in need of accurate histograms I would recommend looking into using a bigwig for your histogram.

[tracks.yourtrack]
... your config here ...
histograms.storeClass=JBrowse/Store/SeqFeature/BigWig
histograms.urlTemplate=coverage.bw

This works on any CanvasFeatures based track

cmdcolin avatar Jan 21 '19 22:01 cmdcolin

I guess you have also said your are using REST based histograms so that is another alternative

cmdcolin avatar Jan 21 '19 22:01 cmdcolin

Thanks Colin, I'll be using the REST tracks for my installation.

On Mon, Jan 21, 2019 at 10:58 PM Colin Diesh [email protected] wrote:

I guess you have also said your are using REST based histograms so that is another alternative

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/GMOD/jbrowse/issues/1303#issuecomment-456219669, or mute the thread https://github.com/notifications/unsubscribe-auth/AX8mQwRvj-ACy9U_cFoNIk_PhF164UPVks5vFkX5gaJpZM4aBYqK .

Tom-Shorter avatar Jan 22 '19 13:01 Tom-Shorter

Cool. Sorry about the trouble, I'll leave this open

If you want to attach any test data for this issue to reproduce this (and if possible reproduce #1249) that would be great

cmdcolin avatar Jan 22 '19 16:01 cmdcolin