You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-7Lines changed: 39 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,16 +8,20 @@ Tangram is a Python package, written in [PyTorch](https://pytorch.org/) and base
8
8
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.
9
9
10
10
***
11
-
## How to run Tangram
11
+
## How to run Tangram at cell level
12
12
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.
14
14
15
+
* install tangram-sc from shell:
15
16
```
16
17
pip install tangram-sc
18
+
```
19
+
* import tangram
20
+
```
17
21
import tangram as tg
18
22
```
19
23
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`:
21
25
22
26
```
23
27
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`
42
46
For more details on how to use Tangram check out [our tutorial](https://github.com/broadinstitute/Tangram/blob/master/example/1_tutorial_tangram.ipynb). [](https://colab.research.google.com/drive/1SVLUIZR6Da6VUyvX_2RkgVxbPn8f62ge?usp=sharing)
43
47
44
48
***
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
+
45
77
## How Tangram works under the hood
46
78
Tangram instantiates a `Mapper` object passing the following arguments:
47
79
-_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
77
109
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)
78
110
79
111
If you have questions, please contact the authors of the method:
0 commit comments