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
about: Cell2location doesn’t do what it should? Please help us fix it!
4
+
title: ''
5
+
labels: bug
6
+
assignees: ''
7
+
---
8
+
9
+
-[ ] I have confirmed this bug exists on the latest version of cell2location. See https://github.com/BayraktarLab/cell2location#installation
10
+
-[ ] I follow the instructions from the [scvi-tools tutorial](https://cell2location.readthedocs.io/en/latest/notebooks/cell2location_tutorial.html).
11
+
12
+
---
13
+
14
+
**Note**: Please read [this guide](https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports) detailing how to provide the necessary information for us to reproduce your bug.
15
+
16
+
17
+
### Minimal code sample (that we can run without your data, using public data)
18
+
19
+
```python
20
+
# Your code here
21
+
```
22
+
23
+
```pytb
24
+
[Paste the error output produced by the above code here]
about: Template for posting a question to scverse Discourse.
4
+
title: ''
5
+
labels: question
6
+
assignees: ''
7
+
---
8
+
9
+
## Please use the template below to post a question to https://discourse.scverse.org/c/ecosytem/cell2location/.
10
+
11
+
### Problem
12
+
13
+
<!-- Please describe your problem below: -->
14
+
...
15
+
16
+
-[ ] I follow the instructions from the [cell2location tutorial (using on scvi-tools)](https://cell2location.readthedocs.io/en/latest/notebooks/cell2location_tutorial.html).
17
+
-[ ] I have adjusted required hyperparameters to my dataset and tissue `N_cells_per_location` and `detection_alpha`.
18
+
-[ ] I have provided 10X reaction/inlet as `batch_key` for reference NB regression.
19
+
-[ ] I have checked [scverse Discourse](https://discourse.scverse.org/c/ecosytem/cell2location/) and [old Cell2location Community Forum](https://github.com/BayraktarLab/cell2location/discussions), and did not find a solution.
20
+
21
+
22
+
### Description of the data input and hyperparameters
23
+
24
+
<!-- Please briefly describe your : -->
25
+
...
26
+
27
+
<!-- Please briefly describe your spatial data: -->
28
+
...
29
+
30
+
#### Single cell reference data: number of cells, number of cell types, number of genes
31
+
32
+
<!-- Please add this info: -->
33
+
...
34
+
35
+
#### Single cell reference data: technology type (e.g. mix of 10X 3' and 5')
36
+
37
+
<!-- Please add this info: -->
38
+
...
39
+
40
+
#### Spatial data: number of locations numbers, technology type (e.g. Visium, ISS, Nanostring WTA)
[](https://colab.research.google.com/github/BayraktarLab/cell2location/blob/master/docs/notebooks/cell2location_tutorial.ipynb)
11
-
[](https://quay.io/vitkl/cell2location)
11
+
[](https://quay.io/vitkl/cell2location)
Kleshchevnikov, V., Shmatko, A., Dann, E. et al. Cell2location maps fine-grained cell types in spatial transcriptomics. Nat Biotechnol (2022). https://doi.org/10.1038/s41587-021-01139-4
Please note that cell2locations requires 2 user-provided hyperparameters (N_cells_per_location and detection_alpha) - for detailed guidance on setting these hyperparameters and their impact see [the flow diagram and the note](https://github.com/BayraktarLab/cell2location/blob/master/docs/images/Note_on_selecting_hyperparameters.pdf). Many real datasets (especially human) show within-slide variability in RNA detection sensitivity - requiring you to try both recommended settings of the `detection_alpha` parameter: `detection_alpha=200` for low within-slide technical variability and `detection_alpha=20` for high within-slide technical variability.
14
19
15
20
Cell2location is a principled Bayesian model that can resolve fine-grained cell types in spatial transcriptomic data and create comprehensive cellular maps of diverse tissues. Cell2location accounts for technical sources of variation and borrows statistical strength across locations, thereby enabling the integration of single cell and spatial transcriptomics with higher sensitivity and resolution than existing tools. This is achieved by estimating which combination of cell types in which cell abundance could have given the mRNA counts in the spatial data, while modelling technical effects (platform/technology effect, contaminating RNA, unexplained variance).
16
21
@@ -21,11 +26,9 @@ Overview of the spatial mapping approach and the workflow enabled by cell2locati
21
26
22
27
## Usage and Tutorials
23
28
24
-
The tutorial covering the estimation of expresson signatures of reference cell types, spatial mapping with cell2location and the downstream analysis can be found here: https://cell2location.readthedocs.io/en/latest/
25
-
26
-
You can also try cell2location on [Google Colab](https://colab.research.google.com/github/BayraktarLab/cell2location/blob/master/docs/notebooks/cell2location_tutorial.ipynb) on a smaller data subset containing somatosensory cortex.
29
+
The tutorial covering the estimation of expresson signatures of reference cell types, spatial mapping with cell2location and the downstream analysis can be found here and tried on [Google Colab](https://colab.research.google.com/github/BayraktarLab/cell2location/blob/master/docs/notebooks/cell2location_tutorial.ipynb): https://cell2location.readthedocs.io/en/latest/
27
30
28
-
Please report bugs via https://github.com/BayraktarLab/cell2location/issues and ask any usage questions in https://github.com/BayraktarLab/cell2location/discussions.
31
+
Please report bugs via https://github.com/BayraktarLab/cell2location/issues and ask any usage questions about [cell2location](https://discourse.scverse.org/c/ecosytem/cell2location/42), [scvi-tools](https://discourse.scverse.org/c/help/scvi-tools/7) or [Visium data](https://discourse.scverse.org/c/general/visium/32) in scverse community discourse.
29
32
30
33
Cell2location package is implemented in a general way (using https://pyro.ai/ and https://scvi-tools.org/) to support multiple related models - both for spatial mapping, estimating reference cell type signatures and downstream analysis.
Before installing cell2location and it's dependencies, it could be necessary to make sure that you are creating a fully isolated conda environment by telling python to NOT use user site for installing packages, ideally by adding this line to your `~/.bashrc` file , but this would also work during a terminal session:
64
+
Before installing cell2location and it's dependencies, it could be necessary to make sure that you are creating a fully isolated conda environment by telling python to NOT use user site for installing packagesby running this line before creating conda environment and every time before activatin conda environment in a new terminal session:
62
65
63
66
```bash
64
-
export PYTHONNOUSERSITE="someletters"
67
+
export PYTHONNOUSERSITE="literallyanyletters"
65
68
```
66
69
67
70
@@ -76,12 +79,147 @@ Cell2location architecture is designed to simplify extended versions of the mode
76
79
We thank all paper authors for their contributions:
77
80
Vitalii Kleshchevnikov, Artem Shmatko, Emma Dann, Alexander Aivazidis, Hamish W King, Tong Li, Artem Lomakin, Veronika Kedlian, Mika Sarkin Jain, Jun Sung Park, Lauma Ramona, Liz Tuck, Anna Arutyunyan, Roser Vento-Tormo, Moritz Gerstung, Louisa James, Oliver Stegle, Omer Ali Bayraktar
78
81
79
-
We also thank Krzysztof Polanski, Luz Garcia Alonso, Carlos Talavera-Lopez, Ni Huang for feedback on the package, Martin Prete for dockerising cell2location and other software support.
82
+
We also thank Pyro developers (Fritz Obermeyer, Martin Jankowiak), Krzysztof Polanski, Luz Garcia Alonso, Carlos Talavera-Lopez, Ni Huang for feedback on the package, Martin Prete for dockerising cell2location and other software support.
80
83
81
84
## FAQ
82
85
83
86
See https://github.com/BayraktarLab/cell2location/discussions
84
87
85
88
## Future development and experimental features
89
+
Future developments of cell2location are focused on 1) scalability to 100k-mln+ locations using amortised inference of cell abundance (same ideas as used in VAE), 2) extending cell2location to related spatial analysis tasks that require modification of the model (such as using cell type hierarchy information), and 3) incorporating features presented by more recently proposed methods (such as CAR spatial proximity modelling). We are also experimenting with Numpyro and JAX (https://github.com/vitkl/cell2location_numpyro).
### Issues with package version mismatches often originate from python user site rather than conda environment being used to install a subset of packages
108
+
109
+
Before installing cell2location and it's dependencies, it could be necessary to make sure that you are creating a fully isolated conda environment by telling python to NOT use user site for installing packages by running this line before creating conda environment and every time before activatin conda environment in a new terminal session:
86
110
87
-
We also provide an experimental numpyro translation of the model which has improved memory efficiency (allowing analysis of multiple Visium samples on Google Colab) and minor improvements in speed - https://github.com/vitkl/cell2location_numpyro. You can try it on Google Colab [](https://colab.research.google.com/github/vitkl/cell2location_numpyro/blob/main/docs/notebooks/cell2location_short_demo_colab.ipynb) - however note that both numpyro itself and cell2location_numpyro are in very active development.
111
+
```bash
112
+
export PYTHONNOUSERSITE="literallyanyletters"
113
+
```
114
+
115
+
### Useful code for reading and combining multiple Visium sections
116
+
117
+
Keeping info on distinct sections in a csv file (Google Sheet).
118
+
119
+
```python
120
+
sample_annot = pd.read_csv('./sample_annot.csv')
121
+
122
+
from glob import glob
123
+
sample_annot['path'] = pd.Series(
124
+
glob(f'{sp_data_folder}*'),
125
+
index=[sub('^.+WTSI_', '', sub('_GRCh38-2020-A$', '', i)) for i in glob(f'{sp_data_folder}*')]
126
+
)[sample_annot['Sample_ID']].values
127
+
import os
128
+
sample_annot['file'] = [os.path.basename(i) for i in sample_annot['path']]
0 commit comments