Installation of Giotto using Windows 10 WSL2
Microsoft recently released the Windows Subsystem for Linux 2 to facilitate the development of open source packages, many of which require a Linux base system. WSL2 allows users to install and use Linux directly in Windows 10.
1. Installation of WSL2
omg!ubuntu! provides a good tutorial to install WSL2 on Windows 10. This will cover installing WSL2, enabling WSL2, and upgrading to WSL2 if coming from a previous version. Official installation from Microsoft is also good.
2. Install a distro
Pick and install a Linux distro from the Microsoft Store. Several different distros are available, such as OpenSUSE, Pengwin, Fedora Remix, and Alpine Linux. Choose Ubuntu 20.04 LTS which is most popular and one we support. To do so, open Microsoft Store app, search for "Ubuntu 20.04", and then click the "Get" button.
While we are also in the Microsoft Store app, I recommend installing the Windows Terminal, a great alternative to Powershell and Command Prompt.
3. Setting up
3.1 First time using Ubuntu
Open the Windows Terminal app, then beside the Tab on the top, where you see the "+" icon, click on the downward arrow beside it, and select "Ubuntu". This will open a Ubuntu tab. The first time you run the distro things will seem a little slow. This is expected. the distro has to unpack and decompress all of its contents.
For some extra help, you can also check out Ubuntu on WSL2 is Generally Available, How to install Linux WSL2 on Windows 10.
3.2 Getting R and python packages
The base image is quite barebone and doesn't contain many packages. Install R (version 4.0 or version 3.6 will work).
See this tutorial: How to install R on Ubuntu 20.04. This covers the installation of 4.0. The python that comes with Ubuntu 20.04 is v3.6.
3.3 Giotto
You can next launch R to install Giotto using the Linux instructions on the native install page.
> remotes::install_github("RubD/Giotto")
> devtools::install_bitbucket("qzhudfci/smfishhmrf-r", ref="master")
Then install the python packages accordingly. The first time you use Ubuntu you may need to install matplotlib, scikit-learn, scipy, numpy, which are basic packages. This can be done using pip:
$ pip3 install --user matplotlib scipy numpy scikit-learn
Next install the other prerequisites of Giotto:
$ pip3 install --user pandas igraph networkx leidenalg community smfishHmrf
For Giotto viewer:
$ sudo apt-get install imagemagick
$ sudo apt install ruby ruby-dev libmagickwand-dev
$ sudo gem install tileup
$ pip3 install --user --upgrade --no-cache-dir --no-deps scikit-image opencv-python scikit-learn smfish-image-processing giotto-viewer
Giotto will be used just as it were in a standard native Linux system.
3.4 X Windows
If you are plotting a figure in R, the X Windows may not be set up in Ubuntu WSL2, so you will not see a plot. Set up the X Windows as follows.
3.4.1 VcXsrv Windows X Server
The X server is a provider of graphics resources and keyboard/mouse events. I am using the VcXsrv Windows X Server that is open-source and is frequently update.
The first step is to install the third-part display manager called VcXsrv Windows X Server available at:
sourceforge.
Once installed, don't forget to allow VcXsrv in the Windows firewall settings.
Windows Security -> Firewall & network protection -> Allow an app through firewall -> make sure VcXsrv has both public and private checked.
Next launch the app. Open the icon "XLaunch" on the desktop.
Set the Display Number to 0:
Then next:
Then remember to disable access control:
Then Finish.
The app should minimize to an icon on the bottom right corner of the task bar.
Then in the Windows Terminal, Ubuntu tab, finally do the following to link the DISPLAY environment variable to XLaunch Server:
$ export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0
You can insert the above line in the ~/.bashrc file so that you do not need to launch it every time, like so:
This will launch the export command upon shell start up.
After doing this, starting a graphical application should work then, enjoy!
For more information and help, please refer to Getting graphical applications to work on WSL2 and Running WSL GUI Apps on Windows 10.
Note: XLaunch should be launched each time before starting a plotting app such as R. For example at Windows start up. Once it is started it will hide in the background in the little X icon in the task bar.
Starting Giotto in WSL2:
Some successful plotting example in R to verify X Windows is working: