mamsi 0.1.1__tar.gz
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.
- mamsi-0.1.1/LICENCE +28 -0
- mamsi-0.1.1/PKG-INFO +197 -0
- mamsi-0.1.1/README.md +162 -0
- mamsi-0.1.1/mamsi/Data/Adducts/adduct_all.xlsx +0 -0
- mamsi-0.1.1/mamsi/Data/Adducts/adduct_most_common.xlsx +0 -0
- mamsi-0.1.1/mamsi/Data/Adducts/all_adducts_neg.csv +16 -0
- mamsi-0.1.1/mamsi/Data/Adducts/all_adducts_pos.csv +33 -0
- mamsi-0.1.1/mamsi/Data/Adducts/common_adducts_neg.csv +10 -0
- mamsi-0.1.1/mamsi/Data/Adducts/common_adducts_pos.csv +21 -0
- mamsi-0.1.1/mamsi/Data/ROI/HPOS_ROI_V_3_2_1.csv +129 -0
- mamsi-0.1.1/mamsi/Data/ROI/LNEG_ROI_V_5_1_1.csv +132 -0
- mamsi-0.1.1/mamsi/Data/ROI/LPOS_ROI_V_5_1_2.csv +379 -0
- mamsi-0.1.1/mamsi/Data/ROI/RNEG_ROI_V_3_2_0.csv +129 -0
- mamsi-0.1.1/mamsi/Data/ROI/RPOS_ROI_V_3_2_0.csv +136 -0
- mamsi-0.1.1/mamsi/__init__.py +2 -0
- mamsi-0.1.1/mamsi/mamsi_pls.py +505 -0
- mamsi-0.1.1/mamsi/mamsi_struct_search.py +1005 -0
- mamsi-0.1.1/mamsi.egg-info/PKG-INFO +197 -0
- mamsi-0.1.1/mamsi.egg-info/SOURCES.txt +22 -0
- mamsi-0.1.1/mamsi.egg-info/dependency_links.txt +1 -0
- mamsi-0.1.1/mamsi.egg-info/requires.txt +9 -0
- mamsi-0.1.1/mamsi.egg-info/top_level.txt +1 -0
- mamsi-0.1.1/setup.cfg +4 -0
- mamsi-0.1.1/setup.py +48 -0
mamsi-0.1.1/LICENCE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Lukas Kopecky
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
mamsi-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: mamsi
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Multi-Adduct Mass Spectrometry Integration (MAMSI) is a Python package for the integration of multimodal LC-MS and MSI data.
|
|
5
|
+
Home-page: https://github.com/kopeckylukas/py-mamsi
|
|
6
|
+
Author: Lukas Kopecky
|
|
7
|
+
Author-email: l.kopecky22@imperial.ac.uk
|
|
8
|
+
License: BSD 3-Clause License
|
|
9
|
+
Classifier: Intended Audience :: Science/Research
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved
|
|
12
|
+
Classifier: Topic :: Software Development
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering
|
|
14
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
15
|
+
Classifier: Operating System :: POSIX
|
|
16
|
+
Classifier: Operating System :: Unix
|
|
17
|
+
Classifier: Operating System :: MacOS
|
|
18
|
+
Classifier: Programming Language :: Python
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENCE
|
|
26
|
+
Requires-Dist: mbpls==1.0.4
|
|
27
|
+
Requires-Dist: pandas
|
|
28
|
+
Requires-Dist: numpy
|
|
29
|
+
Requires-Dist: matplotlib
|
|
30
|
+
Requires-Dist: scipy
|
|
31
|
+
Requires-Dist: scikit-learn
|
|
32
|
+
Requires-Dist: seaborn
|
|
33
|
+
Requires-Dist: networkx
|
|
34
|
+
Requires-Dist: pyvis
|
|
35
|
+
|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
[](LICENCE)
|
|
39
|
+
[](https://kopeckylukas.github.io/py-mamsi/)
|
|
40
|
+
[](https://kopeckylukas.github.io/py-mamsi/)
|
|
41
|
+
|
|
42
|
+
MAMSI is a Python framework designed for the integration of multi-assay mass spectrometry datasets.
|
|
43
|
+
In addition, the MAMSI framework provides a platform for linking statistically significant features of untargeted multi-assay liquid chromatography – mass spectrometry (LC-MS) metabolomics datasets into clusters defined by their structural properties based on mass-to-charge ratio (*m/z*) and retention time (*RT*).
|
|
44
|
+
|
|
45
|
+
*N.B. the framework was tested on metabolomics phenotyping data, but it should be usable with other types of LC-MS data.*
|
|
46
|
+
|
|
47
|
+
# Overview
|
|
48
|
+
## Features
|
|
49
|
+
- Data integration analysis using the Multi-Block Partial Least Squares (MB-PLS) [[1](#references)] algorithm.
|
|
50
|
+
- Multi-Block Variable Importance in Projection (MB-VIP) [[2](#references)].
|
|
51
|
+
- Estimation of statistically significant features (variables) using MB-VIP and permutation testing.
|
|
52
|
+
- Linking significant features into clusters defined by structural properties of metabolites.
|
|
53
|
+
- Feature network links.
|
|
54
|
+
- Annotation of untargeted LC-MS features (only supported for assays analysed by the National Phenome Centre).
|
|
55
|
+
|
|
56
|
+
## Documentation
|
|
57
|
+
The documentation for this package is available at [https://kopeckylukas.github.io/py-mamsi/](https://kopeckylukas.github.io/py-mamsi/).
|
|
58
|
+
|
|
59
|
+
# Installation
|
|
60
|
+
### Dependencies
|
|
61
|
+
- mbpls==1.0.4
|
|
62
|
+
- pandas
|
|
63
|
+
- numpy
|
|
64
|
+
- matplotlib
|
|
65
|
+
- scipy
|
|
66
|
+
- scikit-learn
|
|
67
|
+
- seaborn
|
|
68
|
+
- networkx
|
|
69
|
+
- pyvis
|
|
70
|
+
|
|
71
|
+
## User Installation
|
|
72
|
+
You can install MAMSI from source code given you have installed both Python (>=3.9) and PIP.
|
|
73
|
+
|
|
74
|
+
First, clone the repository from GitHub to your computer. You can use following commands if you have a version of Git installed on your computer:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
git clone https://github.com/kopeckylukas/py-mamsi
|
|
78
|
+
|
|
79
|
+
cd py-mamsi
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
When you are in the cloned project folder, type the following code to install MAMSI and all dependencies:
|
|
83
|
+
```bahs
|
|
84
|
+
pip install .
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Alternatively**, you can install dependencies using pip and MAMSI using Python:
|
|
88
|
+
```bash
|
|
89
|
+
pip install -r requirements.txt
|
|
90
|
+
python setup.py develop
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
# Quickstart
|
|
94
|
+
You can find all MAMSI tutorials by visiting our **[MAMSI Tutorials](https://github.com/kopeckylukas/py-mamsi-tutorials)** repository or follow this quickstart guide.
|
|
95
|
+
|
|
96
|
+
**Load Packages**
|
|
97
|
+
```python
|
|
98
|
+
from mamsi.mamsi_pls import MamsiPls
|
|
99
|
+
from mamsi.mamsi_struct_search import MamsiStructSearch
|
|
100
|
+
import pandas as pd
|
|
101
|
+
import numpy as np
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Load Sample Data**
|
|
105
|
+
<br> Data used within this quickstart guide originate from the AddNeuroMed cohort [[3](#references)] - dataset of Alzheimer's disease patients.
|
|
106
|
+
You can download the sample data from this [link](https://github.com/kopeckylukas/py-mamsi-tutorials/tree/main/sample_data).
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
metadata = pd.read_csv('../sample_data/alz_metadata.csv')
|
|
111
|
+
# The PLS algorithm requires the response variable to be numeric.
|
|
112
|
+
# We will encode the outcome "Gender" (Biological Sex) as 1 for female and 0 for male subjects.
|
|
113
|
+
y = metadata["Gender"].apply(lambda x: 1 if x == 'Female' else 0)
|
|
114
|
+
|
|
115
|
+
# Import LC-MS data
|
|
116
|
+
# Add prefix to the columns names. This will be crucial for interpreting the results later on.
|
|
117
|
+
hpos = pd.read_csv('./sample_data/alz_hpos.csv').add_prefix('HPOS_')
|
|
118
|
+
lpos = pd.read_csv('./sample_data/alz_lpos.csv').add_prefix('LPOS_')
|
|
119
|
+
lneg = pd.read_csv('./sample_data/alz_lneg.csv').add_prefix('LNEG_')
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Fit MB-PLS Model and Estimate LVs**
|
|
123
|
+
```python
|
|
124
|
+
mamsipls = MamsiPls(n_components=1)
|
|
125
|
+
mamsipls.fit([hpos, lpos, lneg], y_train)
|
|
126
|
+
|
|
127
|
+
mamsipls.estimate_lv([hpos, lpos, lneg], y_train, metric='auc')
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Estimate Feature Importance**
|
|
131
|
+
<br> You can visualise the MB-VIP:
|
|
132
|
+
```python
|
|
133
|
+
mb_vip = mamsipls.mb_vip(plot=True)
|
|
134
|
+
```
|
|
135
|
+
or estimate empirical p-values for all features:
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
p_vals, null_vip = mamsipls.mb_vip_permtest([hpos, lpos, lneg], y, n_permutations=10000, return_scores=True)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Interpret Statistically Significant Features**
|
|
142
|
+
```python
|
|
143
|
+
x = pd.concat([hpos, lpos, lneg], axis=1)
|
|
144
|
+
|
|
145
|
+
mask = np.where(p_vals < 0.01)
|
|
146
|
+
selected = x.iloc[:, mask[0]]
|
|
147
|
+
```
|
|
148
|
+
Use `MamsiStrustSearch` to search for structural links within the statistically significant features. <br>
|
|
149
|
+
Firstly, all features are split into retention time (*RT*) windows of 5 seconds intervals, then each RT window is searched for isotopologue signatures by searching mass differences of 1.00335 Da between mass-to-charge ratios (*m/z*) of the features; if two or more features resemble a mass isotopologue signature then they are grouped together. This is followed by a search for common adduct signatures. This is achieved by calculating hypothetical neutral masses based on common adducts in electrospray ionisation. If hypothetical neutral masses match for two or more features within a pre-defined tolerance (15 *ppm*) then these features are grouped together. Overlapping adduct clusters and isotopologue clusters are then merged to form structural clusters. Further, we search cross-assay clusters using [M+H]<sup>+</sup>/[M-H]<sup>-</sup> as link references. Additionally, our structural search tool, that utilises region of interest [(ROI) files](https://github.com/phenomecentre/npc-open-lcms) from peakPantheR [[4](#references)], allows for automated annotation of some features based on the *RT* for a given chromatography and *m/z*.
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
struct = MamsiStructSearch(rt_win=5, ppm=10)
|
|
153
|
+
struct.load_lcms(selected)
|
|
154
|
+
struct.get_structural_clusters(annotate=True)
|
|
155
|
+
```
|
|
156
|
+
Further, you can use the `MamsiStrustSearch.get_correlation_clusters()` method to find correlation clusters.
|
|
157
|
+
```python
|
|
158
|
+
struct.get_correlation_clusters(flat_method='silhouette', max_clusters=11)
|
|
159
|
+
```
|
|
160
|
+
Finally, we visualise the structural relationships using a network plot. The different node colours represent different flattened hierarchical correlation clusters, while the edges between nodes identify their structural links. You can also save the network as an NX object and review in Cytoscape to get better insight on what the structural relationships between individual features are (e.g. adduct links, isotopologues, cross-assay links).
|
|
161
|
+
```python
|
|
162
|
+
network = struct.get_structural_network(include_all=True, interactive=False, labels=True, return_nx_object=True)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
# Issues and Collaboration
|
|
166
|
+
Thank you for supporting the MAMSI project. MAMSI is an open-source software and welcomes any form of contribution and support.
|
|
167
|
+
|
|
168
|
+
## Issues
|
|
169
|
+
Please submit any bugs or issues via the project's GitHub [issue page](https://github.com/kopeckylukas/py-mamsi/issues) and any include details about the (```mamsi.__version__```) together with any relevant input data/metadata.
|
|
170
|
+
|
|
171
|
+
## Collaboration
|
|
172
|
+
### Pull requests
|
|
173
|
+
You can actively collaborate on MAMSI package by submitting any changes via a pull request. All pull requests will be reviewed by the MAMSI team and merged in due course.
|
|
174
|
+
|
|
175
|
+
### Contributions
|
|
176
|
+
If you would like to become a contributor on the MAMSI project, please contact [Lukas Kopecky](https://profiles.imperial.ac.uk/l.kopecky22).
|
|
177
|
+
|
|
178
|
+
# Acknowledgement
|
|
179
|
+
This package was developed as part of Lukas Kopecky's PhD project at [Imperial College London](https://www.imperial.ac.uk/metabolism-digestion-reproduction/research/systems-medicine/), funded by [Waters UK](https://www.waters.com/nextgen/gb/en.html). It is free to use, published under BSD 3-Clause [licence](./LICENCE).
|
|
180
|
+
|
|
181
|
+
The authors of this package would like to acknowledge the authors of the [mbpls](https://pypi.org/project/mbpls/) package [[1](#references)] which became the backbone of MAMSI. For more information on MB-PLS, please visit [MB-PLS Documentation](https://mbpls.readthedocs.io/en/latest/index.html).
|
|
182
|
+
|
|
183
|
+
Further, we would like to thank Prof Simon Lovestone and Dr Shivani Misra for allowing us to use their data, AddNeuroMed [[3](#references)] and MY Diabetes [[5](#references)] respectively, for the development of this package.
|
|
184
|
+
|
|
185
|
+
# Citing us
|
|
186
|
+
If you use MAMSI in a scientific publication, we would appreciate citations. The MAMSI publication is currently under the review process.
|
|
187
|
+
|
|
188
|
+
# References
|
|
189
|
+
[1] A. Baum and L. Vermue, "Multiblock PLS: Block dependent prediction modeling for Python," *J. Open Source Softw.*, vol. 4, no. 34, 2019, doi: [10.21105/joss.01190](https://joss.theoj.org/papers/10.21105/joss.01190).
|
|
190
|
+
|
|
191
|
+
[2] C. Wieder *et al.*, "PathIntegrate: Multivariate modelling approaches for pathway-based multi-omics data integration," *PLOS Comput. Biol.*, vol. 20, no. 3, p. e1011814, Mar 2024, doi: [10.1371/journal.pcbi.1011814](https://pubmed.ncbi.nlm.nih.gov/38527092/).
|
|
192
|
+
|
|
193
|
+
[3] S. Lovestone *et al.*, "AddNeuroMed—The European Collaboration for the Discovery of Novel Biomarkers for Alzheimer's Disease," *Ann. N. Y. Acad. Sci*, vol. 1180, no. 1, pp. 36-46, 2009, doi: [10.1111/j.1749-6632.2009.05064.x](https://nyaspubs.onlinelibrary.wiley.com/doi/10.1111/j.1749-6632.2009.05064.x).
|
|
194
|
+
|
|
195
|
+
[4] A. M. Wolfer *et al.*, "peakPantheR, an R package for large-scale targeted extraction and integration of annotated metabolic features in LC–MS profiling datasets," *Bioinformatics*, vol. 37, no. 24, pp. 4886-4888, 2021, doi: [10.1093/bioinformatics/btab433](https://academic.oup.com/bioinformatics/article/37/24/4886/6298587).
|
|
196
|
+
|
|
197
|
+
[5] S. Misra *et al.*, "Systematic screening for monogenic diabetes in people of South Asian and African Caribbean ethnicity: Preliminary results from the My Diabetes study," presented at the *Diabet. Med.*, Mar 2018.
|
mamsi-0.1.1/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
[](LICENCE)
|
|
4
|
+
[](https://kopeckylukas.github.io/py-mamsi/)
|
|
5
|
+
[](https://kopeckylukas.github.io/py-mamsi/)
|
|
6
|
+
|
|
7
|
+
MAMSI is a Python framework designed for the integration of multi-assay mass spectrometry datasets.
|
|
8
|
+
In addition, the MAMSI framework provides a platform for linking statistically significant features of untargeted multi-assay liquid chromatography – mass spectrometry (LC-MS) metabolomics datasets into clusters defined by their structural properties based on mass-to-charge ratio (*m/z*) and retention time (*RT*).
|
|
9
|
+
|
|
10
|
+
*N.B. the framework was tested on metabolomics phenotyping data, but it should be usable with other types of LC-MS data.*
|
|
11
|
+
|
|
12
|
+
# Overview
|
|
13
|
+
## Features
|
|
14
|
+
- Data integration analysis using the Multi-Block Partial Least Squares (MB-PLS) [[1](#references)] algorithm.
|
|
15
|
+
- Multi-Block Variable Importance in Projection (MB-VIP) [[2](#references)].
|
|
16
|
+
- Estimation of statistically significant features (variables) using MB-VIP and permutation testing.
|
|
17
|
+
- Linking significant features into clusters defined by structural properties of metabolites.
|
|
18
|
+
- Feature network links.
|
|
19
|
+
- Annotation of untargeted LC-MS features (only supported for assays analysed by the National Phenome Centre).
|
|
20
|
+
|
|
21
|
+
## Documentation
|
|
22
|
+
The documentation for this package is available at [https://kopeckylukas.github.io/py-mamsi/](https://kopeckylukas.github.io/py-mamsi/).
|
|
23
|
+
|
|
24
|
+
# Installation
|
|
25
|
+
### Dependencies
|
|
26
|
+
- mbpls==1.0.4
|
|
27
|
+
- pandas
|
|
28
|
+
- numpy
|
|
29
|
+
- matplotlib
|
|
30
|
+
- scipy
|
|
31
|
+
- scikit-learn
|
|
32
|
+
- seaborn
|
|
33
|
+
- networkx
|
|
34
|
+
- pyvis
|
|
35
|
+
|
|
36
|
+
## User Installation
|
|
37
|
+
You can install MAMSI from source code given you have installed both Python (>=3.9) and PIP.
|
|
38
|
+
|
|
39
|
+
First, clone the repository from GitHub to your computer. You can use following commands if you have a version of Git installed on your computer:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git clone https://github.com/kopeckylukas/py-mamsi
|
|
43
|
+
|
|
44
|
+
cd py-mamsi
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
When you are in the cloned project folder, type the following code to install MAMSI and all dependencies:
|
|
48
|
+
```bahs
|
|
49
|
+
pip install .
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Alternatively**, you can install dependencies using pip and MAMSI using Python:
|
|
53
|
+
```bash
|
|
54
|
+
pip install -r requirements.txt
|
|
55
|
+
python setup.py develop
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
# Quickstart
|
|
59
|
+
You can find all MAMSI tutorials by visiting our **[MAMSI Tutorials](https://github.com/kopeckylukas/py-mamsi-tutorials)** repository or follow this quickstart guide.
|
|
60
|
+
|
|
61
|
+
**Load Packages**
|
|
62
|
+
```python
|
|
63
|
+
from mamsi.mamsi_pls import MamsiPls
|
|
64
|
+
from mamsi.mamsi_struct_search import MamsiStructSearch
|
|
65
|
+
import pandas as pd
|
|
66
|
+
import numpy as np
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Load Sample Data**
|
|
70
|
+
<br> Data used within this quickstart guide originate from the AddNeuroMed cohort [[3](#references)] - dataset of Alzheimer's disease patients.
|
|
71
|
+
You can download the sample data from this [link](https://github.com/kopeckylukas/py-mamsi-tutorials/tree/main/sample_data).
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
metadata = pd.read_csv('../sample_data/alz_metadata.csv')
|
|
76
|
+
# The PLS algorithm requires the response variable to be numeric.
|
|
77
|
+
# We will encode the outcome "Gender" (Biological Sex) as 1 for female and 0 for male subjects.
|
|
78
|
+
y = metadata["Gender"].apply(lambda x: 1 if x == 'Female' else 0)
|
|
79
|
+
|
|
80
|
+
# Import LC-MS data
|
|
81
|
+
# Add prefix to the columns names. This will be crucial for interpreting the results later on.
|
|
82
|
+
hpos = pd.read_csv('./sample_data/alz_hpos.csv').add_prefix('HPOS_')
|
|
83
|
+
lpos = pd.read_csv('./sample_data/alz_lpos.csv').add_prefix('LPOS_')
|
|
84
|
+
lneg = pd.read_csv('./sample_data/alz_lneg.csv').add_prefix('LNEG_')
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Fit MB-PLS Model and Estimate LVs**
|
|
88
|
+
```python
|
|
89
|
+
mamsipls = MamsiPls(n_components=1)
|
|
90
|
+
mamsipls.fit([hpos, lpos, lneg], y_train)
|
|
91
|
+
|
|
92
|
+
mamsipls.estimate_lv([hpos, lpos, lneg], y_train, metric='auc')
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Estimate Feature Importance**
|
|
96
|
+
<br> You can visualise the MB-VIP:
|
|
97
|
+
```python
|
|
98
|
+
mb_vip = mamsipls.mb_vip(plot=True)
|
|
99
|
+
```
|
|
100
|
+
or estimate empirical p-values for all features:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
p_vals, null_vip = mamsipls.mb_vip_permtest([hpos, lpos, lneg], y, n_permutations=10000, return_scores=True)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Interpret Statistically Significant Features**
|
|
107
|
+
```python
|
|
108
|
+
x = pd.concat([hpos, lpos, lneg], axis=1)
|
|
109
|
+
|
|
110
|
+
mask = np.where(p_vals < 0.01)
|
|
111
|
+
selected = x.iloc[:, mask[0]]
|
|
112
|
+
```
|
|
113
|
+
Use `MamsiStrustSearch` to search for structural links within the statistically significant features. <br>
|
|
114
|
+
Firstly, all features are split into retention time (*RT*) windows of 5 seconds intervals, then each RT window is searched for isotopologue signatures by searching mass differences of 1.00335 Da between mass-to-charge ratios (*m/z*) of the features; if two or more features resemble a mass isotopologue signature then they are grouped together. This is followed by a search for common adduct signatures. This is achieved by calculating hypothetical neutral masses based on common adducts in electrospray ionisation. If hypothetical neutral masses match for two or more features within a pre-defined tolerance (15 *ppm*) then these features are grouped together. Overlapping adduct clusters and isotopologue clusters are then merged to form structural clusters. Further, we search cross-assay clusters using [M+H]<sup>+</sup>/[M-H]<sup>-</sup> as link references. Additionally, our structural search tool, that utilises region of interest [(ROI) files](https://github.com/phenomecentre/npc-open-lcms) from peakPantheR [[4](#references)], allows for automated annotation of some features based on the *RT* for a given chromatography and *m/z*.
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
struct = MamsiStructSearch(rt_win=5, ppm=10)
|
|
118
|
+
struct.load_lcms(selected)
|
|
119
|
+
struct.get_structural_clusters(annotate=True)
|
|
120
|
+
```
|
|
121
|
+
Further, you can use the `MamsiStrustSearch.get_correlation_clusters()` method to find correlation clusters.
|
|
122
|
+
```python
|
|
123
|
+
struct.get_correlation_clusters(flat_method='silhouette', max_clusters=11)
|
|
124
|
+
```
|
|
125
|
+
Finally, we visualise the structural relationships using a network plot. The different node colours represent different flattened hierarchical correlation clusters, while the edges between nodes identify their structural links. You can also save the network as an NX object and review in Cytoscape to get better insight on what the structural relationships between individual features are (e.g. adduct links, isotopologues, cross-assay links).
|
|
126
|
+
```python
|
|
127
|
+
network = struct.get_structural_network(include_all=True, interactive=False, labels=True, return_nx_object=True)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
# Issues and Collaboration
|
|
131
|
+
Thank you for supporting the MAMSI project. MAMSI is an open-source software and welcomes any form of contribution and support.
|
|
132
|
+
|
|
133
|
+
## Issues
|
|
134
|
+
Please submit any bugs or issues via the project's GitHub [issue page](https://github.com/kopeckylukas/py-mamsi/issues) and any include details about the (```mamsi.__version__```) together with any relevant input data/metadata.
|
|
135
|
+
|
|
136
|
+
## Collaboration
|
|
137
|
+
### Pull requests
|
|
138
|
+
You can actively collaborate on MAMSI package by submitting any changes via a pull request. All pull requests will be reviewed by the MAMSI team and merged in due course.
|
|
139
|
+
|
|
140
|
+
### Contributions
|
|
141
|
+
If you would like to become a contributor on the MAMSI project, please contact [Lukas Kopecky](https://profiles.imperial.ac.uk/l.kopecky22).
|
|
142
|
+
|
|
143
|
+
# Acknowledgement
|
|
144
|
+
This package was developed as part of Lukas Kopecky's PhD project at [Imperial College London](https://www.imperial.ac.uk/metabolism-digestion-reproduction/research/systems-medicine/), funded by [Waters UK](https://www.waters.com/nextgen/gb/en.html). It is free to use, published under BSD 3-Clause [licence](./LICENCE).
|
|
145
|
+
|
|
146
|
+
The authors of this package would like to acknowledge the authors of the [mbpls](https://pypi.org/project/mbpls/) package [[1](#references)] which became the backbone of MAMSI. For more information on MB-PLS, please visit [MB-PLS Documentation](https://mbpls.readthedocs.io/en/latest/index.html).
|
|
147
|
+
|
|
148
|
+
Further, we would like to thank Prof Simon Lovestone and Dr Shivani Misra for allowing us to use their data, AddNeuroMed [[3](#references)] and MY Diabetes [[5](#references)] respectively, for the development of this package.
|
|
149
|
+
|
|
150
|
+
# Citing us
|
|
151
|
+
If you use MAMSI in a scientific publication, we would appreciate citations. The MAMSI publication is currently under the review process.
|
|
152
|
+
|
|
153
|
+
# References
|
|
154
|
+
[1] A. Baum and L. Vermue, "Multiblock PLS: Block dependent prediction modeling for Python," *J. Open Source Softw.*, vol. 4, no. 34, 2019, doi: [10.21105/joss.01190](https://joss.theoj.org/papers/10.21105/joss.01190).
|
|
155
|
+
|
|
156
|
+
[2] C. Wieder *et al.*, "PathIntegrate: Multivariate modelling approaches for pathway-based multi-omics data integration," *PLOS Comput. Biol.*, vol. 20, no. 3, p. e1011814, Mar 2024, doi: [10.1371/journal.pcbi.1011814](https://pubmed.ncbi.nlm.nih.gov/38527092/).
|
|
157
|
+
|
|
158
|
+
[3] S. Lovestone *et al.*, "AddNeuroMed—The European Collaboration for the Discovery of Novel Biomarkers for Alzheimer's Disease," *Ann. N. Y. Acad. Sci*, vol. 1180, no. 1, pp. 36-46, 2009, doi: [10.1111/j.1749-6632.2009.05064.x](https://nyaspubs.onlinelibrary.wiley.com/doi/10.1111/j.1749-6632.2009.05064.x).
|
|
159
|
+
|
|
160
|
+
[4] A. M. Wolfer *et al.*, "peakPantheR, an R package for large-scale targeted extraction and integration of annotated metabolic features in LC–MS profiling datasets," *Bioinformatics*, vol. 37, no. 24, pp. 4886-4888, 2021, doi: [10.1093/bioinformatics/btab433](https://academic.oup.com/bioinformatics/article/37/24/4886/6298587).
|
|
161
|
+
|
|
162
|
+
[5] S. Misra *et al.*, "Systematic screening for monogenic diabetes in people of South Asian and African Caribbean ethnicity: Preliminary results from the My Diabetes study," presented at the *Diabet. Med.*, Mar 2018.
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Ion name,Ion mass,Charge ,1/Charge,Mass
|
|
2
|
+
[M-H]-,M - 1.007276 ,1-,1,-1.007276
|
|
3
|
+
[M-H2O-H]-,M- 19.01839,1-,1,-19.01839
|
|
4
|
+
[M+Na-2H]-,M + 20.974666 ,1-,1,20.974666
|
|
5
|
+
[M+Cl]-,M + 34.969402 ,1-,1,34.969402
|
|
6
|
+
[M+Hac-H]-,M + 59.013851 ,1-,1,59.013851
|
|
7
|
+
[2M-H]-,2M - 1.007276 ,,2,-1.007276
|
|
8
|
+
[2M+FA-H]-,2M + 44.998201 ,,2,44.998201
|
|
9
|
+
[2M+Hac-H]-,2M + 59.013851 ,,2,59.013851
|
|
10
|
+
[3M-H]-,3M - 1.007276 ,,3,-1.007276
|
|
11
|
+
[M-3H]3-,M/3 - 1.007276 ,3,0.333333333,-1.007276
|
|
12
|
+
[M-2H]2-,M/2 - 1.007276 ,2,0.5,-1.007276
|
|
13
|
+
[M+K-2H]-,M + 36.948606 ,1,1,36.948606
|
|
14
|
+
[M+FA-H]-,M + 44.998201 ,1,1,44.998201
|
|
15
|
+
[M+Br]-,M + 78.918885 ,1,1,78.918885
|
|
16
|
+
[M+TFA-H]-,M + 112.985586 ,1,1,112.985586
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Ion name,Ion mass,Charge ,1/Charge,Mass
|
|
2
|
+
[M+H]+,M + 1.007276 ,1+,1,1.007276
|
|
3
|
+
[M+NH4]+,M + 18.033823 ,1+,1,18.033823
|
|
4
|
+
[M+Na]+,M + 22.989218 ,1+,1,22.989218
|
|
5
|
+
[M+K]+,M + 38.963158 ,1+,1,38.963158
|
|
6
|
+
[M+2H]2+,M/2 + 1.007276 ,2+,0.5,1.007276
|
|
7
|
+
[2M+H]+,2M + 1.007276 ,0.5,2,1.007276
|
|
8
|
+
[2M+NH4]+,2M + 18.033823 ,0.5,2,18.033823
|
|
9
|
+
[2M+Na]+,2M + 22.989218 ,0.5,2,22.989218
|
|
10
|
+
[2M+ACN+H]+,2M + 42.033823 ,0.5,2,42.033823
|
|
11
|
+
[2M+ACN+Na]+,2M + 64.015765 ,0.5,2,64.015765
|
|
12
|
+
[2M+K]+,2M + 38.963158 ,0.5,2,38.963158
|
|
13
|
+
[M+H+Na]2+,M/2 + 11.998247 ,2,0.5,11.998247
|
|
14
|
+
[M+H+K]2+,M/2 + 19.985217 ,2,0.5,19.985217
|
|
15
|
+
[M+ACN+H]+,M + 42.033823 ,1,1,42.033823
|
|
16
|
+
[M+2Na-H]+,M + 44.971160 ,1,1,44.971160
|
|
17
|
+
[M+IsoProp+H]+,M + 61.06534,1,1,61.065340
|
|
18
|
+
[M+ACN+Na]+,M + 64.015765 ,1,1,64.015765
|
|
19
|
+
[M+2K-H]+,M + 76.919040 ,1,1,76.919040
|
|
20
|
+
[M+DMSO+H]+,M + 79.02122 ,1,1,79.021220
|
|
21
|
+
[M+2ACN+H]+,M + 83.060370 ,1,1,83.060370
|
|
22
|
+
[M+IsoProp+Na+H]+,M + 84.05511,1,1,84.055110
|
|
23
|
+
[M+CH3OH+H]+,M + 33.033489 ,1,1,33.033489
|
|
24
|
+
[M+ACN+2H]2+,M/2 + 21.520550 ,2,0.5,21.520550
|
|
25
|
+
[M+2Na]2+,M/2 + 22.989218 ,2,0.5,22.989218
|
|
26
|
+
[M+2ACN+2H]2+,M/2 + 42.033823 ,2,0.5,42.033823
|
|
27
|
+
[M+3ACN+2H]2+,M/2 + 62.547097 ,2,0.5,62.547097
|
|
28
|
+
[M+H+NH4]2+,M/2 + 9.520550 ,2,0.5,9.520550
|
|
29
|
+
[M+3H]3+,M/3 + 1.007276 ,3,0.33,1.007276
|
|
30
|
+
[M+2H+Na]3+,M/3 + 8.334590 ,3,0.33,8.334590
|
|
31
|
+
[M+H+2Na]3+,M/3 + 15.7661904 ,3,0.33,15.662453
|
|
32
|
+
[M+3Na]3+,M/3 + 22.989218 ,3,0.33,22.989218
|
|
33
|
+
[M+H-H2O]+,M + 64.015765 ,1,1,-17.008024
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Ion name,Ion mass,Charge ,1/Charge,Mass
|
|
2
|
+
[M-H]-,M - 1.007276 ,1-,1,-1.007276
|
|
3
|
+
[M-H2O-H]-,M- 19.01839,1-,1,-19.01839
|
|
4
|
+
[M+Na-2H]-,M + 20.974666 ,1-,1,20.974666
|
|
5
|
+
[M+Cl]-,M + 34.969402 ,1-,1,34.969402
|
|
6
|
+
[M+Hac-H]-,M + 59.013851 ,1-,1,59.013851
|
|
7
|
+
[2M-H]-,2M - 1.007276 ,,2,-1.007276
|
|
8
|
+
[2M+FA-H]-,2M + 44.998201 ,,2,44.998201
|
|
9
|
+
[2M+Hac-H]-,2M + 59.013851 ,,2,59.013851
|
|
10
|
+
[3M-H]-,3M - 1.007276 ,,3,-1.007276
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Ion name,Ion mass,Charge ,1/Charge,Mass
|
|
2
|
+
[M+H]+,M + 1.007276 ,1+,1,1.007276
|
|
3
|
+
[M+NH4]+,M + 18.033823 ,1+,1,18.033823
|
|
4
|
+
[M+Na]+,M + 22.989218 ,1+,1,22.989218
|
|
5
|
+
[M+K]+,M + 38.963158 ,1+,1,38.963158
|
|
6
|
+
[M+2H]2+,M/2 + 1.007276 ,2+,0.5,1.007276
|
|
7
|
+
[M+H-H2O]+,M + 64.015765 ,1,1,-17.008024
|
|
8
|
+
[2M+H]+,2M + 1.007276 ,0.5,2,1.007276
|
|
9
|
+
[2M+NH4]+,2M + 18.033823 ,0.5,2,18.033823
|
|
10
|
+
[2M+Na]+,2M + 22.989218 ,0.5,2,22.989218
|
|
11
|
+
[2M+K]+,2M + 38.963158 ,0.5,2,38.963158
|
|
12
|
+
[M+H+Na]2+,M/2 + 11.998247 ,2,0.5,11.998247
|
|
13
|
+
[M+H+K]2+,M/2 + 19.985217 ,2,0.5,19.985217
|
|
14
|
+
,,,,
|
|
15
|
+
,,,,
|
|
16
|
+
,,,,
|
|
17
|
+
,,,,
|
|
18
|
+
,,,,
|
|
19
|
+
,,,,
|
|
20
|
+
,,,,
|
|
21
|
+
,,,,
|