Examples of RQL-queries

Let us consider the following simple database composed of three tables: gen, met and ann, containing heterogeneous data for 6 samples. These tables contain quantitative attributes (G1, G2, G3, G4, M1, M2, M3, A3), binary attributes (A1, A2) and categorical attributes (time, sample):

Database example
    Example 1

If you consider that a gene is over-expressed if its level is greater than 0.5, you can test the following query:

FINDRULES
SCOPE t1 IN gen
HAVING t1.ATT > 0.5 OVER ALL MINUS sample

In this case, the rule G3=>G4 means that for each sample such that G3 is over-expressed then G4 is also over-expressed. It's also possible to test it for genes and for metabolites with the following query:

FINDRULES
SCOPE t1 IN (SELECT G1, G2, G3, G4, M1, M2, M3
                       FROM gen, met
                       WHERE gen.sample=met.sample)
HAVING t1.ATT > 0.5 OVER ALL

In this case, you can have rules between genes and metabolites (M3=>G4). It's also possible to specify different thresholds depending on the type of the entity for instance by defining two predicates.

    Example 2

We can also define different predicates depending on the type of the attributes:

FINDRULES
SCOPE t1 IN ( SELECT G1, G2, G3, G4, M1, M2, M3, A1, A2
                       FROM gen, met, ann
                       WHERE gen.sample=met.sample and gen.sample=ann.sample)
HAVING t1.ATT > 0.5 OVER ALL MINUS A1, A2
AND 1: t1.ATT = 1 OVER A1, A2
AND 0: t1.ATT = 0 OVER A1, A2
FINDRULES
SCOPE t1 IN (SELECT *
                       FROM gen NATURAL JOIN met NATURAL JOIN ann)
HAVING t1.ATT > 0.5 OVER ALL MINUS A1, A2
AND 1: t1.ATT = 1 OVER A1, A2
AND 0: t1.ATT = 0 OVER A1, A2

This query allows to find rules between quantitative attributes with values higher than 0.5 and binary attributes equal to 1 or 0.
The rule A11=>M2 means that A1 = 1 guarantees M2 > 0.5 (A1 = 1 is a sufficient condition to observe a high value for M2).
The rule G3=>A10 means that each time G3 > 0.5 then A1 = 0. Here A1 = 0 is a necessary condition to observed a high value for G3.

    Example 3

This is another example with two tuple variables, where we consider that a gene does not vary between two samples if the variation of the expression levels is between 0.0 and 0.2:

FINDRULES
SCOPE t1 IN gen, t2 IN gen
HAVING ABS(t2.ATT – t1.ATT)<0.1 OVER G1, G2, G3, G4

The rule G3=>G4 means that if G3 does not vary between two samples then G4 does not vary neither between these two samples.

    Example 4

This is another example with two tuple variables, where we consider that a metabolite grows significantly between two consecutive samples if the difference between their values is greater than 0.8:

FINDRULES
SCOPE t1 IN (SELECT M1, M2, M3, time FROM met NATURAL JOIN ann),
             t2 IN (SELECT M1, M2, M3, time FROM met NATURAL JOIN ann)
WHERE t1.time = t2.time + 1
HAVING t2.ATT – t1.ATT > 0.8 OVER M1, M2, M3

The rule M2=>M3 means that if M2 grows between two consecutive samples then M3 also grows between these two consecutive samples.

    Example 5

In this query, we have defined two tuple variables (t1 and t2) and add a condition which indicates that we will test all the couples of consecutive samples:

FINDRULES
SCOPE t1 IN ann, t2 IN ann
WHERE t2.time = t1.time + 1
HAVING t1.ATT = t2.ATT OVER A1, A2
AND ABS(t2.ATT – t1.ATT) < 5 OVER A3

The rule A2=>A3 means that to equal consecutive values of A2 correspond close consecutive values of A3.

    Example 6

This is an example of query with three tuple variables::

FINDRULES
SCOPE t1 IN (SELECT G1, G2, G3, G4, time FROM gen NATURAL JOIN ann),
             t2 IN (SELECT G1, G2, G3, G4, time FROM gen NATURAL JOIN ann),
             t3 IN (SELECT G1, G2, G3, G4, time FROM gen NATURAL JOIN ann)
WHERE t2.time = t1.time + 1 AND t3.time = t2.time + 1
HAVING (t2.ATT - t1.ATT) > 0.2 AND (t2.ATT-t3.ATT) > 0.2 OVER G1, G2, G3, G4

The rule G1=>G2 means that when a local maximum exists for G1 (with s5) then a local maximum also exists for G2.

 
< Previous                                                                                                                         Next >