Apache Spark SQL & Machine Learning on Genetic Variant Classifications

Introduction

Covid-19 has driven up the interest of the bioinformatics, the data science of collecting and analyzing complex biological data such as genetic codes and sequences, a combination of mathematics and biology.

Context

ClinVar is a public resource containing annotations about human genetic variants. Detail can be found on the National Institute of Health website.

https://www.ncbi.nlm.nih.gov/clinvar/

These variants are usually manually classified by clinical laboratories on a categorical spectrum ranging from benign, likely benign, uncertain significance, likely pathogenic, and pathogenic. Variants that have conflicting classifications (from laboratory to laboratory) can cause confusion when clinicians or researchers try to interpret whether the variant has an impact on the disease of a given patient.

Objective

The objective is to predict whether a ClinVar variant will have conflicting classifications. This is presented as a binary classification problem, each record in the dataset is a genetic variant.

Conflicting classifications are when two of any of the following three categories are present for one variant, two submissions of one category are not considered conflicting.

· Likely Benign or Benign

· VUS (Variance of Uncertain Significance. A variation in a genetic sequence for which the association with disease risk is unclear)

· Likely Pathogenic or Pathogenic

Class Label

Conflicting classification has been assigned to the CLASS column. It is a binary representation of whether or not a variant has conflicting classifications, where 0 represents consistent classifications and 1 represents conflicting classifications.

The genetic variant dataset is public domain available from Kaggle

https://www.kaggle.com/kevinarvai/clinvar-conflicting

ML Project Steps

Data Acquisition

Download the csv file from Kaggle, place into a folder on Apache Spark driver node:

https://www.kaggle.com/kevinarvai/clinvar-conflicting?select=clinvar_conflicting.csv

Load the csv file into Spark SQL DataFrame

Data Exploration:

Notice there are lots missing values, i.e., null values in the dataset. Dataset having significant missing values usually affect training and prediction accuracy.

Some column values are large, like 6 digits, some column values are smaller than 1. Without addressing, this can confuse ML algorithm, which may regard some small values as statistically insignificant and disregard as result. This can be addressed in the data preprocessing using scaler. I plan to use MinMaxScaler, which will make all feature column values between 0 and 1

Evaluate schema:

The DataFrame has 46 columns, with one column CLASS as target/label and 45 columns as features.

Some of them are String data types, which need to be encoded into numeric datatype for ML algorithm to crunching them.

Distribution of row count of CLASS 1 (genetically conflicting) and 0 (genetically consistent) as following:

Data Preprocessing

NULL replacement

Replace null values in the String columns as “ABCD” and 0 in numeric columns

Encode the String value to integer using StringIndexer

Rearrange the DataFrame, after encoding, the first column of the resultant DataFrame is CLASS, the label.

Make all integer column to double

Feature Vectorization

Apache Spark ML requires to place feature data to be in form of vector, i.e., place all feature columns into one vector, following code is to generate a column that is a vector that contains all feature columns

Extract from output DataFrame into a new DataFrame, that only contains vector column features and label column CLASS

Normalize feature values in vector column features, using MinMax Scaler

Train/Test Split, randomly split 70% of rows for training, 30% for test

Training and Prediction

Algorithm Selection

Since this is a binary classification, I plan to use Multilayer Perceptron Classifier and Logistic Regression.

Multilayer Perceptron Classifier, there are 45 feature columns, and binary classification, I construct a neural network of 4 layer as below:

Train and test the neural network

Logistic Regression Classifier

Take away:

Both Mutilayer Perceptron Classifier and Logistic Regression produce same prediction accuracy about 75% given the dataset having significant amount missing values (null values). To improve machine learning performance, reduce missing values and possible adding additional feature columns may help.

As always, code used in this writing is in my GitHub Repo:

https://github.com/geyungjen/jentekllc

Thank you for your time viewing this writing.

Last updated

Was this helpful?