From 17c41c252491a40928bd8600e7642926df09f47e Mon Sep 17 00:00:00 2001 From: Tom David Mueller Date: Fri, 3 Oct 2025 19:04:13 +0200 Subject: [PATCH 1/5] utilize streaming during collect --- src/parse/deconv.py | 2 +- src/render/compression.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parse/deconv.py b/src/parse/deconv.py index aaa498b1..f6ff11d8 100644 --- a/src/parse/deconv.py +++ b/src/parse/deconv.py @@ -45,7 +45,7 @@ def parseDeconv( ) # Collect here as this is the data we are operating on - relevant_heatmap_lazy = relevant_heatmap_lazy.collect().lazy() + relevant_heatmap_lazy = relevant_heatmap_lazy.collect(streaming=True).lazy() # Get count for compression level calculation heatmap_count = relevant_heatmap_lazy.select(pl.len()).collect().item() diff --git a/src/render/compression.py b/src/render/compression.py index 316e5d2c..3db04a7e 100644 --- a/src/render/compression.py +++ b/src/render/compression.py @@ -50,7 +50,7 @@ def downsample_heatmap(data, max_datapoints=20000, rt_bins=400, mz_bins=50, logg ) # We need to collect here because scipy requires numpy arrays - sorted_data = sorted_data.collect() + sorted_data = sorted_data.collect(streaming=True).lazy() # Count peaks total_count = sorted_data.select(pl.count()).item() From 5420ac8aaf3894de4a97e7aef4eabeed2375a925 Mon Sep 17 00:00:00 2001 From: Tom David Mueller Date: Fri, 3 Oct 2025 22:20:59 +0200 Subject: [PATCH 2/5] add tic table parsing --- src/parse/deconv.py | 24 ++++++++++++++++++++++++ src/render/compression.py | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/parse/deconv.py b/src/parse/deconv.py index f6ff11d8..fa3e16ab 100644 --- a/src/parse/deconv.py +++ b/src/parse/deconv.py @@ -69,6 +69,30 @@ def parseDeconv( dataset_id, f'ms{ms_level}_{descriptor}_heatmap_{size}', current_heatmap_lazy ) + + # Create TIC table + ms1_heatmap = file_manager.get_results( + dataset_id, ['ms1_raw_heatmap'], use_polars=True + )['ms1_raw_heatmap'] + ms1_heatmap = ms1_heatmap.with_columns(pl.lit(1).alias('level')) + ms1_heatmap = ms1_heatmap.drop(['mass', 'mass_idx']) + ms2_heatmap = file_manager.get_results( + dataset_id, ['ms2_raw_heatmap'], use_polars=True + )['ms2_raw_heatmap'] + ms2_heatmap = ms2_heatmap.with_columns(pl.lit(2).alias('level')) + ms2_heatmap = ms2_heatmap.drop(['mass', 'mass_idx']) + tic_data = pl.concat([ms1_heatmap, ms2_heatmap], how='vertical') + tic_data = ( + tic_data.group_by('scan_idx') + .agg([ + pl.col('rt').first().alias('rt'), + pl.col('level').first().alias('level'), + pl.col('intensity').sum().alias('tic'), + ]) + ) + file_manager.store_data(dataset_id, 'tic', tic_data) + + logger.log("20.0 %", level=2) diff --git a/src/render/compression.py b/src/render/compression.py index 3db04a7e..4590b288 100644 --- a/src/render/compression.py +++ b/src/render/compression.py @@ -50,7 +50,7 @@ def downsample_heatmap(data, max_datapoints=20000, rt_bins=400, mz_bins=50, logg ) # We need to collect here because scipy requires numpy arrays - sorted_data = sorted_data.collect(streaming=True).lazy() + sorted_data = sorted_data.collect(streaming=True) # Count peaks total_count = sorted_data.select(pl.count()).item() From d1ab85d8c72cdeaeee6d9fb9b36c27bf3df1b259 Mon Sep 17 00:00:00 2001 From: Tom David Mueller Date: Fri, 3 Oct 2025 22:27:32 +0200 Subject: [PATCH 3/5] add tic component on back-end side --- content/FLASHDeconv/FLASHDeconvLayoutManager.py | 2 ++ src/render/components.py | 6 ++++++ src/render/initialize.py | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/content/FLASHDeconv/FLASHDeconvLayoutManager.py b/content/FLASHDeconv/FLASHDeconvLayoutManager.py index a86164f5..8cbb760d 100644 --- a/content/FLASHDeconv/FLASHDeconvLayoutManager.py +++ b/content/FLASHDeconv/FLASHDeconvLayoutManager.py @@ -17,6 +17,7 @@ 'Mass table (Scan table needed)', '3D S/N plot (Mass table needed)', 'Score Distribution Plot' + 'TIC Chromatogram' # "Sequence view" and "Internal fragment map" is added when "input_sequence" is submitted ] @@ -31,6 +32,7 @@ 'mass_table', '3D_SN_plot', 'fdr_plot', + 'tic_chromatogram', # "sequence view" and "internal fragment map" added when "input_sequence" is submitted ] diff --git a/src/render/components.py b/src/render/components.py index 2469c1de..b651c141 100644 --- a/src/render/components.py +++ b/src/render/components.py @@ -99,3 +99,9 @@ class FLASHQuant: def __init__(self): self.title = 'QuantVis' self.componentName = 'FLASHQuantView' + + +class Chromatogram: + def __init__(self): + self.title = 'TIC' + self.componentName = 'TICChromatogram' diff --git a/src/render/initialize.py b/src/render/initialize.py index be693aef..ac69a30d 100644 --- a/src/render/initialize.py +++ b/src/render/initialize.py @@ -3,7 +3,7 @@ from src.render.components import ( PlotlyHeatmap, PlotlyLineplot, PlotlyLineplotTagger, Plotly3Dplot, Tabulator, SequenceView, InternalFragmentMap, FlashViewerComponent, - FDRPlotly, FLASHQuant + FDRPlotly, FLASHQuant, Chromatogram ) from src.render.compression import compute_compression_levels @@ -172,6 +172,10 @@ def initialize_data(comp_name, selected_data, file_manager, tool): data = file_manager.get_results(selected_data, ['quant_dfs']) data_to_send['quant_data'] = data['quant_dfs'] component_arguments = FLASHQuant() + elif comp_name == 'tic_chromatogram': + data = file_manager.get_results(selected_data, ['tic']) + data_to_send['tic'] = data['tic'] + component_arguments = Chromatogram() components = [[FlashViewerComponent(component_arguments)]] From d84b504c0a1dcbab830ca3001d8dd8fca68e7832 Mon Sep 17 00:00:00 2001 From: Tom David Mueller Date: Sun, 5 Oct 2025 12:42:01 +0200 Subject: [PATCH 4/5] add tic chromatogram --- content/FLASHDeconv/FLASHDeconvLayoutManager.py | 4 ++-- src/parse/deconv.py | 2 ++ src/render/components.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/content/FLASHDeconv/FLASHDeconvLayoutManager.py b/content/FLASHDeconv/FLASHDeconvLayoutManager.py index 8cbb760d..67200348 100644 --- a/content/FLASHDeconv/FLASHDeconvLayoutManager.py +++ b/content/FLASHDeconv/FLASHDeconvLayoutManager.py @@ -16,8 +16,8 @@ 'Raw spectrum (Scan table needed)', 'Mass table (Scan table needed)', '3D S/N plot (Mass table needed)', - 'Score Distribution Plot' - 'TIC Chromatogram' + 'Score Distribution Plot', + 'TIC Chromatogram', # "Sequence view" and "Internal fragment map" is added when "input_sequence" is submitted ] diff --git a/src/parse/deconv.py b/src/parse/deconv.py index fa3e16ab..70e645fe 100644 --- a/src/parse/deconv.py +++ b/src/parse/deconv.py @@ -90,9 +90,11 @@ def parseDeconv( pl.col('intensity').sum().alias('tic'), ]) ) + tic_data = tic_data.sort("scan_idx", descending=False) file_manager.store_data(dataset_id, 'tic', tic_data) + logger.log("20.0 %", level=2) diff --git a/src/render/components.py b/src/render/components.py index b651c141..61da0f75 100644 --- a/src/render/components.py +++ b/src/render/components.py @@ -6,7 +6,7 @@ # Create a _RELEASE constant. We'll set this to False while we're developing # the component, and True when we're ready to package and distribute it. -_RELEASE = True +_RELEASE = False _component_func = None From ac399ded7de7cef535f3c5db6f1627cbda56e35d Mon Sep 17 00:00:00 2001 From: Tom David Mueller Date: Sun, 5 Oct 2025 12:43:31 +0200 Subject: [PATCH 5/5] disable dev mode --- src/render/components.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render/components.py b/src/render/components.py index 61da0f75..b651c141 100644 --- a/src/render/components.py +++ b/src/render/components.py @@ -6,7 +6,7 @@ # Create a _RELEASE constant. We'll set this to False while we're developing # the component, and True when we're ready to package and distribute it. -_RELEASE = False +_RELEASE = True _component_func = None