Skip to content
Open
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
16 changes: 16 additions & 0 deletions R/plotAbundanceDensity.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#'
#' @param colour_by Deprecated. Use \code{colour.by} instead.
#'
#' @param colour.features \code{Character vector}. A named vector of colors
#' for features. Names should match feature names. Useful for matching
#' colors across multiple plots. (Default: \code{NULL})
#'
#' @param shape.by \code{Character scalar}. Defines a column from
#' \code{colData}, that is used to group observations to different point shape
#' groups. Must be a value of \code{colData()} function. \code{shape.by} is
Expand Down Expand Up @@ -165,6 +169,7 @@ setMethod("plotAbundanceDensity", signature = c(x = "SummarizedExperiment"),
assay.type = assay_name, assay_name = "counts",
n = min(nrow(x), 25L), colour.by = colour_by,
colour_by = NULL,
colour.features = NULL,
shape.by = shape_by,
shape_by = NULL,
size.by = size_by,
Expand Down Expand Up @@ -219,6 +224,7 @@ setMethod("plotAbundanceDensity", signature = c(x = "SummarizedExperiment"),
layout = layout,
xlab = assay.type,
colour_by = colour_by,
colour_features = colour.features,
shape_by = shape_by,
size_by = size_by,
...)
Expand Down Expand Up @@ -295,6 +301,7 @@ setMethod("plotAbundanceDensity", signature = c(x = "SummarizedExperiment"),
xlab,
ylab = NULL,
colour_by = NULL,
colour_features = NULL,
shape_by = NULL,
size_by = NULL,
point_shape = point.shape,
Expand Down Expand Up @@ -356,6 +363,9 @@ setMethod("plotAbundanceDensity", signature = c(x = "SummarizedExperiment"),
size = point_size,
colour = point_colour)
point_args$args$mapping$y <- sym("Y")
if (!is.null(colour_features)) {
point_args$args$fill <- NULL
}
if (layout == "point"){
plot_out <- plot_out +
do.call(geom_point, point_args$args)
Expand Down Expand Up @@ -412,6 +422,12 @@ setMethod("plotAbundanceDensity", signature = c(x = "SummarizedExperiment"),
axis.line.y = element_blank()) # Removes y-axis
}
}
# Apply custom feature colours if provided
if (!is.null(colour_features)) {
plot_out <- plot_out +
aes(fill = .data[["Y"]]) +
scale_fill_manual(values = colour_features, guide = "none")
}
# add additional guides
plot_out <- .add_extra_guide(plot_out, shape_by, size_by)
# add legend
Expand Down
5 changes: 5 additions & 0 deletions man/plotAbundanceDensity.Rd

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

Loading