# MEDprofiles

{% embed url="<https://youtu.be/BFR1UnIjnYQ?si=xSZtLOA-yRYouB6E>" %}
MEDprofiles Video Tutorial
{% endembed %}

The *MEDprofiles 'Prepare Data' component* is accessible on the [*Input Module*](https://medomicslab.gitbook.io/medomics-docs/tutorials/design/input-module) page and looks like this:

<figure><img src="https://4288370141-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUO0RN9PzFLqAgLEwwaSn%2Fuploads%2FKOlDt5Uymyl8aeQ3mSvl%2FMEDprofilesPage.PNG?alt=media&#x26;token=c457f38c-211d-4b0a-9472-a6cc6fb50897" alt=""><figcaption><p>MEDprofiles dashboard</p></figcaption></figure>

## 2. Create or select your master table

The master table is the entry point of the *MEDprofiles* process. It is a CSV file that must adhere to the following format:

* Column names must be 'PatientID', 'Date', 'Time\_point', and others must contain '\_'.
* The first line (after columns) must contain 'string' or 'num' in the first position, 'datetime.date' in the second, and 'num' in all others.
* The first column (excluding the first line) must contain strings or integers.
* The second column (excluding the first line) must contain datetime values.
* The third column (excluding the first line) must contain null or integer values.
* The other columns (excluding the first line) must contain numerical values.

If you have already created a master table, it will be automatically detected and you should be able to select it in the third input box (see figure below). If this is not the case, this component will allow you to create one. Depending on your actions in the application, different options will be available:

<figure><img src="https://4288370141-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUO0RN9PzFLqAgLEwwaSn%2Fuploads%2F9wWXL4D38f9xRThhSAP8%2FMEDprofilesSelectMasterTable.PNG?alt=media&#x26;token=e0524cf3-fa96-4ba6-ae60-4578a49ef943" alt=""><figcaption><p>Create or select your master table</p></figcaption></figure>

* *Select CSV files*: If you have generated embedding data using the extraction module, the generated files will appear in the list box and you can select the ones to use for master table creation.

<figure><img src="https://4288370141-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUO0RN9PzFLqAgLEwwaSn%2Fuploads%2FQbLHNXpBkagKKen4dqKM%2FMEDprofilesSelectFiles.PNG?alt=media&#x26;token=63ec18cc-d380-4ed7-b33a-4accdb7b09e1" alt=""><figcaption></figcaption></figure>

* Otherwise, the input box list will be empty. In this case, if you want to use the *MEDprofiles prepare data component*, you will need to explore the[ extraction module](https://medomicslab.gitbook.io/medomics-docs/tutorials/design/extraction-modules) and generate data that adheres to the master table format (refer to the extraction pages tutorials for more information).

This section is divided into two subparts: one for master table creation and the other for master table selection.

### 2.1. Create your master table

You need to select the files you want to include in your master table. Afterward, you can choose the name under which you want to save your master table. The default name is 'master\_table.csv.' It's important that your chosen name ends with the CSV extension. If some of your selected files contain columns with type mismatches (for example, if your patient identifiers are numbers in some files and strings in another), a warning will appear, and you won't be able to proceed with master table creation. If this is the case, check your data types.

<figure><img src="https://4288370141-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUO0RN9PzFLqAgLEwwaSn%2Fuploads%2FP1Ge7OE6vinZhBRV6mt2%2FMEDprofilesDataSelected.PNG?alt=media&#x26;token=a5468f53-28ed-49a0-aa47-bb65fbb0cd07" alt=""><figcaption></figcaption></figure>

If everything is in order, you can press the '*Create Master Table*' button. Once the master table creation process is complete (which usually takes a few seconds), a message will appear at the bottom (see figure below), indicating that the master table has been generated and saved in the mongoDB database under DATA/MEDprofiles/master\_tables. This will also update the master table selection input box.

<figure><img src="https://4288370141-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUO0RN9PzFLqAgLEwwaSn%2Fuploads%2FJ8qe5Sj8gdgd2z5MzIPD%2FMEDprofilesMasterSucess.PNG?alt=media&#x26;token=68755bae-e8e0-47ae-9acb-560f3d8eeec4" alt=""><figcaption><p>Master table created successfully</p></figcaption></figure>

The '*Create Master Table*' button will also analyzes your selected master table and create the classes that will be associated with your MEDprofiles (i.e. the *MEDclasses*). The created classes will be registered under 'DATA/MEDprofiles/MEDclasses' and will be displayed in the application as follows :

{% hint style="info" %}
The classes will be created based on the column names of the master table.
{% endhint %}

{% hint style="info" %}
In the master table, the column names adhere to the format 'className\_attributeName'.
{% endhint %}

<figure><img src="https://4288370141-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUO0RN9PzFLqAgLEwwaSn%2Fuploads%2FJV59QwCsfYDM27d1WMIp%2FgenearateMEDclasses.PNG?alt=media&#x26;token=9c8ff2fc-ea4f-4786-850b-10d07d76c22f" alt=""><figcaption><p>Generated MEDclasses</p></figcaption></figure>

### 2.2. Select your master table

Here, you only need to select a master table from the list of available master tables in your chosen folder. If the selector indicates 'No CSV files to show,' it means that no CSV files matching the required format are available in your selected folder from the first part.

<figure><img src="https://4288370141-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUO0RN9PzFLqAgLEwwaSn%2Fuploads%2FORhIrHcL2xEre1Zehu9Z%2FMEDprofilesAvailableMTs.PNG?alt=media&#x26;token=d4bad4b1-9449-4cc5-94d6-6125fceb7be7" alt=""><figcaption><p>Available master tables selection</p></figcaption></figure>

## 3. Instantiate MEDprofiles

Once a master table is selected, you can instantiate your master table data as [MEDprofiles](https://github.com/MEDomics-UdeS/MEDprofiles). You can choose the name under which you want your data to be registered. It is important that the filename ends with the '.pkl' extension.

<figure><img src="https://4288370141-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUO0RN9PzFLqAgLEwwaSn%2Fuploads%2FzqCIriudAxBL9xI4OvRs%2FMEDprofilesInstantiate.PNG?alt=media&#x26;token=c23c5359-5ea7-43ae-95f0-13c519e55928" alt=""><figcaption><p>Instantiate MEDprofiles</p></figcaption></figure>

The process of instantiating MEDprofiles data may take a few minutes. While the process is running, a progress bar will be displayed, indicating the advancement of the process.

{% hint style="warning" %}
If the button "Instantiate MEDprofiles" is disabled, make sure you have selected a master table in the section 2 and the generated MEDclasses are displayed.
{% endhint %}

## 5. Visualize your MEDprofiles data

To open the MEDprofiles figure, you need to select the recently created MEDprofiles binary file (files with the right format are detected and added the list box automatically).&#x20;

<figure><img src="https://4288370141-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUO0RN9PzFLqAgLEwwaSn%2Fuploads%2FENCmN0x1xEpE0LoFNWju%2FMEDprofilesSelectBinary.PNG?alt=media&#x26;token=b5a69b69-857e-4975-99e1-86ca8b8e92d5" alt=""><figcaption><p>MEDprofiles binary file selection</p></figcaption></figure>

Once a binary file is selected, click 'open MEDprofiles Viewer' to access the data viewer:

<figure><img src="https://4288370141-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUO0RN9PzFLqAgLEwwaSn%2Fuploads%2FJzaN4MpAao4xdcJH1K3h%2FMEDprofilesBinaryFileSelected.PNG?alt=media&#x26;token=41edb46b-67a0-422b-be93-b45759e08d9d" alt=""><figcaption><p>Visualize you MEDprofiles data</p></figcaption></figure>

{% hint style="warning" %}
If either of the two elements (MEDclasses folder and/or MEDprofiles binary file) doesn't contain elements to select, ensure that the previous steps have been completed successfully.
{% endhint %}

Check out the next page to learn more about the MEDprofiles viewer!

{% content-ref url="medprofiles/medprofiles-viewer" %}
[medprofiles-viewer](https://medomicslab.gitbook.io/medomics-docs/tutorials/design/input-module/medprofiles/medprofiles-viewer)
{% endcontent-ref %}
