Getting Familiar With BioJulia: BioInformatics for Julia | by Emmett Boudreau | Towards Data Science

Julia is a great programming language that is typically associated with its strong statistical analysis and machine-learning capabilities. However, many people might know that Julia actually has a fairly mature and established group of packages for other applied sciences. Some notable examples include Yao.jl for quantum simulations, JuliaAstro.jl for astronomy (I really want to check this one out, as well) quantitative economics with QuantEcon.jl, and even quantum physics with QuantumBFS.jl and QuantumOptics.jl. With this rich ecosystem for scientific computing with Julia, it’s easy to see why many scientists are Julians either by hobby or work.
This package ecosystem has piqued my interest, so I have decided to dive in to one of them with all of the free time I have had lately due to the virus. It is a great time to do something productive like learn a new applied science with my favorite programming language, after-all; as I see that as being rather productive. Also maybe this is the most optimal of times to learn more about biology and genome sequencing. To be clear, I do not have any domain knowledge in the field of Bioinformatics, but I am seeking to get a foothold in it that I can improve over time with practice and research. I am also interested to see how I might be able to apply machine learning and statistics to Biology with Julia, and cross two applied sciences that I am very interested in.
In order to use BioJulia’s packages, we of course will need to add them. For my selection, I pretty much went to BioJulia’s Github and picked some repositories that sounded interesting. What I didn’t realize in my approach is that BioJulia actually has its own package registry. Rather than adding the packages individually through the Pkg REPL and Github, I decided that the registry is certainly the way to go. From the Pkg REPL, we can add the BioJulia registry with this command:
registry add https://github.com/BioJulia/BioJuliaRegistry.git
Then I was able to add my packages exactly how I normally would. These are the packages that piqued my interest:
BioSequences.jl
GenomeGraphs.jl
BioSymbols.jl
However, this experience ended up being a little less like me adding packages I know nothing about, and a little more like a kid in a candy shop... I also decided to pick up XAM.jl and BigBed.jl. We will also need BioCore.jl, and I went ahead and picked up BioGenerics.jl (not sure if I needed it or not.) By the end of it, I had a pretty large group of Github pages opened up. Fortunately, I have the experimental tab-grouping enabled on my Google Chrome.
I love that feature.
pkg> add BioCorepkg> add BioSymbolspkg> add GenomeGraphspkg> add BioGenericspkg> add BigBedpkg> add BioSequencespkg> add XAM
Surprisingly, my list of packages still doesn’t look too bad!
Of course, for now I’m going to just be performing more research than a human being should be capable of, and picking one of the several packages I just added...
But I’m all in!
I stumbled across this video, if you desire to check it out:
It was really helpful in getting a good idea of where I could start learning in order to have a solid knowledge-base approaching these packages. I actually didn’t realize initially how much my machine-learning, programming, and statistics domain knowledge were going to be applying here, and I was very delighted to know that her first checkbox was entirely filled for me. To summarize she says are the five things to do when getting started with BioInformatics:
Apt abilities in a statistical programming language. (Python, R, Julia) ✔
Be familiar with Bash. ✔
Be able to read data into your programming language of choice. ✔
Be able to perform basic statistical tests (e.g. T-test, chi2 test, F-test) ✔
Find some interesting data and read it into your choice of programming language.
Visualize the data with a plotting library.
Here is the website she suggested for obtaining data:
genome.ucsc.edu
The importance of understanding the data collected was stressed.
She also suggested machine-learning — I am a happy young man on this day. I don’t think I realized how much BioInformatics and machine-learning go together.
(I kind of already did this, I like safaris)
Find the industry standard tools associated with what you want to do prior to doing it.
Once you get more experience, branch out and even try creating your own tools.
So after watching this quick introduction, I decided my next best move would be to start my first project.
For my first BioInformatics project, I decided to browse that UCSC site mentioned earlier for data. Not only does the site have a lot of data, but also a lot of great ways to view said data! Today I will just be getting the data read in, but in the future I will be exploring it, visualizing and testing with it, and maybe I can even find some machine-learning uses for it that are practical.
I was able to wget some Pangolin data I thought looked cool off of this website. To do so was a little strange, as you’re brought to an html page with no styling with 30 minutes of talking about how to get a file with wget... It was certainly weird, and made finding the ftp:// or http:// link really difficult. Here is the one that I ended up using:
wget --timestamping         'ftp://hgdownload.cse.ucsc.edu/goldenPath/manPen1/bigZips/*'
Funny story, my 512GB NVME drive is very low on storage because I am a data-hoarder, so I was pretty scared that I might top off the rest of my SSD with this data and need to go around cleaning. You know what I really need?
NAS.
Here are the files I collected from the repository with wget:
Now I’m going to create a notebook server in this directory.
cd ~/Projects/bioprojectjupyter-notebook
This is an overwhelming amount of data, so the first one that I decided to go about trying to get into Julia is manPen1.2bit. This is because while I don’t know exactly how to read this data into Julia, I know I have a package that can do so. There is a 2bit reader inside of BioSequences.jl, and you can find the documentation here:
biojulia.net
BioSequences.jl has a type stored in a sub-module called TwoBit. However, I ran into an issue when I tried to import it...
“ TwoBit is not defined”
With this in mind, I decided to check what version of BioSequences.jl I had:
On the left-hand side of that documentation page, I changed the version to the proper version that is actually on my computer, then searched for TwoBit. This revealed that the package was no longer a sub-module, but has become its own package, so I’ll have to add it:
pkg> add TwoBit
Now we can import it into Julia and create our reader:
using TwoBitreader = TwoBit.Reader(open("manPen1.2bit", "r"))
Now we can view the genome sequences we just read in using the seqnames() method on our reader:
sequences = TwoBit.seqnames(reader)
And now we have BioData!
That was rather fun! I am incredibly excited to see all of the genomics I will be able to experiment with in Julia. Though I certainly have a long way to go, I think that some practice and reiteration will get me to the point where I can start machine-learning with nucleotides and DNA. Though this is certainly not my domain of knowledge or area of skill, I really think I am going to enjoy genomics as I am rather fond of biology to begin with.
My next step is to try visualizing the data and drawing conclusions from it. Going into this I really didn’t realize how similar this was going to be to what I do every day. I am thankful that it is, and also incredibly excited to learn more. I ordered some books on Amazon that might help me to learn some of this overwhelming amount of information, but for now, I would just like to get familiar with the tools and data formats associated with genomics.