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

Fix sparse matrix cast and ggplot aes_string deprecations #65

Merged
merged 7 commits into from
Dec 28, 2023
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
12 changes: 8 additions & 4 deletions .github/workflows/check-bioc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ on:
push:
branches: [ master, RELEASE_* ]
pull_request:
branches: [ master, RELEASE_* ]

name: R-CMD-check-bioc

Expand All @@ -49,16 +48,21 @@ jobs:
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
container: ${{ matrix.config.cont }}
## Environment variables unique to this job.

concurrency:
group: ${{ github.workflow }} ${{ matrix.config.os }} ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}
cancel-in-progress: true

strategy:
fail-fast: false
matrix:
config:
- { os: ubuntu-latest, r: '4.2', bioc: '3.15', bioc_release: RELEASE_3_15, cont: "bioconductor/bioconductor_docker:RELEASE_3_15", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
- { os: macOS-latest, r: '4.2', bioc: '3.15', bioc_release: RELEASE_3_15 }
- { os: windows-latest, r: '4.2', bioc: '3.15', bioc_release: RELEASE_3_15 }
- { os: ubuntu-latest, r: 'release', bioc: '3.18', cont: "bioconductor/bioconductor_docker:RELEASE_3_18", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
- { os: macOS-latest, r: 'release', bioc: '3.18' }
- { os: windows-latest, r: 'release', bioc: '3.18' }
## Check https://github.com/r-lib/actions/tree/master/examples
## for examples using the http-user-agent

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
Expand Down
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Imports:
SingleCellExperiment,
ggplot2,
ggplot.multistats,
rlang,
tidyr,
tidyselect,
ggthemes,
Expand Down Expand Up @@ -120,4 +121,4 @@ Collate:
'projection-dist.r'
'rankcor.r'
'sigmas-plotting.r'
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ importFrom(SummarizedExperiment,colData)
importFrom(VIM,hotdeck)
importFrom(ggplot.multistats,stat_summaries_hex)
importFrom(ggplot2,aes)
importFrom(ggplot2,aes_string)
importFrom(ggplot2,after_stat)
importFrom(ggplot2,element_blank)
importFrom(ggplot2,element_line)
importFrom(ggplot2,element_rect)
Expand All @@ -163,7 +163,6 @@ importFrom(ggplot2,scale_fill_identity)
importFrom(ggplot2,scale_fill_manual)
importFrom(ggplot2,scale_x_continuous)
importFrom(ggplot2,scale_y_continuous)
importFrom(ggplot2,stat)
importFrom(ggplot2,theme)
importFrom(ggplot2,theme_minimal)
importFrom(ggthemes,extended_range_breaks)
Expand Down Expand Up @@ -207,6 +206,7 @@ importFrom(pcaMethods,pca)
importFrom(pcaMethods,scores)
importFrom(proxy,dist)
importFrom(proxy,pr_DB)
importFrom(rlang,.data)
importFrom(scales,colour_ramp)
importFrom(scales,percent)
importFrom(scales,rescale)
Expand Down
7 changes: 4 additions & 3 deletions R/diffusionmap-plotting.r
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ NULL
#' @importFrom stats setNames
#' @importFrom grDevices palette hcl.colors
#' @importFrom scatterplot3d scatterplot3d
#' @importFrom ggplot2 ggplot aes aes_string
#' @importFrom rlang .data
#' @importFrom ggplot2 ggplot aes
#' @importFrom ggplot2 geom_point
#' @importFrom ggplot2 theme theme_minimal element_blank element_line element_text element_rect
#' @importFrom ggplot2 scale_fill_identity scale_fill_manual scale_fill_gradientn scale_fill_identity
Expand Down Expand Up @@ -142,10 +143,10 @@ plot.DiffusionMap <- function(

use_mapping <- continuous || is_projection || !is.null(col_by)
p <-
ggplot(point_data, aes_string(d1, d2)) +
ggplot(point_data, aes(.data[[d1]], .data[[d2]])) +
theme_really_minimal() +
geom_point(
aes_string(fill = if (use_mapping) 'Colour' else 'ColourExpl'),
aes(fill = if (use_mapping) .data$Colour else .data$ColourExpl),
colour = I('#00000000'),
shape = I(21))

Expand Down
2 changes: 1 addition & 1 deletion R/diffusionmap.r
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ no_censoring <- function(dists, sigma, cb = invisible) {
exp(-d2@x / (2 * sigma ^ 2))
} else {
stopifnot(d2@uplo == 'U')
coords <- as(d2, 'dsTMatrix')
coords <- as(d2, 'TsparseMatrix')
i <- coords@i + 1L
j <- coords@j + 1L
sig2 <- sigma^2
Expand Down
5 changes: 3 additions & 2 deletions R/dpt-plotting.r
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ NULL
#' @importFrom methods is setMethod
#' @importFrom scales colour_ramp rescale
#' @importFrom utils capture.output
#' @importFrom ggplot2 aes_string geom_path geom_point scale_colour_identity
#' @importFrom rlang .data
#' @importFrom ggplot2 geom_path geom_point scale_colour_identity
#' @export
plot.DPT <- function(
x, root = NULL,
Expand Down Expand Up @@ -144,7 +145,7 @@ get_plot_fn <- function(p) {
function(p2, dat, type = 'p', col, ...) {
xy <- colnames(dat)
geom <- switch(type, p = geom_point, l = geom_path, stop)
p2 + geom(aes_string(xy[[1L]], xy[[2L]], colour = 'Path'), data.frame(dat, Path = col))
p2 + geom(aes(.data[[xy[[1L]]]], .data[[xy[[2L]]]], colour = .data$Path), data.frame(dat, Path = col))
}
} else if (is.list(p) && 'points3d' %in% names(p)) {# scatterplot3d
function(p2, ...) {
Expand Down
13 changes: 7 additions & 6 deletions R/gene-relevance-plotting-differential-map.r
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ differential_map <- function(relevance_map, genes = NULL, dims = 1:2, all = FALS
}))
}

#' @importFrom ggplot2 ggplot aes aes_string
#' @importFrom rlang .data
#' @importFrom ggplot2 ggplot aes
#' @importFrom ggplot2 geom_point geom_spoke
#' @importFrom ggplot2 scale_colour_gradientn
#' @importFrom ggplot2 ggtitle facet_wrap
Expand All @@ -80,12 +81,12 @@ plot_differential_map_impl <- function(relevance_map, ..., genes, dims, pal, fac

d1 <- colnames(coords)[[1]]
d2 <- colnames(coords)[[2]]
gg <- ggplot(dtm, aes_string(d1, d2)) +
gg <- ggplot(dtm, aes(.data[[d1]], .data[[d2]])) +
geom_spoke(
aes_string(
angle = 'Angle', radius = 'Magnitude',
alpha = 'PartialsNorm',
colour = 'Expression'
aes(
angle = .data$Angle, radius = .data$Magnitude,
alpha = .data$PartialsNorm,
colour = .data$Expression
),
arrow = arrow(length = unit(.01, 'npc'))
) +
Expand Down
5 changes: 3 additions & 2 deletions R/gene-relevance-plotting-gr-map.r
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ setMethod('plot_gene_relevance', c('GeneRelevance', 'missing'), function(coords,
plot_gene_relevance_impl(coords, iter_smooth = iter_smooth, n_top = n_top, genes = genes, dims = dims, pal = pal, col_na = col_na, limit = limit, ...)
})

#' @importFrom ggplot2 ggplot aes_string
#' @importFrom rlang .data
#' @importFrom ggplot2 ggplot
#' @importFrom ggplot2 geom_point
#' @importFrom ggplot2 scale_color_manual
#' @importFrom ggplot2 ggtitle
Expand Down Expand Up @@ -109,7 +110,7 @@ plot_gene_relevance_impl <- function(relevance_map, ..., iter_smooth, n_top, gen

d1 <- colnames(coords)[[1]]
d2 <- colnames(coords)[[2]]
rel_map <- ggplot(rel_map_data, aes_string(x = d1, y = d2, colour = 'Gene', text = 'TopN')) +
rel_map <- ggplot(rel_map_data, aes(x = .data[[d1]], y = .data[[d2]], colour = .data$Gene, text = .data$TopN)) +
geom_point(alpha = .8) +
geom_rangeframe(colour = par('col')) +
scale_color_manual(values = pal, na.value = col_na) +
Expand Down
7 changes: 4 additions & 3 deletions R/gene-relevance-plotting-rank.r
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ setMethod('plot_gene_relevance_rank', c('GeneRelevance', 'missing'), function(co
#' @importFrom tidyr gather
#' @importFrom tidyselect one_of
#' @importFrom scales percent
#' @importFrom ggplot2 ggplot aes_string stat
#' @importFrom rlang .data
#' @importFrom ggplot2 ggplot after_stat
#' @importFrom ggplot2 scale_fill_gradientn scale_alpha_continuous
#' @importFrom ggplot.multistats stat_summaries_hex
plot_gene_relevance_rank_impl <- function(relevance_map, ..., genes, dims, n_top, pal, bins, faceter) {
Expand All @@ -49,9 +50,9 @@ plot_gene_relevance_rank_impl <- function(relevance_map, ..., genes, dims, n_top

d1 <- colnames(coords)[[1]]
d2 <- colnames(coords)[[2]]
gg <- ggplot(d, aes_string(d1, d2, z = 'Rank')) +
gg <- ggplot(d, aes(.data[[d1]], .data[[d2]], z = .data$Rank)) +
stat_summaries_hex(
aes_string(fill = 'stat(top10)', alpha = 'stat(size)'),
aes(fill = after_stat(.data$top10), alpha = after_stat(.data$size)),
funs = list(top10 = top10, size = 'length', 'median'),
bins = bins
) +
Expand Down
4 changes: 2 additions & 2 deletions R/methods-coercion.r
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ setMethod('as.data.frame', 'DiffusionMap', function(x, row.names = NULL, optiona
#' @importFrom Biobase as.data.frame.ExpressionSet
#' @importFrom ggplot2 fortify
#' @rdname coercions
#' @exportS3Method fortify
#' @exportS3Method fortify DiffusionMap
#' @export fortify.DiffusionMap
fortify.DiffusionMap <- function(model, data, ...) as.data.frame(model, ...)
setAs('DiffusionMap', 'data.frame', function(from) as.data.frame(from))
Expand All @@ -83,7 +83,7 @@ setMethod('as.data.frame', 'DPT', function(x, row.names = NULL, optional = FALSE
#' @importFrom Biobase as.data.frame.ExpressionSet
#' @importFrom ggplot2 fortify
#' @rdname coercions
#' @exportS3Method fortify
#' @exportS3Method fortify DPT
#' @export fortify.DPT
fortify.DPT <- function(model, data, ...) as.data.frame(model, ...)
setAs('DPT', 'data.frame', function(from) as.data.frame(from))
Expand Down
Loading