Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Make scales on "plot all barcode biaxials" view in the debarcoder uniform so the plots can be more easily compared with each other #28

Open
givison opened this issue Oct 16, 2019 · 0 comments

Comments

@givison
Copy link

givison commented Oct 16, 2019

I realized today that the scales for all the scatterplots are different when looking at the "plot all barcode biaxials" view, which makes it challenging to assess the strength of the signal on the positive channels in relation to the negative channels. I think it would be a much more useful visualization if they all had fixed scales. I wrote a small modification to the plot_all_barcode_biaxials() function in the package that fixes the scales on all the plots to be between 0-6 in arcsinh space, and it works well I assign it in my namespace before running the GUI. If you agree that it's a worthwhile feature, feel free to use the code below:

fixed_scales_plot <- function (m, bc.channels) {
    plotlist <- list()
    mahal.dist <- m[, "mahal.dist"]
    m <- m[, bc.channels]
    m <- cbind(m, mahal.dist = mahal.dist)
    m <- data.frame(m)
    for (i in 1:length(bc.channels)) for (j in 1:length(bc.channels)) {
        if (i == j) {
            plot <- (ggplot2::ggplot(ggplot2::aes_string(x = names(m)[i]), 
                                     data = m) + ggplot2::geom_histogram() + ggplot2::scale_x_continuous("") + 
                         ggplot2::scale_y_continuous("") +
                         ggplot2::expand_limits(x = c(0, 6)))
            if (i == 1) 
                plot <- plot + ggplot2::scale_y_continuous(names(m)[i])
            if (j == length(bc.channels)) 
                plot <- plot + ggplot2::scale_x_continuous(names(m)[i])
        }
        else {
            plot <- ggplot2::ggplot(ggplot2::aes_string(x = names(m)[j], 
                                                        y = names(m)[i], colour = "mahal.dist"), data = m)
            if (i > j) {
                plot <- plot + ggplot2::geom_point()
                plot <- plot + ggplot2::scale_colour_gradientn("", 
                                                               breaks = 0:30, colours = rainbow(3))
                plot <- plot + ggplot2::expand_limits(x = c(0, 6), y = c(0, 6))
            }
            else plot <- (plot + ggplot2::geom_blank() + ggplot2::theme(panel.grid.major = ggplot2::element_blank(), 
                                                                        panel.grid.minor = ggplot2::element_blank(), 
                                                                        panel.border = ggplot2::element_blank(), panel.background = ggplot2::element_blank()))
            if (j != 1) 
                plot <- plot + ggplot2::scale_y_continuous("")
            if (i != length(bc.channels)) 
                plot <- plot + ggplot2::scale_x_continuous("")
        }
        plot <- plot + ggplot2::theme(axis.line = ggplot2::element_blank(), 
                                      axis.ticks = ggplot2::element_blank(), axis.text = ggplot2::element_blank(), 
                                      legend.position = "none")
        plotlist <- c(plotlist, list(plot))
    }
    plotlist <- c(plotlist, list(nrow = length(bc.channels)))
    fun <- get("grid.arrange", asNamespace("gridExtra"))
    return(do.call(fun, plotlist))
}

assignInNamespace("plot_all_barcode_biaxials", fixed_scales_plot, "premessa")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant