| 1 | = User stories for using R within the Compute module = |
| 2 | [[TOC()]] |
| 3 | Authors: Danny, Morris, Joeri |
| 4 | |
| 5 | == User story: adding an R script == |
| 6 | |
| 7 | How to demo: |
| 8 | |
| 9 | Within the user interface you can choose [!ComputeProtocol] and then choose [New]. |
| 10 | Then you can give the compute protocol a name, set the type to 'R' and in a text box copy your R script. |
| 11 | |
| 12 | For example: |
| 13 | |
| 14 | ||Name ||!OneTraitQtlMapping || |
| 15 | ||Interpreter ||R || |
| 16 | ||Script ||{{{//I just create any script that works with my parameters}}}[[BR]]{{{onetraitqtlmapping(trait_names, genotypes_name, phenotypes_name)}}}|| |
| 17 | |
| 18 | Next you define the parameters that you have in your script, which are 'traitname' and 'datasetname' and 'iteration'. |
| 19 | These are can be described using ComputeFeature, where we define them as follows: |
| 20 | |
| 21 | ||'''Name''' ||'''Datatype''' ||'''Description''' || |
| 22 | ||traitnames ||List(String) ||This is a list of trait names such as defined in your data set. For example 'height' or 'probe01' || |
| 23 | ||genotypes_name ||xref(Data) ||This a lookup in the list of available Data so the user can choose the genotypes (implicitly links to map || |
| 24 | ||phenotype_name ||xref(Data) ||This is a lookup in the list of available Data so the user can choose the phenotypes || |
| 25 | ||results_name ||String ||This is the name of the new data set that will be created to store the data in (or if it exists, data will be added to it || |
| 26 | |
| 27 | == User story: running an R script == |
| 28 | |
| 29 | How to demo: |
| 30 | |
| 31 | Within the user interface you can choose [Run analyses]. Here you can browse the list of available compute protocols. For example, lets choose the protocol that we defined in the previous user story. Then you are provided with autogenerated input boxes based on the ComputeFeature that you defined; We fill in the parameters: |
| 32 | |
| 33 | ||traitnames ||height,length || |
| 34 | ||genotypes_name ||geno || |
| 35 | ||phenotypes_name || classic || |
| 36 | ||results_name ||My phenotype qtl profiles || |
| 37 | |
| 38 | And push [Next]. |
| 39 | |
| 40 | Automatically a new !ComputeApplication is generated that looks as follows. |
| 41 | |
| 42 | script = |
| 43 | {{{ |
| 44 | //sources useful scripts to interact with MOLGENIS |
| 45 | source("path/your/molgenis/instance/source.R") |
| 46 | |
| 47 | //autogenerated by MOLGENIS based on your parameters |
| 48 | traitnames <- c("height","length") |
| 49 | genotypes_name <- "geno" |
| 50 | phenotypes_name <- "classic" |
| 51 | results_name <- "My phenotype qtl profiles" //spaces will be removed when storing as file... |
| 52 | |
| 53 | //also this includes some useful system parameters |
| 54 | dbPath <- "xyz" |
| 55 | |
| 56 | //here the script as we defined above is copied for full provenance |
| 57 | onetraitqtlmapping(trait_names, genotypes_name, phenotypes_name) |
| 58 | |
| 59 | }}} |
| 60 | |
| 61 | Notice how the parameters are simply passed at the beginning of your script. |
| 62 | This means you can just copy-paste this script in you R terminal and it should work there as well as on the cluster (ideal for testing)! |
| 63 | |
| 64 | If you again push [[NEXT]] this job will be sent to Job manager (user story TODO). |
| 65 | |
| 66 | == User story: using R to define large scale analyses == |
| 67 | |
| 68 | How to demo: |
| 69 | |
| 70 | Within the user interface you repeat user story on 'adding an R script'. Goal now is to make a script uses MOLGENIS job submission API to automatically calculate qtl profiles on all our phenotypes. We again choose [New !ComputePrococol] and add a script that looks like the following: |
| 71 | |
| 72 | {{{ |
| 73 | //here our script will use the job submission API so you can run many R scripts |
| 74 | for(i in 1:number_of_jobs) |
| 75 | { |
| 76 | //cut out a subset of the phenotypes |
| 77 | selectedNames <- sliceList(i,number_of_jobs) |
| 78 | |
| 79 | //define what other job MOLGENIS should call |
| 80 | submitJob(command="onetraitqtlmapping", genotypes_name=genotypes_name, phenotypes_name=phenotypes_name, traitnames=selectedNames); |
| 81 | |
| 82 | //Note: all parameters you pass to submitJob will be automatically passed to the other protocol |
| 83 | //result is that a new "computeapplication" will be created programmatically instead of via the UI to be sent to the cluster |
| 84 | } |
| 85 | }}} |
| 86 | |
| 87 | Note how we replaced "trait_names" with "number_of_jobs" because we just want to run all phenotypes :-) |
| 88 | |
| 89 | ||'''Name''' ||'''Datatype''' ||'''Description''' || |
| 90 | ||genotypes_name ||xref(Data) ||This a lookup in the list of available Data so the user can choose the genotypes (implicitly links to map || |
| 91 | ||phenotype_name ||xref(Data) ||This is a lookup in the list of available Data so the user can choose the phenotypes || |
| 92 | ||results_name ||String ||This is the name of the new data set that will be created to store the data in (or if it exists, data will be added to it || |
| 93 | ||number_of_jobs ||Integer ||This will determine how the phenotype dataset will be split in jobs; should be 1 or larger. || |
| 94 | |
| 95 | |
| 96 | >>Discussion: we could even decide here to generate a whole R script and pass that as the command. How cool would that be? Than the other protocol doesn't even have to exist in the database. |
| 97 | |