Package: virhunter
VirHunterVirHunteris a deep learning method that uses Convolutional Neural Networks (CNNs) and a Random Forest Classifier to identify viruses in sequening datasets. More precisely, VirHunter classifies previously assembled contigs as viral, host and bacterial (contamination).System RequirementsVirHunter installation requires a Unix environment withpython 3.8.
It was tested on Linux and macOS operating systems.
For now, VirHunter is still not fully compatible with M1 chip MacBook.In order to run VirHunter your installation should include conda.
If you are installing it for the first time, we suggest you to use
a lightweightminiconda.
Otherwise, you can use pip for the dependencies' installation.InstallationThe full installation process should take less than 15 minutes on a standard computer.Then clone the repository fromgithubgitclonehttps://github.com/cbib/virhunter.gitGo to the VirHunter root foldercdvirhunter/Installing dependencies with CondaFirst, you have to create the environment from theenvs/environment.ymlfile.
The installation may take around 500 Mb of drive space.condaenvcreate-fenvs/environment.ymlSecond, activate the environment:condaactivatevirhunterInstalling dependencies with pipIf you don't have Conda installed in your system, you can install python dependencies via pip program:pipinstall-renvs/requirements.txtThen if you have macOS you will need to installwgetlibrary to run some scripts (Conda installation already has it). You can do this withbrewpackage manager.brewinstallwgetTesting installation of the VirHunterYou can test that VirHunter was successfully installed on the toy dataset we provide.
IMPORTANT: the toy dataset is intended only to test the correct work of VirHunter.
The trained modules should not be used for prediction on your datasets!First, you have to download the toy datasetbashscripts/download_test_installation.shThen launch the script for testing training and prediction python scripts of VirHunterbashscripts/test_installation.shUsing VirHunter for predictionVirHunter takes as input a fasta file with contigs and outputs a prediction for each contig to be viral, host (plant) or bacterial.For given contigs VirHunter produces a tab delimited csv file with prediction.idstores the fasta header of a contig,lengthdescribes the length of the contig. Columnsvirus,plantandbacteriastore the number of fragments of the contig
that received corresponding prediction by the RF classifier. Finally, columndecisiontell you about the final decision for a given contig.
You should refer to it, when filtering viral contigs.To do predictions VirHunter needs to be fully trained for fragment sizes 500 and 1000. VirHunter will discard from prediction
contigs shorter than 500 bp. VirHunter trained on 500 fragment size will be used for contigs with750 < length < 1500. The VirHunter
trained on fragment size 1500 will be used for contigs longer than 1500 bp.Before running VirHunter you have to fill in thepredict_config.yamlfile.To run VirHunter you can use the already pre-trained models. Provided are fully trained models for 3 host species  (peach, grapevine, sugar beet) and
for fragment sizes 500 and 1000. Weights for these models can be downloaded by running thedownload_weights.shscript:bashscripts/download_weights.shOnce the weights are downloaded, if you want for example to use the weights of the model trained on peach,
you should add in theconfigs/predict_config.yamlpathsweights/peach/1000andweights/peach/500.The command to run predictions is then:pythonvirhunter/predict.pyconfigs/predict_config.yamlTraining your own modelYou can train your own model, for example for a specific host species. Before training, you need to collect sequence
data for training for three reference datasets:viruses,bacteriaandhost.
Examples are provided by runningscripts/download_test_installation.shthat will downloadviruses.fasta,host.fastaandbacteria.fastafiles (real reference datasets should correspond
e.g. to the whole genome of the host, all bacteria and all viruses from the NCBI).Training requires execution of the following steps:prepare the training dataset for the neural network module from fasta files withprepare_ds_nn.py.
This step splits the reference datasets into fragments of fixed size (specified in theconfig.yamlfile, see below)prepare the training dataset for Random Forest classifier module withprepare_ds_rf.pytrain the neural network module withtrain_nn.pytrain the Random Forest module withtrain_rf.pyThe successful training of VirHunter produces weights for the three neural networks from the first module and weights for the
trained Random Forest classifier. They can be subsequently used for prediction.To execute the steps of the training you must first fill in thetrain_config.yaml. This file already contains information on all expected inputs.
Oncetrain_config.yamlis filled you can launch the scripts consecutively providing them with the config file like this:pythonvirhunter/prepare_ds_nn.pyconfigs/train_config.yamlVirHunter on GPUIf you plan to train VirHunter on GPU, please useenvironment_gpu.ymlorrequirements_gpu.txtfor dependencies installation.
Those recipes were tested only on the Linux cluster with multiple GPUs.
If you plan to train VirHunter on cluster with multiple GPUs, you will need to uncomment line withCUDA_VISIBLE_DEVICESvariable and replace""with"N"in header oftrain_nn.py, where N is the number of GPU you want to use.importosos.environ["CUDA_VISIBLE_DEVICES"]="N"