Skip to content

Commit 19c60d1

Browse files
author
gaddams
committed
chngs to docs
1 parent 095974c commit 19c60d1

8 files changed

+47
-19
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
tangram.plot\_utils.plot\_cell\_annotation\_sc
2+
==============================================
3+
4+
.. currentmodule:: tangram.plot_utils
5+
6+
.. autofunction:: plot_cell_annotation_sc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
tangram.plot\_utils.plot\_genes\_sc
2+
===================================
3+
4+
.. currentmodule:: tangram.plot_utils
5+
6+
.. autofunction:: plot_genes_sc

docs/source/classes/tangram.plot_utils.rst

+4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@
2727

2828
plot_cell_annotation
2929

30+
plot_cell_annotation_sc
31+
3032
plot_gene_sparsity
3133

3234
plot_genes
3335

36+
plot_genes_sc
37+
3438
plot_test_scores
3539

3640
plot_training_scores

docs/source/getting_started.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ Cell Level
1717
**************************
1818
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 <https://github.com/broadinstitute/Tangram/blob/master/environment.yml>`_ file.
1919

20+
Create a conda environment for Tangram::
21+
22+
conda env create --file environment.yml
23+
2024
Install tangram-sc from shell::
21-
25+
26+
conda activate tangram-env
2227
pip install tangram-sc
2328
2429
Import tangram::

docs/source/news.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ Tangram News
55

66
- On Mar 9th 2021, Nicholas Eagles wrote a `blog post <http://research.libd.org/rstatsclub/2021/03/09/lessons-learned-applying-tangram-on-visium-data/#.YPsZphNKhb->`_ about applying Tangram on Visium data.
77

8-
- The Tangram method has been used by our colleagues at Harvard and Broad Institute, to map cell types for the developmental mouse brain -see Fig. 2 [`Nature(2021)<https://www.nature.com/articles/s41586-021-03670-5>`_]
8+
- The Tangram method has been used by our colleagues at Harvard and Broad Institute, to map cell types for the developmental mouse brain -see Fig. 2 (`Nature(2021) <https://www.nature.com/articles/s41586-021-03670-5>`_ )
99

1010
- Tangram is now officially a part of `Squidpy <https://squidpy.readthedocs.io/en/stable/index.html>`_

tangram/utils.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ def get_matched_genes(prior_genes_names, sn_genes_names, excluded_genes=None):
7373
prior_genes_names (sequence): List of gene names in the spatial data.
7474
sn_genes_names (sequence): List of gene names in the single nuclei data.
7575
excluded_genes (sequence): Optional. List of genes to be excluded. These genes are excluded even if present in both datasets.
76-
If None, no genes are excluded. Default is None.
76+
If None, no genes are excluded. Default is None.
7777
7878
Returns:
7979
A tuple (mask_prior_indices, mask_sn_indices, selected_genes), with:
80-
mask_prior_indices (list): List of indices for the selected genes in 'prior_genes_names'.
81-
mask_sn_indices (list): List of indices for the selected genes in 'sn_genes_names'.
82-
selected_genes (list): List of names of the selected genes.
80+
mask_prior_indices (list): List of indices for the selected genes in 'prior_genes_names'.
81+
mask_sn_indices (list): List of indices for the selected genes in 'sn_genes_names'.
82+
selected_genes (list): List of names of the selected genes.
8383
For each i, selected_genes[i] = prior_genes_names[mask_prior_indices[i]] = sn_genes_names[mask_sn_indices[i].
8484
"""
8585
prior_genes_names = np.array(prior_genes_names)
@@ -115,8 +115,8 @@ def one_hot_encoding(l, keep_aggregate=False):
115115
116116
Returns:
117117
A DataFrame with a column for each unique value in the sequence and a one-hot-encoding, and an additional
118-
column with the input list if 'keep_aggregate' is True.
119-
The number of rows are equal to len(l).
118+
column with the input list if 'keep_aggregate' is True.
119+
The number of rows are equal to len(l).
120120
"""
121121
df_enriched = pd.DataFrame({"cl": l})
122122
for i in l.unique():
@@ -137,7 +137,7 @@ def project_cell_annotations(
137137
adata_sp (AnnData): spatial data used to save the mapping result.
138138
annotation (str): Optional. Cell annotations matrix with shape (number_cells, number_annotations). Default is 'cell_type'.
139139
threshold (float): Optional. Valid for using with adata_map.obs['F_out'] from 'constrained' mode mapping.
140-
Cell's probability below this threshold will be dropped. Default is 0.5.
140+
Cell's probability below this threshold will be dropped. Default is 0.5.
141141
Returns:
142142
None.
143143
Update spatial Anndata by creating `obsm` `tangram_ct_pred` field with a dataframe with spatial prediction for each annotation (number_spots, number_annotations)
@@ -797,10 +797,10 @@ def df_to_cell_types(df, cell_types):
797797
798798
Args:
799799
df (DataFrame): Columns correspond to cell types. Each row in the DataFrame corresponds to a voxel and
800-
specifies the known number of cells in that voxel for each cell type (int).
801-
The additional column 'centroids' specifies the coordinates of the cells in the voxel (sequence of (x,y) pairs).
800+
specifies the known number of cells in that voxel for each cell type (int).
801+
The additional column 'centroids' specifies the coordinates of the cells in the voxel (sequence of (x,y) pairs).
802802
cell_types (sequence): Sequence of cell type names to be considered for deconvolution.
803-
Columns in 'df' not included in 'cell_types' are ignored for assignment.
803+
Columns in 'df' not included in 'cell_types' are ignored for assignment.
804804
805805
Returns:
806806
A dictionary <cell type name> -> <list of (x,y) coordinates for the cell type>

tangram_tutorial.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@
17421742
"hash": "3ac21f8bf730324e87b2ab04b60f02f57ab9f380889952ce3b825e9207797ed6"
17431743
},
17441744
"kernelspec": {
1745-
"display_name": "Python 3 (ipykernel)",
1745+
"display_name": "Python 3",
17461746
"language": "python",
17471747
"name": "python3"
17481748
},
@@ -1756,7 +1756,7 @@
17561756
"name": "python",
17571757
"nbconvert_exporter": "python",
17581758
"pygments_lexer": "ipython3",
1759-
"version": "3.9.5"
1759+
"version": "3.8.5"
17601760
}
17611761
},
17621762
"nbformat": 4,

tutorial_sq_tangram.ipynb

+12-5
Original file line numberDiff line numberDiff line change
@@ -515,14 +515,15 @@
515515
"cell_type": "markdown",
516516
"metadata": {},
517517
"source": [
518-
"***\n",
519-
"## The _Tangram_ trick: scRNA-seq are the new spatial data\n",
518+
"****\n",
519+
"\n",
520+
"### The _Tangram_ trick: scRNA-seq are the new spatial data\n",
520521
"\n",
521522
"_Tangram_ learns a spatial alignment of the single cell data by looking at a subset of genes, specified by the user, called the training genes. Training genes need to bear interesting signal and to be measured with high quality. Typically, we choose the training genes are 100-1000 differentially expressedx genes, stratified across cell types. Sometimes, we also use the entire transcriptome, or perform different mappings using different set of training genes to see how much the result change.\n",
522523
"\n",
523524
"_Tangram_ fits the scRNA-seq profiles on space using a custom loss function based on cosine similarity. The method is summarized in the sketch below:\n",
524525
"\n",
525-
"![title](figures/how_tangram_works.png)"
526+
"![title](figures/how_tangram_works.png)\n"
526527
]
527528
},
528529
{
@@ -1445,8 +1446,14 @@
14451446
"cell_type": "markdown",
14461447
"metadata": {},
14471448
"source": [
1448-
"***\n",
1449-
"## Deconvolution\n",
1449+
"***"
1450+
]
1451+
},
1452+
{
1453+
"cell_type": "markdown",
1454+
"metadata": {},
1455+
"source": [
1456+
"### Deconvolution\n",
14501457
"\n",
14511458
"For untargeted spatial technologies, like Visium and Slide-seq, a spatial voxel may contain more than one cells. In these cases, it might be useful to disentangle gene expression into single cells - a process called deconvolution. Deconvolution is a requested feature, and also hard to obtain accurately with computational methods. If your goal is to study co-localization of cell types, we recommend you work with the spatial cell type maps instead. If your aim is discovery of cell-cell communication mechanisms, we suggest you compute gene programs, then use `project_cell_annotations` to spatially visualize program usage. To proceed with deconvolution anyways, see below.\n",
14521459
"\n",

0 commit comments

Comments
 (0)