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

Automatic plot resizing in gene-patterns #390

Open
menoldmt opened this issue Aug 16, 2023 · 0 comments
Open

Automatic plot resizing in gene-patterns #390

menoldmt opened this issue Aug 16, 2023 · 0 comments

Comments

@menoldmt
Copy link
Contributor

Problem:

When degPatterns produces plots with many facets here, the generated faceted ggplot becomes too crowded, in some cases making it hard or impossible to interpret the results.
 

Proposed Solution:

Use dynamic chunk creation for each plot. Find the number of gene clusters to be plotted for each contrast, and use this number to determine the plot dimensions used in the chunk options in each of the dynamic chunks created using the subchunkify function's arguments. This will ensure readability regardless of the number of 
clusters.


subchunkify:

# Use subchunkify to dynamically create chunks for variable number of clusters
subchunkify <- function(g, name, fig_height=10, fig_width=10) {
  g_deparsed <- paste0(deparse(function() {g}), collapse = '')
  sub_chunk <- paste0("`","``{r subchunk_", name,
                      ", fig.height=", fig_height,
                      ", fig.width=", fig_width,
                      " , echo=FALSE}",
                      "\n(", g_deparsed, ")()", "\n`", "``")
  cat(knitr::knit(text = knitr::knit_expand(text = sub_chunk), quiet = TRUE))

can be inserted here

and called here like:

deg_plot_cluster <- degPlotCluster(
        n2,
        time=time,
        min_genes=minc,
        col=col
        )
    print(deg_plot_cluster)
    # Get number of cluseters to plot, n

    #fig_dimm <- 10 + ceiling(sqrt(n))/10
    #subchunkify(print(deg_plot_cluster), paste0(name, '_finalclusters'),
    #fig.height=fig.dimm, fig.width=fig.dimm)

This solution is incomplete and requires testing.

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