KrishnaswamyLab / SAUCIE

Other
98 stars 29 forks source link

[info] Use with Tensorflow 2 #23

Open ashipde opened 4 years ago

ashipde commented 4 years ago

This is not an Issue, just a brief on how I was able to use SAUCIE (master version as of today) with current versions of Tensorflow (2.1.0) and Numpy (1.18.1). It may be helpful to others.

System

CentOS Linux 7 with Linux 3.10.0-514.10.2.el7.x86_64 Conda 4.8.3 with Python 3.7.4

Installation of required packages using Conda

SAUCIE requires certain packages. Here, the packages are installed in the Conda environment that I will use to run SAUCIE.

conda activate base
conda create -n tensorflo fcsparser numpy pandas python tensorflow 
conda activate tensorflo
pip install -U fcswrite matplotlib scikit-learn tensorboard

Upgrade SAUCIE's Tensorflow 1 code to work with Tensorflow 2

The tf_upgrade_v2 Python script installed during Tensorflow installation (above) is used. All SAUCIE code files are processed and, with any necessary changes, are put in a new folder that the script creates.

miniconda3/envs/tensorflo/bin/tf_upgrade_v2 --intree SAUCIE/ --outtree SAUCIEnew/

Modify the new SAUCIE.py file

This is for compatibility with latest Numpy. Replace the four instances of as.matrix() with to.numpy().

Use the new SAUCIE

E.g.:

python SAUCIEnew/SAUCIE.py --format fcs --input_dir fcs --output_dir out --batch_correct --cluster

Versions of installed software in the Conda environment

fcsparser 0.2.0 fcswrite 0.5.2 matplotlob 3.2.1 numpy 1.18.1 op-einsum 3.2.1 pandas 1.0.3 pip 20.0.2 python 3.7.6 scipy 1.4.1 tensorboard 2.2.1 tensorflow 2.1.0