Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
592 changes: 592 additions & 0 deletions scripts/oncotree_to_oncotree.py

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions scripts/ontology_to_ontology_mapping_tool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Ontology to Ontology Mapping Tool

The Ontology Mapping tool was developed to facilitate the mapping between different cancer classification systems. We currently support mapping between OncoTree, ICD-O, NCIt, UMLS and HemeOnc systems.

### Prerequisites
The Ontology Mapping tool runs on python 3 and requires `pandas` and `requests` libraries. These libraries can be installed using
```
pip3 install pandas
pip3 install requests
```

### Running the tool

The tool can be run with the following command:
```
python <path/to/scripts/ontology_to_ontology_mapping_tool.py> --source-file <path/to/source/file> --target-file <path/to/target/file> --source-code <source_ontology_code> --target-code <target_ontology_code>
```

**Options**
```
-i | --source-file: This is the source file path. The source file must contain one of the ONCOTREE_CODE, NCIT_CODE, UMLS_CODE, ICDO_TOPOGRAPHY_CODE, ICDO_MORPHOLOGY_CODE or HEMEONC_CODE in the file header and it must contain codes corresponding to the Ontology System.
-o | --target-file: This is the path to the target file that will be generated. It will contain ontologies mapped from source code in <source-file> to <target-code>.
-s | --source-code: This is the source ontology code in <source-file>. It must be one of the ONCOTREE_CODE, NCIT_CODE, UMLS_CODE, ICDO_TOPOGRAPHY_CODE, ICDO_MORPHOLOGY_CODE or HEMEONC_CODE.
-t | --target-code: This is the target ontology code that the script will attempt to map the source file ontology code to. It must be one of the ONCOTREE_CODE, NCIT_CODE, UMLS_CODE, ICDO_TOPOGRAPHY_CODE, ICDO_MORPHOLOGY_CODE or HEMEONC_CODE.
```

**Note**
- The source file should be tab delimited and should contain one of the ontology: ONCOTREE_CODE, NCIT_CODE, UMLS_CODE, ICDO_TOPOGRAPHY_CODE, ICDO_MORPHOLOGY_CODE or HEMEONC_CODE in the file header.
- We currently are allowing only one ontology to another ontology mapping. In the future, we plan to extend the tool to support mapping to multiple ontology systems.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Ontology to Ontology Mapping Tool

This tool helps compare existing OncoTree mapped ontologies against a reference OncoTree Codes file, and gives an output file named "missing_oncotree_codes.xlsx" that consist of a list of OncoTree codes that are missing from the inputted file. In order to use this tool, you must:
1. Download the 'refrence_oncotree_codes.xlsx' file
2. Input an excel file that consists of OncoTree codes in column 1 and other ontology codes (UMLS, NCIT, SNOMED, ICDO Topography, HEMEONC, or ICDO Morphology) in the other columns.

This tool MUST consist of OncoTree codes in column 1 to compare the two files. The output file will only give OncoTree codes that are missing from the file you inputted.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pandas as pd
import os

file_a = pd.read_excel("reference_oncotree_codes.xlsx")
oncotree_codes_a = file_a.iloc[:, 0].dropna()

while True:
file_b = input("Enter name of the file in an Excel format ('.xlsx')")
if '.xlsx' not in file_b:
print("You forgot to add '.xlsx'. Please try again and add the required '.xlsx'.")
elif '.xlsx' in file_b:
if os.path.exists(file_b):
file_b = pd.read_excel(file_b)
file_b = file_b.astype(str)
file_b.replace({'': pd.NA}, inplace=True)
oncotree_codes_b = file_b.iloc[:, 0].dropna()

missing_codes = oncotree_codes_a[~oncotree_codes_a.isin(oncotree_codes_b)]

print("The following OncoTree codes from File A are NOT found in File B:")
for code in missing_codes:
print("-", code)


output_df = missing_codes
output_file_path = "missing_oncotree_codes.xlsx"
output_df.to_excel(output_file_path, index=False)
else:
print("This file does not exist in your folders. Try transferring the excel file into the same folder as where this code is in")
Loading
Loading