Filtering your annotated variants lets you query interesting subsets of your variants.
A secondary purpose of filtering is when you want to view your results in the results viewer and you have more than 100K variants.
Once you have your annotated results, you can filter variants in the results viewer. There are 4 kinds of filters:
- Samples
- Genes
- Sample Properties
- Variant Properties
We will go through each of these filters and their functionality after we talk about the common GUI elements of each.
We will use a subset of a synthetic dataset that is a trio. There are 5 individuals in this dataset.
- The Proband
- Mother
- Father
- Sibling 1
- Sibling 2
Some of the variants are shared by the Proband and Mother, and all other combinations.
You can remove variants associated with a set of sample IDs by clicking on the checkboxes here. For example, we want all of the variants that are associated with the mother. We’ll click on the “mother” checkbox until it is a green check.
If we look at the Variant tab, we can see that our variants include multiple members:
Here’s a visual summary of the results.
These are all of the variants that are associated with the mother, and include variants that are shared by other family members. What about variants that are exclusive to the mother?
For example, we can filter for
To exclude samples, click on the checkbox until you see a red x.
After filtering, we find that 385 variants are exclusive to the mother. We can confirm this by going to the Variant tab:
Gene-level filtering can be done here. You can input a list of genes, separated by line-breaks.
Clearing our previous filter, let’s filter to only those variants that are in BRCA1 and BRCA2.
To filter, we take the following steps in the Gene filter section:
- Enter a list of genes, 1 gene per line in the text box. You can also upload a list of genes as well.
- Apply the filter
- See the results. There are 63 variants associated with BRCA1/BRCA2.
Going to the Variant tab, we can confirm that the variants belong to BRCA1 and BRCA2.
Here’s the visual summary of the filter:
In variant properties, you can filter by variant type based on your annotations. For example, let’s filter our dataset to missense variants.
- Under Variant Properties:
- Click on “Query Builder”.
- Mouse into the left bottom corner of the query builder window, and click the “+” sign.
B. Make your filter by selecting the values for the following dropdown boxes:
- Variant Annotation
- Sequence Ontology
- One of
- Missense checkbox
C. Finally, click the “Apply Filter” Button:
You will be left with 299 variants. Here’s a visual summary of what we did:
You can build more sophisticated operations by combining each filter step using Boolean logic.
You can add another filter by clicking the + underneath your filter.
By default, the filters are combined using AND logic, which are more restrictive, because they require variants to meet both filters.
Here’s an example of using AND logic. Here we are combining two filters: Missense Variants (from Variant Annotation >> Sequence Ontology) and Pathogenic variants (from ClinVar >> Clinical Significance).
- Select “ClinVar”
- Select “Clinical Significance”
- Select “One of”
- Select “Pathogenic”
- Click “Filter Result”
If we look at the Variant tab, we can see that our combined filter selected both Pathogenic and Missense Variants.
When we apply the filter, we get 9 variants that meet both criteria. Here’s a visual summary of the filtering:
These filters can also be combined using OR logic, which is more permissive (that is, these filters will return a greater number than the AND logic) we might want variants that are either missense OR pathogenic.
We can do this by clicking the “and” that links our two filters, which will switch it to an “or”:
When we apply the filter, we get 300 variants. The breakdown is below.
We can use the parentheses to group filters together. This can be helpful when we combine different types of logic.
To make a grouped filter, click the ( button next to the + button in the interface:
Then you can build a set of filters much like above. Notice that they are grouped within a set of parentheses.
Keep in mind that you can nest parentheses within parentheses to make even more complex filters. We’ll use this to be able to combine three filters with AND and OR logic below.
By default, when you click the “and” / “or” of one set of filters, all filters will be changed. If you want to combine AND / OR logic, you can group one of the logic operations using parentheses.
For example, say we want the above OR subset combined as an AND with those variants that have PS1 evidence. We can
This is what our final filter looks like:
Here’s a visual breakdown of this complex filter:
If we mouse over the top left of a filter or filter group, we’ll see a faint “NOT”.
Clicking this will change the logic to NOT.
Then we can hit Apply Filter again. In our case, we have 1,729 variants that do not meet our filter criterion. This makes sense because there were 9 variants total that met our grouped criterion, and 1,738 variants total, and 1738 - 9 = 1729.
Finally, if you need to delete a filter, you can mouse to the right of the filter. A faint “X” will appear. Clicking on it will delete that filter.
Let’s combine a sample filter with a grouped variant filter.
In our case, we want variants that are associated with the mother of the family combined with our joint missense/pathogenic variant filter.
Filters can be exported and saved as JSON files for further reuse. They can be applied to a new set of variants in the GUI, or can be applied to result SQLite files on the command line.
To export your filters, click on the save icon in the bottom right:
A modal box will pop up and ask you to name your filter set:
When you click OK, the filter will be saved on the top right:
Finally, you can click on the download button for the individual filter to save it to disk:
Here’s an example of what a filter looks like in the JSON format:
{ "sample": { "require": [], "reject": [] }, "genes": [], "variant": { "operator": "and", "rules": [ { "operator": "and", "rules": [ { "column": "clinvar__sig", "test": "hasData", "value": null, "negate": false }, { "column": "clingen__disease", "test": "hasData", "value": null, "negate": false } ], "negate": false } ], "negate": false }, "smartfilter": {}, "samplefilter": { "operator": "and", "rules": [], "negate": false } }
JSON filters can be applied by clicking on the upload icon:
A file select box will pop up and you can select the JSON filter to load it:
Then you can hit Apply Filter as usual to apply it.
JSON filters can also be applied on the command-line using the
oc util filtersqlite
command. More information is
here.