@@ -57,13 +57,15 @@ In order to allow the analysis team to also use DataSHIELD to perform analysis,
## 4. Harmonise Each Variable
To pull and transform the original variables from the original table, you need to individually harmonise each target variable in the view.
The harmonisation approach for each target variable depends on whether it is a categorical variable or not.
For **categorical target variables**, continue reading [4.1](#41-the-target-variable-is-categorical) below. For **continuos target variables**, got to [4.2](#42-the-target-variable-is-continuous).
For **categorical target variables**, continue reading [4.1](#41-the-target-variable-is-categorical) below.
For **continuos target variables**, got to [4.2](#42-the-target-variable-is-continuous).
### **4.1.** The target variable is categorical
For categorical target variables you can use the graphical web interface:
***4.1.1.** Click on a categorical variable in the view
> NOTE
> **NOTE**
If you know that you will not be able to harmonise any of your original variables to this variable, skip to 4.1.6.
***4.1.2.** Click on `Derive` > `Categorize another variable to this`
@@ -77,14 +79,35 @@ For categorical target variables you can use the graphical web interface:
So in this example, we are mapping the original categories "Vaginal" and "Instrumental" to 1 and "Caesarean" to 2.
We are also mapping missing, empty or any other values to 9 and tagging them as missing.
***4.1.5.** Click `Next`. In this window, you will be able to see a preview of what the resulting harmonised variable will look like. Click on `Full summary` to see summary statistics or on the `Values` tab to see a fragment of the resulting values.
***4.1.5.** Click `Next`. In this window, you will be able to see a preview of what the resulting harmonised variable will look like. Click on `Full summary` to see summary statistics or on the `Values` tab to see a fragment of what the resulting values will be.
This preview, gives you a chance to assess if the resulting values will be in line with what you intended. If not, you can go back by clicking on `Previous`, then change the mappings and try again.
***4.1.5.** Click `Finish`
***4.1.6.** Before you move on to another variable, you must set the harmonisation status of this one. On the variable's page, click on `Edit Annotation` > `Apply annotation`.
***4.1.7.** Select `Harmonization` > `Harmonization Status` and then select the appropriate status. Click `Save`.
***4.1.8.** If you selected either `Impossible` or `Undetermined` in the previous step, you should also add a comment explaining why. To do this, click again on `Edit Annotation` > `Apply annotation`. Select `Harmonization` > `Comment`, write your comment and then click `Save`.
***4.1.9.** You are now finished with this variable! If you have not yet harmonised all the other variables, go back to the [beginning of section 4](#4-harmonise-each-variable) and start harmonising another variable!
### **4.2. The target variable is continuous**
For continuous target variables you have to use [MagmaJS](http://opaldoc.obiba.org/en/latest/magma-user-guide/methods.html) scripts.
> **NOTE**
Examples of scripts used to harmonise the EPICE-PT variables for this demo project are available [here](magmajs).
***4.2.1.** Select a continuous variable on the view
***4.2.2.** Click on the `Script` tab and then `Edit`
***4.2.3.** Based on the [MagmaJS documentation](http://opaldoc.obiba.org/en/latest/magma-user-guide/methods.html) and on our [example scripts](magmajs), write the script and click `Test`.
In this window, you will be able to see a preview of what the resulting harmonised variable will look like. Click on `Full summary` to see summary statistics or on the `Values` tab to see a fragment of what the resulting values will be.
This preview, gives you a chance to assess if the resulting values will be in line with what you intended. If not, you can go back by clicking on `Close`, then change your script and try again.
The script is applied to each row of the original table. For example, if your script is:
```javascript
$('weight').div(1000).round(2)
```
It means that you are pulling the values of a variable named `weight` from the original table, dividing them by 1000 and then rounding the resulting number to two decimal places (this could be a script to convert grams into kilograms, for example).
***4.2.4.** When you are happy with your script, click `Save`
***4.1.5.** Before you move on to another variable, you must set the harmonisation status of this one. On the variable's page, click on `Edit Annotation` > `Apply annotation`.
***4.1.6.** Select `Harmonization` > `Harmonization Status` and then select the appropriate status. Click `Save`.
***4.1.7.** If you selected either `Impossible` or `Undetermined` in the previous step, you should also add a comment explaining why. To do this, click again on `Edit Annotation` > `Apply annotation`. Select `Harmonization` > `Comment`, write your comment and then click `Save`.
***4.1.8.** You are now finished with this variable! If you have not yet harmonised all the other variables, go back to the [beginning of section 4](#4-harmonise-each-variable) and start harmonising another variable!