Guest User

Untitled

a guest
Jun 11th, 2021
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.42 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
  7. <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.css"/>
  8.  
  9. <!-- Necessary includes for LocusZoom.js -->
  10. <script src="https://cdn.jsdelivr.net/npm/d3@^5.16.0" type="text/javascript"></script>
  11. <script src="../dist/locuszoom.app.min.js" type="text/javascript"></script>
  12. <link rel="stylesheet" href="../dist/locuszoom.css" type="text/css"/>
  13.  
  14. <!-- LaTeX -->
  15. <script type="text/x-mathjax-config">
  16. MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
  17. </script>
  18. <script type="text/javascript"
  19. src="http://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
  20. </script>
  21.  
  22. <script type="application/javascript" src="../dist/ext/lz-dynamic-urls.min.js"></script>
  23.  
  24. <!-- Additional standalone code required for credible set calculations; not part of base LZjs -->
  25. <script type="application/javascript" src="https://unpkg.com/[email protected]/dist/gwas-credible-sets.min.js" integrity="sha384-lJL/xQT18Xu6GVovitlKgX4kL8hw6YfgLGVM5PWcFUMe+tfvznEwsJlauLzB1AnQ" crossorigin="anonymous"></script>
  26. <script type="application/javascript" src="../dist/ext/lz-credible-sets.min.js"></script>
  27.  
  28. <title>LocusZoom.js ~ Credible Sets</title>
  29.  
  30. <style>
  31. body {
  32. background-color: #FAFAFA;
  33. margin: 0 20px;
  34. }
  35.  
  36. img {
  37. max-width: 100%;
  38. box-sizing: border-box;
  39. }
  40.  
  41. ul.top_hits li {
  42. margin-bottom: 0;
  43. }
  44. </style>
  45.  
  46. </head>
  47.  
  48. <body>
  49. <div class="container">
  50.  
  51. <h1 style="margin-top: 1em;"><strong>LocusZoom.js</strong></h1>
  52.  
  53. <h3 style="float: left; color: #777">Credible Sets Demonstration</h3>
  54. <h6 style="float: right;"><a href="../index.html">&lt; return home</a></h6>
  55.  
  56. <hr style="clear: both;">
  57.  
  58. <p>
  59. With the help of a standalone JavaScript library, LocusZoom can identify and plot the members of a credible set
  60. based on the displayed plot region. This example shows how to integrate that library into a custom datasource, and
  61. how to take advantage of several visualization options for displaying the credible set members. See the library
  62. <a href="https://github.com/statgen/gwas-credible-sets/">source code</a> and
  63. <a href="https://statgen.github.io/gwas-credible-sets/">documentation</a> for information about the method.
  64. </p>
  65.  
  66. <p>
  67. To begin, move your mouse over the plot below and select "Display Options". This demonstration allows credible
  68. sets to be displayed as a primary coloring overlay, a separate annotation track, or both. Note that credible sets
  69. are calculated client-side by the web browser, which means that this feature can be used without requiring backend
  70. changes to an existing API server.
  71. </p>
  72.  
  73. <h3>Interactive Plot</h3>
  74. <div class="row">
  75. <div class="two columns">
  76. <h4>Top Hits</h4>
  77. <ul class="top_hits" style="padding-left: 0.2rem; min-width: 110px;"></ul>
  78. </div>
  79. <div class="ten columns">
  80. <div id="plot" class="lz-container-responsive"></div>
  81. </div>
  82. </div>
  83. <hr>
  84.  
  85. <div class="row">
  86. <footer style="text-align: center;">
  87. &copy; Copyright <script>document.write(new Date().getFullYear())</script> <a href="https://github.com/statgen">The University of Michigan Center for Statistical
  88. Genetics</a><br>
  89. </footer>
  90. </div>
  91.  
  92. <script type="application/javascript">
  93. /*
  94. Specify the data sources to use
  95. */
  96. // Determine if we're online, based on browser state or presence of an optional query parameter
  97. var apiBase = "https://portaldev.sph.umich.edu/api/v1/";
  98. var assocFile = "http://localhost:8000/csvjson.json";
  99. data_sources = new LocusZoom.DataSources()
  100. // .add("assoc", ["AssociationLZ", {
  101. // url: apiBase + "statistic/single/",
  102. // params: { source: 45, id_field: "variant" }
  103. // }])
  104. .add("assoc", ["AssociationLZ", {url: assocFile, params: {analysis: true, id_field: "variant"}}])
  105. // .add("assoc", ["AssociationLZ", {url: "assoc_10_114550452-115067678.json?", params: {analysis: true, id_field: "variant"}}])
  106. .add("credset", ["CredibleSetLZ", { params: { fields: { log_pvalue: 'assoc:log_pvalue' }, threshold: 0.95, significance_threshold: 7.301 } }])
  107. .add("ld", ["LDServer", { url: "https://portaldev.sph.umich.edu/ld/", params: { source: '1000G', build: 'GRCh37', population: 'ALL' } }])
  108. .add("gene", ["GeneLZ", {url: apiBase + "annotation/genes/", params: { build: 'GRCh37' }}])
  109. .add("recomb", ["RecombLZ", {url: apiBase + "annotation/recomb/results/", params: { build: 'GRCh37' }}])
  110. .add("constraint", ["GeneConstraintLZ", { url: "https://gnomad.broadinstitute.org/api/", params: { build: 'GRCh37' } }]);
  111.  
  112. /*
  113. Define and render the plot
  114. */
  115. // Fetch custom layout defined for usage with credible sets
  116. var stateUrlMapping = {chr: "chrom", start: "start", end: "end"};
  117. // Fetch initial position from the URL, or use some defaults
  118. var initialState = LzDynamicUrls.paramsFromUrl(stateUrlMapping);
  119. if (!Object.keys(initialState).length) {
  120. initialState = {chr: 16, start: 74947245, end: 75547245};
  121. // initialState = {chr: 4, start: 173008488, end: 177000000};
  122. }
  123.  
  124. layout = LocusZoom.Layouts.get("plot", "association_credible_set", {state: initialState});
  125.  
  126. // Generate the LocusZoom plot
  127. window.plot = LocusZoom.populate("#plot", data_sources, layout);
  128.  
  129. // Changes in the plot can be reflected in the URL, and vice versa (eg browser back button can go back to
  130. // a previously viewed region)
  131. LzDynamicUrls.plotUpdatesUrl(plot, stateUrlMapping);
  132. LzDynamicUrls.plotWatchesUrl(plot, stateUrlMapping);
  133.  
  134.  
  135. /*
  136. Add a sidebar to the page with "top hits" items
  137.  
  138. RBMS1, for example, has a region of high LD and therefore includes many points in the credible set
  139. */
  140. // Load a region of the plot based on a specified region string
  141. function jumpTo(region) {
  142. var target = region.split(":");
  143. var chr = target[0];
  144. var pos = target[1];
  145. var start = 0;
  146. var end = 0;
  147. if (!pos.match(/[-+]/)) {
  148. start = +pos - 300000;
  149. end = +pos + 300000;
  150. }
  151. plot.applyState({chr: chr, start: start, end: end, ldrefvar: ""});
  152. return false;
  153. }
  154.  
  155. // Populate a list of top hits links for the plot
  156. var top_hits = [
  157. ["16:75247245", "BCAR1 (default)"],
  158. ["10:114758349", "TCF7L2"],
  159. ["16:53819169", "FTO"],
  160. ["9:22051670", "CDKN2A/B"],
  161. ["7:28196413", "JAZF1"],
  162. ["12:71433293", "TSPAN8"],
  163. ["8:95937502", "TP53INP1"],
  164. ["6:20679709", "CDKAL1"],
  165. ["2:161346447", "RBMS1"],
  166. ["15:77832762", "HMG20A"],
  167. ["7:15052860", "DGKB"]
  168. ];
  169. top_hits.forEach(function (hit) {
  170. d3.select("ul.top_hits").append("li")
  171. .html("<a href=\"javascript:void(0);\" onclick=\"javascript:jumpTo('" + hit[0] + "');\">" + hit[1] + "</a>");
  172. });
  173. </script>
  174.  
  175. </div>
  176.  
  177. </body>
  178. </html>
Advertisement
Add Comment
Please, Sign In to add comment