Answers.Body: <p>JBrowse2 apparently has support for track filtering, which has been merged for the next release:</p>
  <p><a href="https://github.com/GMOD/jbrowse-components/pull/4393" rel="nofollow noreferrer">https://github.com/GMOD/jbrowse-components/pull/4393</a></p>
  <p><a href="https://github.com/GMOD/jbrowse-components/pull/4410#issuecomment-2144154361" rel="nofollow noreferrer">https://github.com/GMOD/jbrowse-components/pull/4410#issuecomment-2144154361</a></p>
  <blockquote>
  <p>This allows users to configure a filter in their config.json as an array of jexl strings, or set an array of jexl filters</p>
  </blockquote>
  <p>I asked the JBrowse2 developers about this. Contrary to my expectation, JBrowse2 treats gene-type tracks different from BAM/CRAM tracks for this filtering, so it is not currently available for BAM (but can be added).</p>
  <p>Here's the rest of <a href="https://github.com/GMOD/jbrowse-components/pull/4393#issuecomment-2248882563" rel="nofollow noreferrer">their comment</a>:</p>
  <blockquote>
  <p>it sounds a bit like what this user wants is related to &quot;regions of interest&quot;</p>
  <p>IGV has the &quot;regions of interest&quot; functionality</p>
  <p>JBrowse 2 has the sort of general spreadsheet functionality which a user can load with a BED file with regions of interest, and then it will have links to the various places they want to go</p>
  <p>if you are trying to auto-generate a link, you can auto-link to a spreadsheet view in JBrowse like this</p>
  <p>example here with a VCF file but works with BED also
  <a href="https://jbrowse.org/code/jb2/main/?config=test_data/volvox/config.json&amp;session=spec-%7B%22views%22%5B%7B%22type%22:%22SpreadsheetView%22,%22uri%22:%22test_data/volvox/volvox.filtered.vcf.gz%22,%22assembly%22:%22volvox%22%7D%5D%7D" rel="nofollow noreferrer">https://jbrowse.org/code/jb2/main/?config=test_data/volvox/config.json&amp;session=spec-{&quot;views&quot;[{&quot;type&quot;:&quot;SpreadsheetView&quot;,&quot;uri&quot;:&quot;test_data/volvox/volvox.filtered.vcf.gz&quot;,&quot;assembly&quot;:&quot;volvox&quot;}]}</a></p>
  <p>note that a custom user interface could also use the embedded jbrowse components to create a little filterable data grid outside of the jbrowse app, and then automatically control the jbrowse app</p>
  <p>full url query params docs here <a href="https://jbrowse.org/jb2/docs/urlparams/" rel="nofollow noreferrer">https://jbrowse.org/jb2/docs/urlparams/</a></p>
  </blockquote>
  <hr />
  <p>Update: I've just seen information about a new ultra-fast genome browser called GW:</p>
  <p><a href="https://doi.org/10.1101/2024.07.26.605272" rel="nofollow noreferrer">https://doi.org/10.1101/2024.07.26.605272</a></p>
  <p>It claims that it can do region filtering:</p>
  <blockquote>
  <p>GW supports ‘filter’ and ‘count’ commands that can accept a simple expression for filtering and quantifying aligned sequencing reads. Reads can be filtered or counted using an expression of the form ‘{property} {operation} {value}’, where a ‘property’ relates to the alignment, ‘operation’ is a standard operator, and ‘value’ is the desired filtering value. Currently, over 40 different properties can be used, derived from attributes of the alignment (mapq, pos, tlen etc), flag values (‘paired’, ‘proper-pair’ etc or numeric values, 1, 2, respectively), or standard SAM-tag values (Alignment score AS, Edit distance NM etc). These properties can be combined with up to 10 operators which include common comparison operators (greater than ‘&gt;’, equal to ‘==’ etc) as well as bitwise ‘&amp;’ operator, and sequence specific operators (‘contains’ and its opposite ‘omit’). The value side of the expression is chosen by the user and is typically a numeric value, but can also be a string value. Expressions can also be chained to create more complex subsets of the data and may be useful for many analytical tasks that would normally require additional bioinformatics tools.</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-07-24T20:57:11.323Z
Answers.Text: I added a comment to our github that tries to add some details about this @terdon, let me know if that helps https://github.com/GMOD/jbrowse-components/pull/4393#issuecomment-2248882563bas (I created a note about how you can create a 'spreadsheet' to jump between different regions, which might be helpful in this sort of 'regions of interest' scenario)
Answers.UserDisplayName: Colin D
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-07-23T23:27:30.060Z
Answers.LastActivityDate: 2024-07-27T06:41:18.010Z
Answers.LastEditDate: 2024-07-27T06:41:18.010Z
Answers.UserDisplayName: gringer
Body: <p>I have a web-based application that does variant calling and offers the option of opening a bam file using either <a href="https://igv.org/" rel="nofollow noreferrer">IGV</a> or <a href="https://jbrowse.org/jb2/" rel="nofollow noreferrer">JBrowse</a>, both running as integrated webapps, not desktop applications. Some of my users want to avoid seeing incidental findings, variants in genomic locations not related to the phenotype of their patient. To that end, I let them run gene list analyses, limiting the variants displayed to only those regions that fall in or near their genes of interest.</p>
  <p>I also provide a bam file that is filtered by the regions of the gene list. This is done by getting a bed file with the regions of the genes, and then creating a new, second bam file, filtering the full sample's bam file using this bed. However, I would like to stop doing that since that is time and resource consuming, and takes up a lot of space for what is essentially duplicated info. I still don't want them to accidentally see regions they don't want to see though, so I am looking for a way to limit users to only specific regions  of a bam file, but without needing to filter the bam file itself.</p>
  <p>IGV does provide a &quot;gene list&quot; option, but that just opens the regions of the target genes in separate panes, the user can still navigate to other regions. And I don't even know if it is available in the webapp version.</p>
  <p>Is there a way to open a bam file in either IGV or JBrowse but only allow the user to navigate to specific regions of that bam file and not the entire alignment? I fear there won't be since the IGV and JBrowse developers would understandably assume that anyone who wants this can just filter the bam file, but maybe someone has a workaround or suggestion?</p>
  
Tags: <sam><igv><jbrowse>
Title: Can I limit IGV (or JBrowse) to only specific regions of a bam file?
ThreadText: # Can I limit IGV (or JBrowse) to only specific regions of a bam file?
  
  (Asked by: username_0 on 2024-07-23)
  
  I have a web-based application that does variant calling and offers the option of opening a bam file using either [IGV](https://igv.org/) or [JBrowse](https://jbrowse.org/jb2/), both running as integrated webapps, not desktop applications. Some of my users want to avoid seeing incidental findings, variants in genomic locations not related to the phenotype of their patient. To that end, I let them run gene list analyses, limiting the variants displayed to only those regions that fall in or near their genes of interest.
  
  I also provide a bam file that is filtered by the regions of the gene list. This is done by getting a bed file with the regions of the genes, and then creating a new, second bam file, filtering the full sample's bam file using this bed. However, I would like to stop doing that since that is time and resource consuming, and takes up a lot of space for what is essentially duplicated info. I still don't want them to accidentally see regions they don't want to see though, so I am looking for a way to limit users to only specific regions of a bam file, but without needing to filter the bam file itself.
  
  IGV does provide a "gene list" option, but that just opens the regions of the target genes in separate panes, the user can still navigate to other regions. And I don't even know if it is available in the webapp version.
  
  Is there a way to open a bam file in either IGV or JBrowse but only allow the user to navigate to specific regions of that bam file and not the entire alignment? I fear there won't be since the IGV and JBrowse developers would understandably assume that anyone who wants this can just filter the bam file, but maybe someone has a workaround or suggestion?
  
  **Tags:** sam, igv, jbrowse
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-07-23. Score: 1
  
  JBrowse2 apparently has support for track filtering, which has been merged for the next release:
  
  <https://github.com/GMOD/jbrowse-components/pull/4393>
  
  <https://github.com/GMOD/jbrowse-components/pull/4410#issuecomment-2144154361>
  
  > This allows users to configure a filter in their config.json as an array of jexl strings, or set an array of jexl filters
  
  I asked the JBrowse2 developers about this. Contrary to my expectation, JBrowse2 treats gene-type tracks different from BAM/CRAM tracks for this filtering, so it is not currently available for BAM (but can be added).
  
  Here's the rest of [their comment](https://github.com/GMOD/jbrowse-components/pull/4393#issuecomment-2248882563):
  
  > it sounds a bit like what this user wants is related to "regions of interest"
  >
  > IGV has the "regions of interest" functionality
  >
  > JBrowse 2 has the sort of general spreadsheet functionality which a user can load with a BED file with regions of interest, and then it will have links to the various places they want to go
  >
  > if you are trying to auto-generate a link, you can auto-link to a spreadsheet view in JBrowse like this
  >
  > example here with a VCF file but works with BED also
  > [https://jbrowse.org/code/jb2/main/?config=test\_data/volvox/config.json&session=spec-{"views"[{"type":"SpreadsheetView","uri":"test\_data/volvox/volvox.filtered.vcf.gz","assembly":"volvox"}]}](https://jbrowse.org/code/jb2/main/?config=test_data/volvox/config.json&session=spec-%7B%22views%22%5B%7B%22type%22:%22SpreadsheetView%22,%22uri%22:%22test_data/volvox/volvox.filtered.vcf.gz%22,%22assembly%22:%22volvox%22%7D%5D%7D)
  >
  > note that a custom user interface could also use the embedded jbrowse components to create a little filterable data grid outside of the jbrowse app, and then automatically control the jbrowse app
  >
  > full url query params docs here <https://jbrowse.org/jb2/docs/urlparams/>
  
  ---
  
  Update: I've just seen information about a new ultra-fast genome browser called GW:
  
  <https://doi.org/10.1101/2024.07.26.605272>
  
  It claims that it can do region filtering:
  
  > GW supports ‘filter’ and ‘count’ commands that can accept a simple expression for filtering and quantifying aligned sequencing reads. Reads can be filtered or counted using an expression of the form ‘{property} {operation} {value}’, where a ‘property’ relates to the alignment, ‘operation’ is a standard operator, and ‘value’ is the desired filtering value. Currently, over 40 different properties can be used, derived from attributes of the alignment (mapq, pos, tlen etc), flag values (‘paired’, ‘proper-pair’ etc or numeric values, 1, 2, respectively), or standard SAM-tag values (Alignment score AS, Edit distance NM etc). These properties can be combined with up to 10 operators which include common comparison operators (greater than ‘>’, equal to ‘==’ etc) as well as bitwise ‘&’ operator, and sequence specific operators (‘contains’ and its opposite ‘omit’). The value side of the expression is chosen by the user and is typically a numeric value, but can also be a string value. Expressions can also be chained to create more complex subsets of the data and may be useful for many analytical tasks that would normally require additional bioinformatics tools.
  
  > **Comments:**
  > **username_2**: I added a comment to our github that tries to add some details about this @username_0, let me know if that helps https://github.com/GMOD/jbrowse-components/pull/4393#issuecomment-2248882563bas (I created a note about how you can create a 'spreadsheet' to jump between different regions, which might be helpful in this sort of 'regions of interest' scenario)  
  
  ---
  
  