protdata 0.1.2__tar.gz → 0.1.4__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.
protdata-0.1.4/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2025, Chan Zuckerberg Biohub
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.
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: protdata
3
+ Version: 0.1.4
4
+ Summary: Proteomics data loaders for AnnData format.
5
+ Author: Max Frank
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
12
+ Requires-Python: <4.0,>=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: anndata
16
+ Requires-Dist: pandas
17
+ Requires-Dist: numpy
18
+ Requires-Dist: pyteomics
19
+ Provides-Extra: dev
20
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
21
+ Requires-Dist: black~=25.1; extra == "dev"
22
+ Requires-Dist: flake8~=7.0; extra == "dev"
23
+ Requires-Dist: isort~=5.0; extra == "dev"
24
+ Requires-Dist: pre-commit~=3.0; extra == "dev"
25
+ Requires-Dist: pylint~=3.0; extra == "dev"
26
+ Requires-Dist: pytest~=8.0; extra == "dev"
27
+ Provides-Extra: docs
28
+ Requires-Dist: sphinx>=8.2.1; extra == "docs"
29
+ Requires-Dist: sphinx-book-theme>=1.1.0; extra == "docs"
30
+ Requires-Dist: sphinx-autodoc-typehints>=2.2.0; extra == "docs"
31
+ Requires-Dist: sphinx-issues>=5.0.1; extra == "docs"
32
+ Requires-Dist: sphinx-copybutton; extra == "docs"
33
+ Requires-Dist: sphinx-toolbox>=3.8.0; extra == "docs"
34
+ Requires-Dist: sphinxext.opengraph; extra == "docs"
35
+ Requires-Dist: sphinx_design; extra == "docs"
36
+ Requires-Dist: myst-nb; extra == "docs"
37
+ Requires-Dist: scanpydoc[theme,typehints]>=0.15.3; extra == "docs"
38
+ Requires-Dist: awkward>=2.3; extra == "docs"
39
+ Requires-Dist: IPython; extra == "docs"
40
+ Requires-Dist: myst_parser; extra == "docs"
41
+ Dynamic: license-file
42
+
43
+ # protdata
44
+
45
+ [![Test](https://github.com/czbiohub-sf/protdata/actions/workflows/test.yml/badge.svg)](https://github.com/czbiohub-sf/protdata/actions/workflows/test.yml)
46
+ ![PyPI - Version](https://img.shields.io/pypi/v/protdata)
47
+ [![docs online](https://img.shields.io/badge/docs-online-blue)](https://protdata-czbiohub.vercel.app/)
48
+
49
+ Proteomics data loaders for the [AnnData](https://anndata.readthedocs.io/) format.
50
+
51
+ This package provides loader functions to import proteomics data (e.g., MaxQuant) into the AnnData structure for downstream analysis and integration with single-cell and multi-omics workflows.
52
+
53
+ ## Features
54
+
55
+ - **Multiple formats**: Support for MaxQuant, FragPipe, DIA-NN, and mzTab files
56
+ - **Reads metadata**: Automatically extracts and organizes sample and protein metadata
57
+
58
+ ## Installation
59
+
60
+ Protdata has minimal dependencies listed in [pyproject.toml](https://github.com/czbiohub-sf/protdata/blob/main/pyproject.toml)
61
+
62
+ To install the latest release from PyPI, run:
63
+
64
+ ```bash
65
+ pip install protdata
66
+ ```
67
+
68
+ Or install from source:
69
+ ```bash
70
+ git clone https://github.com/czbiohub-sf/protdata.git
71
+ cd protdata
72
+ pip install -e . # or make setup-develop for developers
73
+ ```
74
+
75
+ ## Usage Example
76
+
77
+ ### MaxQuant Import
78
+
79
+ You can download an example proteinGroups [file here](https://github.com/czbiohub-sf/protdata/raw/main/data/proteinGroups.txt)
80
+ ```python
81
+ import protdata
82
+
83
+ adata = load_maxquant_to_anndata("/path/to/proteinGroups.txt")
84
+ print(adata)
85
+ ```
86
+
87
+ ### DIA-NN Import
88
+
89
+ You can download an example DIA-NN report [file here](https://github.com/czbiohub-sf/protdata/raw/main/data/report.pg_matrix.tsv)
90
+
91
+ ```python
92
+ from protdata.io import read_diann
93
+
94
+ adata = read_diann("/path/to/report.pg_matrix.tsv")
95
+ print(adata)
96
+ ```
97
+
98
+ ### FragPipe Import
99
+
100
+ You can download an example FragPipe output [file here](https://github.com/czbiohub-sf/protdata/raw/main/data/combined_protein.tsv)
101
+
102
+ ```python
103
+ from protdata.io import read_fragpipe
104
+
105
+ adata = read_fragpipe("/path/to/combined_protein.tsv")
106
+ print(adata)
107
+ ```
108
+
109
+ ### mzTab Import
110
+
111
+ You can download an example mzTab [file here](https://github.com/czbiohub-sf/protdata/raw/main/data/SILAC_SQ.mzTab)
112
+
113
+ ```python
114
+ from protdata.io import read_mztab
115
+
116
+ adata = read_mztab("/path/to/SILAC_SQ.mzTab")
117
+ print(adata)
118
+ ```
119
+ ## Authors
120
+
121
+ `protdata` is created and maintained by the [Computational Biology Platform](https://www.czbiohub.org/comp-biology/) at the [Chan Zuckerberg Biohub San Francisco](https://www.czbiohub.org/sf/).
122
+
123
+ To get in touch please use the [GihHub issues](https://github.com/czbiohub-sf/protdata/issues) page.
124
+
125
+ ## Contributing
126
+
127
+ If you want to contribute to `protdata`, please read the [Contribution Guide](https://prodata.sf.czbiohub.org/contributing)
128
+
129
+ ## Changelog
130
+ See [Release Notes](https://prodata.sf.czbiohub.org/release_notes)
@@ -0,0 +1,88 @@
1
+ # protdata
2
+
3
+ [![Test](https://github.com/czbiohub-sf/protdata/actions/workflows/test.yml/badge.svg)](https://github.com/czbiohub-sf/protdata/actions/workflows/test.yml)
4
+ ![PyPI - Version](https://img.shields.io/pypi/v/protdata)
5
+ [![docs online](https://img.shields.io/badge/docs-online-blue)](https://protdata-czbiohub.vercel.app/)
6
+
7
+ Proteomics data loaders for the [AnnData](https://anndata.readthedocs.io/) format.
8
+
9
+ This package provides loader functions to import proteomics data (e.g., MaxQuant) into the AnnData structure for downstream analysis and integration with single-cell and multi-omics workflows.
10
+
11
+ ## Features
12
+
13
+ - **Multiple formats**: Support for MaxQuant, FragPipe, DIA-NN, and mzTab files
14
+ - **Reads metadata**: Automatically extracts and organizes sample and protein metadata
15
+
16
+ ## Installation
17
+
18
+ Protdata has minimal dependencies listed in [pyproject.toml](https://github.com/czbiohub-sf/protdata/blob/main/pyproject.toml)
19
+
20
+ To install the latest release from PyPI, run:
21
+
22
+ ```bash
23
+ pip install protdata
24
+ ```
25
+
26
+ Or install from source:
27
+ ```bash
28
+ git clone https://github.com/czbiohub-sf/protdata.git
29
+ cd protdata
30
+ pip install -e . # or make setup-develop for developers
31
+ ```
32
+
33
+ ## Usage Example
34
+
35
+ ### MaxQuant Import
36
+
37
+ You can download an example proteinGroups [file here](https://github.com/czbiohub-sf/protdata/raw/main/data/proteinGroups.txt)
38
+ ```python
39
+ import protdata
40
+
41
+ adata = load_maxquant_to_anndata("/path/to/proteinGroups.txt")
42
+ print(adata)
43
+ ```
44
+
45
+ ### DIA-NN Import
46
+
47
+ You can download an example DIA-NN report [file here](https://github.com/czbiohub-sf/protdata/raw/main/data/report.pg_matrix.tsv)
48
+
49
+ ```python
50
+ from protdata.io import read_diann
51
+
52
+ adata = read_diann("/path/to/report.pg_matrix.tsv")
53
+ print(adata)
54
+ ```
55
+
56
+ ### FragPipe Import
57
+
58
+ You can download an example FragPipe output [file here](https://github.com/czbiohub-sf/protdata/raw/main/data/combined_protein.tsv)
59
+
60
+ ```python
61
+ from protdata.io import read_fragpipe
62
+
63
+ adata = read_fragpipe("/path/to/combined_protein.tsv")
64
+ print(adata)
65
+ ```
66
+
67
+ ### mzTab Import
68
+
69
+ You can download an example mzTab [file here](https://github.com/czbiohub-sf/protdata/raw/main/data/SILAC_SQ.mzTab)
70
+
71
+ ```python
72
+ from protdata.io import read_mztab
73
+
74
+ adata = read_mztab("/path/to/SILAC_SQ.mzTab")
75
+ print(adata)
76
+ ```
77
+ ## Authors
78
+
79
+ `protdata` is created and maintained by the [Computational Biology Platform](https://www.czbiohub.org/comp-biology/) at the [Chan Zuckerberg Biohub San Francisco](https://www.czbiohub.org/sf/).
80
+
81
+ To get in touch please use the [GihHub issues](https://github.com/czbiohub-sf/protdata/issues) page.
82
+
83
+ ## Contributing
84
+
85
+ If you want to contribute to `protdata`, please read the [Contribution Guide](https://prodata.sf.czbiohub.org/contributing)
86
+
87
+ ## Changelog
88
+ See [Release Notes](https://prodata.sf.czbiohub.org/release_notes)
@@ -0,0 +1,102 @@
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+ from datetime import datetime
5
+ from importlib import metadata
6
+ from pathlib import Path
7
+
8
+ from sphinx.application import Sphinx
9
+
10
+ HERE = Path(__file__).parent
11
+ sys.path.insert(0, str(HERE.parent.parent))
12
+
13
+ import protdata
14
+
15
+
16
+ # -- General configuration ------------------------------------------------
17
+
18
+ project = "protdata"
19
+ author = "Max Frank"
20
+ copyright = f"{datetime.now():%Y}, Max Frank"
21
+ release = version = metadata.version("protdata")
22
+
23
+ templates_path = ["_templates"]
24
+ html_static_path = ["_static"]
25
+ source_suffix = {".rst": "restructuredtext", ".md": "myst-nb"}
26
+ master_doc = "index"
27
+ default_role = "literal"
28
+ exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"]
29
+ pygments_style = "sphinx"
30
+ html_favicon = "_static/img/protdata_favicon.svg"
31
+
32
+ extensions = [
33
+ "myst_nb",
34
+ "sphinx_copybutton",
35
+ "sphinx.ext.autodoc",
36
+ "sphinx.ext.intersphinx",
37
+ "sphinx.ext.doctest",
38
+ "sphinx.ext.coverage",
39
+ "sphinx.ext.mathjax",
40
+ "sphinx.ext.napoleon",
41
+ "sphinx.ext.autosummary",
42
+ "sphinx_autodoc_typehints",
43
+ "sphinx_issues",
44
+ "sphinx_design",
45
+ "sphinxext.opengraph",
46
+ "scanpydoc",
47
+ "IPython.sphinxext.ipython_console_highlighting",
48
+ ]
49
+
50
+ myst_enable_extensions = ["colon_fence", "dollarmath"]
51
+ myst_heading_anchors = 3
52
+ nb_execution_mode = "off"
53
+
54
+ autosummary_generate = True
55
+ autodoc_member_order = "bysource"
56
+ napoleon_google_docstring = False
57
+ napoleon_numpy_docstring = True
58
+ napoleon_use_rtype = True
59
+ napoleon_use_param = True
60
+ typehints_defaults = "braces"
61
+ issues_github_path = "czbiohub-sf/protdata"
62
+
63
+ nitpicky = True
64
+ nitpick_ignore = []
65
+
66
+ intersphinx_mapping = dict(
67
+ python=("https://docs.python.org/3", None),
68
+ numpy=("https://numpy.org/doc/stable", None),
69
+ pandas=("https://pandas.pydata.org/pandas-docs/stable", None),
70
+ anndata=("https://anndata.readthedocs.io/en/stable/", None),
71
+ scipy=("https://docs.scipy.org/doc/scipy", None),
72
+ h5py=("https://docs.h5py.org/en/latest", None),
73
+ )
74
+
75
+ # qualname_overrides = {
76
+ # "h5py._hl.group.Group": "h5py.Group",
77
+ # "h5py._hl.files.File": "h5py.File",
78
+ # "h5py._hl.dataset.Dataset": "h5py.Dataset",
79
+ # "anndata._core.anndata.AnnData": "anndata.AnnData",
80
+ # }
81
+
82
+
83
+ # -- Social cards ---------------------------------------------------------
84
+
85
+ # ogp_site_url = "https://protdata.readthedocs.io/"
86
+
87
+
88
+ # -- Options for HTML output ----------------------------------------------
89
+
90
+ html_theme = "scanpydoc"
91
+ html_theme_options = dict(
92
+ use_repository_button=True,
93
+ repository_url="https://github.com/czbiohub-sf/protdata",
94
+ repository_branch="main",
95
+ navigation_with_keys=False,
96
+ )
97
+ html_show_sphinx = False
98
+ html_logo = "_static/img/protdata_schema.svg"
99
+
100
+
101
+ def setup(app: Sphinx):
102
+ app.add_css_file("css/custom.css")
@@ -1,8 +1,11 @@
1
- import pandas as pd
2
- import numpy as np
3
- import anndata as ad
4
- from typing import Union
5
1
  import os
2
+ from typing import Union
3
+
4
+ import anndata as ad
5
+ import numpy as np
6
+ import pandas as pd
7
+
8
+ from .utils import cleanup_obsvar
6
9
 
7
10
 
8
11
  def read_diann(
@@ -13,17 +16,22 @@ def read_diann(
13
16
  """
14
17
  Load DIA-NN protein group matrix (report.pg_matrix.tsv) into an AnnData object.
15
18
 
16
- Args:
17
- file: Path to DIA-NN report.pg_matrix.tsv or a pandas DataFrame.
18
- intensity_suffix: Suffix for intensity columns (default: '_Intensity').
19
- index_column: Column name for protein group IDs (default: 'Protein.Group').
20
- sep: File separator (default: tab).
21
-
22
- Returns:
23
- AnnData object with:
24
- - X: intensity matrix (proteins x samples)
25
- - var: protein metadata
26
- - obs: sample metadata
19
+ Parameters
20
+ ----------
21
+ file
22
+ Path to DIA-NN report.pg_matrix.tsv file or a pandas DataFrame containing the data.
23
+ index_column
24
+ Column name for protein group IDs.
25
+ sep
26
+ File separator.
27
+
28
+ Returns
29
+ -------
30
+ :class:`anndata.AnnData` object with:
31
+
32
+ - ``X``: intensity matrix (samples x proteins)
33
+ - ``var``: protein metadata (indexed by protein group IDs)
34
+ - ``obs``: sample metadata (indexed by sample names)
27
35
  """
28
36
  if isinstance(file, pd.DataFrame):
29
37
  df = file.copy()
@@ -46,9 +54,11 @@ def read_diann(
46
54
  ]
47
55
 
48
56
  df.columns = [
49
- os.path.basename(col)
50
- if isinstance(col, str) and col not in no_sample_column
51
- else str(col)
57
+ (
58
+ os.path.basename(col)
59
+ if isinstance(col, str) and col not in no_sample_column
60
+ else str(col)
61
+ )
52
62
  for col in df.columns
53
63
  ]
54
64
 
@@ -59,7 +69,7 @@ def read_diann(
59
69
  # Find intensity columns (all columns not in no_sample_column)
60
70
  intensity_cols = df.columns.difference(no_sample_column, sort=False).tolist()
61
71
  if not intensity_cols:
62
- raise ValueError(f"No intensity columns found.")
72
+ raise ValueError("No intensity columns found.")
63
73
 
64
74
  # Build X matrix (proteins x samples)
65
75
  X = df[intensity_cols].to_numpy(dtype=np.float32).T
@@ -67,12 +77,18 @@ def read_diann(
67
77
  # Build var (proteins)
68
78
  var = df[df.columns.intersection(no_sample_column, sort=False)].copy()
69
79
  var.index = df[index_column]
80
+ var = cleanup_obsvar(var)
70
81
 
71
82
  # Build obs (samples)
72
83
  obs = pd.DataFrame(index=intensity_cols)
84
+ obs = cleanup_obsvar(obs)
73
85
 
74
86
  # Build uns
75
- uns = {"Search_Engine": "DIANN"}
87
+ uns = {
88
+ "RawInfo": {
89
+ "Search_Engine": "DIANN",
90
+ },
91
+ }
76
92
 
77
93
  # Create AnnData
78
94
  adata = ad.AnnData(X=X, obs=obs, var=var)
@@ -1,8 +1,11 @@
1
- import pandas as pd
2
- import numpy as np
3
- import anndata as ad
4
- from typing import Union
5
1
  import warnings
2
+ from typing import Union
3
+
4
+ import anndata as ad
5
+ import numpy as np
6
+ import pandas as pd
7
+
8
+ from .utils import cleanup_obsvar
6
9
 
7
10
 
8
11
  def read_fragpipe(
@@ -16,21 +19,28 @@ def read_fragpipe(
16
19
  sep: str = "\t",
17
20
  ) -> ad.AnnData:
18
21
  """
19
- Load FragPipe-Philosopher protein group matrix into an AnnData object.
20
-
21
- Args:
22
- file: Path to combined_protein.tsv or a pandas DataFrame.
23
- intensity_column_prefix: Prefix for intensity columns (default: '[sample] MaxLFQ Intensity ').
24
- index_column: Column name for protein IDs (default: 'Protein').
25
- gene_names_column: Column name for gene names (default: 'Gene Names').
26
- confidence_column: Column name for protein probability (default: 'Protein Probability').
27
- sep: File separator (default: tab).
28
-
29
- Returns:
30
- AnnData object with:
31
- - X: intensity matrix (proteins x samples)
32
- - var: protein metadata
33
- - obs: sample metadata
22
+ Load a FragPipe protein group matrix into an AnnData object.
23
+
24
+ Parameters
25
+ ----------
26
+ file
27
+ Path to the FragPipe combined_protein.tsv file or a pandas DataFrame containing the data.
28
+ intensity_column_suffixes
29
+ Suffix(es) for intensity columns to extract.
30
+ The first suffix is used for the main matrix (X), others are stored as layers if present.
31
+ index_column
32
+ Column name to use as protein index.
33
+ sep
34
+ File separator if reading from file.
35
+
36
+ Returns
37
+ -------
38
+ :class:`anndata.AnnData` object with:
39
+
40
+ - ``X``: intensity matrix (samples x proteins)
41
+ - ``var``: protein metadata (indexed by protein IDs)
42
+ - ``obs``: sample metadata (indexed by sample names)
43
+ - ``layers``: additional intensity matrices if multiple intensity column suffixes are provided
34
44
  """
35
45
  if isinstance(intensity_column_suffixes, str):
36
46
  intensity_column_suffixes = [intensity_column_suffixes]
@@ -74,12 +84,18 @@ def read_fragpipe(
74
84
  )
75
85
  var = df.loc[:, ~sample_columns].copy()
76
86
  var.index = df[index_column]
87
+ var = cleanup_obsvar(var)
77
88
 
78
89
  # Build obs (samples)
79
90
  obs = pd.DataFrame(index=sample_names)
91
+ obs = cleanup_obsvar(obs)
80
92
 
81
93
  # Build uns
82
- uns = {"Search_Engine": "FragPipe_Philosopher"}
94
+ uns = {
95
+ "RawInfo": {
96
+ "Search_Engine": "FragPipe",
97
+ },
98
+ }
83
99
 
84
100
  # Create AnnData
85
101
  adata = ad.AnnData(X=X, obs=obs, var=var, layers=layers)
@@ -1,13 +1,22 @@
1
- import pandas as pd
2
- import numpy as np
3
- import anndata as ad
4
- from typing import Optional, Union, List
1
+ from __future__ import annotations
2
+
5
3
  import warnings
4
+ from typing import List, Union
5
+
6
+ import anndata as ad
7
+ import numpy as np
8
+ import pandas as pd
9
+
10
+ from .utils import cleanup_obsvar
6
11
 
7
12
 
8
13
  def read_maxquant(
9
14
  file: Union[str, pd.DataFrame],
10
- intensity_column_prefixes: List[str] | str = ["LFQ intensity ", "Intensity "],
15
+ intensity_column_prefixes: List[str] | str = [
16
+ "LFQ intensity ",
17
+ "Intensity ",
18
+ "MS/MS count ",
19
+ ],
11
20
  index_column: str = "Protein IDs",
12
21
  filter_columns: list[str] = [
13
22
  "Only identified by site",
@@ -20,18 +29,28 @@ def read_maxquant(
20
29
  """
21
30
  Load MaxQuant proteinGroups.txt into an AnnData object.
22
31
 
23
- Args:
24
- file: Path to proteinGroups.txt or a pandas DataFrame.
25
- intensity_column_prefix: Prefix for intensity columns (default: 'LFQ intensity ').
26
- index_column: Column name for protein IDs (default: 'Protein IDs').
27
- gene_names_column: Column name for gene names (default: 'Gene names').
28
- sep: File separator (default: tab).
29
-
30
- Returns:
31
- AnnData object with:
32
- - X: intensity matrix (proteins x samples)
33
- - var: protein metadata
34
- - obs: sample metadata
32
+ Parameters
33
+ ----------
34
+ file
35
+ Path to the MaxQuant proteinGroups.txt file or a pandas DataFrame containing the data.
36
+ intensity_column_prefixes
37
+ Prefix(es) for intensity columns to extract.
38
+ The first prefix is used for the main matrix (X), others are stored as layers if present.
39
+ index_column
40
+ Column name to use as protein index.
41
+ filter_columns
42
+ Columns to use for filtering out contaminants or unwanted entries.
43
+ sep
44
+ File separator if reading from file.
45
+
46
+ Returns
47
+ -------
48
+ :class:`anndata.AnnData` object with:
49
+
50
+ - ``X``: intensity matrix (samples x proteins)
51
+ - ``var``: protein metadata (indexed by protein IDs)
52
+ - ``obs``: sample metadata (indexed by sample names)
53
+ - ``layers``: additional intensity matrices if multiple intensity column prefixes are provided
35
54
  """
36
55
  if isinstance(intensity_column_prefixes, str):
37
56
  intensity_column_prefixes = [intensity_column_prefixes]
@@ -65,7 +84,10 @@ def read_maxquant(
65
84
  if col in [prefix + sample_name for sample_name in sample_names]
66
85
  ]
67
86
  if len(prefix_cols) == len(sample_names):
68
- layers[prefix.strip()] = df[prefix_cols].to_numpy(dtype=np.float32).T
87
+ # Cannot have '/' in the key (hdf5 interprets as a group for serialization)
88
+ layers[prefix.strip().replace("/", "_")] = (
89
+ df[prefix_cols].to_numpy(dtype=np.float32).T
90
+ )
69
91
  else:
70
92
  warnings.warn(
71
93
  f"Number of columns for prefix '{prefix}' does not match number of samples."
@@ -78,12 +100,19 @@ def read_maxquant(
78
100
  )
79
101
  var = df.loc[:, ~sample_columns].copy()
80
102
  var.index = df[index_column]
103
+ var = cleanup_obsvar(var)
81
104
 
82
105
  # Build obs (samples)
83
106
  obs = pd.DataFrame(index=sample_names)
107
+ obs = cleanup_obsvar(obs)
84
108
 
85
109
  # Build uns
86
- uns = {"Search_Engine": "MaxQuant"}
110
+ uns = {
111
+ "RawInfo": {
112
+ "Search_Engine": "MaxQuant",
113
+ "filter_columns": filter_columns,
114
+ },
115
+ }
87
116
 
88
117
  # Create AnnData
89
118
  adata = ad.AnnData(X=X, obs=obs, var=var, layers=layers, uns=uns)