Skip to content

Commit

Permalink
ensure detectInfusionScans() can handle duplicated file names
Browse files Browse the repository at this point in the history
  • Loading branch information
jasenfinch committed Aug 11, 2023
1 parent f018641 commit ed00ed9
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions R/detect.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,35 @@
detectInfusionScans <- function(files,
thresh = 0.5){

idx <- tibble(
Sample = files
) %>%
rowid_to_column(var = 'idx')

ms <- files %>%
future_map(~{
ms <- .x %>%
openMSfile()

file_header <- ms %>%
header()
header() %>%
as_tibble()

return(file_header)
}) %>%
set_names(files)
set_names(idx$idx) %>%
bind_rows(.id = 'idx') %>%
mutate(
idx = as.numeric(idx)
) %>%
left_join(idx,
by = 'idx',
relationship = 'many-to-many')

hd <- ms %>%
bind_rows(.id = 'Sample') %>%
as_tibble() %>%
select(Sample,seqNum,acquisitionNum,polarity,totIonCurrent,filterString) %>%
split(.$polarity) %>%
map(~{
d <- .
d %>%
split(.$Sample) %>%
map(~{
a <- .
a %>%
split(.$filterString) %>%
map(~{
b <- .
b %>%
mutate(acquisitionNum = seq_len(nrow(.)))
}) %>%
bind_rows()
}) %>%
bind_rows() %>%
select(Sample,acquisitionNum,polarity,totIonCurrent,filterString)
}) %>%
bind_rows() %>%
hd <- ms %>%
select(idx,seqNum,acquisitionNum,polarity,totIonCurrent,filterString) %>%
group_by(idx,polarity,filterString) %>%
mutate(acquisitionNum = seq_len(n())) %>%
group_by(acquisitionNum) %>%
summarise(totIonCurrent = mean(totIonCurrent))

Expand Down

0 comments on commit ed00ed9

Please sign in to comment.