Skip to content

Commit 7986f9c

Browse files
committed
Package TrajectoryNet
1 parent 10df9e0 commit 7986f9c

File tree

20 files changed

+449
-200
lines changed

20 files changed

+449
-200
lines changed

.github/workflows/pre-commit.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: pre-commit
2+
on:
3+
push:
4+
branches-ignore:
5+
- 'master'
6+
7+
jobs:
8+
pre-commit:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Cancel Previous Runs
12+
uses: styfle/[email protected]
13+
with:
14+
access_token: ${{ github.token }}
15+
- uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
19+
- uses: actions/setup-python@v2
20+
with:
21+
python-version: "3.7"
22+
architecture: "x64"
23+
24+
- uses: actions/cache@v2
25+
with:
26+
path: ~/.cache/pre-commit
27+
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}-
28+
29+
- uses: pre-commit/[email protected]
30+
continue-on-error: true
31+
32+
- name: Commit files
33+
run: |
34+
if [[ `git status --porcelain --untracked-files=no` ]]; then
35+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
36+
git config --local user.name "github-actions[bot]"
37+
git commit -m "pre-commit" -a
38+
fi
39+
40+
- name: Push changes
41+
uses: ad-m/github-push-action@master
42+
with:
43+
github_token: ${{ secrets.GITHUB_TOKEN }}
44+
branch: ${{ github.ref }}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Publish Python 🐍 distributions 📦 to PyPI
10+
11+
on:
12+
release:
13+
types: [published]
14+
15+
jobs:
16+
deploy:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Set up Python
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: '3.x'
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install build
29+
- name: Build package
30+
run: python -m build
31+
- name: Publish distribution 📦 to Test PyPI
32+
uses: pypa/gh-action-pypi-publish@release/v1
33+
with:
34+
skip_existing: true
35+
user: __token__
36+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
37+
repository_url: https://test.pypi.org/legacy/
38+
- name: Publish distribution 📦 to PyPI
39+
uses: pypa/gh-action-pypi-publish@release/v1
40+
with:
41+
user: __token__
42+
password: ${{ secrets.PYPI_API_TOKEN }}

.gitignore

Lines changed: 98 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,101 @@
1-
*__pycache__*
2-
*.pyc
31
results/tmp/
42
*.jpg
5-
.snakemake
63

7-
.ipynb_checkpoints
4+
#Vim
5+
*.sw?
6+
7+
# Byte-compiled / optimized / DLL files
8+
__pycache__/
9+
*.py[cod]
10+
11+
# C extensions
12+
*.so
13+
14+
# Distribution / packaging
15+
.Python
16+
env/
17+
build/
18+
develop-eggs/
19+
dist/
20+
downloads/
21+
eggs/
22+
.eggs/
23+
lib/
24+
lib64/
25+
parts/
26+
sdist/
27+
var/
28+
*.egg-info/
29+
.installed.cfg
30+
*.egg
31+
32+
# PyInstaller
33+
# Usually these files are written by a python script from a template
34+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
35+
*.manifest
36+
*.spec
37+
38+
# Installer logs
39+
pip-log.txt
40+
pip-delete-this-directory.txt
41+
42+
# Unit test / coverage reports
43+
htmlcov/
44+
.tox/
45+
.coverage
46+
.coverage.*
47+
.cache
48+
nosetests.xml
49+
coverage.xml
50+
*.cover
51+
52+
# Translations
53+
*.mo
54+
*.pot
55+
56+
# Django stuff:
57+
*.log
58+
59+
# Sphinx documentation
60+
docs/_build/
61+
62+
# PyBuilder
63+
target/
64+
65+
# DotEnv configuration
66+
.env
67+
68+
# Database
69+
*.db
70+
*.rdb
71+
72+
# Pycharm
73+
.idea
74+
75+
# VS Code
76+
.vscode/
77+
78+
# Spyder
79+
.spyproject/
80+
81+
# Jupyter NB Checkpoints
82+
.ipynb_checkpoints/
83+
84+
# exclude data from source control by default
85+
/data/
86+
87+
# exclude old folder by default
88+
/old/
89+
90+
# Mac OS-specific storage files
91+
.DS_Store
92+
93+
# vim
94+
*.swp
95+
*.swo
96+
97+
# Mypy cache
98+
.mypy_cache/
99+
100+
# Snakemake cache
101+
.snakemake/

README.md

Lines changed: 0 additions & 63 deletions
This file was deleted.

README.rst

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
Pytorch Implementation of TrajectoryNet
2+
=======================================
3+
4+
This library runs code associated with the TrajectoryNet paper [1].
5+
6+
7+
Installation
8+
------------
9+
10+
TrajectoryNet is available in `pypi`. Install by running the following
11+
12+
.. code-block:: bash
13+
14+
pip install TrajectoryNet
15+
16+
This code was tested with python 3.7 and 3.8.
17+
18+
Example
19+
-------
20+
21+
.. image:: figures/eb_high_quality.png
22+
:alt: EB PHATE Scatterplot
23+
:height: 300
24+
25+
.. image:: figures/EB-Trajectory.gif
26+
:alt: Trajectory of density over time
27+
:height: 300
28+
29+
30+
Basic Usage
31+
-----------
32+
33+
Run with
34+
35+
.. code-block:: bash
36+
37+
python -m TrajectoryNet.main --dataset EB
38+
39+
To use a custom dataset expose the coordinates and timepoint information according to the example jupyter notebooks in the `/notebooks/` folder.
40+
41+
TrajectoryNet requires the following:
42+
43+
1. An embedding matrix titled `[embedding_name]` (Cells x Dimensions)
44+
2. A sample labels array titled `sample_labels` (Cells)
45+
3. (Optionally) a delta embedding representing RNA velocity titled `delta_[embedding_name]` (Cells x Dimensions)
46+
47+
48+
49+
To run TrajectoryNet with a custom dataset use:
50+
51+
.. code-block:: bash
52+
53+
python -m TrajectoryNet.main --dataset [PATH_TO_NPZ_FILE] --embedding_name [EMBEDDING_NAME]
54+
python -m TrajectoryNet.eval --dataset [PATH_TO_NPZ_FILE] --embedding_name [EMBEDDING_NAME]
55+
56+
57+
See `notebooks/EB-Eval.ipynb` for an example on how to use TrajectoryNet on a PCA embedding to get trajectories in the gene space.
58+
59+
60+
References
61+
----------
62+
[1] Tong, A., Huang, J., Wolf, G., van Dijk, D., and Krishnaswamy, S. TrajectoryNet: A Dynamic Optimal Transport Network for Modeling Cellular Dynamics. In International Conference on Machine Learning, 2020. `arxiv <http://arxiv.org/abs/2002.04461>`_ `ICML <https://proceedings.icml.cc/paper/2020/hash/9d740bd0f36aaa312c8d504e28c42163>`_
63+
64+
---
65+
66+
If you found this library useful, please consider citing::
67+
68+
@inproceedings{tong2020trajectorynet,
69+
title = {TrajectoryNet: A Dynamic Optimal Transport Network for Modeling Cellular Dynamics},
70+
shorttitle = {{{TrajectoryNet}}},
71+
booktitle = {Proceedings of the 37th International Conference on Machine Learning},
72+
author = {Tong, Alexander and Huang, Jessie and Wolf, Guy and {van Dijk}, David and Krishnaswamy, Smita},
73+
year = {2020}
74+
}

0 commit comments

Comments
 (0)