Skip to content

Commit a71a18a

Browse files
committed
update readInfinieXMl to use start time as time for all wells
1 parent 10208a7 commit a71a18a

File tree

5 files changed

+99
-81
lines changed

5 files changed

+99
-81
lines changed

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: rrobot
22
Title: Useful R functions for the Tecan Freedom Evo
3-
Version: 1.2
3+
Version: 1.2.1
44
Date: 2020-04-22
55
Authors@R: as.person(c(
66
"Daniel C Angst <[email protected]> [aut, cre]",
@@ -9,6 +9,7 @@ Authors@R: as.person(c(
99
Description: functions for generating worklists and reading data from reader.
1010
Depends:
1111
R (>= 3.3.2),
12+
rlang,
1213
xml2,
1314
XML,
1415
jsonlite,
@@ -24,4 +25,4 @@ License: file LICENCE
2425
URL: https://github.com/dcangst/rrobot
2526
Encoding: UTF-8
2627
LazyData: true
27-
RoxygenNote: 7.1.1
28+
RoxygenNote: 7.3.0

R/iControlFunctions.R

Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
#' @section Output:
77
#' \code{list} with data in longform format and parameters
88
#' @export
9-
readInfiniteXML <- function(file){
9+
readInfiniteXML <- function(file) {
1010
data_xml <- withCallingHandlers(xml2::read_xml(file),
11-
warning = function(w){
12-
if (any(grepl("is not absolute", w))){
13-
invokeRestart( "muffleWarning" )
11+
warning = function(w) {
12+
if (any(grepl("is not absolute", w))) {
13+
invokeRestart("muffleWarning")
1414
}
15-
})
15+
}
16+
)
1617

1718
# plate name
1819
plate_name <- xml_text(xml_find_first(data_xml, "//Plate"), trim = TRUE)
@@ -21,38 +22,47 @@ readInfiniteXML <- function(file){
2122
measurementNames <- xml_attr(xml_find_all(data_xml, "//Section"), "Name")
2223
nMeasurement <- length(measurementNames)
2324

24-
#parameter
25+
# parameter
2526
pars_node <- xml_find_all(data_xml, "//Section/Parameters")
26-
parameter <- lapply(pars_node, function(x){
27+
parameter <- lapply(pars_node, function(x) {
2728
.listToDf(xml_attrs(xml_children(x)))
2829
})
2930
names(parameter) <- measurementNames
3031

31-
#data
32+
# data
3233
data <- xml_find_all(data_xml, "//Section/Data")
3334
data_nodes <- lapply(data, xml_children)
3435
data_attrs1 <- lapply(lapply(data_nodes, xml_attrs), .listToDf)
3536
data_values <- lapply(
3637
lapply(
37-
lapply(data_nodes, xml_children), xml_text), .listToDf)
38+
lapply(data_nodes, xml_children), xml_text
39+
), .listToDf
40+
)
3841
names(data_values) <- c(measurementNames)
3942
data_values_df <- data.frame(data_values)
4043
data_values_df <- sapply(data_values_df, as.numeric)
4144
n_values <- dim(data_values_df)[1]
4245

43-
#times
46+
# times
4447
time <- data.frame(
45-
t_start = .convertXMLtime(xml_attr(xml_find_all(data_xml, "//Section"),
46-
"Time_Start")),
47-
t_end = .convertXMLtime(xml_attr(xml_find_all(data_xml, "//Section"),
48-
"Time_End")),
49-
name = str_c("time_", measurementNames))
50-
times <- data.frame(plyr::dlply(time, ("name"),
51-
function(x)(seq(x[, 1], x[, 2], length.out = n_values))))
48+
t_start = .convertXMLtime(xml_attr(
49+
xml_find_all(data_xml, "//Section"),
50+
"Time_Start"
51+
)),
52+
t_end = .convertXMLtime(xml_attr(
53+
xml_find_all(data_xml, "//Section"),
54+
"Time_End"
55+
)),
56+
name = str_c("time_", measurementNames)
57+
)
58+
times <- data.frame(plyr::dlply(
59+
time, ("name"),
60+
function(x) (rep(x[, 1], times = n_values))
61+
))
5262

53-
#data.frame
63+
# data.frame
5464
rows <- str_sub(data_attrs1[[1]]$Pos, 1, 1)
55-
rows_n <- as.integer(sapply(rows, function(x){
65+
rows_n <- as.integer(sapply(rows, function(x) {
5666
which(x == LETTERS)
5767
}))
5868
cols <- as.integer(str_sub(data_attrs1[[1]]$Pos, 2))
@@ -66,7 +76,8 @@ readInfiniteXML <- function(file){
6676
well = wells,
6777
data_values_df,
6878
times,
69-
stringsAsFactors = FALSE)
79+
stringsAsFactors = FALSE
80+
)
7081
data <- data[order(data$well), ]
7182

7283
return(list(data = as_tibble(data), parameter = parameter))
@@ -86,7 +97,7 @@ readInfiniteXML2 <- function(file) {
8697

8798
measurements <- lapply(dataXML[which(names(dataXML) == "Section")], function(section) {
8899
attributesSection <- t(as.data.frame(section$.attrs)) %>%
89-
as_tibble()
100+
as_tibble()
90101
data <- lapply(
91102
section[which(names(section) == "Data")],
92103
function(data) {
@@ -96,46 +107,48 @@ readInfiniteXML2 <- function(file) {
96107
data[which(names(data) == "Well")],
97108
function(well) {
98109
unlist(well)
99-
}) %>%
110+
}
111+
) %>%
100112
bind_rows() %>%
101113
bind_cols(dataAttributes)
102114
if ("Time_Start" %in% names(measurements)) {
103115
measurements <- measurements %>%
104116
rename(Time_Start_Inc = Time_Start)
105117
}
106118
return(measurements)
107-
}) %>%
119+
}
120+
) %>%
108121
bind_rows() %>%
109122
bind_cols(attributesSection)
110123
})
111124
dataDf <- measurements$Section
112125

113126
# format data
114127
rows <- str_sub(dataDf$.attrs.Pos, 1, 1)
115-
rows_n <- as.integer(sapply(rows, function(x){
128+
rows_n <- as.integer(sapply(rows, function(x) {
116129
which(x == LETTERS)
117130
}))
118131
cols <- as.integer(str_sub(dataDf$.attrs.Pos, 2))
119132
wells <- (rows_n - 1) * max(cols) + cols
120133

121134
if ("Time_Start_Inc" %in% names(dataDf)) {
122-
data <- dataDf %>%
123-
transmute(
124-
plate = dataXML$Plate$ID,
125-
cycle = as.integer(Cycle),
126-
tStart = lubridate::as_datetime(Time_Start) + lubridate::as.duration(Time_Start_Inc),
127-
name = Name,
128-
pos = .attrs.Pos,
129-
row = rows,
130-
col = cols,
131-
well = wells,
132-
value = as.numeric(Single.text)
133-
)
135+
data <- dataDf %>%
136+
transmute(
137+
plate = dataXML$Plate$ID,
138+
cycle = as.integer(Cycle),
139+
tStart = lubridate::as_datetime(Time_Start) + lubridate::as.duration(Time_Start_Inc),
140+
name = Name,
141+
pos = .attrs.Pos,
142+
row = rows,
143+
col = cols,
144+
well = wells,
145+
value = as.numeric(Single.text)
146+
)
134147
} else {
135148
data <- dataDf %>%
136149
transmute(
137150
plate = dataXML$Plate$ID,
138-
cycle = as.integer(Cycle),
151+
cycle = as.integer(Cycle),
139152
tStart = lubridate::as_datetime(Time_Start),
140153
name = Name,
141154
pos = .attrs.Pos,

R/rrobot.r

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,82 @@
22
#' A package containing tools for worklist generation for the freedom evo.
33
#'
44
#'
5-
#'@section base methods:
5+
#' @section base methods:
66
#'
77
#' \code{\link{init}} - initialize a new worklist
88
#'
99
#' \code{\link{write.gwl}} - write worklist
1010
#'
1111
#' \code{\link{addToWorktable}} - add labware to worktable
12-
#'
12+
#'
1313
#' \code{\link{addToWorklist}} - add an arbitrary command
1414
#'
15-
#'@section Basic Worklist methods:
16-
#'
15+
#' @section Basic Worklist methods:
16+
#'
1717
#' \code{\link{aspirate}}
18-
#'
18+
#'
1919
#' \code{\link{dispense}}
20-
#'
20+
#'
2121
#' \code{\link{wash}}
22-
#'
22+
#'
2323
#' \code{\link{gwl_flush}}
24-
#'
24+
#'
2525
#' \code{\link{gwl_break}}
26-
#'
26+
#'
2727
#' \code{\link{distribute}}
2828
#'
29-
#'@section Advanced Worklist methods:
30-
#'
29+
#' @section Advanced Worklist methods:
30+
#'
3131
#' \code{\link{adv_aspirate}}
32-
#'
32+
#'
3333
#' \code{\link{adv_dispense}}
34-
#'
34+
#'
3535
#' \code{\link{adv_gwl_comment}}
3636
#'
3737
#' \code{\link{adv_wash}}
3838
#'
3939
#' \code{\link{adv_mix}}
40-
#'
40+
#'
4141
#' \code{\link{moveLiHa}}
42-
#'
42+
#'
4343
#' \code{\link{moveMCA}}
44-
#'
44+
#'
4545
#' \code{\link{MCAvector}}
46-
#'
46+
#'
4747
#' \code{\link{MCArelative}}
4848
#'
4949
#' \code{\link{startTimer}}
5050
#'
5151
#' \code{\link{waitTimer}}
5252
#'
5353
#' \code{\link{sterile_wash}}
54-
#'
54+
#'
5555
#' \code{\link{fwCommand}}
5656
#'
57-
#'@section Worklist check methods:
58-
#'
57+
#' @section Worklist check methods:
58+
#'
5959
#' \code{\link{read_gwl}} - read in a gwl file
6060
#'
6161
#' \code{\link{gwlToTable}} - produces a list of markdown tables with images
6262
#'
6363
#' \code{\link{gwlToHTML}} - produces a HTML report of the worklist
6464
#'
65-
#'@section Reader methods:
66-
#'
65+
#' @section Reader methods:
66+
#'
6767
#' \code{\link{readInfiniteXML}} - returns data.frame, multiple reads
6868
#'
69-
#'@section Pickolo methods:
70-
#'
69+
#' @section Pickolo methods:
70+
#'
7171
#' \code{\link{readColonies}} - in which wells was there growth?
7272
#'
7373
#' \code{\link{plotColonies}} - returns a ggplot plot of the plate & colonies
74-
#'
75-
#'@section Data:
74+
#'
75+
#' @section Data:
7676
#'
7777
#' \code{\link{basic}} - basic worktable layout at ETHZ as of 27.01.2015
7878
#'
7979
#' \code{\link{ansi_table}} - look up table for ANSI (Windows-1252) characters (used in \code{\link{ANSIIFromWells}})
8080
#'
8181
#' @name rrobot
82-
#' @docType package
82+
#' @docType _PACKAGE
8383
NULL

exampleScript.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ for (iGroup in pipGroups){
8888
.groups = "drop"
8989
)
9090

91-
if (!all(tipVolumes$volume < 800)){
92-
stop("volume too high")
91+
if (!all(tipVolumes$volume < 800)) {
92+
rlang::abort("volume too high")
9393
}
9494

9595
# generate the tip mask (boolean vector, 0 = tip not used, 1 = tip used) and the volume mask (volume in ul)
@@ -130,14 +130,14 @@ for (iGroup in pipGroups){
130130
volume = volAdd,
131131
well = well,
132132
.groups = "drop")
133-
133+
134134
# make masks
135135
masksCol <- generateMasks(tipVolumeCol$tip, tipVolumeCol$volume)
136-
136+
137137
# write dispense command
138138
adv_dispense(
139139
tipMask = masksCol$tip_mask,
140-
volumes = masksCol$vol_mask,
140+
volumes = c(masksCol$vol_mask, 4),
141141
RackLabel = "MP3pos_mid",
142142
wellSelection = tipVolumeCol$well,
143143
ncol = 12, nrow = 8)

man/rrobot.Rd

Lines changed: 14 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)