Skip to content

Colour/fill palette order inconsistent between spectra plot types #181

Description

@jackscanlan

*.fl.png, *.ln.png and *.st.png plots have different palette orders and colour:value combinations for both the spectra-cn and spectra-asm plots. Below are examples for the spectra-cn plots:

Image Image Image

Compare the scale_*_manual arguments between the plot_line/plot_fill and plot_stack functions in plot_spectra_cn.R, which I think it causing it:

plot_line <- function(dat, name, x_max, y_max, zero, cutoff) {
  ggplot(data=dat, aes(x=kmer_multiplicity, y=Count, group=dat[,1], colour=dat[,1])) +
    geom_line() +
    scale_color_manual(values = merqury_brw(dat[,1]), name="k-mer") +
    plot_zero_line(zero=zero) +
    plot_zero_fill(zero=zero) +
    plot_cutoff(cutoff) +
    theme_bw() +
    format_theme() +
    scale_y_continuous(labels=fancy_scientific) +
    coord_cartesian(xlim=c(0,x_max), ylim=c(0,y_max))
}

plot_fill <- function(dat, name, x_max, y_max, zero, cutoff) {
  ggplot(data=dat, aes(x=kmer_multiplicity, y=Count)) +
    geom_ribbon(aes(ymin=0, ymax=pmax(Count,0), fill=dat[,1], colour=dat[,1]), alpha=ALPHA, linetype=1) +
    plot_zero_fill(zero=zero) +
    plot_cutoff(cutoff) +
    theme_bw() +
    format_theme() +
    scale_color_manual(values = merqury_brw(dat[,1]), name="k-mer") +
    scale_fill_manual(values = merqury_brw(dat[,1]), name="k-mer") +
    scale_y_continuous(labels=fancy_scientific) +
    coord_cartesian(xlim=c(0,x_max), ylim=c(0,y_max))
}

plot_stack <- function(dat, name, x_max, y_max, zero, cutoff) {
  dat[,1]=factor(dat[,1], levels=rev(levels(dat[,1]))) #[c(4,3,2,1)] reverse the order to stack from read-only
  ggplot(data=dat, aes(x=kmer_multiplicity, y=Count, fill=dat[,1], colour=dat[,1])) +
    geom_area(size=LINE_SIZE , alpha=ALPHA) +
    plot_zero_stack(zero=zero) +
    plot_cutoff(cutoff) +
    theme_bw() +
    format_theme() +
    scale_color_manual(values = merqury_brw(dat[,1], direction=1), name="k-mer", breaks=rev(levels(dat[,1]))) +
    scale_fill_manual(values = merqury_brw(dat[,1], direction=1), name="k-mer", breaks=rev(levels(dat[,1]))) +
    scale_y_continuous(labels=fancy_scientific) +
    coord_cartesian(xlim=c(0,x_max), ylim=c(0,y_max))
}

Similar cause for the spectra-asm plots I imagine.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions