CellView Lens Machine Learning

These instructions give details of the steps to enable the machine learning features of the CellView Lens plugin.  When properly configured, you will see additional buttons to train a neural net model and to use these models to create new populations predicted by the neural net.

Setup

The first step is to set up your python environment to utilize the Keras/Tensorflow libraries.  This is best achieved by using the Anaconda Python distribution to simplify package management.

Install Conda

Download and install the latest anaconda here:
https://www.anaconda.com/products/individual

Create Python Tensorflow Environment

Once installed, open a terminal window and execute the following command to create a Tensorflow environment with the correct version of Python:

conda create -n tf tensorflow python=3.7

This creates an environment named 'tf' that you will use to install the libraries needed.  In your terminal window, execute this command to start your new environment:

conda activate tf

Now, in your new environment, execute the following sequence of commands to install all the needed libraries:

pip install --ignore-installed --upgrade tensorflow

conda install -y scipy
pip install --exists-action i --upgrade scikit-learn
pip install --exists-action i --upgrade pandas
pip install --exists-action i --upgrade pandas-datareader
pip install --exists-action i --upgrade matplotlib
pip install --exists-action i --upgrade pillow
pip install --exists-action i --upgrade tqdm
pip install --exists-action i --upgrade requests
pip install --exists-action i --upgrade h5py
pip install --exists-action i --upgrade pyyaml
pip install --exists-action i --upgrade tensorflow_hub
pip install --exists-action i --upgrade bayesian-optimization
pip install --exists-action i --upgrade spacy
pip install --exists-action i --upgrade gensim
pip install --exists-action i --upgrade flask
pip install --exists-action i --upgrade boto3
pip install --exists-action i --upgrade gym
pip install --exists-action i --upgrade tensorflow
pip install --exists-action i --upgrade keras

pip show tensorflow

The last command verifies that you have installed Tensorflow correctly.

 

It is recommended you install another useful tool, jupyter notebook, where you can execute, view, and save python code:

conda install -y jupyter

To open a notebook in your web browser to begin executing python code, execute this command:

jupyter notebook

Determine Python Path

The next step it to determine the location of the python command in the conda environment that we will use to run machine learning scripts.  We will set this path in your prefs file to be used by the plugin.  To determine the location of the conda installation, execute the following:

which conda

This returns the path to the conda command, and will show you location of the conda installation (the conda command is in the 'bin' folder).  The parent folder of 'bin' will contain a folder named 'envs' that contains folders for each environment you have created (the 'envs' folder will contain a subfolder named 'tf').  In the 'tf' folder, there will be subfolder named 'bin' which will contain the python command we want to use.  The path to the python command will look something like this:

/Users/<YourUserName>/opt/anaconda3/envs/tf/bin/python

This is the path that you will set in your FlowJo10.prefs file.


Finally, you execute this command to finish your setup and return your terminal to its original environment.

conda deactivate