Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/145 chondro replace #156

Merged
merged 61 commits into from
Jun 21, 2020
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
5691614
Add update.dataset.R
eoduniyi Jun 1, 2020
d79f548
Update aggregate.R
eoduniyi Jun 1, 2020
620fce7
Replace `chondro` with `fauxCell` in aggregate.R
eoduniyi Jun 8, 2020
4143504
Revert "Replace `chondro` with `fauxCell` in aggregate.R"
eoduniyi Jun 8, 2020
2a2ca32
Revert "Revert "Replace `chondro` with `fauxCell` in aggregate.R""
eoduniyi Jun 8, 2020
639c540
Update aggregate.R
eoduniyi Jun 8, 2020
877f0dc
Update aggregate.R
eoduniyi Jun 8, 2020
b07f6e9
Replace `chondro` with `fauxCell` in apply.R
eoduniyi Jun 9, 2020
d494934
Replace `chondro` with `fauxCell` in as.data.frame.R
eoduniyi Jun 9, 2020
be6562d
Replace `chondro` with `fauxCell` in bind.R
eoduniyi Jun 9, 2020
71cff49
Replace `chondro` with `fauxCell` in chk.hy.R
eoduniyi Jun 9, 2020
c065e5c
Update collapse.R
eoduniyi Jun 9, 2020
01cbe01
Replace `chondro` with `fauxCell` in cov.R
eoduniyi Jun 9, 2020
fa63536
Replace `chondro` with `fauxCell` in dim.R
eoduniyi Jun 9, 2020
d853948
Replace `chondro` with `fauxCell` in dimnames.R
eoduniyi Jun 9, 2020
8e60dc8
Replace `chondro` with `fauxCell` in droplevel.R
eoduniyi Jun 9, 2020
e044dc2
Update droplevels.R
eoduniyi Jun 9, 2020
afc7336
Replace `chondro` with `fauxCell` in empty.R
eoduniyi Jun 9, 2020
b2812aa
Replace `chondro` with `fauxCell` in extract.R
eoduniyi Jun 9, 2020
8a89cd3
Replace `chondro` with `fauxCell` in hyperspec-package.R
eoduniyi Jun 9, 2020
2933c87
Replace `chondro` with `fauxCell` in labels.R
eoduniyi Jun 9, 2020
17ebf0e
Replace `chondro` with `fauxCell` in levelplot.R and map.sel.poly.R
eoduniyi Jun 9, 2020
bc78a02
Replace `chondro` with `fauxCell` in mark.peak.R
eoduniyi Jun 9, 2020
dd24880
Replace `chondro` with `fauxCell` in matlab.palette.R
eoduniyi Jun 9, 2020
5cf9094
Replace `chondro` with `fauxCell` in mean_sd.R
eoduniyi Jun 9, 2020
ee79323
Replace `chondro` with `fauxCell` in merge.R
eoduniyi Jun 9, 2020
7615b3b
Replace `chondro` with `fauxCell` in mvtnorm.R
eoduniyi Jun 9, 2020
3d017a5
Replace `chondro` with `fauxCell` in pearson.dist.R
eoduniyi Jun 9, 2020
0b51ef4
Replace `chondro` with `fauxCell` in plot.R
eoduniyi Jun 9, 2020
073b69d
Replace `chondro` with `fauxCell` in plotmap.R
eoduniyi Jun 9, 2020
67f2b5f
Replace `chondro` with `fauxCell` in plotspc.R
eoduniyi Jun 9, 2020
75ab3c0
Replace `chondro` with `fauxCell` in qplot.R
eoduniyi Jun 9, 2020
ce6dc52
Update collapse.R
eoduniyi Jun 9, 2020
3f4dccb
Replace `chondro` with `fauxCell` in qplotmixmap.R
eoduniyi Jun 9, 2020
4794b4e
Replace `chondro` with `fauxCell` in scale.R
eoduniyi Jun 9, 2020
52ed7d6
Replace `chondro` with `fauxCell` in show.R
eoduniyi Jun 9, 2020
7dc985c
Replace `chondro` with `fauxCell` in spc.fit.poly.R
eoduniyi Jun 9, 2020
10197a4
Update spc.fit.poly.R
eoduniyi Jun 9, 2020
3aad5a7
Replace `chondro` with `fauxCell` in split.R
eoduniyi Jun 9, 2020
69b5e4a
Replace `chondro` with `fauxCell` in sweep.R
eoduniyi Jun 9, 2020
457d9e5
Replace `chondro` with `fauxCell` in trellis.factory.key.R
eoduniyi Jun 9, 2020
38fe4bb
Replace `chondro` with `fauxCell` in wl.R
eoduniyi Jun 9, 2020
bd5a0d8
Replace `chondro` with `fauxCell` in wl2i.R
eoduniyi Jun 9, 2020
b1429d9
Update spc.fit.poly.R
eoduniyi Jun 9, 2020
f0f5c0f
example data set to check treatment of unstable solutions in spc.fit.…
cbeleites Jun 9, 2020
187ba6e
Merge branch 'develop' into feature/145-chondro-replace
eoduniyi Jun 9, 2020
acda678
Update DESCRIPTION
eoduniyi Jun 9, 2020
294c23d
styling
cbeleites Jun 9, 2020
554d4ed
Merge branch 'feature/145-chondro-replace' of github.com:cbeleites/hy…
cbeleites Jun 9, 2020
4ba2384
Remove update.dataset.R
eoduniyi Jun 9, 2020
885667c
translate documentation to markdown
cbeleites Jun 9, 2020
d345826
Merge branch 'feature/145-chondro-replace' of github.com:cbeleites/hy…
cbeleites Jun 9, 2020
a49f1e2
buxfix: use of labels() instead of @label
cbeleites Jun 9, 2020
1e54e18
fix LaTeX -> markdown translation error
cbeleites Jun 9, 2020
fb024f6
Merge branch 'develop' into feature/145-chondro-replace
cbeleites Jun 9, 2020
0e6ff2c
change one last occurence of chondro -> fauxCell
cbeleites Jun 9, 2020
8440c6b
Update DESCRIPTION
eoduniyi Jun 15, 2020
a2300e9
Merge branch 'develop' into feature/145-chondro-replace
eoduniyi Jun 15, 2020
d556dfa
Merge branch 'develop' into feature/145-chondro-replace
GegznaV Jun 21, 2020
167b847
Fix typo
GegznaV Jun 21, 2020
a77363b
Fix documentation: multiline md might not work
GegznaV Jun 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hyperSpec/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Type: Package
Title: Work with Hyperspectral Data, i.e. Spectra + Meta Information (Spatial,
Time, Concentration, ...)
Version: 0.99-20200608
Date: 2020-06-08
Date: 2020-06-15
Maintainer: Claudia Beleites <Claudia.Beleites@chemometrix.gmbh>
Authors@R: c(
person("Claudia", "Beleites", role = c("aut","cre", "dtc"), email = "Claudia.Beleites@chemometrix.gmbh"),
Expand Down
20 changes: 10 additions & 10 deletions hyperSpec/R/aggregate.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
##' @import stats
##' @include hyperspec-class.R
##' @examples
##' cluster.means <- aggregate (chondro, chondro$clusters, mean_pm_sd)
##' plot(cluster.means, stacked = ".aggregate", fill = ".aggregate",
##' region.means <- aggregate (fauxCell, fauxCell$region, mean_pm_sd)
##' plot(region.means, stacked = ".aggregate", fill = ".aggregate",
##' col = matlab.dark.palette (3))
##'
##' ## make some "spectra"
Expand Down Expand Up @@ -154,17 +154,17 @@ setMethod("aggregate", signature = signature(x = "hyperSpec"), .aggregate)

.test(.aggregate) <- function() {
context("aggregate")
test_that("chondro cluster means", {
cluster.means <- aggregate(chondro, chondro$clusters, mean_pm_sd)
expect_true(all(is.na(cluster.means$y)))
expect_true(all(is.na(cluster.means$x)))
test_that("fauxCell region means", {
region.means <- aggregate(fauxCell, fauxCell$region, mean_pm_sd)
expect_true(all(is.na(region.means$y)))
expect_true(all(is.na(region.means$x)))

expect_equal(cluster.means$clusters, cluster.means$.aggregate)
expect_equal(region.means$region, region.means$.aggregate)

for (cluster in levels(chondro$clusters)) {
for (region in levels(fauxCell$region)) {
expect_equivalent(
cluster.means [[cluster.means$clusters == cluster, ]],
apply(chondro [[chondro$clusters == cluster, ]], 2, mean_pm_sd)
region.means [[region.means$region == region, ]],
apply(fauxCell [[fauxCell$region == region, ]], 2, mean_pm_sd)
)
}
})
Expand Down
2 changes: 1 addition & 1 deletion hyperSpec/R/apply.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
##' @examples
##'
##'
##' plotspc (apply (chondro, 2, range))
##' plotspc (apply (fauxCell, 2, range))
##'
##' avgflu <- apply (flu, 1, mean,
##' label.spc = expression (bar (I)),
Expand Down
28 changes: 14 additions & 14 deletions hyperSpec/R/as.data.frame.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
##' @keywords methods
##' @examples
##'
##' as.data.frame (chondro [1:3,, 600 ~ 620])
##' as.matrix (chondro [1:3,, 600 ~ 620])
##' as.data.frame (fauxCell [1:3,, 600 ~ 620])
##' as.matrix (fauxCell [1:3,, 600 ~ 620])
##' lm (c ~ spc, data = flu [,,450])

as.data.frame.hyperSpec <- function(x, row.names = TRUE, optional = NULL, ...) {
Expand Down Expand Up @@ -73,8 +73,8 @@ as.matrix.hyperSpec <- function(x, ...) {
##' expanded *in place*.
##' @examples
##'
##' as.wide.df (chondro [1:5,, 600 ~ 610])
##' summary (as.wide.df (chondro [1:5,, 600 ~ 610]))
##' as.wide.df (fauxCell [1:5,, 600 ~ 610])
##' summary (as.wide.df (fauxCell [1:5,, 600 ~ 610]))

as.wide.df <- function(x, wl.prefix = "") {
chk.hy(x)
Expand Down Expand Up @@ -106,31 +106,31 @@ as.wide.df <- function(x, wl.prefix = "") {
.test(as.wide.df) <- function() {
context("as.wide.df")

test_that("chondro", {
test_that("fauxCell", {
expect_equal(
as.wide.df(chondro [1:5, , 600 ~ 610]),
cbind(chondro [1:5]$.., chondro [[1:5, , 600 ~ 610]])
as.wide.df(fauxCell [1:5, , 600 ~ 610]),
cbind(fauxCell [1:5]$.., fauxCell [[1:5, , 600 ~ 610]])
)
})

test_that("column names", {
expect_equal(
colnames(as.wide.df(chondro)),
c(grep("spc", colnames(chondro), value = TRUE, invert = TRUE), colnames(chondro$spc))
colnames(as.wide.df(fauxCell)),
c(grep("spc", colnames(fauxCell), value = TRUE, invert = TRUE), colnames(fauxCell$spc))
)

expect_equal(
colnames(as.wide.df(chondro)),
c(grep("spc", colnames(chondro), value = TRUE, invert = TRUE), wl(chondro))
colnames(as.wide.df(fauxCell)),
c(grep("spc", colnames(fauxCell), value = TRUE, invert = TRUE), wl(fauxCell))
)

expect_true(!any(is.na(colnames(as.wide.df(barbiturates [[1]])))))
})

test_that("column names with wl.prefix", {
expect_equal(
colnames(as.wide.df(chondro, wl.prefix = "wl")),
c(grep("spc", colnames(chondro), value = TRUE, invert = TRUE), paste0("wl", colnames(chondro$spc)))
colnames(as.wide.df(fauxCell, wl.prefix = "wl")),
c(grep("spc", colnames(fauxCell), value = TRUE, invert = TRUE), paste0("wl", colnames(fauxCell$spc)))
)
})
}
Expand Down Expand Up @@ -223,7 +223,7 @@ as.long.df <- function(x, rownames = FALSE, wl.factor = FALSE, na.rm = TRUE) {
##' see the example.
##' @export
##' @examples
##' df <- as.t.df (apply (chondro, 2, mean_pm_sd))
##' df <- as.t.df (apply (fauxCell, 2, mean_pm_sd))
##' head (df)
##'
##' if (require (ggplot2)){
Expand Down
14 changes: 7 additions & 7 deletions hyperSpec/R/bind.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@
##' @keywords methods manip
##' @examples
##'
##' chondro
##' bind ("r", chondro, chondro)
##' rbind (chondro, chondro)
##' cbind (chondro, chondro)
##' bind ("r", list (chondro, chondro, chondro))
##' fauxCell
##' bind ("r", fauxCell, fauxCell)
##' rbind (fauxCell, fauxCell)
##' cbind (fauxCell, fauxCell)
##' bind ("r", list (fauxCell, fauxCell, fauxCell))
##'
##' x <- chondro[,, 600 : 605]
##' x <- fauxCell[,, 600 : 605]
##' x$a <- 1
##' x@@data <- x@@data[, sample (ncol (x), ncol (x))] # reorder columns
##'
##' y <- chondro [nrow (chondro) : 1,, 1730 : 1750] # reorder rows
##' y <- fauxCell [nrow (fauxCell) : 1,, 1730 : 1750] # reorder rows
##' y$b <- 2
##'
##' cbind2 (x, y) # works
Expand Down
4 changes: 2 additions & 2 deletions hyperSpec/R/chk.hy.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
##' @keywords methods
##' @export
##' @examples
##' chk.hy (chondro)
##' validObject (chondro)
##' chk.hy (fauxCell)
##' validObject (fauxCell)
chk.hy <- function(object) {
if (!is(object, "hyperSpec")) {
stop("no hyperSpec object")
Expand Down
14 changes: 7 additions & 7 deletions hyperSpec/R/collapse.R
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,17 @@ collapse <- function(..., wl.tolerance = hy.getOption("wl.tolerance"), collapse.


test_that("factor behaviour of collapse", {
a <- chondro [chondro$clusters == "lacuna"]
a$clusters <- droplevels(a$clusters)
b <- chondro [chondro$clusters != "lacuna"]
b$clusters <- droplevels(b$clusters)
a <- fauxCell [fauxCell$region == "nucleus"]
a$region <- droplevels(a$region)
b <- fauxCell [fauxCell$region != "nucleus"]
b$region <- droplevels(b$region)

tmp <- collapse(a, b)
tmp$clusters
tmp$region

expect_equal(
sort(levels(tmp$clusters)),
sort(levels(chondro$clusters))
sort(levels(tmp$region)),
sort(levels(fauxCell$region))
)
})

Expand Down
4 changes: 2 additions & 2 deletions hyperSpec/R/cov.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
##' @rdname cov
##' @export
##' @examples
##' image (cov (chondro))
##' image (cov (fauxCell))
setMethod("cov", signature = signature(x = "hyperSpec", y = "missing"), function(x, y, use, method) {
validObject(x)

Expand All @@ -26,7 +26,7 @@ setMethod("cov", signature = signature(x = "hyperSpec", y = "missing"), function
##' @rdname cov
##' @export
##' @examples
##' pcov <- pooled.cov (chondro, chondro$clusters)
##' pcov <- pooled.cov (fauxCell, fauxCell$region)
##' plot (pcov$means)
##' image (pcov$COV)
##'
Expand Down
10 changes: 5 additions & 5 deletions hyperSpec/R/dim.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
##' @export
##' @examples
##'
##' ncol (chondro)
##' ncol (fauxCell)
setMethod("ncol", signature = signature("hyperSpec"), function(x) {
validObject(x)

Expand All @@ -30,7 +30,7 @@ setMethod("ncol", signature = signature("hyperSpec"), function(x) {
##' @seealso \code{\link[base]{nrow}}
##' @export
##' @examples
##' nrow (chondro)
##' nrow (fauxCell)
setMethod("nrow", signature = signature("hyperSpec"), function(x) {
validObject(x)

Expand All @@ -46,7 +46,7 @@ setMethod("nrow", signature = signature("hyperSpec"), function(x) {
##' @export
##' @examples
##'
##' nwl (chondro)
##' nwl (fauxCell)
nwl <- function(x) {
chk.hy(x)
validObject(x)
Expand All @@ -68,7 +68,7 @@ nwl <- function(x) {
##' @keywords methods
##' @export
##' @examples
##' dim (chondro)
##' dim (fauxCell)
setMethod("dim", signature = signature("hyperSpec"), function(x) {
validObject(x)
c(nrow = nrow(x@data), ncol = ncol(x@data), nwl = ncol(x@data$spc))
Expand All @@ -81,7 +81,7 @@ setMethod("dim", signature = signature("hyperSpec"), function(x) {
##' @seealso \code{\link[base]{length}}
##' @export
##' @examples
##' length (chondro)
##' length (fauxCell)
setMethod("length", signature = signature("hyperSpec"), function(x) {
validObject(x)
nrow(x@data)
Expand Down
2 changes: 1 addition & 1 deletion hyperSpec/R/dimnames.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ setReplaceMethod("rownames", signature = signature(x = "hyperSpec"), function(x,
##' @seealso \code{\link[base]{colnames}}
##' @export
##' @examples
##' colnames (chondro)
##' colnames (fauxCell)

setMethod("colnames",
signature = signature(x = "hyperSpec"),
Expand Down
18 changes: 9 additions & 9 deletions hyperSpec/R/droplevels.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,30 @@
#'
#' @examples
#'
#' chondro[1:3]$clusters
#' droplevels(chondro [1:3])$clusters
#' fauxCell[1:3]$region
#' droplevels(fauxCell [1:3])$region
setMethod("droplevels", signature = "hyperSpec", definition = .droplevels)

.test(.droplevels) <- function() {
context("droplevels")

test_that("no change on object without levels to drop", {
expect_equal(droplevels(chondro), chondro)
expect_equal(droplevels(fauxCell), fauxCell)
})

test_that("dropping levels", {
tmp <- droplevels(chondro [1:3])
expect_equal(tmp@data, droplevels(chondro@data [1:3, ]))
tmp <- droplevels(fauxCell [1:3])
expect_equal(tmp@data, droplevels(fauxCell@data [1:3, ]))

expect_equal(
tmp [, c("x", "y", "filename", "spc")],
chondro [1:3, c("x", "y", "filename", "spc")]
tmp [, c("x", "y", "spc")],
fauxCell [1:3, c("x", "y", "spc")]
)

expect_equal(tmp$clusters, factor(rep("matrix", 3)))
expect_equal(tmp$region, factor(rep("matrix", 3)))
})

test_that("no change if factor is `except`ed", {
expect_equal(droplevels(chondro, except = 4), chondro)
expect_equal(droplevels(fauxCell, except = 4), fauxCell)
})
}
2 changes: 1 addition & 1 deletion hyperSpec/R/empty.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
##' @keywords manip
##' @export
##' @examples
##' empty (chondro, nrow = 2, spc = 0)
##' empty (fauxCell, nrow = 2, spc = 0)
##' @param x hyperSpec object
##' @param nrow number of rows the new object should have
##' @param spc value to initialize the new spectra matrix with
Expand Down
8 changes: 4 additions & 4 deletions hyperSpec/R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@
##' plot (flu[!index], "spc", add = TRUE, col = "blue") # select spectra
##'
##' ## index into the data columns ---------------------------------------
##' range (chondro[[,"x"]])
##' colnames (chondro[[,1]])
##' dim (chondro[[,c(TRUE, FALSE, FALSE)]])
##' chondro$x
##' range (fauxCell[[,"x"]])
##' colnames (fauxCell[[,1]])
##' dim (fauxCell[[,c(TRUE, FALSE, FALSE)]])
##' fauxCell$x
##'
##'
##' ## the shortcut functions --------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion hyperSpec/R/hyperspec-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
##' package.
##' @rdname hyperSpec-package
##' @include flu.R
##' @include chondro.R
##' @include fauxCell.R
##' @include laser.R
##' @include paracetamol.R
##' @include barbiturates.R
Expand Down
2 changes: 1 addition & 1 deletion hyperSpec/R/labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,6 @@
##' @export
##' @examples
##'
##' labels (chondro)
##' labels (fauxCell)
##'
setMethod("labels", signature = signature(object = "hyperSpec"), .labels)
8 changes: 4 additions & 4 deletions hyperSpec/R/levelplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ setGeneric("levelplot", package = "lattice")

dots <- modifyList(
list(
xlab = data@label [[use.x]],
xlab = data@label [[use.x]],
ylab = data@label [[use.y]]
),
dots
Expand Down Expand Up @@ -84,10 +84,10 @@ setGeneric("levelplot", package = "lattice")
expect_silent(levelplot(laser, contour = TRUE, col = "#00000080"))

## applying a function before plotting
expect_silent(plotmap(chondro, func = max, col.regions = gray(seq(0, 1, 0.05))))
expect_silent(plotmap(fauxCell, func = max, col.regions = gray(seq(0, 1, 0.05))))

expect_silent(plotmap(chondro, clusters ~ x * y, transform.factor = FALSE))
expect_silent(plotmap(chondro, clusters ~ x * y, col.regions = gray(seq(0, 1, 0.05))))
expect_silent(plotmap(fauxCell, region ~ x * y, transform.factor = FALSE))
expect_silent(plotmap(fauxCell, region ~ x * y, col.regions = gray(seq(0, 1, 0.05))))
})
}

Expand Down
6 changes: 3 additions & 3 deletions hyperSpec/R/map.sel.poly.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
##' @examples
##' if (interactive ()){
##' ## convenience wrapper
##' map.sel.poly (chondro)
##' map.sel.poly (fauxCell)
##'
##' ## customized version
##' data <- sample (chondro [,, 1004 - 2i ~ 1004 + 2i], 300)
##' data <- sample (fauxCell [,, 1004 - 2i ~ 1004 + 2i], 300)
##'
##' plotdata <- plotvoronoi (data, clusters ~ y * x, col.regions = alois.palette ())
##' plotdata <- plotvoronoi (data, region ~ y * x, col.regions = alois.palette ())
##' print (plotdata)
##' map.sel.poly (plotdata)
##'
Expand Down
4 changes: 2 additions & 2 deletions hyperSpec/R/mark.peak.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
##' @author R. Kiselev
##' @export
##' @examples
##' plot (chondro [7])
##' markpeak (chondro [7], 1662)
##' plot (fauxCell [7])
##' markpeak (fauxCell [7], 1662)
markpeak <- function(spc, xpos, col = "red") {
chk.hy(spc)
validObject(spc)
Expand Down
Loading