/
get_lvls.R
32 lines (29 loc) · 983 Bytes
/
get_lvls.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
get_lvls<-function(X){
TickTable<-function(X){
data.frame(
start=xml_nodes(X,'StartTickIndex') %>%
xml_text() %>% as.numeric() ,
end=xml_nodes(X,'EndTickIndex') %>%
xml_text() %>% as.numeric()
) %>% mutate(.,Measure=seq(nrow(.))) %>%
rowwise() %>%
do(data.frame(Tick=seq(.$start,.$end),Measure=.$Measure))
}
getcounts<-function(x){
counts<-xml_nodes(x,'CorrectedEmissionValues') %>%
lapply(.,{. %>%
xml_children %>%
xml_text() %>%
as.numeric()})
analytes<- xml_nodes(x,'AnalyteName') %>%
xml_text() %>% paste0(.,'lvl')
setNames(counts,analytes) %>%
bind_cols() %>%
mutate(.,Well=seq(nrow(.)))
}
xml_nodes(X,"AnalyteDataSetsByAnalyteName") %>%
lapply(.,getcounts) %>%
{mapply(function(x,y){mutate(x,Tick=y)},.,seq(.),SIMPLIFY = F)} %>%
bind_rows() %>%
inner_join(.,TickTable(X),by='Tick')
}#end