Machine learning is a method of training machines to make predictions based on experience. It uses an algorithm that iteratively learns from data and keeps getting better with additional data. These models can be effectively used to determine the effect of various variables and relationship between them. Machine learning is now being increasingly used in the field of science.
In this article, I demonstrate the use of machine learning in predicting the 1 year outcome of patients on the basis of their echocardiogram parameters. The dataset was taken from the UCI database. This data has the echocardiogram of 132 patients. Due to missing data, 60 patient observations were used.
I will be using several alternate machine learning models and presenting the confusion matrix of them. Confusion matrix is a 2X2 table with the comparison of predicted and actual values.
In this part, we will remove the rows which contain missing data. We will not be imputing the missing values since it may effect out model. We will remove the variables that will not be useful for our study. The column “aliveat1”, which denotes if the patient is alive at 1 year will be turned in to a factor. This will be our dependent variable which we will try to predict with out model on the basis of the echocardiogram paramaters.
In this example, we are trying to predict whether the patient will be alive at 1 year, given the set of echocardiogram parameters. In other words, we are trying to classify the patient as either alive (1) or dead (0). This is a classical Machine learning classification problem and several algorithms may be used to solve it. Here we have used decision tree, Naive bayes, Support Vector Machines (SVM) and Random forest. With larger datasets, we will be able to compare these models based on their Confusion matrix scores.
Note: If there is any error in the installation, install unmet dependencies, as per in the error message.
Files to be downloaded
In this paper the reference genome is the Human X chromosome. Only X chromosome is being used as a reference genome in order to reduce the download and analysis time. The user may also use the entire genome of the relevant organism. The reference genome may also be downloaded from the Hisat2 website since it is provided in a pre-indexed format.This link contains the reference genome as well as the sample fastq files. The following workflow includes files from the above archive. The data may be replaced with the relevant data as well.
HISAT2: Alignment of RNA-Seq reads to the genome
Map the reads from each sample to the reference genome:
The explanation for each part of the command is as follows:
hisat2: calls the hisat2 program. This will work only if the hisat2 folder has been added to the PATH properly
-p 8: “-p” specifies how many threads should be allocated to the command. Here, 8 threads have been allocated. Should always be equal or less than the available threads on the system
-dta: reports alignments tailored for transcript assemblers
-x: Name (or path to name) after this will the hisat2 index file
chrX_data/indexes/chrX_tran: Path to the index files. “chrX_tran” is the common name of all the reference file in the index folder. e.g., the files in the folder are chrX_tran.1.ht2, chrX_tran.2.ht2, chrX_tran.3.ht2, etc
–1: Has to be put before the forward read of the sample
chrX_data/samples/ERR188044_chrX_1.fastq.gz: Forward read of sample
-2: Has to be put before the reverse read of the sample
chrX_data/samples/ERR188044_chrX_2.fastq.gz: Reverse read of sample
-S: Default sam output
ERR188044_chrX.sam: File for SAM output
Likewise, the same commands have to be issued for all the input files, as follows:
Stringtie: Assemble and quantify expressed genes and transcripts
As per the Stringtie website:
“StringTie is a fast and highly efficient assembler of RNA-Seq alignments into potential transcripts. It uses a novel network flow algorithm as well as an optional de novo assembly step to assemble and quantitate full-length transcripts representing multiple splice variants for each gene locus. Its input can include not only the alignments of raw reads used by other transcript assemblers, but also alignments longer sequences that have been assembled from those reads.In order to identify differentially expressed genes between experiments, StringTie’s output can be processed by specialized software like Ballgown, Cuffdiff or other programs (DESeq2, edgeR, etc.)”
Here, stringtie creates a file “stringtie_merged.gtf” using the “mergelist.txt” file. “mergelist.txt” has the list of all the sample.gtf files. Sample.gtf files were generated in the previous step by the “–merge” argument. Paths are necessary if the gtf files are not in the working directory. “mergelist.txt” looks like this in our experiment:
You should also have a phenotype file in csv format which specifies information about your sample. The example data includes a phenotype file (geuvadis_phenodata.csv) with the following content:
Since we already have the expression values of various genes for these samples, we will be using R to see which genes are differentially regulated based on several parameters. Here we may choose to compare them on the basis of “population” or “sex”.
pheno_data <- read.csv("geuvadis_phenodata.csv")
Next, we read in the expression data that has been calculated by StringTie
Finding genes with significantly different expression
Here we identify transcripts that have statistically significant difference in expression between groups. Here we see if there is an expression difference on the basis of sex. We can do so using stattest function of Ballgown.
We use “getFC=TRUE” parameter so that we can look at the confounder-adjusted fold change between the two groups.
Next we identity genes which show statistical significant difference groups
Identify genes that show statistically significant differences between groups. For this we can run the same function that we used to identify differentially expressed transcripts, but here we set feature=”gene” in the stattest command: