msreport 0.0.24__py3-none-any.whl → 0.0.26__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.
msreport/__init__.py CHANGED
@@ -10,4 +10,4 @@ import msreport.normalize
10
10
  import msreport.plot
11
11
  import msreport.reader
12
12
 
13
- __version__ = "0.0.24"
13
+ __version__ = "0.0.26"
msreport/helper/table.py CHANGED
@@ -176,12 +176,22 @@ def find_sample_columns(
176
176
  columns.
177
177
 
178
178
  Returns:
179
- A list of sample column names.
179
+ A list of column names containing the substring and any entry of 'samples'.
180
+ Columns are returned in the order of entries in 'samples'.
180
181
  """
182
+ WHITESPACE_CHARS = " ."
183
+
181
184
  matched_columns = []
182
- for column in find_columns(table, substring):
183
- if any([sample in column for sample in samples]):
184
- matched_columns.append(column)
185
+ substring_columns = find_columns(table, substring)
186
+ for sample in samples:
187
+ sample_columns = [c for c in substring_columns if sample in c]
188
+ for col in sample_columns:
189
+ column_remainder = (
190
+ col.replace(substring, "").replace(sample, "").strip(WHITESPACE_CHARS)
191
+ )
192
+ if column_remainder == "":
193
+ matched_columns.append(col)
194
+ break
185
195
  return matched_columns
186
196
 
187
197
 
msreport/plot.py CHANGED
@@ -718,7 +718,10 @@ def volcano_ma(
718
718
  )
719
719
 
720
720
  ax.set_xlabel(x_variable)
721
- ax.set_ylabel(f"{y_variable} [-log10]")
721
+ if y_variable == pvalue_tag:
722
+ ax.set_ylabel(f"{y_variable} [-log10]")
723
+ else:
724
+ ax.set_ylabel(f"{y_variable} [log2]")
722
725
 
723
726
  fig.tight_layout()
724
727
  return fig, axes
@@ -1075,13 +1078,13 @@ def pvalue_histogram(
1075
1078
  )
1076
1079
 
1077
1080
  # Adjust x- and y-axis
1078
- ax.set_xlabel(None)
1079
1081
  ax.set_xticks(np.arange(0, 1.01, 0.5))
1080
1082
  ax.tick_params(labelsize=9)
1081
1083
  if plot_number > 0:
1082
1084
  ax.tick_params(axis="y", color="none")
1083
1085
 
1084
- # Add second label
1086
+ # Add x-label and second y-label
1087
+ ax.set_xlabel(pvalue_tag, fontsize=9)
1085
1088
  ax2 = ax.twinx()
1086
1089
  ax2.set_yticks([])
1087
1090
  ax2.set_ylabel(comparison_group, fontsize=9)
msreport/qtable.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from __future__ import annotations
2
- from typing import Any, Optional
2
+ from typing import Any, Iterable, Optional
3
3
  import os
4
4
  import warnings
5
5
 
@@ -196,8 +196,9 @@ class Qtable:
196
196
  columns = helper.find_sample_columns(self.data, tag, samples)
197
197
  table = self.get_data(exclude_invalid=exclude_invalid)[columns]
198
198
  if samples_as_columns:
199
- mapping = _str_to_substr_mapping(columns, samples)
200
- table.rename(columns=mapping, inplace=True)
199
+ sample_to_columns = _match_samples_to_tag_columns(samples, columns, tag)
200
+ columns_to_samples = {v: k for k, v in sample_to_columns.items()}
201
+ table.rename(columns=columns_to_samples, inplace=True)
201
202
  return table
202
203
 
203
204
  def make_expression_table(
@@ -502,15 +503,30 @@ def _exclude_invalid(df: pd.DataFrame) -> pd.DataFrame:
502
503
  return df[df["Valid"]].copy()
503
504
 
504
505
 
505
- def _str_to_substr_mapping(strings, substrings) -> dict[str, str]:
506
- """Mapping of strings to substrings.
506
+ def _match_samples_to_tag_columns(
507
+ samples: Iterable[str],
508
+ columns: Iterable[str],
509
+ tag: str,
510
+ ) -> dict:
511
+ """Mapping of samples to columns which contain the sample and the tag.
507
512
 
508
- Strings point to a matching substring. If multiple substrings are found in a string,
509
- only one is reported.
513
+ Args:
514
+ samples: A list of sample names.
515
+ columns: A list of column names.
516
+ tag: A string that must be present in the column names.
517
+
518
+ Returns:
519
+ A dictionary that maps sample names to column names that contain the sample
520
+ name and the tag.
510
521
  """
522
+ WHITESPACE_CHARS = " ."
523
+
511
524
  mapping = dict()
512
- for sub in substrings:
513
- mapping.update({s: sub for s in strings if sub in s})
525
+ for sample in samples:
526
+ for col in columns:
527
+ if col.replace(tag, "").replace(sample, "").strip(WHITESPACE_CHARS) == "":
528
+ mapping[sample] = col
529
+ break
514
530
  return mapping
515
531
 
516
532
 
msreport/reader.py CHANGED
@@ -2196,9 +2196,11 @@ def extract_fragpipe_localization_probabilities(localization_entry: str) -> dict
2196
2196
  _, probabilities = msreport.peptidoform.parse_modified_sequence(
2197
2197
  probability_sequence, "(", ")"
2198
2198
  )
2199
- modification_probabilities[modification] = {
2200
- site: float(probability) for site, probability in probabilities
2201
- }
2199
+ if modification not in modification_probabilities:
2200
+ modification_probabilities[modification] = {}
2201
+ modification_probabilities[modification].update(
2202
+ {site: float(probability) for site, probability in probabilities}
2203
+ )
2202
2204
  return modification_probabilities
2203
2205
 
2204
2206
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: msreport
3
- Version: 0.0.24
3
+ Version: 0.0.26
4
4
  Summary: Post processing and analysis of quantitative proteomics data
5
5
  Author-email: "David M. Hollenstein" <hollenstein.david@gmail.com>
6
6
  License: Apache-2.0
@@ -1,4 +1,4 @@
1
- msreport/__init__.py,sha256=9Zyj1HfxCZFhrNmvHluUpPe70tZZJwQxSbALKzKqGj8,343
1
+ msreport/__init__.py,sha256=plg-xX45MtHFaMW2qKkNZMTku2gH1Eu5iY4mmFdYSa8,343
2
2
  msreport/analyze.py,sha256=JBLuFLYJjI-8NIIwzq2gEJKJYFmKyuLUwf8NgSzC9_c,25350
3
3
  msreport/errors.py,sha256=qJan3lzRX6uwnByg9LfAfGKEKC2tm9SYUBvk3TdH_AM,300
4
4
  msreport/export.py,sha256=pyB8D1VjvfJWO6ka6uMnHsbc6SRlmCyhUB2sfBlhYDQ,20095
@@ -7,9 +7,9 @@ msreport/impute.py,sha256=UJXfni8xjfIrdaq-tIa9MOyklHLQxq-LHRlbHi7G5IM,10441
7
7
  msreport/isobar.py,sha256=H6AJA81AJQ-gGoc8NEFpNAe6ofwzoK4BGnxQHZ80GlA,6551
8
8
  msreport/normalize.py,sha256=fQx1QQxusrfddcA_oATz88_ojOqClLQVxNNoJxdOOX4,19334
9
9
  msreport/peptidoform.py,sha256=C0IWyvnKivGyizkrtpA_i_lLgw8YZgIxuFBtURrE6rw,11879
10
- msreport/plot.py,sha256=q21AdLatXGLPSgD0jKYebnygMhm_c7I9Efv8Xa7sqo0,43865
11
- msreport/qtable.py,sha256=o5_yAmSvs1yv8DgJH7LGDaR4ArLLgcLwdII2zlfkOFg,22420
12
- msreport/reader.py,sha256=m550jNjJxzaORbR_fI6wB87WSY6bAjxtWuo8BSebigM,104847
10
+ msreport/plot.py,sha256=MUWYSzNKRct9JYDQE7uL_zLxlG8vjTS2so9e4EXyvHw,44005
11
+ msreport/qtable.py,sha256=g9hrVyUdQbiNkBnnFNp4JXNiEAEb_yddrefy34gYMgM,22947
12
+ msreport/reader.py,sha256=PngSiFqX0uFcXCwyU9lwKANGgG8PeoejpcMB3EmlvQc,104972
13
13
  msreport/aggregate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  msreport/aggregate/condense.py,sha256=sNBEsSqCej-zvzd8QeyaScBxUnP_UcaZWzQx9dvRAD8,5860
15
15
  msreport/aggregate/pivot.py,sha256=tCxdhSdXAgEobnsp-n2DX91PwTiNYbx_FYgY6SOef4M,5079
@@ -17,14 +17,14 @@ msreport/aggregate/summarize.py,sha256=aI0YP9Kg4ZTVjS6c9gzu3xqvLOTsYJ5ZT3FcUJyg1
17
17
  msreport/helper/__init__.py,sha256=8B7gdXn5tFeZATBF30TMaWu0ppc7xFa72JLxMYt_qUM,535
18
18
  msreport/helper/calc.py,sha256=ReMP1jA7bz-a7J1DdlAVATN9zjSXENqbw652WfjSEkY,4088
19
19
  msreport/helper/maxlfq.py,sha256=DE9yX4vjMRSmolffrpC9UkCXmSs-rCN15cnlNzma4zw,14938
20
- msreport/helper/table.py,sha256=xAp1me8c6bllfLk27JCl2mFq6fL7jAe4Ic8Gw2yNhf4,11037
20
+ msreport/helper/table.py,sha256=N-veDU3vQ2NeOfKcxUop5SfCv2iW038akkSKxU2yjzg,11464
21
21
  msreport/helper/temp.py,sha256=jNulgDATf9sKXEFWMXAhjflciOZPAqlxg_7QZS7IkW8,3736
22
22
  msreport/rinterface/__init__.py,sha256=Z1I-4buERXTPIZmhdaTKZWfbJv_qVcqnUVqIJZx1Du8,146
23
23
  msreport/rinterface/limma.py,sha256=ATtsVyGSnqUGkyodQTgdpIFhEb4dJZ6wvSjrRsCrNRY,5421
24
24
  msreport/rinterface/rinstaller.py,sha256=sm6CJD0-XSxdDpUnL9EAI_CAIgo1NucYxPI9gL93zqw,1377
25
25
  msreport/rinterface/rscripts/limma.R,sha256=gr_yjMm_YoG45irDhWOo6gkRQSTwj_7uU_p3NBRHPm8,4331
26
- msreport-0.0.24.dist-info/licenses/LICENSE.txt,sha256=Pd-b5cKP4n2tFDpdx27qJSIq0d1ok0oEcGTlbtL6QMU,11560
27
- msreport-0.0.24.dist-info/METADATA,sha256=JBfnxTvf3tal-1UgCJvocxpN79vvSP6c0O7_HOMt_lE,5339
28
- msreport-0.0.24.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
29
- msreport-0.0.24.dist-info/top_level.txt,sha256=Drl8mCckJHFIw-Ovh5AnyjKnqvLJltDOBUr1JAcHAlI,9
30
- msreport-0.0.24.dist-info/RECORD,,
26
+ msreport-0.0.26.dist-info/licenses/LICENSE.txt,sha256=Pd-b5cKP4n2tFDpdx27qJSIq0d1ok0oEcGTlbtL6QMU,11560
27
+ msreport-0.0.26.dist-info/METADATA,sha256=0OpBlUdIaAqhdzEK9Mkq12rVJpeJHuYflFI4griTxqE,5339
28
+ msreport-0.0.26.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
29
+ msreport-0.0.26.dist-info/top_level.txt,sha256=Drl8mCckJHFIw-Ovh5AnyjKnqvLJltDOBUr1JAcHAlI,9
30
+ msreport-0.0.26.dist-info/RECORD,,