Skip to content

Commit

Permalink
add magick package to dependencies to solve vignette building fail
Browse files Browse the repository at this point in the history
Merge branch 'devel' of https://github.com/microbiome/miaViz into rename_cluster

# Conflicts:
#	NEWS
  • Loading branch information
thpral committed Jun 14, 2024
2 parents 4b6b93b + 8afe980 commit 180ddfe
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
^renv$
^renv\.lock$
^miaViz\.Rproj$
^\.Rproj\.user$
.github
Expand All @@ -7,3 +9,4 @@
inst/extras/
^doc$
^Meta$
^\.Rprofile$
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ docs
.DS_Store
/doc/
/Meta/
renv/
.Rprofile

3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: miaViz
Title: Microbiome Analysis Plotting and Visualization
Version: 1.13.2
Version: 1.13.3
Authors@R:
c(person(given = "Tuomas", family = "Borman", role = c("aut", "cre"),
email = "[email protected]",
Expand Down Expand Up @@ -52,6 +52,7 @@ Imports:
DirichletMultinomial,
ggrepel,
SingleCellExperiment
magick
Suggests:
knitr,
rmarkdown,
Expand Down
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ Changes in version 1.11.x

Changes in version 1.13.x
+ plot*Tree: bugfix, ununique nodes
+ Added confidence.level parameter to plotCCA
+ replace cluster with addCluster after renaming in mia package
4 changes: 2 additions & 2 deletions R/plotAbundance.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
#' data(GlobalPatterns, package="mia")
#' se <- GlobalPatterns
#'
#' ## Plotting abundance using the first taxonomic rank as default
#' plotAbundance(se, assay.type="counts")
#' ## Plotting counts using the first taxonomic rank as default
#' plotAbundance(se, assay.type="counts", use_relative=FALSE) + labs(y="Counts")
#'
#' ## Using "Phylum" as rank
#' plotAbundance(se, assay.type="counts", rank = "Phylum", add_legend = FALSE)
Expand Down
36 changes: 21 additions & 15 deletions R/plotCCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#'
#' @param ellipse.linetype Discrete number specifying the style of ellipses.
#' (default: \code{ellipse.linetype = 1})
#'
#' @param confidence.level Number between 0 and 1 to adjust confidence level.
#' (default: \code{confidence.level = 0.95})
#'
#' @param add.vectors TRUE or FALSE, should vectors appear in the plot.
#' (default: \code{add.vectors = TRUE})
Expand Down Expand Up @@ -179,8 +182,8 @@ setGeneric("plotRDA", signature = c("object"),
#' @export
setMethod("plotRDA", signature = c(object = "SingleCellExperiment"),
function(object, dimred,
add.ellipse = TRUE, ellipse.alpha = 0.2, ellipse.linewidth = 0.1, ellipse.linetype = 1,
vec.size = 0.5, vec.color = vec.colour, vec.colour = "black", vec.linetype = 1,
add.ellipse = TRUE, ellipse.alpha = 0.2, ellipse.linewidth = 0.1, ellipse.linetype = 1,
confidence.level = 0.95, vec.size = 0.5, vec.color = vec.colour, vec.colour = "black", vec.linetype = 1,
arrow.size = 0.25, label.color = label.colour, label.colour = "black", label.size = 4,
vec.text = TRUE, repel.labels = TRUE, sep.group = "\U2014", repl.underscore = " ",
add.significance = TRUE, add.expl.var = TRUE, add.vectors = TRUE, parse.labels = TRUE, ...){
Expand Down Expand Up @@ -219,19 +222,22 @@ setMethod("plotRDA", signature = c(object = "SingleCellExperiment"),
if( !.are_whole_numbers(ellipse.linetype) ){
stop("'vec.linetype' must be a whole number.", call. = FALSE)
}
if( ellipse.alpha < 0 || ellipse.alpha > 1 ){
if ( !(is.numeric(ellipse.alpha) && ellipse.alpha > 0 && ellipse.alpha < 1 ) ) {
stop("'ellipse.alpha' must be a number between 0 and 1.", call. = FALSE)
}
if ( !is.numeric(ellipse.linewidth) && ellipse.linewidth > 0 ) {
if ( !(is.numeric(ellipse.linewidth) && ellipse.linewidth > 0) ) {
stop("'ellipse.linewidth' must be a positive number.", call. = FALSE)
}
if ( !is.numeric(vec.size) && vec.size > 0 ) {
if( !(is.numeric(confidence.level) && confidence.level > 0 && confidence.level < 1) ) {
stop("'confidence.level' must be a number between 0 and 1.", call. = FALSE)
}
if ( !(is.numeric(vec.size) && vec.size > 0) ) {
stop("'vec.size' must be a positive number.", call. = FALSE)
}
if ( !is.numeric(arrow.size) && arrow.size > 0 ) {
if ( !(is.numeric(arrow.size) && arrow.size > 0) ) {
stop("'arrow.size' must be a positive number.", call. = FALSE)
}
if ( !is.numeric(label.size) && label.size > 0 ) {
if ( !(is.numeric(label.size) && label.size > 0) ) {
stop("'label.size' must be a positive number.", call. = FALSE)
}
if ( !.is_non_empty_string(vec.color) ) {
Expand All @@ -256,11 +262,11 @@ setMethod("plotRDA", signature = c(object = "SingleCellExperiment"),
# Create a plot
plot <- .rda_plotter(
plot_data, ellipse.alpha = ellipse.alpha, ellipse.linewidth = ellipse.linewidth,
ellipse.linetype = ellipse.linetype, vec.size = vec.size, vec.color = vec.color,
vec.colour = vec.colour, vec.linetype = vec.linetype, arrow.size = arrow.size,
label.color = label.color, label.colour = label.colour, label.size = label.size,
vec.text = vec.text, add.ellipse = add.ellipse, repel.labels = repel.labels,
parse.labels = parse.labels, ...
ellipse.linetype = ellipse.linetype, confidence.level = confidence.level, vec.size = vec.size,
vec.color = vec.color, vec.colour = vec.colour, vec.linetype = vec.linetype,
arrow.size = arrow.size, label.color = label.color, label.colour = label.colour,
label.size = label.size, vec.text = vec.text, add.ellipse = add.ellipse,
repel.labels = repel.labels, parse.labels = parse.labels, ...
)
return(plot)
}
Expand Down Expand Up @@ -493,7 +499,7 @@ setMethod("plotRDA", signature = c(object = "matrix"),
# Plot based on the data
#' @importFrom ggrepel geom_text_repel geom_label_repel
.rda_plotter <- function(
plot_data, ellipse.alpha = 0.2, ellipse.linewidth = 0.1, ellipse.linetype = 1,
plot_data, ellipse.alpha = 0.2, ellipse.linewidth = 0.1, ellipse.linetype = 1, confidence.level = 0.95,
vec.size = 0.5, vec.color = vec.colour, vec.colour = "black",
vec.linetype = 1, arrow.size = 0.25, min.segment.length = 5,
label.color = label.colour, label.colour = "black", label.size = 4,
Expand All @@ -516,12 +522,12 @@ setMethod("plotRDA", signature = c(object = "matrix"),
aes(x = .data[[xvar]], y = .data[[yvar]],
color = .data[[colour_var]], fill = after_scale(color)),
geom = "polygon", alpha = ellipse.alpha,
linewidth = ellipse.linewidth, linetype = ellipse.linetype)
linewidth = ellipse.linewidth, linetype = ellipse.linetype, level = confidence.level)
} else if ( add.ellipse %in% c("color", "colour") ){
plot <- plot +
stat_ellipse(data = data,
aes(x = .data[[xvar]], y = .data[[yvar]], color = .data[[colour_var]]),
geom = "polygon", alpha = 0, linetype = ellipse.linetype)
geom = "polygon", alpha = 0, linetype = ellipse.linetype, level = confidence.level)
}

}
Expand Down
4 changes: 2 additions & 2 deletions man/plotAbundance.Rd

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

4 changes: 4 additions & 0 deletions man/plotCCA.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/test-2plotSeries.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
context("plot series")
test_that("plot series", {
# Load data from miaTime package
skip_if_not_installed("miatime")
skip_if_not_installed("miaTime")
data(SilvermanAGutData, package = "miaTime")
tse <- SilvermanAGutData
tse_sub <- tse[1:5]
Expand Down

0 comments on commit 180ddfe

Please sign in to comment.