BioKlustering: a web app for semi-supervised learning of maximally imbalanced genomic data

Summary: Accurate phenotype prediction from genomic sequences is a highly coveted task in biological and medical research. While machine-learning holds the key to accurate prediction in a variety of fields, the complexity of biological data can render many methodologies inapplicable. We introduce BioKlustering, a user-friendly open-source and publicly available web app for unsupervised and semi-supervised learning specialized for cases when sequence alignment and/or experimental phenotyping of all classes are not possible. Among its main advantages, BioKlustering 1) allows for maximally imbalanced settings of partially observed labels including cases when only one class is observed, which is currently prohibited in most semi-supervised methods, 2) takes unaligned sequences as input and thus, allows learning for widely diverse sequences (impossible to align) such as virus and bacteria, 3) is easy to use for anyone with little or no programming expertise, and 4) works well with small sample sizes. Availability and Implementation: BioKlustering (https://bioklustering.wid.wisc.edu) is a freely available web app implemented with Django, a Python-based framework, with all major browsers supported. The web app does not need any installation, and it is publicly available and open-source (https://github.com/solislemuslab/bioklustering).


Introduction
Background. The accurate prediction of biological features from genomic data is paramount for precision medicine, sustainable agriculture and climate change research. Yet some characteristics of big biological data render most out-of-the-box methodologies inaccurate or inapplicable. In particular, here we focus on 1) the high complexity (and sometimes impossibility) to align genomic sequences for certain organisms, and 2) the difficulty to obtain labeled samples to use in supervised learning.
First, while the growing interest of the biological community in machine-learning methods is undeniable, many existing methods [1, 2, 3, 4, 5, 6, e.g.] need DNA or RNA alignments as input. Fast evolving organisms like virus or bacteria -especially when big sample sizes are neededmuddle the alignment process with their heterogeneity and genomic diversity to the point that aligning the sequences becomes extremely challenging or impossible [7,8].
Second, supervised learning models are the most accurate options for phenotype prediction. However, these methods rely on large samples of labeled data. In reality, many biological experiments produce partially observed labels given the money and time constraints to phenotype organisms or strains. One example that motivated our work is the case of mycovirus. Mycoviruses infect fungi and can be used as biocontrol of crop pests given that they induce hypovirulence on plant fungal pathogens. Not all mycoviruses cause hypovirulence in the fungal host, and thus, a standard mycovirus dataset will be partially labeled with some labeled sequences that have been tested in planta for their hypovirulence potential, and many more unlabeled sequences that have never been tested in laboratory, and thus, have unknown hypovirulence potential.
Semi-supervised methods [9, 10] allow for partially observed labels, but existing methods require that we observe labels for all classes -albeit in smaller frequencies than the unobserved labels. This condition is not met in the mycovirus dataset, for example, where negative controls (class of mycoviruses that do not cause host hypovirulence) are not available as observed labels only correspond to mycoviruses tested in the lab for their hypovirulence-induced potential. Thus, the use of most semi-supervised methods is prohibited for this maximally imbalanced dataset.
Main contributions. We present BioKlustering (https: //bioklustering.wid.wisc.edu) a user-friendly open-source web app to cluster unaligned genomic sequences based on maximally imbalanced partially observed labels. Unlike most semi-supervised learning methods, our web app does not require all classes to be observed or has any requirements on class balance. Also, unlike most machine-learning methods, our web app does not require large sample sizes. While designed for a semisupervised setup, our web app can also be used when no labels are measured (unsupervised case).
One of the main purposes of our web app is to allow easy and fast clustering of sequences that could inform future biological experiments. Indeed, we see our web app as a hypothesis-generating tool that will allow biological users, for example, to identify clusters of mycovirus sequences that could be either negative controls (from the unobserved class of mycovirus that do not serve as biocontrol and that have never been tested in planta) or new mycovirus sequences that could serve as biocontrol for further experimentation.
We highlight that even when our work is visualizationdriven, not inferential, we believe that it fills a important gap for biological scientists who need to identify similar sequences for experiments when sequence alignment is prohibited and when in vitro or in planta phenotyping of all labels is not possible.

Methods
Input data. Sequences are input as FASTA files and are internally converted to kmer counts. For example, if a sequence is "ACTGG", then its 3-mers are ["ACT", "CTG", "TGG"]. The user can select the length of the kmer and sequences can be aligned or unaligned. Labels are input as an optional separate csv file. The matching is done by assuming that the rows in both files are in the same order. The labels file should assign a value of −1 to the sequences of unknown label.
Models. We implement three unsupervised clustering methods which are extended to the case of partially observed labels by internally optimizing the kmer length and other parameters until we reach maximum consensus with the observed labels.
K-means clustering. The algorithm [11] groups the data into K clusters each formed around a centroid. Each data point is assigned to the nearest centroid, and these centroids are formed by minimizing the squared Euclidian distances within each cluster. The mean shift algorithm is used to identity locations of high density within the kmer space of the data, and then the unsupervised k-means model is run with these locations as the initial centroid coordinates. Parameters of this model include the minimum and maximum kmer length, the random seed, and the number of clusters. Since the mean-shift algorithm does not allow an input number of clusters, when the number of clusters predicted by mean-shift exceeds the number of clusters requested, Algorithm 1 (Appendix) is used to assign output labels.
The unsupervised k-means model can incorporate known labels to create an effective semi-supervised model. The mean shift algorithm is again used to identity locations of high density within the kmer space of the data, and then the unsupervised k-means model is run with these locations as the initial centroid coordinates. Known labels are then compared against predicted labels and these clusters are reassigned into groups that minimize the prediction error.
Gaussian Mixture Model. The algorithm fits a probabilistic model [12] that estimates the underlying multiple Gaussian distributions that best describe the clusters in the data. Starting with a random initialization model parameters, the Expectation-Maximization algorithm runs iteratively until convergence. Parameters of this model include the minimum and maximum kmer length, the random seed, the number of classes, and the covariance type (which determines the shape of the clusters).
The semi-supervised GMM differs from a unsupervised one in the initialization and parameter selection process. A semi-supervised GMM starts with initializing means of the known data by their actual means and the rest with random numbers. A parameter selection process is implemented to compare models with different parameter combinations (kmer length and four covariance types), and the model with high accuracy calculated from known labels will be returned. Finally, for the semi-supervised case only, we use Algorithm 2 (Appendix) to assign output labels from running the GMM to the input labels.
Spectral clustering. This algorithm [13] exploits the potential of eigenvalues of the matrix derived from the input data. In spectral clustering, the input data will be treated as a graph, and each sequence will represent a vertex in the graph. Then, the vertices in the graph will be partitioned based on their similarities. Parameters of this model are the minimum and maximum kmer length, the random seed, the number of classes, and the manner in which we assign labels when the input is projected to a lower dimension space (denoted label assignment option).
The semi-supervised version of spectral clustering will find the optimal parameter values (kmer length and label assignment option) that maximizes the predictive accuracy of the observed labels. We again use Algorithm 2 (Appendix) to assign output labels from running the spectral clustering algorithm to the input labels.
For all three algorithms, the predicted labels and embedded kmer data can be used to visualize the clusters using principle component analysis (PCA) or t-distributed stochastic neighbor embedding (t-SNE).

Validation with Influenza data
We test our three semi-supervised algorithms with Influenza data from two classes: bats and cats [14]. We run four settings: totally unsupervised, semi-supervised with 50% of observed labels (both classes observed), semisupervised with 10% observed labels (both classes observed) and semi-supervised with 10% observed labels (only one class observed).

Web app interface
BioKlustering is an open-source web application developed with Django, a Python-based framework ( Figure   1). The users will be able to predict clusters in genomic data by 1) uploading FASTA files with (aligned/unaligned) genome sequences, 2) selecting a clustering algorithm, and 3) choosing in its corresponding parameters.
BioKlustering provides semi-supervised and unsupervised options depending on the presence of known labels. For each algorithm, the web app presents a description to aid users in the choice of parameters. The selected algorithm will generate prediction results which include an interactive plot (

Validation with Influenza data
We downloaded 64 unaligned nucleotide sequences for bat Influenza virus with lengths between 844 and 2339 bp and 114 unaligned nucleotide sequences for cat Influenza virus with lengths between 538 and 2341 bp from the NCBI database [14]. We use the whole dataset as training given the small sample size.
For this data, we have the labels for all sequences, but we run our learning algorithms under four settings: 1) unsupervised (ignored all labels), 2) semi-supervised with 50% of observed labels randomly selected, 3) semi-supervised with 10% of observed labels randomly selected, and 4) semi-supervised with 10% of observed labels from one class only. Out of the 50% observed labels, 36% of them correspond to the class of bats and 64% to the class of cats. Out of the 10% observed labels, 41% of them correspond to the class of bats and 59% to the class of cats when both classes are observed, and 100% correspond to the class of bats when only one class is observed. For the k-means method, the chosen parameters that maximize the agreement with the observed labels are k min = 5, k max = 7 in all four cases.
For the GMM method, the chosen parameters that maximize the agreement with the observed labels are • k min = 2, k max = 6 with covariance type as "full" for the unsupervised case, • k min = 4, k max = 5 with covariance type as "diagonal" for the semi-supervised case with 10% labels observed (both classes), • k min = 2, k max = 5 with covariance type as "full" for semi-supervised case with 10% observed labels (only 0's), • k min = 3, k max = 4 with covariance type as "tied" for the semi-supervised case with 50% labels observed.
For the spectral clustering, the chosen parameters that maximize the agreement with the observed labels are • k min = 2, k max = 3 with k-means label assign option for the unsupervised case, • k min = k max = 3 with discretize label assign option for the semi-supervised case with 10% labels observed (both classes), • k min = k max = 2 and label assign option as discretize for when only 0's are observed, • there were two setups with the same accuracy for the semi-supervised case with 50% observed labels: k min = k max = 2 with k-means label assign option and k min = 3, k max = 5 with discretize label assign option.
In all cases, the true number of classes is selected (2) and we do not test the performance when the number of clusters is not known in advance. Table 2 shows the prediction accuracy of the three clustering methods comparing only the observed labels. Even when we always return the observed labels, they are used internally to modify the parameters to maximize agreement between predicted labels and observed labels.
Finally, Figure 2 shows the clustering visualization via PCA of the spectral clustering (top), the k-means clustering (middle), and the GMM clustering (bottom).  There are three settings per method: unsupervised (no labels observed), semi-supervised with 10% labels observed (both classes or only one class observed) and semisupervised with 50% labels observed. Color represents predicted labels: green for bats (label 0) and blue for cats (label 1). Point shapes represent true labels: circle for bats (label 0) and triangle for cats (label 1). Green circles or blue triangles correspond to correctly predicted labels, while green triangles and blue circles correspond to wrongly estimated labels.