Skip to content

Commit 1b3905a

Browse files
author
Joe Foley
committed
better alternative to |
1 parent b7547d4 commit 1b3905a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

R/calibration.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,16 @@ calculate.concentration <- function(electrophoresis, ladder.concentrations = NUL
142142
which.markers <- lapply(seq(nrow(electrophoresis$samples)), function(sample.index) which(
143143
electrophoresis$peaks$sample.index == sample.index & (
144144
(electrophoresis$peaks$peak.observations %in% LOWER.MARKER.NAMES & (
145-
is.null(ladder.concentrations) ||
146-
electrophoresis$peaks$concentration == ladder.concentrations[1] # verify this is the right peak (sometimes Bioanalyzer annotates more than one as the marker but it only assigns the hardcoded concentration to one)
145+
if (is.null(ladder.concentrations)) TRUE else electrophoresis$peaks$concentration == ladder.concentrations[1] # verify this is the right peak (sometimes Bioanalyzer annotates more than one as the marker but it only assigns the hardcoded concentration to one)
147146
)
148147
) | (
149148
electrophoresis$peaks$peak.observations %in% UPPER.MARKER.NAMES & (
150-
is.null(ladder.concentrations) ||
151-
electrophoresis$peaks$concentration == ladder.concentrations[length(ladder.concentrations)]
149+
if (is.null(ladder.concentrations)) TRUE else electrophoresis$peaks$concentration == ladder.concentrations[length(ladder.concentrations)]
152150
)
153151
)
154152
)
155153
))
154+
for (i in seq(nrow(electrophoresis$samples))) if (length(which.markers[[i]]) == 0) warning(paste("no markers detected in sample", i))
156155
integrable <- ! any(is.na(electrophoresis$peaks[unlist(which.markers), c("lower.length", "upper.length")])) # peak boundaries aren't given so don't rely on integration
157156

158157
mass.coefficients <- rep(NA, nrow(electrophoresis$samples))
@@ -166,7 +165,7 @@ calculate.concentration <- function(electrophoresis, ladder.concentrations = NUL
166165
non.marker.concentrations <- this.ladder.concentrations[-c(1, if (has.upper.marker) length(this.ladder.concentrations) else NULL)]
167166
ladder.peaks <- which(
168167
electrophoresis$peaks$sample.index == ladder.index &
169-
(is.null(ladder.concentrations) | electrophoresis$peaks$concentration %in% ladder.concentrations)
168+
(if (is.null(ladder.concentrations)) TRUE else electrophoresis$peaks$concentration %in% ladder.concentrations)
170169
)
171170
stopifnot("no ladder peaks recognized" = length(ladder.peaks) > 0)
172171
non.marker.peaks <- setdiff(ladder.peaks, which.markers[[ladder.index]])

0 commit comments

Comments
 (0)