Skip to content

Commit

Permalink
Fixed metadata colors at 2D projections
Browse files Browse the repository at this point in the history
previously the breaks were simply ignored
  • Loading branch information
aviezerl committed Aug 9, 2023
1 parent e29c957 commit f9e06d2
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: MCView
Title: A Shiny App for Metacell Analysis
Version: 0.2.19
Version: 0.2.20
Authors@R:
person(given = "Aviezer",
family = "Lifshitz",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# MCView 0.2.20

* Fixed metadata colors at 2D projections (previously the breaks were simply ignored)

# MCView 0.2.19

* Added an option to use disk for shiny caching (`see shiny_cache_dir` and `shiny_cache_max_size` parameters in `create_bundle`)
Expand Down
1 change: 1 addition & 0 deletions R/import.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#' or a name of a delimited file which contains such data frame. See \code{metadata_fields} for other details.
#' @param metadata_colors a named list with colors for each metadata column, or a name of a yaml file with such list.
#' For numerical metadata columns, colors should be given as a list where the first element is a vector of colors and the second element is a vector of breaks. \cr
#' Note that in case the breaks are out of the range of the metadata values, the colors would be used for the minimum and maximum values. \cr
#' If only colors are given breaks would be implicitly determined from the minimum and maximum of the metadata field. \cr
#' For categorical metadata columns, color can be given either as a named vector where names are the categories and the values are the colors, or as a named list where the first element named 'colors' holds the colors, and the second element
#' called 'categories' holds the categories.
Expand Down
7 changes: 3 additions & 4 deletions R/plot_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,13 @@ mc2d_plot_metadata_ggp_numeric <- function(mc2d_df,
)

md_colors <- get_metadata_colors(dataset, md, colors = colors, color_breaks = color_breaks, metadata = metadata)
# palette <- circlize::colorRamp2(colors = md_colors$colors, breaks = md_colors$breaks)
palette <- circlize::colorRamp2(colors = md_colors$colors, breaks = md_colors$breaks)
colors <- palette(seq(min(md_colors$breaks), max(md_colors$breaks), length.out = 100))

mc2d_df <- mc2d_df %>%
# mutate(col_x = palette(.[[md]])) %>%
arrange(desc(!!sym(md))) %>%
mutate(value = !!sym(md))

# shades <- palette(nrow(mc2d_df))
legend_title <- md

add_scatter_layer <- function(x, showlegend = FALSE) {
Expand All @@ -246,7 +245,7 @@ mc2d_plot_metadata_ggp_numeric <- function(mc2d_df,
hoverinfo = "text",
type = "scatter",
mode = "markers",
colors = md_colors$colors,
colors = colors,
marker = list(
size = point_size * 4,
line = list(
Expand Down
1 change: 1 addition & 0 deletions man/import_dataset.Rd

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

1 change: 1 addition & 0 deletions man/update_metadata_colors.Rd

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

0 comments on commit f9e06d2

Please sign in to comment.