Closed sebkopf closed 1 year ago
This is what's already possible in isoorbi version 1.1.0, what I don't like is the need for the define_blocks_for_dual_inlet
call (maybe define_blocks_manually
should be an option? or the segment function should automatically make one gigantic block with all the data if it is called without prior block definition? thoughts @brettdavidheiser @123caj @SabrielxD ). The other problem is the need for multiple scans for the ratio calculation funcitons - I don't actually see a need for all of them to throw an error even if it calculates a single ratio, e.g. the mean
method should be just fine to run with a single value even though at present we throw an error if that hapens - what do you think @123caj ?
library(isoorbi)
library(ggplot2)
library(tidyr)
ratios <-
system.file("extdata", "testfile_dual_inlet_new.isox", package = "isoorbi") |>
orbi_read_isox() |>
# defining at lest 1 block is required at the moment before segmenting
orbi_define_blocks_for_dual_inlet(
ref_block_time.min = 1000,
change_over_time.min = 1) |>
# segment into 1 scan at a time (requires multiple scans with current ratio calculations)
orbi_segment_blocks(by_scans = 3) |>
# calculations
orbi_define_basepeak(basepeak_def = "M0") |>
orbi_summarize_results(ratio_method = "sum")
#> orbi_read_isox() is loading .isox data from file path:
#> testfile_dual_inlet_new.isox
#> orbi_define_blocks_for_dual_inlet() identified 1 blocks (1 'ref', 0 'sam') in data from 1 file(s)
#> orbi_segment_blocks() segmented 1 data blocks in 1 file(s) into 820 segments / block (on average) with 3 scans / segment (on average)
#> orbi_define_basepeak() is setting the M0 isotopocule as the ratio denominator...
#> orbi_summarize_results() is grouping the data by 'filename', 'compound', 'basepeak', 'isotopocule', 'block', 'sample_name', 'segment', 'data_group', 'data_type' and summarizing ratios using the 'sum' method...
# simple plot
ratios |>
ggplot() +
aes(x = mean_time.min, y = ratio) +
geom_line() +
facet_wrap(~isotopocule, scales = "free_y") +
theme_bw()
Created on 2023-07-03 with reprex v2.0.2
@sebkopf Allowing ratio calculation with single scans should be fine. Use case: data acquired with many micro scans. Perhaps throw a warning that certain stats cannot be calculated, as they require minimum x scans?
Segmenting data currently appears several times in the code base (GUI). Perhaps we can come up with a separate core function that would work for any kind of grouped data "block" flagged for analysis (i.e., direct infusion, dual inlet, proteomics/ metabolomics-IRMS)
I like the idea of being able to have ratios from a single scan because you have all of the data you need and it is what we truly care about.
I think you have a good idea in the segment function should automatically make one gigantic block with all the data if it is called without prior block definition?
This way it just works and if someone does a direct infusion they have all there data grouped together.
implemented in 1.2. with orbi_calculate_ratios()
currently this is tricky because segmenting requires blocks definition first and ratio calculations require more than 1 values please chime in @brettdavidheiser how you would ideally like to have this implemented