Skip to main content

FastTENET

Project description

Drawing

Indroduction

  • FastTENET is an accelerated TENET algorithm based on manycore computing.

Installation

  • :snake: Anaconda is recommended to use and develop FastTENET.
  • :penguin: Linux distros are tested and recommended to use and develop FastTENET.

Anaconda virtual environment

After installing anaconda, create a conda virtual environment for FastTENET. In the following command, you can change the Python version (e.g.,python=3.7 or python=3.9).

conda create -n fasttenet python=3.9

Now, we can activate our virtual environment for FastTENET as follows.

conda activate fasttenet

Install from PyPi

pip install fasttenet
  • Default backend framework of the FastTENET is PyTorch Lightning.
  • You need to install other backend frameworks such as CuPy, Jax, and TensorFlow

Install from GitHub repository

First, clone the recent version of this repository.

git clone https://github.com/cxinsys/fasttenet.git

Now, we need to install FastTENET as a module.

cd fasttenet
pip install -e .
  • Default backend framework of the FastTENET is PyTorch Lightning.

Install backend frameworks

FastTENET supports several backend frameworks including CuPy, JAX, TensorFlow, PyTorch and PyTorch-Lightning.
To use frameworks, you need to install the framework manually


  • PyTorch Lightning

PyTorch Lightning is a required dependency library for FastTENET and is installed automatically when you install FastTENET.
If the library is not installed, you can install it manually via pip.

python -m pip install lightning

PyTorch is a required dependency library for FastTENET and is installed automatically when you install FastTENET.
If the library is not installed, you can install it manually.

conda install pytorch torchvision torchaudio pytorch-cuda=xx.x -c pytorch -c nvidia (check your CUDA version)

Install Cupy from Conda-Forge with cudatoolkit supported by your driver

conda install -c conda-forge cupy cuda-version=xx.x (check your CUDA version)

Install JAX with CUDA > 12.x

pip install -U "jax[cuda12]"

Use 'XLA_PYTHON_CLIENT_PREALLOCATE=false' to disables the preallocation behavior
(https://jax.readthedocs.io/en/latest/gpu_memory_allocation.html)


Install TensorFlow-GPU with CUDA

python3 -m pip install tensorflow[and-cuda]

Tutorial

FastTENET class

Create FastTENET instance

FastTENET class requires data path as parameter

parameters

  • dpath_exp_data: expression data path, required
  • dpath_trj_data: trajectory data path, required
  • dpath_branch_data: branch(cell select) data path, required
  • dpath_tf_data: tf data path, required
  • spath_result_matrix: result matrix data path, optional, default: None
  • make_binary: if True, make binary expression and node name file, optional, default: False
import fasttenet as fte

worker = fte.FastTENET(dpath_exp_data=dpath_exp_data,
                           dpath_trj_data=dpath_trj_data,
                           dpath_branch_data=dpath_branch_data,
                           dpath_tf_data=dpath_tf_data,
                           spath_result_matrix=spath_result_matrix,
                           make_binary=True)

Run FastTENET

parameters

  • backend: optional, default: 'cpu'
  • device_ids: list or number of devcies to use, optional, default: [0] (cpu), [list of whole gpu devices] (gpu)
  • procs_per_device: The number of processes to create per device when using non 'cpu' devices, optional, default: 1
  • batch_size: Required
  • kp: kernel percentile, optional, default: 0.5
  • method: approximations for calculating TE, optional, 'shift_left' method is recommended to achieve results similar to TENET.
result_matrix = worker.run(backend='gpu',
                                device_ids=8,
                                procs_per_device=4,
                                batch_size=2 ** 16,
                                kp=0.5,
                                method='shift_left',
                                )

Run FastTENET with YAML config file

  • Before run tutorial_config.py, batch_size parameter must be modified to fit your gpu memory size
  • You can set parameters and run FastTENET via a YAML file
  • The config file must have values set for all required parameters

Usage

python tutorial_config.py --config [config file path]

Example

python tutorial_config.py --config ../configs/config_tuck_sub.yml

Output

TE_result_matrix.txt

Run FastTENET with tutorial_notf.py

  • Before run tutorial_notf.py, batch_size parameter must be modified to fit your gpu memory size

Usage

python tutorial_notf.py --fp_exp [expression file path] 
                        --fp_trj [trajectory file path] 
                        --fp_br [cell select file path] 
                        --backend [name of backend framework]
                        --num_devices [number of devices]
                        --batch_size [batch size]
                        --sp_rm [save file path]

Example

python tutorial_notf.py --fp_exp expression_dataTuck.csv 
                        --fp_trj pseudotimeTuck.txt 
                        --fp_br cell_selectTuck.txt 
                        --backend lightning
                        --num_devices 8
                        --batch_size 32768
                        --sp_rm TE_result_matrix.txt

Output

TE_result_matrix.txt

Run FastTENET with tutorial_tf.py

  • Before run tutorial_tf.py, batch_size parameter must be modified to fit your gpu memory size

Usage

python tutorial_tf.py --fp_exp [expression file path] 
                      --fp_trj [trajectory file path] 
                      --fp_br [cell select file path] 
                      --fp_tf [tf file path] 
                      --backend [name of backend framework]
                      --num_devices [number of devices]
                      --batch_size [batch size]
                      --sp_rm [save file path]

Example

python tutorial_tf.py --fp_exp expression_dataTuck.csv 
                      --fp_trj pseudotimeTuck.txt 
                      --fp_br cell_selectTuck.txt 
                      --fp_tf mouse_tfs.txt 
                      --backend lightning
                      --num_devices 8
                      --batch_size 32768
                      --sp_rm TE_result_matrix.txt

Output

TE_result_matrix.txt

Run make_grn.py

parameters

  • fp_rm: result matrix, required
  • fp_nn: node name file, required
  • fp_tf: tf list file, optional
  • fdr: specifying fdr, optional, default: 0.01
  • t_degrees: specifying number of outdegrees, optional, generate final GRNs by incrementally increasing the fdr
    value until the total number of outdegrees is greater than the parameter value.
  • trim_threshold: trimming threshold, optional, default: 0

Usage

When specifying an fdr

python make_grn.py --fp_rm [result matrix path] --fp_nn [node name file path] --fp_tf [tf file path] --fdr [fdr]

Example

python make_grn.py --fp_rm TE_result_matrix.txt --fp_nn expression_dataTuck_node_name.npy --fp_tf mouse_tf.txt --fdr 0.01

Output

TE_result_matrix.byGRN.fdr0.01.sif, TE_result_matrix.byGRN.fdr0.01.sif.outdegrees.txt
TE_result_matrix.byGRN.fdr0.01.trimIndirect0.sif, TE_result_matrix.byGRN.fdr0.01.trimIndirect0.sif.outdegrees.txt

Usage

When specifying the t_degrees

python make_grn.py --fp_rm [result matrix path] --fp_nn [node name file path] --fp_tf [tf file path] --t_degrees [number of outdegrees]

Example

python make_grn.py --fp_rm TE_result_matrix.txt --fp_nn expression_dataTuck_node_name.npy --fp_tf mouse_tf.txt --t_degrees 1000

Output

TE_result_matrix.byGRN.fdr0.06.sif, TE_result_matrix.byGRN.fdr0.06.sif.outdegrees.txt
TE_result_matrix.byGRN.fdr0.06.trimIndirect0.sif, TE_result_matrix.byGRN.fdr0.06.trimIndirect0.sif.outdegrees.txt

TODO

  • add 'jax' backend module
  • add 'lightning' backend module

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fasttenet-0.1.2.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

fasttenet-0.1.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file fasttenet-0.1.2.tar.gz.

File metadata

  • Download URL: fasttenet-0.1.2.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for fasttenet-0.1.2.tar.gz
Algorithm Hash digest
SHA256 dd3863e2dd1684991f64afb93c3c080e1ae8f2638fd62dba271a08ae635dc9ad
MD5 c1fa49a3786e5ff3e517d3d160258f2d
BLAKE2b-256 f0e6bebd7a098a0b8ec1c8250620b040ed89fa04314a7892c505f5b26fffc464

See more details on using hashes here.

File details

Details for the file fasttenet-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: fasttenet-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for fasttenet-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ee32cbe3e3b2333d374277a9471480e59f53f85a7357dba992555f2ce56bfff6
MD5 84787fa67cbc681cdedcf35f7e9ce738
BLAKE2b-256 534b12a0b58fa963046661a96d71018dbb5f17b1b477e6d7edbfb60fc9ec8657

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page