Installation for Pysodb and Stagate

This tutorial demonstrates how to install pycodb on other methods.

Using stagate as an example, install pysodb in its installation environment.

Reference tutorials presents can be found at https://github.com/QIFEIDKN/STAGATE_pyG and https://github.com/TencentAILabHealthcare/pysodb.

Installing softwares and tools

1. The first step is to install Anaconda, Visual Studio Code and CUDA in advance.

Reference tutorials presents how to install anaconda and Visual Studio Code. And they can be found at https://docs.anaconda.com/anaconda/install/index.html and https://docs.anaconda.com/anaconda/user-guide/tasks/integration/vscode/.

Since STAGATE_pyG is based on pyG (PyTorch Geometric) framework, it requires GPUs on a device and need to install CUDA tool. A tutorials is available at https://developer.nvidia.com/cuda-downloads.

2. Launch Visual Studio Code and open a terminal window.

Henceforth, various packages or modules will be installed via the command line

Installation STAGATE_pyG

3. Select the installation path and open it

[ ]:
cd <path>

4. Clone STAGATE_pyG code

[ ]:
git clone https://github.com/QIFEIDKN/STAGATE_pyG

5. Open the STAGATE_pyG directory

[ ]:
cd STAGATE_pyG

6. Create a conda environment

[ ]:
conda create -n <environment_name> python=3.8

7. Activate a conda environment

If the conda environment is used on the terminal, run the following command to activate it:

[ ]:
conda activate <environment_name>

8. Install torch with CUDA

eg. pip install torch==1.13.0+cu117 -f https://download.pytorch.org/whl/cu117/torch_stable.html

[ ]:
pip install torch==<torch_version>+<cuda_version> -f https://download.pytorch.org/whl/<cuda_version>/torch_stable.html

9. Install PyTorch Geometric

Install a PyTorch Geometric according to the version of pytorch and CUDA, system. Select the package and copy a run command to run on your terminal. https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html

eg. pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv torch_geometric -f https://data.pyg.org/whl/torch-1.13.0+cu117.html

10. Install other python packages

[ ]:
pip install -r requirement.txt

11. Install STAGATE_pyG as a dependency or third-party package with pip

[ ]:
pip install <third-party package>

Installation mclust library in STAGATE_pyG conda environment

STAGATE uses the mclust package to identify spatial domains, which is an R library.

The next tutorial will show how to install the mclust package using r and rpy2 for python in a conda environment.

Activate by running the command “conda activate “

12. Install r and rpy2 in in a conda environment

[ ]:
conda install -c r rpy2

Run following command on the terminal to set the R_HOME environment variable to the location of the R executable within a conda environment.

[ ]:
export R_HOME=/home/<user_name>/anaconda3/envs/<environment_name>/lib/R

Run following command on the terminal to set the R_LIBS_USER environment variable to where R will install any packages that are installed within this conda environment.

[ ]:
export R_LIBS_USER=/home/<user_name>/anaconda3/envs/<environment_name>/lib/R/library

13. Enter the python interpreter to install mclust library

Run “python” at the terminal to enter the python interpreter and install mclust library in the python interpreter

[ ]:
python

Run the following commands in sequence:

[ ]:
import rpy2.robjects.packages as r
utils = r.importr("utils")
package_name = "mclust"
utils.install_packages(package_name)

Then, select a loading channel to install mclust.

Finally, exit the python interpreter.

[ ]:
exit()

Installation pysobd

Keep the conda environment active

14. Clone pycodb code

[ ]:
git clone https://github.com/TencentAILabHealthcare/pysodb.git

15. Open the pycodb directory

[ ]:
cd pysodb

16. Install a pysodb package from source code

[ ]:
python setup.py install

17. Install pysodb as a dependency or third-party package with pip

[ ]:
pip install <third-party package>
[5]:
print('finish!')
finish