Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion content/FLASHDeconv/FLASHDeconvLayoutManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
'Raw spectrum (Scan table needed)',
'Mass table (Scan table needed)',
'3D S/N plot (Mass table needed)',
'Score Distribution Plot'
'Score Distribution Plot',
'TIC Chromatogram',
# "Sequence view" and "Internal fragment map" is added when "input_sequence" is submitted
]

Expand All @@ -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
]

Expand Down
28 changes: 27 additions & 1 deletion src/parse/deconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -69,6 +69,32 @@ 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'),
])
)
tic_data = tic_data.sort("scan_idx", descending=False)
file_manager.store_data(dataset_id, 'tic', tic_data)




logger.log("20.0 %", level=2)

Expand Down
6 changes: 6 additions & 0 deletions src/render/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
2 changes: 1 addition & 1 deletion src/render/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

# Count peaks
total_count = sorted_data.select(pl.count()).item()
Expand Down
6 changes: 5 additions & 1 deletion src/render/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)]]

Expand Down