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

Lower DPI for vignette images to fix CRAN errors and notes #323

Merged
merged 5 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Author: Dylan Beaudette [aut, cre], Pierre Roudier [aut, ctb], Andrew Brown [aut
Maintainer: Dylan Beaudette <[email protected]>
Depends: R (>= 3.5.0)
Imports: grDevices, graphics, stats, utils, methods, grid, lattice, cluster, stringr, data.table, farver, digest, colorspace, ape
Suggests: mvtnorm, soilDB, sp, sf, latticeExtra, tactile, compositions, markovchain, xtable,testthat, Gmedian, Hmisc, tibble, RColorBrewer, scales, MASS, mpspline2, soiltexture, gower, knitr, rmarkdown, dendextend
Suggests: mvtnorm, soilDB, sp, sf, latticeExtra, tactile, compositions, markovchain, xtable,testthat, Gmedian, Hmisc, tibble, RColorBrewer, scales, mpspline2, soiltexture, gower, knitr, rmarkdown, dendextend
Description: The Algorithms for Quantitative Pedology (AQP) project was started in 2009 to organize a loosely-related set of concepts and source code on the topic of soil profile visualization, aggregation, and classification into this package (aqp). Over the past 8 years, the project has grown into a suite of related R packages that enhance and simplify the quantitative analysis of soil profile data. Central to the AQP project is a new vocabulary of specialized functions and data structures that can accommodate the inherent complexity of soil profile information; freeing the scientist to focus on ideas rather than boilerplate data processing tasks <doi:10.1016/j.cageo.2012.10.020>. These functions and data structures have been extensively tested and documented, applied to projects involving hundreds of thousands of soil profiles, and deeply integrated into widely used tools such as SoilWeb <https://casoilresource.lawr.ucdavis.edu/soilweb-apps>. Components of the AQP project (aqp, soilDB, sharpshootR, soilReports packages) serve an important role in routine data analysis within the USDA-NRCS Soil Science Division. The AQP suite of R packages offer a convenient platform for bridging the gap between pedometric theory and practice.
License: GPL (>= 3)
LazyLoad: yes
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# aqp 2.2 (2025-02-14)
* CRAN release
* `evanGenHz()` now uses `stats::cmdscale()` instead of `MASS:isoMDS()`
* migrating a few functions from sharpshootR to aqp:
- `plotProfileDendrogram()`
- `aggregateColorPlot()`
Expand Down
1 change: 1 addition & 0 deletions R/aqp-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#'
#' @importFrom ape as.phylo plot.phylo tiplabels
#'
#'
"_PACKAGE"

#' @export aqp.env
Expand Down
20 changes: 9 additions & 11 deletions R/evalGenHz.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' Data-driven evaluation of generalized horizon labels using nMDS and
#' silhouette width.
#'
#' Non-metric multidimensional scaling is performed via [MASS::isoMDS()].
#' Classic multidimensional scaling is performed via [stats::cmdscale()].
#' The input distance matrix is generated by [cluster::daisy()] using
#' (complete cases of) horizon-level attributes from `obj` as named in
#' `vars`.
Expand All @@ -25,14 +25,12 @@
#'
#' @param stand standardize variables before computing distance matrix, passed to [cluster::daisy()]
#'
#' @param trace verbose output from passed to [MASS::isoMDS()]
#'
#' @param metric distance metric, passed to [cluster::daisy()]
#'
#' @return a list is returned containing:
#' * horizons: `c('mds.1', mds.2', 'sil.width', 'neighbor')`
#' * stats: mean and standard deviation `vars`, computed by generalized horizon label
#' * dist: the distance matrix as passed to [MASS::isoMDS()]
#' * dist: the distance matrix as passed to [stats::cmdscale()]
#'
#' @author D.E. Beaudette
#'
Expand All @@ -41,9 +39,7 @@
#' @keywords manip
#'
#' @export
evalGenHZ <- function(obj, genhz = GHL(obj, required = TRUE), vars, non.matching.code='not-used', stand=TRUE, trace=FALSE, metric='euclidean') {
if(!requireNamespace("MASS", quietly = TRUE))
stop("package `MASS` is required", call.=FALSE)
evalGenHZ <- function(obj, genhz = GHL(obj, required = TRUE), vars, non.matching.code = 'not-used', stand = TRUE, metric = 'euclidean') {

# hack to make R CMD check happy
value <- summarize <- NULL
Expand Down Expand Up @@ -81,8 +77,9 @@ evalGenHZ <- function(obj, genhz = GHL(obj, required = TRUE), vars, non.matching
d[dupe.idx] <- fudge
}

# perform non-metric MDS of dissimilarity matrix
mds <- MASS::isoMDS(d, trace = trace)
## TODO: allow user-defined ordination function
# perform metric MDS of dissimilarity matrix
mds <- stats::cmdscale(d, k = 2)

# compute silhouette widths after removing not-used genhz class
sil.idx <- which(complete.cases(h[, vars, drop = FALSE]) & h[[genhz]] != non.matching.code)
Expand All @@ -95,9 +92,10 @@ evalGenHZ <- function(obj, genhz = GHL(obj, required = TRUE), vars, non.matching
h$sil.width <- NA
h$neighbor <- NA

## TODO: access results from user-defined ordination function
# copy values
h$mds.1[no.na.idx] <- mds$points[, 1]
h$mds.2[no.na.idx] <- mds$points[, 2]
h$mds.1[no.na.idx] <- mds[, 1]
h$mds.2[no.na.idx] <- mds[, 2]
h$sil.width[sil.idx] <- sil[, 3]
h$neighbor[sil.idx] <- levels(h[[genhz]])[sil[, 2]]

Expand Down
3 changes: 1 addition & 2 deletions R/previewColors.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@
#'
#' @author D.E. Beaudette
#'
#'
#'
#' @return When \code{method = "grid" or "manual"} a vector of color order is returned. When \code{method = "MDS"}, the output from \code{MASS::cmdscale}.
#' @return When `method` = "grid" or "manual", a vector of color order is returned. When `method = "MDS"`, the output from [stats::cmdscale()].
#' @export
#'
#' @examples
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Install suggested packages:
p <- c("colorspace", "ape", "soilDB", "latticeExtra", "tactile", "compositions",
"sharpshootR", "markovchain", "xtable", "testthat", "Gmedian",
"farver", "Hmisc", "tibble", "RColorBrewer", "scales", "digest",
"MASS", "mpspline2", "soiltexture", "knitr", "rmarkdown", "mvtnorm")
"mpspline2", "soiltexture", "knitr", "rmarkdown", "mvtnorm")

install.packages(p)
```
Expand Down
7 changes: 2 additions & 5 deletions man/evalGenHZ.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/previewColors.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/testthat/test-genhz.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,4 @@ test_that("generalizeHz SPC method", {

expect_equal(GHL(sp4), "mylabel")
})

14 changes: 8 additions & 6 deletions vignettes/Introduction-to-SoilProfileCollection-Objects.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ vignette: >

```{r setup, echo=FALSE, results='hide', warning=FALSE}
knitr::opts_chunk$set(
message = FALSE,
warning = FALSE,
background = '#F7F7F7',
fig.align = 'center',
dev = 'png',
comment = "#>"
message = FALSE,
warning = FALSE,
background = '#F7F7F7',
fig.align = 'center',
dev = 'png',
dpi = as.integer(Sys.getenv("R_AQP_VIGNETTE_IMAGE_DPI", unset = 32)),
optipng = knitr::hook_optipng,
comment = "#>"
)
options(width = 100, stringsAsFactors = FALSE, timeout = 600)

Expand Down
2 changes: 2 additions & 0 deletions vignettes/Munsell-color-conversion.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ knitr::opts_chunk$set(
background = '#F7F7F7',
fig.align = 'center',
dev = 'png',
dpi = as.integer(Sys.getenv("R_AQP_VIGNETTE_IMAGE_DPI", unset = 32)),
optipng = knitr::hook_optipng,
comment = "#>"
)

Expand Down
2 changes: 2 additions & 0 deletions vignettes/NCSP.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ knitr::opts_chunk$set(
background = '#F7F7F7',
fig.align = 'center',
dev = 'png',
dpi = as.integer(Sys.getenv("R_AQP_VIGNETTE_IMAGE_DPI", unset = 32)),
optipng = knitr::hook_optipng,
comment = "#>"
)

Expand Down
2 changes: 2 additions & 0 deletions vignettes/aqp-overview.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ knitr::opts_chunk$set(
background = '#F7F7F7',
fig.align = 'center',
dev = 'png',
dpi = as.integer(Sys.getenv("R_AQP_VIGNETTE_IMAGE_DPI", unset = 32)),
optipng = knitr::hook_optipng,
comment = "#>"
)

Expand Down
2 changes: 2 additions & 0 deletions vignettes/label-placement.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ knitr::opts_chunk$set(
background = '#F7F7F7',
fig.align = 'center',
dev = 'png',
dpi = as.integer(Sys.getenv("R_AQP_VIGNETTE_IMAGE_DPI", unset = 32)),
optipng = knitr::hook_optipng,
comment = "#>"
)
options(width = 100, stringsAsFactors = FALSE, timeout = 600)
Expand Down
4 changes: 3 additions & 1 deletion vignettes/missing-data.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ knitr::opts_chunk$set(
background = '#F7F7F7',
fig.align = 'center',
dev = 'png',
dpi = as.integer(Sys.getenv("R_AQP_VIGNETTE_IMAGE_DPI", unset = 32)),
optipng = knitr::hook_optipng,
comment = "#>"
)

Expand Down Expand Up @@ -148,4 +150,4 @@ plotSPC(x, color = 'hz.not.missing', width = 0.33, name.style = 'center-center',
text(x = 1:length(x), y = .b[o], labels = x$abs.not.missing[o], cex = 0.85, pos = 1)
mtext('Absolute Non-Missing (cm)', side = 1, line = -0.5)

```
```
2 changes: 2 additions & 0 deletions vignettes/new-in-aqp-2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ knitr::opts_chunk$set(
background = '#F7F7F7',
fig.align = 'center',
dev = 'png',
dpi = as.integer(Sys.getenv("R_AQP_VIGNETTE_IMAGE_DPI", unset = 32)),
optipng = knitr::hook_optipng,
comment = "#>"
)

Expand Down
Loading