Shians / NanoMethViz

https://shians.github.io/NanoMethViz/
Apache License 2.0
23 stars 1 forks source link

Improve aggregate plotting behaviour #7

Closed Shians closed 3 years ago

Shians commented 3 years ago

Currently, the aggregate plotting function has two interfaces

plot_agg_regions <- function(
    x,
    regions,
    features_group = NULL,
    flank = 2000,
    stranded = TRUE,
    span = 0.05,
    palette = ggplot2::scale_colour_brewer(palette = "Set1")
) 

and

plot_agg_regions_sample_grouped <- function(
    x,
    regions,
    flank = 2000,
    stranded = TRUE,
    span = 0.05,
    palette = ggplot2::scale_colour_brewer(palette = "Set1")
) 

The first was an initial implementation that took lists of features such that each member of the list was a feature group. This decision lead to many list-handling code blocks that were complicated to interpret. Furthermore, since the grouping was implicit in the feature level data structure, it made it impossible to group by sample-level information. Therefore, the second function was created in order to group by a column in the sample annotation.

A re-implementation is required. Ideally allowing grouping by any column found in either the sample annotation or feature annotation, preferably using a single data.frame for the regions.

Shians commented 3 years ago

Fixed in 1fbaedd

New interface is

plot_agg_regions <- function(
    x,
    regions,
    group_col = NULL,
    flank = 2000,
    stranded = TRUE,
    span = 0.05,
    palette = ggplot2::scale_colour_brewer(palette = "Set1")
)

Regions are now provided as a table only, with optional columns to specify grouping. The grouping column is specified by group_col and column can be selected from either the regions table or samples(x). plot_agg_regions_sample_grouped() is therefore made redundant.