gsMap 1.60__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gsMap/GNN_VAE/__init__.py +0 -0
- gsMap/GNN_VAE/adjacency_matrix.py +95 -0
- gsMap/GNN_VAE/model.py +87 -0
- gsMap/GNN_VAE/train.py +97 -0
- gsMap/__init__.py +5 -0
- gsMap/__main__.py +3 -0
- gsMap/cauchy_combination_test.py +163 -0
- gsMap/config.py +734 -0
- gsMap/find_latent_representation.py +209 -0
- gsMap/format_sumstats.py +410 -0
- gsMap/generate_ldscore.py +551 -0
- gsMap/generate_r2_matrix.py +743 -0
- gsMap/jackknife.py +514 -0
- gsMap/latent_to_gene.py +257 -0
- gsMap/main.py +39 -0
- gsMap/make_annotations.py +560 -0
- gsMap/regression_read.py +294 -0
- gsMap/spatial_ldsc_multiple_sumstats.py +307 -0
- gsMap/visualize.py +154 -0
- gsmap-1.60.dist-info/LICENSE +21 -0
- gsmap-1.60.dist-info/METADATA +124 -0
- gsmap-1.60.dist-info/RECORD +24 -0
- gsmap-1.60.dist-info/WHEEL +4 -0
- gsmap-1.60.dist-info/entry_points.txt +3 -0
gsMap/visualize.py
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
import argparse
|
2
|
+
from pathlib import Path
|
3
|
+
from typing import Literal
|
4
|
+
|
5
|
+
import scanpy as sc
|
6
|
+
import numpy as np
|
7
|
+
import pandas as pd
|
8
|
+
import plotly.express as px
|
9
|
+
from gsMap.config import VisualizeConfig, add_Visualization_args
|
10
|
+
|
11
|
+
|
12
|
+
def load_ldsc(ldsc_input_file):
|
13
|
+
ldsc = pd.read_csv(ldsc_input_file, compression='gzip')
|
14
|
+
ldsc.spot = ldsc.spot.astype(str).replace('\.0', '', regex=True)
|
15
|
+
ldsc.index = ldsc.spot
|
16
|
+
ldsc['logp'] = -np.log10(ldsc.p)
|
17
|
+
return ldsc
|
18
|
+
|
19
|
+
|
20
|
+
# %%
|
21
|
+
def load_st_coord(adata, ldsc, annotation):
|
22
|
+
spot_name = adata.obs_names.to_list()
|
23
|
+
space_coord = pd.DataFrame(adata.obsm['spatial'], columns=['sx', 'sy'], index=spot_name)
|
24
|
+
space_coord = space_coord[space_coord.index.isin(ldsc.spot)]
|
25
|
+
space_coord_concat = pd.concat([space_coord.loc[ldsc.spot], ldsc.logp], axis=1)
|
26
|
+
space_coord_concat.head()
|
27
|
+
if annotation is not None:
|
28
|
+
annotation = pd.Series(adata.obs[annotation].values, index=adata.obs_names, name='annotation')
|
29
|
+
space_coord_concat = pd.concat([space_coord_concat, annotation], axis=1)
|
30
|
+
return space_coord_concat
|
31
|
+
|
32
|
+
|
33
|
+
# %%
|
34
|
+
def draw_scatter(space_coord_concat, title=None, fig_style: Literal['dark', 'light'] = 'light',
|
35
|
+
point_size: int = None, width=800, height=600, annotation=None):
|
36
|
+
# change theme to plotly_white
|
37
|
+
if fig_style == 'dark':
|
38
|
+
px.defaults.template = "plotly_dark"
|
39
|
+
else:
|
40
|
+
px.defaults.template = "plotly_white"
|
41
|
+
|
42
|
+
custom_color_scale = [
|
43
|
+
(1, '#d73027'), # Red
|
44
|
+
(7 / 8, '#f46d43'), # Red-Orange
|
45
|
+
(6 / 8, '#fdae61'), # Orange
|
46
|
+
(5 / 8, '#fee090'), # Light Orange
|
47
|
+
(4 / 8, '#e0f3f8'), # Light Blue
|
48
|
+
(3 / 8, '#abd9e9'), # Sky Blue
|
49
|
+
(2 / 8, '#74add1'), # Medium Blue
|
50
|
+
(1 / 8, '#4575b4'), # Dark Blue
|
51
|
+
(0, '#313695') # Deep Blue
|
52
|
+
]
|
53
|
+
# custom_color_scale = px.colors.diverging.balance
|
54
|
+
custom_color_scale.reverse()
|
55
|
+
fig = px.scatter(
|
56
|
+
space_coord_concat,
|
57
|
+
x='sx',
|
58
|
+
y='sy',
|
59
|
+
color='logp', # Color the points by the 'logp' column
|
60
|
+
symbol='annotation' if annotation is not None else None,
|
61
|
+
title=title,
|
62
|
+
color_continuous_scale=custom_color_scale,
|
63
|
+
range_color=[0, max(space_coord_concat.logp)],
|
64
|
+
)
|
65
|
+
|
66
|
+
if point_size is not None:
|
67
|
+
fig.update_traces(marker=dict(size=point_size))
|
68
|
+
|
69
|
+
fig.update_layout(legend_title_text='Annotation')
|
70
|
+
|
71
|
+
fig.update_layout(
|
72
|
+
autosize=False,
|
73
|
+
width=width,
|
74
|
+
height=height,
|
75
|
+
)
|
76
|
+
|
77
|
+
# Adjusting the legend
|
78
|
+
fig.update_layout(
|
79
|
+
legend=dict(
|
80
|
+
yanchor="top",
|
81
|
+
y=0.99,
|
82
|
+
xanchor="left",
|
83
|
+
x=-0.39,
|
84
|
+
font=dict(
|
85
|
+
size=10,
|
86
|
+
)
|
87
|
+
)
|
88
|
+
)
|
89
|
+
# change color bar title
|
90
|
+
fig.update_layout(coloraxis_colorbar_title='-log10(p)')
|
91
|
+
|
92
|
+
return fig
|
93
|
+
|
94
|
+
|
95
|
+
def run_Visualize(config: VisualizeConfig):
|
96
|
+
print(f'------Loading LDSC results of {config.input_ldsc_dir}...')
|
97
|
+
ldsc = load_ldsc(ldsc_input_file=Path(config.input_ldsc_dir) / f'{config.sample_name}_{config.trait_name}.csv.gz')
|
98
|
+
|
99
|
+
print(f'------Loading ST data of {config.sample_name}...')
|
100
|
+
adata = sc.read_h5ad(f'{config.input_hdf5_path}')
|
101
|
+
|
102
|
+
space_coord_concat = load_st_coord(adata, ldsc, annotation=config.annotation)
|
103
|
+
fig = draw_scatter(space_coord_concat,
|
104
|
+
title=config.fig_title,
|
105
|
+
fig_style=config.fig_style,
|
106
|
+
point_size=config.point_size,
|
107
|
+
width=config.fig_width,
|
108
|
+
height=config.fig_height,
|
109
|
+
annotation=config.annotation
|
110
|
+
)
|
111
|
+
|
112
|
+
# save the figure to html
|
113
|
+
|
114
|
+
# Visualization
|
115
|
+
output_dir = Path(config.output_figure_dir)
|
116
|
+
output_dir.mkdir(parents=True, exist_ok=True, mode=0o755)
|
117
|
+
output_file_html = output_dir / f'{config.sample_name}_{config.trait_name}.html'
|
118
|
+
output_file_pdf = output_dir / f'{config.sample_name}_{config.trait_name}.pdf'
|
119
|
+
|
120
|
+
fig.write_html(str(output_file_html))
|
121
|
+
fig.write_image(str(output_file_pdf))
|
122
|
+
|
123
|
+
print(
|
124
|
+
f'------The visualization result is saved in a html file: {output_file_html} which can interactively viewed in a web browser and a pdf file: {output_file_pdf}.')
|
125
|
+
|
126
|
+
|
127
|
+
if __name__ == '__main__':
|
128
|
+
TEST = True
|
129
|
+
if TEST:
|
130
|
+
test_dir = '/storage/yangjianLab/chenwenhao/projects/202312_gsMap/data/gsMap_test/Nature_Neuroscience_2021'
|
131
|
+
name = 'E16.5_E1S1'
|
132
|
+
|
133
|
+
config = VisualizeConfig(
|
134
|
+
input_hdf5_path=f'/storage/yangjianLab/songliyang/SpatialData/Data/Embryo/Mice/Cell_MOSTA/h5ad/E16.5_E1S1.MOSTA.h5ad',
|
135
|
+
input_ldsc_dir=
|
136
|
+
f'/storage/yangjianLab/songliyang/SpatialData/Data/Embryo/Mice/Cell_MOSTA/ldsc_enrichment_frac/E16.5_E1S1/',
|
137
|
+
output_figure_dir='/storage/yangjianLab/chenwenhao/projects/202312_gsMap/data/gsMap_test/Nature_Neuroscience_2021/snake_workdir/Cortex_151507/figure/',
|
138
|
+
sample_name=name,
|
139
|
+
trait_name='GIANT_EUR_Height_2022_Nature',
|
140
|
+
fig_title='GIANT_EUR_Height_2022_Nature',
|
141
|
+
fig_height=800,
|
142
|
+
fig_width=800,
|
143
|
+
fig_style='light',
|
144
|
+
point_size=2,
|
145
|
+
annotation='annotation',
|
146
|
+
)
|
147
|
+
run_Visualize(config)
|
148
|
+
else:
|
149
|
+
parser = argparse.ArgumentParser(description="Visualization the results")
|
150
|
+
add_Visualization_args(parser)
|
151
|
+
args = parser.parse_args()
|
152
|
+
config = VisualizeConfig(**vars(args))
|
153
|
+
|
154
|
+
run_Visualize(config)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 liyang
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,124 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: gsMap
|
3
|
+
Version: 1.60
|
4
|
+
Summary: Genetics-informed pathogenic spatial mapping
|
5
|
+
Author-email: liyang <songliyang@westlake.edu.cn>, wenhao <chenwenhao@westlake.edu.cn>
|
6
|
+
Requires-Python: >=3.8
|
7
|
+
Description-Content-Type: text/markdown
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
9
|
+
Classifier: Intended Audience :: Developers
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
11
|
+
Classifier: Programming Language :: Python :: 3.8
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
14
|
+
Requires-Dist: numpy
|
15
|
+
Requires-Dist: pandas
|
16
|
+
Requires-Dist: scipy
|
17
|
+
Requires-Dist: scikit-learn
|
18
|
+
Requires-Dist: matplotlib
|
19
|
+
Requires-Dist: seaborn
|
20
|
+
Requires-Dist: tqdm
|
21
|
+
Requires-Dist: progress
|
22
|
+
Requires-Dist: pyyaml
|
23
|
+
Requires-Dist: torch
|
24
|
+
Requires-Dist: torch-geometric
|
25
|
+
Requires-Dist: pyranges
|
26
|
+
Requires-Dist: pyfiglet
|
27
|
+
Requires-Dist: plotly
|
28
|
+
Requires-Dist: kaleido
|
29
|
+
Requires-Dist: sphinx ; extra == "doc"
|
30
|
+
Requires-Dist: sphinx-argparse ; extra == "doc"
|
31
|
+
Requires-Dist: sphinx-autobuild ; extra == "doc"
|
32
|
+
Requires-Dist: sphinx-autodoc-typehints ; extra == "doc"
|
33
|
+
Requires-Dist: sphinx-basic-ng ; extra == "doc"
|
34
|
+
Requires-Dist: sphinx-charts ; extra == "doc"
|
35
|
+
Requires-Dist: sphinx-copybutton ; extra == "doc"
|
36
|
+
Requires-Dist: sphinx_inline_tabs ; extra == "doc"
|
37
|
+
Requires-Dist: sphinx-markdown-tables ; extra == "doc"
|
38
|
+
Requires-Dist: sphinx-rtd-theme ; extra == "doc"
|
39
|
+
Requires-Dist: sphinxcontrib-applehelp ; extra == "doc"
|
40
|
+
Requires-Dist: sphinxcontrib-devhelp ; extra == "doc"
|
41
|
+
Requires-Dist: sphinxcontrib-htmlhelp ; extra == "doc"
|
42
|
+
Requires-Dist: sphinxcontrib-jquery ; extra == "doc"
|
43
|
+
Requires-Dist: sphinxcontrib-jsmath ; extra == "doc"
|
44
|
+
Requires-Dist: sphinxcontrib-qthelp ; extra == "doc"
|
45
|
+
Requires-Dist: sphinxcontrib-serializinghtml ; extra == "doc"
|
46
|
+
Requires-Dist: furo ; extra == "doc"
|
47
|
+
Requires-Dist: myst-parser ; extra == "doc"
|
48
|
+
Requires-Dist: nbsphinx ; extra == "doc"
|
49
|
+
Project-URL: Documentation, https://...
|
50
|
+
Project-URL: Home, https://github.com/LeonSong1995/gsMap
|
51
|
+
Project-URL: Website, https://...
|
52
|
+
Provides-Extra: doc
|
53
|
+
|
54
|
+
# gsMap (genetically informed spatial mapping of cells for complex traits)
|
55
|
+
[](https://github.com/LeonSong1995/gsMap/stargazers)
|
56
|
+
[](https://opensource.org/licenses/MIT)
|
57
|
+
|
58
|
+
|
59
|
+
## Features
|
60
|
+
|
61
|
+
....
|
62
|
+
|
63
|
+
## Installation
|
64
|
+
|
65
|
+
install use pip:
|
66
|
+
|
67
|
+
```bash
|
68
|
+
pip install gsMap-mapping
|
69
|
+
```
|
70
|
+
|
71
|
+
install from source:
|
72
|
+
|
73
|
+
```bash
|
74
|
+
git clone
|
75
|
+
cd gsMap-mapping
|
76
|
+
pip install -e .
|
77
|
+
```
|
78
|
+
|
79
|
+
## Usage
|
80
|
+
|
81
|
+
To use gsMap, navigate to the command line and enter `gsMap` followed by the subcommand that corresponds to the desired operation. Each subcommand may require specific arguments to run.
|
82
|
+
|
83
|
+
### Basic Command Structure
|
84
|
+
|
85
|
+
```bash
|
86
|
+
gsMap subcommand [arguments...]
|
87
|
+
```
|
88
|
+
|
89
|
+
- `subcommand`: The specific operation you wish to perform.
|
90
|
+
- `arguments`: The arguments and options required for the subcommand.
|
91
|
+
|
92
|
+
### Available Subcommands
|
93
|
+
|
94
|
+
(Provide a list and brief description of each available subcommand. For example:)
|
95
|
+
|
96
|
+
- `run_find_latent_representations`: Finds latent representations using a GNN-VAE model.
|
97
|
+
- `run_latent_to_gene`: Maps latent representations to gene markers.
|
98
|
+
- `run_generate_ldscore`: Generates LD scores for genomic spots.
|
99
|
+
- `run_spatial_ldsc`: Conducts spatial LDSC analysis.
|
100
|
+
- `run_cauchy_combination`: Performs Cauchy combination tests for annotations.
|
101
|
+
- `run_all_mode`: Executes a comprehensive pipeline covering all steps.
|
102
|
+
|
103
|
+
### Examples
|
104
|
+
|
105
|
+
To run a specific functionality, you need to provide the appropriate subcommand and arguments. For example:
|
106
|
+
### Running Requirement
|
107
|
+
|
108
|
+
|
109
|
+
```bash
|
110
|
+
gsMap run_find_latent_representations --input_hdf5_path <path> --output_hdf5_path <path> --sample_name <name>
|
111
|
+
```
|
112
|
+
|
113
|
+
This command initiates the process of finding latent representations based on the given HDF5 input and output paths and sample name.
|
114
|
+
|
115
|
+
## Contributing
|
116
|
+
|
117
|
+
...
|
118
|
+
|
119
|
+
## License
|
120
|
+
|
121
|
+
....
|
122
|
+
|
123
|
+
---
|
124
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
gsMap/__init__.py,sha256=JxySn7SeLHZIin7_NnWdVJk6FCUs8Ov4Pttwn2fL4N0,78
|
2
|
+
gsMap/__main__.py,sha256=jR-HT42Zzfj2f-7kFJy0bkWjNxcV1MyfQHXFpef2nSE,62
|
3
|
+
gsMap/cauchy_combination_test.py,sha256=WI71HmSJ38Q2VEohnVrWHL02MnY0clqX9Fb5VrXCCz4,6758
|
4
|
+
gsMap/config.py,sha256=2-gQR-nJRI9XfxegGCuUYMPDf43nuo7gWXR8JhtKWjs,39578
|
5
|
+
gsMap/find_latent_representation.py,sha256=liRXtQKixYwGA6ZQmfXXVeHAypobACYO1wYT-wyr3AU,8337
|
6
|
+
gsMap/format_sumstats.py,sha256=wC8eSFCbD8qpq5JOaxhYP5iL3JZ6NmG-JPThyQ52tDM,13838
|
7
|
+
gsMap/generate_ldscore.py,sha256=s2nhq9MvQa6wfRRsCe93lv54zyimvNn1aW0-dG-PsXo,25494
|
8
|
+
gsMap/generate_r2_matrix.py,sha256=BGe4WrCm19nQwzYz5vmNIC7tfIM2_QUMPd8JdfFDock,29761
|
9
|
+
gsMap/jackknife.py,sha256=nEDPVQJOPQ_uqfUCGX_v5cQwokgCqUmJTT_8rVFuIQo,18244
|
10
|
+
gsMap/latent_to_gene.py,sha256=lvEokL3po0kTnMk7mQvBwN0gkfO26myudRRQX1pX0BQ,11269
|
11
|
+
gsMap/main.py,sha256=ttGY1uSmHaC6R1fPfuvonr3Nj5lZt_U3UFw15VQKDIM,1511
|
12
|
+
gsMap/make_annotations.py,sha256=QhI3aTO9eOUuqvDXLe23eUGjld7bt_1H6vtvWX5TR5Y,23984
|
13
|
+
gsMap/regression_read.py,sha256=ATfUapl4zypkUwo8xivzD7aGlZNSMavR-xVavSsmVkI,8780
|
14
|
+
gsMap/spatial_ldsc_multiple_sumstats.py,sha256=Ixt8HpWZyJ7L1OA539mkvykdIDoZG9VT9ivwRmCOSwA,14440
|
15
|
+
gsMap/visualize.py,sha256=FMuSInYfNZQMLHgh-jjER4j-U78SQVNCZJOTnL-xhgM,5645
|
16
|
+
gsMap/GNN_VAE/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
|
+
gsMap/GNN_VAE/adjacency_matrix.py,sha256=0-qw5qHGrGugkjgVyWLYjC0Qa_iKvR1TnFxAgCaxJFw,3500
|
18
|
+
gsMap/GNN_VAE/model.py,sha256=3uWTM_zjgCjBGnuutiua0ZV2W7WiIG5RA9Y9gRHmYA8,3349
|
19
|
+
gsMap/GNN_VAE/train.py,sha256=cAj81gJ9AwV-f5gqS1PjNtfkcZ1s_TtRcDIPIb4AtoM,3389
|
20
|
+
gsmap-1.60.dist-info/entry_points.txt,sha256=f5v4sQuuAI2r6HiM9_2b_awPm9-IkqCk9KuAQIp5nNs,41
|
21
|
+
gsmap-1.60.dist-info/LICENSE,sha256=Ni2F-lLSv_H1xaVT3CoSrkiKzMvlgwh-dq8PE1esGyI,1094
|
22
|
+
gsmap-1.60.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
23
|
+
gsmap-1.60.dist-info/METADATA,sha256=GelXw8zrDlZivWoHXDgMlKNk_abULmj15KQ9skrJTog,3940
|
24
|
+
gsmap-1.60.dist-info/RECORD,,
|