Skip to content

Commit

Permalink
vcf2maf and maf2maf python tools (#51)
Browse files Browse the repository at this point in the history
* split standardize_mutation_data.py to vcf2maf and maf2maf tools
* update requirements

---------

Co-authored-by: Madupuri <[email protected]>
  • Loading branch information
rmadupuri and Madupuri authored Apr 24, 2023
1 parent 45ab327 commit 247b08f
Show file tree
Hide file tree
Showing 6 changed files with 2,311 additions and 1,662 deletions.
44 changes: 40 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Usage:

```
bash import-scripts/annotation_suite/annotation_suite_wrapper.sh
bash annotation_suite_wrapper.sh
-i | --input-directory input data directory for processing mutation data files
-o | --output-directory output directory to write processed and annotated mutation data files to
Expand All @@ -19,7 +19,7 @@ bash import-scripts/annotation_suite/annotation_suite_wrapper.sh

**Output Directory** ( `-o | --output-directory` ) : This is the output directory where the processed (standardized) MAFs and annotated MAFs will be written. Sub-directories within the output directory will hold the standardized MAFs and annotated MAFs. These sub-directories will be created if they do not already exist. Any existing files within the output-directory and subdirectories will be deleted when this script is run.

The standardized MAFs generated by `standardize_mutation_data.py` will be written to `${OUTPUT_DATA_DIRECTORY}/processed`. The annotated MAFs from running the Genome Nexus annotation pipeline will be written to `${OUTPUT_DATA_DIRECTORY}/annotated`.
The standardized MAFs generated by `vcf2maf.py` and `maf2maf.py` will be written to `${OUTPUT_DATA_DIRECTORY}/processed`. The annotated MAFs from running the Genome Nexus annotation pipeline will be written to `${OUTPUT_DATA_DIRECTORY}/annotated`.

**Merged Mutation File** ( `-m | --merged-mutation-file` ) : This is the filepath of the final (standardized and annotated) MAF. The annotation suite wrapper will call `merge_mafs.py` with the argument ` --input-mafs-directory` that points to an input directory containing the annotated MAF(s) - within the scope of the annotation suite, this input directory will be `${OUTPUT_DATA_DIRECTORY}/annotated`.

Expand All @@ -30,7 +30,8 @@ The standardized MAFs generated by `standardize_mutation_data.py` will be writte
**Annotation Suite Scripts Directory** ( ` -p | --annotation-scripts-home` ) : needs to point to the directory where the packaged Genome Nexus Annotation Pipeline JAR and annotation suite python scripts and data files are located:

- merge_mafs.py (located in this repository)
- standardize_mutation_data.py (located in this repository)
- vcf2maf.py (located in this repository)
- maf2maf.py (located in this repository)
- annotator.jar - The genome nexus annotation pipeline (See how to build the jar file [here](https://github.com/genome-nexus/genome-nexus-annotation-pipeline))
- application.properties (optional) - custom properties for the annotation pipeline. The common use case is to specify custom genome nexus url with `genomenexus.base` property.
- AwsSsl.truststore - custom trust store. Used to hold an ssl certificate (aka HTTPS certificate) of trusted websites. In our case the trust store holds certificates of custom genome nexus instance. See how to create trust store and upload the certificate [here](#create-a-trust-store).
Expand Down Expand Up @@ -88,4 +89,39 @@ The MAF merging script supports two different input arguments for merging MAFs:

### Germline files

If "germline" is in the filename then `standardize_mutation_data.py` will assume that the file contains germline data. This will set the value in the output MAF `Mutation_Status` column to "GERMLINE". Please follow this naming convention if the mutation data file(s) are germline data.
If "germline" is in the filename then `vcf2maf.py` and `maf2maf.py` will assume that the file contains germline data. This will set the value in the output MAF `Mutation_Status` column to "GERMLINE". Please follow this naming convention if the mutation data file(s) are germline data.

## VCF to MAF Conversion Tool

[VCF](https://samtools.github.io/hts-specs/VCFv4.2.pdf) is a standard text file format for storing variation data. It contains meta-information lines, a header line, and then data lines each containing information about a position in the genome.

[Mutation Annotation Format](https://software.broadinstitute.org/software/igv/MutationAnnotationFormat) (MAF) is a tab-delimited text file with aggregated mutation information from VCF Files.

`vcf2maf.py` can be used as a standalone tool to convert a VCF file to a Mutation Annotation Format (MAF) file.

Usage:

```
python3 vcf2maf.py --help
-i | --input-data A list of .vcf files or input data directories, separated by commas [required]
-o | --output-directory output data directory [optional]
-c | --center name of the center (standard MAF field = 'Center') [optional]
-s | --sequence-source Sequencing source (standard MAF field = 'Sequencing_Source'), e.g., WXS or WGS [optional]
-t | --tumor-id The ID of the tumor sample utilized in the genotype columns of the VCF file. [optional]
-n | --normal-id The ID of the normal sample utilized in the genotype columns of the VCF file. [optional]
```

### Requirements
```
python 3
```
### Running the tool example
```
python3 vcf2maf.py --input-data /data/vcfs --output-directory /data/maf/ --center-name CTR --sequence-source WGS --tumor-id Tumor --normal-id Normal
```
This command converts the VCF files in /vcf folder to MAF format.
- The `--input-data` option is used to specify either a single VCF file or a directory containing multiple VCF files (separated by commas). This option supports passing multiple input files or directories at once.
- The `--output-directory` option allows you to specify the directory where the MAF files will be saved. If no output path is provided, the default output directory `vcf2maf_output` will be used in the current working directory.
- The `--tumor-id` option allows you to specify the ID of the tumor sample used in the genotype columns of the VCF file. If the option is not used, the script will automatically identify the tumor ID from either the `tumor_sample` keyword in the meta data lines or the sample columns from VCF header.
- The `--normal-id` option allows you to specify the ID of the normal sample used in the genotype columns of the VCF file. If the option is not used, the script will automatically identify the normal ID from either the `normal_sample` keyword in the meta data lines or the sample columns from VCF header.
15 changes: 10 additions & 5 deletions annotation_suite_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,11 @@ else
JAVA_SSL_ARGS="-Djavax.net.ssl.trustStore=${SSL_CERT_PATH}"
fi


PROCESSED_SUB_DIR_NAME="${OUTPUT_DATA_DIRECTORY}/processed"
ANNOTATED_SUB_DIR_NAME="${OUTPUT_DATA_DIRECTORY}/annotated"
FILE_EXTENSIONS_LIST="vcf,maf,txt" # text files are treated as MAFs to handle names like data_mutations_extended.txt

STANDARDIZE_MUTATION_DATA_SCRIPT=${ANNOTATION_SUITE_SCRIPTS_HOME}/standardize_mutation_data.py
VCF2MAF_SCRIPT=${ANNOTATION_SUITE_SCRIPTS_HOME}/vcf2maf.py
MAF2MAF_SCRIPT=${ANNOTATION_SUITE_SCRIPTS_HOME}/maf2maf.py
GENOME_NEXUS_ANNOTATOR_JAR=${ANNOTATION_SUITE_SCRIPTS_HOME}/annotator.jar
MERGE_MAFS_SCRIPT=${ANNOTATION_SUITE_SCRIPTS_HOME}/merge_mafs.py

Expand All @@ -116,9 +115,15 @@ function initAndCleanWorkingDirectory {
function standardizeMutationFilesFromDirectory {
# processed files will be written to ${OUTPUT_DATA_DIRECTORY}/processed
echo -e "\t[INFO] standardizeMutationFilesFromDirectory(), standardized mutation files from ${INPUT_DATA_DIRECTORY} will be written to ${PROCESSED_SUB_DIR_NAME}"
python3 ${STANDARDIZE_MUTATION_DATA_SCRIPT} --input-directory "${INPUT_DATA_DIRECTORY}" --output-directory "${PROCESSED_SUB_DIR_NAME}" --center ${CENTER_NAME} --sequence-source ${SEQUENCE_SOURCE} --extensions ${FILE_EXTENSIONS_LIST}
python3 ${VCF2MAF_SCRIPT} --input-data "${INPUT_DATA_DIRECTORY}" --output-directory "${PROCESSED_SUB_DIR_NAME}" --center ${CENTER_NAME} --sequence-source ${SEQUENCE_SOURCE}
if [ $? -gt 0 ] ; then
echo -e "\n[ERROR] standardizeMutationFilesFromDirectory(), error encountered while running ${VCF2MAF_SCRIPT}"
exit 1
fi

python3 ${MAF2MAF_SCRIPT} --input-data "${INPUT_DATA_DIRECTORY}" --output-directory "${PROCESSED_SUB_DIR_NAME}" --center ${CENTER_NAME} --sequence-source ${SEQUENCE_SOURCE}
if [ $? -gt 0 ] ; then
echo -e "\n[ERROR] standardizeMutationFilesFromDirectory(), error encountered while running ${STANDARDIZE_MUTATION_DATA_SCRIPT}"
echo -e "\n[ERROR] standardizeMutationFilesFromDirectory(), error encountered while running ${MAF2MAF_SCRIPT}"
exit 1
fi
}
Expand Down
Loading

0 comments on commit 247b08f

Please sign in to comment.