AdrianBZG / InterMine-Data-Browser-Tool

InterMine Data Browser: a tool for exploring semi-homogeneous biological datasets
http://data-browser.apps.intermine.org/
Other
4 stars 38 forks source link

Option to show multiple filters for the same filter type at once #41

Closed yochannah closed 6 years ago

yochannah commented 6 years ago

Users may wish to show more than one dataset / GO term / pathway at a time. Can we consider how we might manage adding multiple constraints to filter types?

This should be completed once the other tickets are done; I've labelled it milestone 3 for now

AdrianBZG commented 6 years ago

@yochannah For this one we need a way to query the im-table with a disjunction of conjuctions (intersection of unions), where each set of unions is a different filter -> (A OR B) AND (C OR D) ...

AdrianBZG commented 6 years ago

@yochannah Or straightforward option: just use all the filters with disjunction (intersection).

yochannah commented 6 years ago

so, it is possible to set OR logic when adding a constraint, but it doesn't always work the way you'd want because it just assigns OR to all of the previous logic - e.g. If I have A and B, I could run

          table.query.addConstraint({
            "path": "goAnnotation.ontologyTerm.namespace",
            "op": "==",
            "value": "biological_process",
            "code" : "C"
          }, "or"); // <-- note the or here

and I'd end up with (A and B) or C - I couldn't set it to A and (B or C) this way. THAT SAID, there might be another way, using ONE OF. I'll put that in the next comment :)

yochannah commented 6 years ago

Ok, let me know if this approach works: for pathway, GO, etc- anywhere we might want multiple filters, do the following:

  1. rather than using a lookup or an = operator, use ONE OF - e.g.
      "where": [{
        "path": "Gene.symbol",
        "op": "ONE OF",
        "values": ["ENA6", "TSPAN6"],
        "code": "A"
      }]
  1. When it's time to add or remove a filter, simply delete the whole constraint and re-add it:
          // 1. remove the old constraint
          var constraintToRemove = table.query.constraints[0];
          table.query.removeConstraint(constraintToRemove);
          // 2. add a new constraint, with more items appended into the array
          constraintToRemove.values.push("CFH");
          table.query.addConstraint(constraintToRemove);

https://yochannah.github.io/im-tables-examples/constraint-modification.html

AdrianBZG commented 6 years ago

@yochannah As I already notified you, this ONE OF approach is perfect :+1:

AdrianBZG commented 6 years ago

@yochannah Although it was intended for Milestone 3, it's already done 🥇

http://im-browser-prototype.herokuapp.com/