Skip to content

Commit f655b73

Browse files
committed
version 1.0.2 release
1 parent b5ca7b7 commit f655b73

File tree

7 files changed

+84
-82
lines changed

7 files changed

+84
-82
lines changed

build/lib/paste/PASTE.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def pairwise_align(layer1, layer2, alpha = 0.1):
3333
pi, logw = ot.gromov.fused_gromov_wasserstein(M, D1.to_numpy(), D2.to_numpy(), a, b, loss_fun='square_loss', alpha= alpha, verbose=False, log=True)
3434
return pi
3535

36-
def center_align(A, layers, lmbda, alpha = 0.1, n_components = 15, threshold = 0.001):
36+
def center_align(A, layers, lmbda, alpha = 0.1, n_components = 15, threshold = 0.001, random_seed = None):
3737
"""
3838
Computes center alignment of layers.
3939
@@ -61,7 +61,7 @@ def center_align(A, layers, lmbda, alpha = 0.1, n_components = 15, threshold = 0
6161
D = []
6262
for layer in layers:
6363
D.append(generateDistanceMatrix(layer, layer))
64-
model = NMF(n_components=n_components, init='random', random_state=0)
64+
model = NMF(n_components=n_components, solver = 'mu', beta_loss = 'kullback-leibler', init='random', random_state = random_seed)
6565
W = model.fit_transform(A.gene_exp)
6666
H = model.components_
6767
center_coordinates = A.coordinates
@@ -78,7 +78,7 @@ def center_align(A, layers, lmbda, alpha = 0.1, n_components = 15, threshold = 0
7878
while R_diff > 0.001 and iteration_count < 10:
7979
print("Iteration: " + str(iteration_count))
8080
pi, r = center_ot(W, H, layers, center_coordinates, common_genes, alpha)
81-
W, H = center_NMF(W, H, layers, pi, lmbda, n_components)
81+
W, H = center_NMF(W, H, layers, pi, lmbda, n_components, random_seed)
8282
R_new = np.dot(r,lmbda)
8383
iteration_count += 1
8484
R_diff = abs(R - R_new)
@@ -100,10 +100,10 @@ def center_ot(W, H, layers, center_coordinates, common_genes, alpha):
100100
r.append(r_q)
101101
return pi, np.array(r)
102102

103-
def center_NMF(W, H, layers, pi, lmbda, n_components):
103+
def center_NMF(W, H, layers, pi, lmbda, n_components, random_seed):
104104
n = W.shape[0]
105105
B = n*sum([lmbda[i]*np.dot(pi[i], layers[i].gene_exp) for i in range(len(layers))])
106-
model = NMF(n_components=n_components, init='random', random_state=0)
106+
model = NMF(n_components=n_components, solver = 'mu', beta_loss = 'kullback-leibler', init='random', random_state = random_seed)
107107
W_new = model.fit_transform(B)
108108
H_new = model.components_
109109
return W_new, H_new

dist/paste-bio-1.0.1.tar.gz

-10.6 KB
Binary file not shown.

dist/paste-bio-1.0.2.tar.gz

10.5 KB
Binary file not shown.
-11 KB
Binary file not shown.
11.1 KB
Binary file not shown.

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = paste-bio
3-
version = 1.0.1
3+
version = 1.0.2
44
author = Max Land
55
author_email = [email protected]
66
description = A computational method to align and integrate spatial transcriptomics experiments.

src/paste_bio.egg-info/PKG-INFO

Lines changed: 78 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,92 @@
11
Metadata-Version: 2.1
22
Name: paste-bio
3-
Version: 1.0.1
3+
Version: 1.0.2
44
Summary: A computational method to align and integrate spatial transcriptomics experiments.
55
Home-page: https://github.com/raphael-group/paste
66
Author: Max Land
77
Author-email: [email protected]
88
License: UNKNOWN
99
Project-URL: Bug Tracker, https://github.com/raphael-group/paste/issues
10-
Description: # PASTE
11-
12-
PASTE is a computational method that leverages both gene expression similarity and spatial distances between spots align and integrate spatial transcriptomics data. In particular, there are two methods:
13-
1. `pairwise_align`: align spots across pairwise ST layers.
14-
2. `center_align`: integrate multiple ST layers into one center layer.
15-
16-
You can read our preprint [here](https://www.biorxiv.org/content/10.1101/2021.03.16.435604v1).
17-
18-
PASTE is actively being worked on with future updates coming.
19-
20-
### Dependencies
21-
22-
To run PASTE, you will need the following Python packages:
23-
1. POT: Python Optimal Transport (https://PythonOT.github.io/)
24-
2. NetworkX (https://networkx.org/)
25-
3. Numpy
26-
4. Pandas
27-
5. scipy.spatial
28-
6. sklearn.preprocessing
29-
30-
### Installation
31-
32-
The easiest way is to install PASTE on pypi: https://pypi.org/project/paste-bio/.
33-
34-
`pip install paste-bio`
35-
36-
Check out Tutorial.ipynb for an example of how to use PASTE.
37-
38-
Or you can clone the respository and run from command line (see below).
39-
40-
41-
### Command Line
42-
43-
We provide the option of running PASTE from the command line.
44-
45-
First, clone the repository:
46-
47-
`git clone https://github.com/raphael-group/paste.git`
48-
49-
Sample execution: `python paste-cmd-line.py -m pairwise -f file1.csv file2.csv file3.csv`
50-
51-
Note: `pairwise` will return pairwise alignment between each consecutive pair of files (e.g. \[file1,file2\], \[file2,file3\]).
52-
53-
| Flag | Name | Description | Default Value |
54-
| --- | --- | --- | --- |
55-
| -m | mode | Select either `pairwise` or `center` | (str) `pairwise` |
56-
| -f | files | Path to data files (.csv) | None |
57-
| -d | direc | Directory to store output files | Current Directory |
58-
| -a | alpha | alpha parameter for PASTE | (float) `0.1` |
59-
| -p | n_components | n_components for NMF step in `center_align` | (int) `15` |
60-
| -l | lmbda | lambda parameter in `center_align` | (floats) probability vector of length `n` |
61-
| -i | intial_layer | Specify which file is also the intial layer in `center_align` | (int) `1` |
62-
| -t | threshold | Convergence threshold for `center_align` | (float) `0.001` |
63-
64-
Input files are .csv files of the form:
65-
66-
```
67-
'gene_a' 'gene_b'
68-
'2x5' 0 9
69-
'2x7' 2 6
70-
```
71-
Where the columns indexes are gene names (str), row indexes are spatial coordinates (str), and entries are gene counts (int). In particular, row indexes are of the form `AxB` where `A` and `B` are floats.
72-
73-
`pairwise_align` outputs a (.csv) file containing mapping of spots between each consecutive pair of layers. The rows correspond to spots of the first layer, and cols the second.
74-
75-
`center_align` outputs two files containing the low dimensional representation (NMF decomposition) of the center layer gene expression, and files containing a mapping of spots between the center layer (rows) to each input layer (cols).
76-
77-
### Sample Dataset
78-
79-
Added sample spatial transcriptomics dataset consisting of four breast cancer layers courtesy of:
80-
81-
Ståhl, Patrik & Salmén, Fredrik & Vickovic, Sanja & Lundmark, Anna & Fernandez Navarro, Jose & Magnusson, Jens & Giacomello, Stefania & Asp, Michaela & Westholm, Jakub & Huss, Mikael & Mollbrink, Annelie & Linnarsson, Sten & Codeluppi, Simone & Borg, Åke & Pontén, Fredrik & Costea, Paul & Sahlén, Pelin Akan & Mulder, Jan & Bergmann, Olaf & Frisén, Jonas. (2016). Visualization and analysis of gene expression in tissue sections by spatial transcriptomics. Science. 353. 78-82. 10.1126/science.aaf2403.
82-
83-
Note: Original data is (.tsv), but we converted it to (.csv).
84-
8510
Platform: UNKNOWN
8611
Classifier: Programming Language :: Python :: 3
8712
Classifier: License :: OSI Approved :: BSD License
8813
Classifier: Operating System :: OS Independent
8914
Requires-Python: >=3.6
9015
Description-Content-Type: text/markdown
16+
License-File: LICENSE
17+
18+
# PASTE
19+
20+
PASTE is a computational method that leverages both gene expression similarity and spatial distances between spots align and integrate spatial transcriptomics data. In particular, there are two methods:
21+
1. `pairwise_align`: align spots across pairwise ST layers.
22+
2. `center_align`: integrate multiple ST layers into one center layer.
23+
24+
You can read our preprint [here](https://www.biorxiv.org/content/10.1101/2021.03.16.435604v1).
25+
26+
PASTE is actively being worked on with future updates coming.
27+
28+
### Dependencies
29+
30+
To run PASTE, you will need the following Python packages:
31+
1. POT: Python Optimal Transport (https://PythonOT.github.io/)
32+
3. Numpy
33+
4. Pandas
34+
5. scipy.spatial
35+
6. sklearn.preprocessing
36+
37+
### Installation
38+
39+
The easiest way is to install PASTE on pypi: https://pypi.org/project/paste-bio/.
40+
41+
`pip install paste-bio`
42+
43+
Check out Tutorial.ipynb for an example of how to use PASTE.
44+
45+
Or you can clone the respository and run from command line (see below).
46+
47+
48+
### Command Line
49+
50+
We provide the option of running PASTE from the command line.
51+
52+
First, clone the repository:
53+
54+
`git clone https://github.com/raphael-group/paste.git`
55+
56+
Sample execution: `python paste-cmd-line.py -m pairwise -f file1.csv file2.csv file3.csv`
57+
58+
Note: `pairwise` will return pairwise alignment between each consecutive pair of files (e.g. \[file1,file2\], \[file2,file3\]).
59+
60+
| Flag | Name | Description | Default Value |
61+
| --- | --- | --- | --- |
62+
| -m | mode | Select either `pairwise` or `center` | (str) `pairwise` |
63+
| -f | files | Path to data files (.csv) | None |
64+
| -d | direc | Directory to store output files | Current Directory |
65+
| -a | alpha | alpha parameter for PASTE | (float) `0.1` |
66+
| -p | n_components | n_components for NMF step in `center_align` | (int) `15` |
67+
| -l | lmbda | lambda parameter in `center_align` | (floats) probability vector of length `n` |
68+
| -i | intial_layer | Specify which file is also the intial layer in `center_align` | (int) `1` |
69+
| -t | threshold | Convergence threshold for `center_align` | (float) `0.001` |
70+
71+
Input files are .csv files of the form:
72+
73+
```
74+
'gene_a' 'gene_b'
75+
'2x5' 0 9
76+
'2x7' 2 6
77+
```
78+
Where the columns indexes are gene names (str), row indexes are spatial coordinates (str), and entries are gene counts (int). In particular, row indexes are of the form `AxB` where `A` and `B` are floats.
79+
80+
`pairwise_align` outputs a (.csv) file containing mapping of spots between each consecutive pair of layers. The rows correspond to spots of the first layer, and cols the second.
81+
82+
`center_align` outputs two files containing the low dimensional representation (NMF decomposition) of the center layer gene expression, and files containing a mapping of spots between the center layer (rows) to each input layer (cols).
83+
84+
### Sample Dataset
85+
86+
Added sample spatial transcriptomics dataset consisting of four breast cancer layers courtesy of:
87+
88+
Ståhl, Patrik & Salmén, Fredrik & Vickovic, Sanja & Lundmark, Anna & Fernandez Navarro, Jose & Magnusson, Jens & Giacomello, Stefania & Asp, Michaela & Westholm, Jakub & Huss, Mikael & Mollbrink, Annelie & Linnarsson, Sten & Codeluppi, Simone & Borg, Åke & Pontén, Fredrik & Costea, Paul & Sahlén, Pelin Akan & Mulder, Jan & Bergmann, Olaf & Frisén, Jonas. (2016). Visualization and analysis of gene expression in tissue sections by spatial transcriptomics. Science. 353. 78-82. 10.1126/science.aaf2403.
89+
90+
Note: Original data is (.tsv), but we converted it to (.csv).
91+
92+

0 commit comments

Comments
 (0)