masster 0.4.18__py3-none-any.whl → 0.4.20__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.
Potentially problematic release.
This version of masster might be problematic. Click here for more details.
- masster/__init__.py +0 -1
- masster/_version.py +1 -1
- masster/logger.py +42 -0
- masster/sample/load.py +6 -5
- masster/sample/sample.py +0 -9
- masster/study/defaults/merge_def.py +43 -2
- masster/study/helpers.py +52 -11
- masster/study/merge.py +1418 -105
- masster/study/plot.py +11 -5
- masster/study/study.py +18 -0
- masster/wizard/__init__.py +5 -2
- masster/wizard/wizard.py +1199 -27
- {masster-0.4.18.dist-info → masster-0.4.20.dist-info}/METADATA +1 -1
- {masster-0.4.18.dist-info → masster-0.4.20.dist-info}/RECORD +17 -18
- masster/wizard.py +0 -1175
- {masster-0.4.18.dist-info → masster-0.4.20.dist-info}/WHEEL +0 -0
- {masster-0.4.18.dist-info → masster-0.4.20.dist-info}/entry_points.txt +0 -0
- {masster-0.4.18.dist-info → masster-0.4.20.dist-info}/licenses/LICENSE +0 -0
masster/study/plot.py
CHANGED
|
@@ -512,9 +512,9 @@ def plot_consensus_2d(
|
|
|
512
512
|
filename=None,
|
|
513
513
|
colorby="number_samples",
|
|
514
514
|
cmap=None,
|
|
515
|
-
markersize=
|
|
515
|
+
markersize=8,
|
|
516
516
|
sizeby="inty_mean",
|
|
517
|
-
scaling="
|
|
517
|
+
scaling="static",
|
|
518
518
|
alpha=0.7,
|
|
519
519
|
width=600,
|
|
520
520
|
height=450,
|
|
@@ -529,7 +529,7 @@ def plot_consensus_2d(
|
|
|
529
529
|
colorby (str): Column name to use for color mapping (default: "number_samples")
|
|
530
530
|
sizeby (str): Column name to use for size mapping (default: "inty_mean")
|
|
531
531
|
markersize (int): Base marker size (default: 6)
|
|
532
|
-
|
|
532
|
+
scaling (str): Controls whether points scale with zoom. Options:
|
|
533
533
|
'dynamic' - points use circle() and scale with zoom
|
|
534
534
|
'static' - points use scatter() and maintain fixed pixel size
|
|
535
535
|
alpha (float): Transparency level (default: 0.7)
|
|
@@ -553,7 +553,7 @@ def plot_consensus_2d(
|
|
|
553
553
|
if colorby not in data.columns:
|
|
554
554
|
self.logger.error(f"Column {colorby} not found in consensus_df.")
|
|
555
555
|
return
|
|
556
|
-
if sizeby not in data.columns:
|
|
556
|
+
if sizeby is not None and sizeby not in data.columns:
|
|
557
557
|
self.logger.warning(f"Column {sizeby} not found in consensus_df.")
|
|
558
558
|
sizeby = None
|
|
559
559
|
# if sizeby is not None, set markersize to sizeby
|
|
@@ -673,10 +673,16 @@ def plot_consensus_2d(
|
|
|
673
673
|
p.yaxis.axis_label = "m/z"
|
|
674
674
|
scatter_renderer: Any = None
|
|
675
675
|
if scaling.lower() in ["dyn", "dynamic"]:
|
|
676
|
+
# Calculate appropriate radius for dynamic scaling based on data range
|
|
677
|
+
rt_range = data["rt"].max() - data["rt"].min()
|
|
678
|
+
mz_range = data["mz"].max() - data["mz"].min()
|
|
679
|
+
# Use a fraction of the smaller dimension for radius, similar to sample plotting
|
|
680
|
+
dynamic_radius = min(rt_range, mz_range) * 0.0005 * markersize
|
|
681
|
+
|
|
676
682
|
scatter_renderer = p.circle(
|
|
677
683
|
x="rt",
|
|
678
684
|
y="mz",
|
|
679
|
-
radius=
|
|
685
|
+
radius=dynamic_radius,
|
|
680
686
|
fill_color={"field": colorby, "transform": color_mapper},
|
|
681
687
|
line_color=None,
|
|
682
688
|
alpha=alpha,
|
masster/study/study.py
CHANGED
|
@@ -120,7 +120,10 @@ from masster.study.merge import merge
|
|
|
120
120
|
from masster.study.merge import _reset_consensus_data
|
|
121
121
|
from masster.study.merge import _extract_consensus_features
|
|
122
122
|
from masster.study.merge import _perform_adduct_grouping
|
|
123
|
+
from masster.study.merge import _consensus_cleanup
|
|
124
|
+
from masster.study.merge import _identify_adduct_by_mass_shift
|
|
123
125
|
from masster.study.merge import _finalize_merge
|
|
126
|
+
from masster.study.merge import _count_tight_clusters
|
|
124
127
|
from masster.study.processing import integrate
|
|
125
128
|
from masster.study.processing import find_ms2
|
|
126
129
|
from masster.study.parameters import store_history
|
|
@@ -496,6 +499,8 @@ class Study:
|
|
|
496
499
|
_reset_consensus_data = _reset_consensus_data
|
|
497
500
|
_extract_consensus_features = _extract_consensus_features
|
|
498
501
|
_perform_adduct_grouping = _perform_adduct_grouping
|
|
502
|
+
_consensus_cleanup = _consensus_cleanup
|
|
503
|
+
_identify_adduct_by_mass_shift = _identify_adduct_by_mass_shift
|
|
499
504
|
_finalize_merge = _finalize_merge
|
|
500
505
|
|
|
501
506
|
# === Default Parameters ===
|
|
@@ -873,6 +878,15 @@ class Study:
|
|
|
873
878
|
+ (self.consensus_mapping_df.estimated_size() if self.consensus_mapping_df is not None else 0)
|
|
874
879
|
)
|
|
875
880
|
|
|
881
|
+
# Calculate tight clusters count
|
|
882
|
+
tight_clusters_count = 0
|
|
883
|
+
if consensus_df_len > 0:
|
|
884
|
+
try:
|
|
885
|
+
tight_clusters_count = _count_tight_clusters(self, mz_tol=0.04, rt_tol=0.3)
|
|
886
|
+
except Exception as e:
|
|
887
|
+
# If tight clusters calculation fails, just use 0
|
|
888
|
+
tight_clusters_count = 0
|
|
889
|
+
|
|
876
890
|
# Add warning symbols for out-of-range values
|
|
877
891
|
consensus_warning = f" {_WARNING_SYMBOL}" if consensus_df_len < 50 else ""
|
|
878
892
|
|
|
@@ -901,6 +915,9 @@ class Study:
|
|
|
901
915
|
elif max_samples < samples_df_len * 0.8:
|
|
902
916
|
max_samples_warning = f" {_WARNING_SYMBOL}"
|
|
903
917
|
|
|
918
|
+
# Add warning for tight clusters
|
|
919
|
+
tight_clusters_warning = f" {_WARNING_SYMBOL}" if tight_clusters_count > 10 else ""
|
|
920
|
+
|
|
904
921
|
summary = (
|
|
905
922
|
f"Study folder: {self.folder}\n"
|
|
906
923
|
f"Last save: {self.filename}\n"
|
|
@@ -910,6 +927,7 @@ class Study:
|
|
|
910
927
|
f"- not in consensus: {ratio_not_in_consensus_to_total:.0f}%\n"
|
|
911
928
|
f"Consensus: {consensus_df_len}{consensus_warning}\n"
|
|
912
929
|
f"- RT spread: {rt_spread_text}{rt_spread_warning}\n"
|
|
930
|
+
f"- Tight clusters: {tight_clusters_count}{tight_clusters_warning}\n"
|
|
913
931
|
f"- Min samples count: {min_samples:.0f}\n"
|
|
914
932
|
f"- Mean samples count: {mean_samples:.0f}\n"
|
|
915
933
|
f"- Max samples count: {max_samples:.0f}{max_samples_warning}\n"
|
masster/wizard/__init__.py
CHANGED
|
@@ -4,8 +4,11 @@ Wizard module for automated processing of mass spectrometry studies.
|
|
|
4
4
|
This module provides the Wizard class for fully automated processing of MS data
|
|
5
5
|
from raw files to final study results, including batch conversion, assembly,
|
|
6
6
|
alignment, merging, plotting, and export.
|
|
7
|
+
|
|
8
|
+
The create_script() function allows immediate generation of standalone analysis
|
|
9
|
+
scripts without creating a Wizard instance first.
|
|
7
10
|
"""
|
|
8
11
|
|
|
9
|
-
from .wizard import Wizard, wizard_def
|
|
12
|
+
from .wizard import Wizard, wizard_def, create_script
|
|
10
13
|
|
|
11
|
-
__all__ = ["Wizard", "wizard_def"]
|
|
14
|
+
__all__ = ["Wizard", "wizard_def", "create_script"]
|