diff --git a/DESCRIPTION b/DESCRIPTION index d22628c..b22d079 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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", diff --git a/NEWS.md b/NEWS.md index c1a1f47..4922c9b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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`) diff --git a/R/import.R b/R/import.R index bafb983..ca001ad 100644 --- a/R/import.R +++ b/R/import.R @@ -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. diff --git a/R/plot_metadata.R b/R/plot_metadata.R index 9519aba..9679c41 100644 --- a/R/plot_metadata.R +++ b/R/plot_metadata.R @@ -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) { @@ -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( diff --git a/man/import_dataset.Rd b/man/import_dataset.Rd index 8d411ba..7e5140f 100644 --- a/man/import_dataset.Rd +++ b/man/import_dataset.Rd @@ -85,6 +85,7 @@ or a name of a delimited file which contains such data frame. See \code{metadata \item{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.} diff --git a/man/update_metadata_colors.Rd b/man/update_metadata_colors.Rd index 042d30f..5a3c176 100644 --- a/man/update_metadata_colors.Rd +++ b/man/update_metadata_colors.Rd @@ -13,6 +13,7 @@ update_metadata_colors(project, dataset, metadata_colors, overwrite = FALSE) \item{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.}