elsiklab / gwasviewer

A JBrowse plugin for viewing GWAS data
11 stars 0 forks source link

scoreFun and style color #9

Open demis001 opened 3 years ago

demis001 commented 3 years ago

@elsiklab,

I am new to javascript, would you please show me how to write scoreFun and the style based on the p-value score. I loaded the plot and the Y axis doesn't show the entire data, I changed to maxHeight to 250 still missing some data point. The data looks like this:

chr1    9940342 9940342 NMNAT1  2.81e-10
chr1    9941343 9941343 LZIC    4.5e-05
chr1    1064776 1064776 C1orf159    6.78e-06
chr1    9941922 9941922 NMNAT1  2.56e-10
chr1    9941922 9941922 LZIC    1.21e-05
chr1    9941923 9941923 RBP7    2.59e-06

Best, @demis001

cmdcolin commented 3 years ago

the code is not able to auto-adjust to scores currently

however, when I load this file it looks like this

localhost_jbrowse__data=hg19 loc=chr1%3A9915441 9974704 tracks=DNA%2CHDL_pvals highlight=

Is something missing?

cmdcolin commented 3 years ago

See https://github.com/elsiklab/gwasviewer/issues/3 for autoscaling to scores issue

cmdcolin commented 3 years ago

you might also consider moving to jbrowse 2, it has autoscaling to scores https://github.com/cmdcolin/jbrowse-plugin-gwas

demis001 commented 3 years ago

@cmdcolin Thanks! Sorry for the late reply, I didn't get mail conformation:

I never used React before to use jbrowse 2, I installed the dev version 1.16.11 release. It seems complicated to setup jbrowse 2. I got the display you posted, but the mouse hover is not working to display the p-value for every dot. Any idea? I will play with the auto-scaling, but the mouse hover is not working. It works for some dot but missing for the rest. Here is the code trackData.json:

 {
     "maxFeatureScreenDensity": 6,
     "maxHeight" : 210,
      "showLabels" : true,
      "scoreFun" : "function(feature) { return -Math.log10(feature.get('score')) }",
     "storeClass" : "JBrowse/Store/SeqFeature/NCList",
     "urlTemplate" : "tracks/meta_cis_eQTL/{refseq}/trackData.json",
     "label" : "Umeta_cis_eQTL",
     "key" : "meta cis eQTL",
     "type" : "GWASViewer/View/Track/VariantPlotter",
      "useEnsemblR2" : false,
       "useMyVariantInfo" : false,
       "width" : 10,

       "style":{
              "color" : "function(feature) { var s = -Math.log10(feature.get('score')); if(s<=50 && s>=20)    return 'green'; else if(s>50) return 'orange';else if (s>=10 && s<20) return 'red'; else return 'blue' }",
             "label" :  "function(feature) { return feature.get('score') }"
     }
  }

Any idea why label isn't shown when mouse hover?

cmdcolin commented 3 years ago

mouse hover scores do work for me

it is sort of a hack but you have to hold your mouse a little to the left of the circle, because the mouseover area is a thin rectangle while the drawn glyph is a circle

localhost_jbrowse__loc=chr1%3A92098931 100000000 tracks=Umeta_cis_eQTL highlight=

demis001 commented 3 years ago

@cmdcolin

I had an issue displaying the data when I hover it over or popup. The hover is only work for some dots not for all, , I don't know why it behaves that way, I have changed "useMyVariantInfo" : true and the popup menu comes for some of the dot but the popup window don't have a close icon (see the image).

screen_shot_GWASviewer

My data is a cis-eQTL data from RNA-Seq data. What I want is to display a line from the bed file associated with the dot when hover:

eg: chr start end associated_gene -log10(pvaue) chr1 993082 993082 MTND1P23 4.04431224968649

Then: In "detial window", for the gene associated with the eQTL in each dot, I want to display all associated eQTL for that gene:

From this test data as a bed format:

chr1    993082  993082  MTND1P23    4.04431224968649
chr1    1002398 1002398 MTATP8P1    3.64016451766011
chr1    1006912 1006912 MTATP8P1    3.88272870434424
chr1    1007514 1007514 MTATP8P1    3.99567862621736
chr1    1009570 1009570 MTATP8P1    3.83863199776503
chr1    1009638 1009638 MTATP8P1    3.87614835903291
chr1    1009854 1009854 MTATP8P1    3.84163750790475
chr1    1015219 1015219 MTATP8P1    3.60205999132796
chr1    1015348 1015348 MTATP8P1    3.60205999132796
chr1    1016363 1016363 MTATP8P1    3.58838029403677
chr1    1017182 1017182 MTATP8P1    3.56383735295924
chr1    1018365 1018365 MTATP8P1    3.63827216398241
chr1    1018528 1018528 MTATP8P1    3.63638802010786
chr1    1018686 1018686 MTATP8P1    3.55752023093555
chr1    1021585 1021585 MTATP8P1    3.66554624884907
chr1    1021725 1021725 MTATP8P1    3.82390874094432
chr1    1021791 1021791 MTATP8P1    3.61618463401957
chr1    1022188 1022188 MTATP8P1    3.63827216398241
chr1    1027146 1027146 MTATP8P1    3.54821356447571
chr1    1027560 1027560 MTATP8P1    3.54821356447571
chr1    1038479 1038479 MTATP8P1    3.55129368009492
chr1    1039330 1039330 MTATP8P1    3.52432881167557
chr1    1040401 1040401 MTATP8P1    3.53017798402184
chr1    1041583 1041583 MTATP8P1    3.56703070912559
chr1    1041840 1041840 MTATP8P1    4.15552282425432
chr1    1044510 1044510 MTATP8P1    3.55129368009492
chr1    1049076 1049076 MTATP8P1    3.55595520408192
chr1    1062896 1062896 MTATP8P1    3.99139982823808
chr1    1064030 1064030 MTND1P23    4.68824613894425
chr1    1064030 1064030 MTATP8P1    4.27736607746619

I want to show:

chr   start         end          associated_gene   -log10(pvaue)
chr1    993082  993082  MTND1P23    4.04431224968649
chr1    1064030 1064030 MTND1P23    4.68824613894425

For most of the dot

chr   start         end          associated_gene   -log10(pvaue)
chr1    1002398 1002398 MTATP8P1    3.64016451766011
chr1    1006912 1006912 MTATP8P1    3.88272870434424
chr1    1007514 1007514 MTATP8P1    3.99567862621736
chr1    1009570 1009570 MTATP8P1    3.83863199776503
chr1    1009638 1009638 MTATP8P1    3.87614835903291
chr1    1009854 1009854 MTATP8P1    3.84163750790475
chr1    1015219 1015219 MTATP8P1    3.60205999132796
chr1    1015348 1015348 MTATP8P1    3.60205999132796
chr1    1016363 1016363 MTATP8P1    3.58838029403677
chr1    1017182 1017182 MTATP8P1    3.56383735295924
chr1    1018365 1018365 MTATP8P1    3.63827216398241
chr1    1018528 1018528 MTATP8P1    3.63638802010786
chr1    1018686 1018686 MTATP8P1    3.55752023093555
chr1    1021585 1021585 MTATP8P1    3.66554624884907
chr1    1021725 1021725 MTATP8P1    3.82390874094432
chr1    1021791 1021791 MTATP8P1    3.61618463401957
chr1    1022188 1022188 MTATP8P1    3.63827216398241
chr1    1027146 1027146 MTATP8P1    3.54821356447571
chr1    1027560 1027560 MTATP8P1    3.54821356447571
chr1    1038479 1038479 MTATP8P1    3.55129368009492
chr1    1039330 1039330 MTATP8P1    3.52432881167557
chr1    1040401 1040401 MTATP8P1    3.53017798402184
chr1    1041583 1041583 MTATP8P1    3.56703070912559
chr1    1041840 1041840 MTATP8P1    4.15552282425432
chr1    1044510 1044510 MTATP8P1    3.55129368009492
chr1    1049076 1049076 MTATP8P1    3.55595520408192
chr1    1062896 1062896 MTATP8P1    3.99139982823808
chr1    1064030 1064030 MTATP8P1    4.27736607746619

Any idea how to achieve this?