| 1 | [[TOC()]] |
| 2 | = R/qtl interface = |
| 3 | |
| 4 | This tutorial describes how to connect XGAP to the RqtlPackage. |
| 5 | |
| 6 | |
| 7 | == Retrieve raw data sets from XGAP into R/qtl for analysis == |
| 8 | 1. Connect XGAP to R as described in RprojectInterface. |
| 9 | |
| 10 | 2. Load the R/qtl package by entering (we assume you installed it ;-)). |
| 11 | |
| 12 | {{{ |
| 13 | library(qtl) |
| 14 | }}} |
| 15 | |
| 16 | 3. Import an a genotype (individual x marker) matrix and a phenotype matrix (individual x trait) into an R/qtl 'cross' object from XGAP by using the !CrossFromMolgenis function. The first parameter denotes the investigation_name, the second and third parameter refer to data matrices. (Tip: list all data matrices available using {{{find.data()}}} |
| 17 | Here we use again the MetaNetwork set as example. |
| 18 | |
| 19 | {{{ |
| 20 | myCross <- CrossFromMolgenis("MetaNetwork" ,"data_genotypes", "data_metaboliteexpression") |
| 21 | }}} |
| 22 | 4. Perform a standard QTL scan on all traits by using the 'scanall' method which a wrapper around a custom 'scanone' function that handles trait names properly. |
| 23 | |
| 24 | {{{ |
| 25 | myResults <- scanall(myCross) |
| 26 | }}} |
| 27 | |
| 28 | == Pushing results back-and-forth between XGAP and R/qtl == |
| 29 | |
| 30 | The results can be handled as any R/qtl data. |
| 31 | 1. For example, make a plot of the first trait by selecting the first 'scanone' object from the result list. |
| 32 | |
| 33 | {{{ |
| 34 | plot(myResults[[1]]) |
| 35 | }}} |
| 36 | Result: |
| 37 | |
| 38 | [[Image(rqtl-metanetwork-trait1plot.png)]] |
| 39 | |
| 40 | 2. Push the results back to the XGAP database by using the !ResultsToMolgenis function. The name for the datamatrix that will be created may not yet exist in the database and will be automatically created. |
| 41 | |
| 42 | {{{ |
| 43 | ResultsToMolgenis("MetaNetwork", "myResults", myResults) |
| 44 | }}} |
| 45 | |
| 46 | 3. You can now use the "Rplot" plugin at the Matrices to also visualize this profile, in a generic way: |
| 47 | |
| 48 | [[Image(xgap-metanetwork-trait1plot.png)]] |
| 49 | |
| 50 | 4. You can access past results by using '''ResultsFromMolgenis''': |
| 51 | |
| 52 | {{{ |
| 53 | myOldResult <- ResultsFromMolgenis("MetaNetwork", "myResults") |
| 54 | }}} |
| 55 | |
| 56 | 5. and plot it again: |
| 57 | |
| 58 | {{{ |
| 59 | plot(myOldResult[[1]]) |
| 60 | }}} |