Skip to content

Commit 909d70b

Browse files
authored
Merge pull request #14 from broadinstitute/ziq
for release
2 parents 5756812 + a4c49a4 commit 909d70b

File tree

14 files changed

+1638
-520
lines changed

14 files changed

+1638
-520
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: set up python 3.8.5
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: 3.8.5
18+
19+
- name: set up conda environment
20+
uses: conda-incubator/setup-miniconda@v2
21+
with:
22+
activate-environment: test
23+
auto-activate-base: false
24+
environment-file: environment.yml
25+
26+
- name: run test
27+
shell: bash -l {0}
28+
run: |
29+
conda install pytest
30+
pip install .
31+
pytest tests/
32+

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,31 @@ __pycache__
1414

1515
# ignore AnnDatas
1616
*.h5ad
17+
# except for test datasets
18+
!test_ad_sc_readytomap.h5ad
19+
!test_ad_sp_readytomap.h5ad
20+
!test_2_ad_sc_readytomap.h5ad
21+
!test_2_ad_sp_readytomap.h5ad
1722
example/data/
23+
24+
# Distribution / packaging
25+
.Python
26+
build/
27+
develop-eggs/
28+
dist/
29+
downloads/
30+
eggs/
31+
.eggs/
32+
lib/
33+
lib64/
34+
parts/
35+
sdist/
36+
var/
37+
wheels/
38+
share/python-wheels/
39+
*.egg-info/
40+
.installed.cfg
41+
*.egg
42+
43+
# ignore coverage report
44+
*.coverage

README.md

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@ Tangram is a Python package, written in [PyTorch](https://pytorch.org/) and base
88
Tangram has been tested on various types of transcriptomic data (10Xv3, Smart-seq2 and SHARE-seq for single cell data; MERFISH, Visium, Slide-seq, smFISH and STARmap as spatial data). In our [preprint](https://www.biorxiv.org/content/10.1101/2020.08.29.272831v1), we used Tangram to reveal spatial maps of cell types and gene expression at single cell resolution in the adult mouse brain. More recently, we have applied our method to different tissue types including human lung, human kidney developmental mouse brain and metastatic breast cancer.
99

1010
***
11-
## How to run Tangram
11+
## How to run Tangram at cell level
1212

13-
To install Tangram, make sure you have [PyTorch](https://pytorch.org/) and [scanpy](https://scanpy.readthedocs.io/en/stable/) installed. If you need more details on the dependences, look at the `environment.yml` file. To install and import tangram, please use the following code:
13+
To install Tangram, make sure you have [PyTorch](https://pytorch.org/) and [scanpy](https://scanpy.readthedocs.io/en/stable/) installed. If you need more details on the dependences, look at the `environment.yml` file.
1414

15+
* install tangram-sc from shell:
1516
```
1617
pip install tangram-sc
18+
```
19+
* import tangram
20+
```
1721
import tangram as tg
1822
```
1923

20-
where `/home/tbiancal/git/Tangram` is substituted with your path pointing to the Tangram repo. The load your spatial data and your single cell data (which should be in [AnnData](https://anndata.readthedocs.io/en/latest/anndata.AnnData.html) format), and pre-process them using `tg.pp_adatas`:
24+
Then load your spatial data and your single cell data (which should be in [AnnData](https://anndata.readthedocs.io/en/latest/anndata.AnnData.html) format), and pre-process them using `tg.pp_adatas`:
2125

2226
```
2327
ad_sp = sc.read_h5ad(path)
@@ -42,6 +46,34 @@ The returned `ad_ge` is a voxel-by-gene AnnData, similar to spatial data `ad_sp`
4246
For more details on how to use Tangram check out [our tutorial](https://github.com/broadinstitute/Tangram/blob/master/example/1_tutorial_tangram.ipynb). [![colab tutorial](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1SVLUIZR6Da6VUyvX_2RkgVxbPn8f62ge?usp=sharing)
4347

4448
***
49+
50+
## Run Tangram at cluster level
51+
52+
To enable faster training and consume less memory, Tangram mapping can be done at cell cluster level.
53+
54+
Prepare the input data as the same you would do for cell level Tangram mapping. Then map using following code:
55+
56+
```
57+
ad_map = tg.map_cells_to_space(
58+
ad_sc,
59+
ad_sp,
60+
mode='clusters',
61+
cluster_label='subclass_label')
62+
```
63+
64+
Provided cluster_label must belong to ad_sc.obs. Above example code is to map at 'subclass_label' level, and the 'subclass_label' is in ad_sc.obs.
65+
66+
To project gene expression to space, use `tg.project_genes` and be sure to set the `cluster_label` argument to the same cluster label in mapping.
67+
68+
```
69+
ad_ge = tg.project_genes(
70+
ad_map,
71+
ad_sc,
72+
cluster_label='subclass_label')
73+
```
74+
75+
***
76+
4577
## How Tangram works under the hood
4678
Tangram instantiates a `Mapper` object passing the following arguments:
4779
- _S_: single cell matrix with shape cell-by-gene. Note that genes is the number of training genes.
@@ -77,12 +109,12 @@ Tangram has been released in the following publication
77109
Biancalani* T., Scalia* G. et al. - _Deep learning and alignment of spatially-resolved whole transcriptomes of single cells in the mouse brain with Tangram_ [biorXiv 10.1101/2020.08.29.272831](https://www.biorxiv.org/content/10.1101/2020.08.29.272831v3) (2020)
78110

79111
If you have questions, please contact the authors of the method:
80-
- Tommaso Biancalani - <[email protected]>
81-
- Gabriele Scalia - <[email protected]>
112+
- Tommaso Biancalani - <[email protected]>
113+
- Gabriele Scalia - <[email protected]>
82114

83115
PyPI maintainer:
84-
- Tommaso Biancalani - <[email protected]>
85-
- Ziqing Lu - <[email protected]>
116+
- Tommaso Biancalani - <[email protected]>
117+
- Ziqing Lu - <[email protected]>
86118

87119
The artwork has been curated by:
88120
- Anna Hupalowska <[email protected]>

environment.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ dependencies:
1111
- nb_conda=2.2.1
1212
- pip:
1313
- scanpy>=1.6.0
14+
- comet_ml
15+
- scikit-learn

example/1_tutorial_tangram.ipynb

Lines changed: 681 additions & 290 deletions
Large diffs are not rendered by default.

setup.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,23 @@
1717
long_description=long_description,
1818
long_description_content_type="text/markdown",
1919
url="https://github.com/broadinstitute/Tangram",
20-
packages=setuptools.find_packages(),
20+
packages=setuptools.find_namespace_packages(),
2121
classifiers=[
2222
"Programming Language :: Python :: 3.6",
2323
"Operating System :: MacOS",
2424
],
2525
python_requires='>=3.6',
2626
install_requires=[
27-
"pip>=19.0.0",
28-
"torch>=1.4.0",
29-
"pandas>=1.1.0",
30-
"numpy>=1.19.1",
31-
"scipy>=1.5.2",
32-
"matplotlib>=3.0.0",
33-
"seaborn>=0.10.1",
34-
"scanpy==1.6.0",
35-
# "jupyterlab>=2.2.6",
27+
"pip",
28+
"torch",
29+
"pandas",
30+
"numpy",
31+
"scipy",
32+
"matplotlib",
33+
"seaborn",
34+
"scanpy",
35+
"comet_ml",
36+
"scikit-learn"
3637
]
3738
)
3839

tangram/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
import os
2-
__version__ = os.environ.get('TANGRAM_VERSION')
2+
__version__ = os.environ.get('TANGRAM_VERSION', "0.0.0")

0 commit comments

Comments
 (0)