Git Product home page Git Product logo

ggnomics's People

Contributors

teunbrand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ggnomics's Issues

Dendrogram scales for discrete data

For discrete data, implement a scale_x_dendrogram/scale_y_dendrogram function that take a hclust-class object compatible with the discrete values of the data, reorders the axis according to the dendrogram and draws the tree as part of the axis.

Potential later addition could be to dynamically generate the hclust data given the data, instead of having to rely on the user to supply it.

rename geom_rectrug

Since it's technically not a rug.
Maybe name it geom_rectmargin / geom_tilemargin.

generalise scale_*_multi

The tricky part of the code is already there, should be relatively trivial to expand to have the user submit a list of scales of their own design.

Uneven Facets in facet_nested()

Hey, I'm using your facet_nested code to generate stacked bar plots in R. (Super useful function so thanks for that by the way)
Unfortunately the variables I'm using to facet by have an uneven number of observations, so in some of them the bars appear huge while in others they appear small.
I'm still a bit new to the more in depth coding side of R, so I may have missed this but is there a way to vary the size of the nested facets and "even" the observation bars so they're all about the same size?
i.e. Make facets with more observations wider so that the bar width for each observation is the same?

Helper function for centering scale around zero

Basically this:

function(input){c(-1,1) * max(abs(input))

So that it can be used with scales:

scale_colour_continuous(limits = that_function)

Should be easy and convenient when scale indicates some kind of log fold change.

Set scales per facet

Currently, it is a bit of a pain to precisely control what the limits of a facet are. Maybe, there might something that can be done to give more control, something that would work like the following:

position_scales_by_facet(
  list(
    scale_x_continuous(limits = c(0, 100)),
    scale_x_continuous(limits = c(50, 150))
  )
)

Specify nrow/ncol in facet_nested?

I have a huge figure (48 outer facets, 2 inner facets, each with 2 parts). If I plot using something like:

tibble %>%
+     mutate(Cluster = fct_relevel(Cluster, unique(tibble$Cluster))) %>%
+     mutate(Genotype = fct_relevel(Genotype, "WT", "mutant")) %>%
+     ggplot(aes(fill = Genotype, x= Genotype, y=Proportion)) +
+     geom_boxplot() +
+     geom_point(pch = 21, position = position_jitterdodge()) +
+     facet_nested(~ Cluster + Timepoint, scales="free") +
+     scale_fill_manual(values=c("skyblue1","darksalmon"))

I get it to work, technically speaking, but all 48 outer facets are all in one row and the plot is unreadable.

Is it possible to implement (or combine with) a facet_wrap(ncol=x,nrow=y) sort of functionality so I can control how many rows or columns of facets there are?

Refactoring of Hi-C plotting

In an effort to make Hi-C matrix plotting more flexible, the following might be neat.

  • Write new, general Hi-C matrix function #23
  • Reshape the geom_hictriangle as a position function #24
  • Add stat functions for Hi-C #25
  • Build facet function for annotations #26

facet_nested merges strips when parents mismatch

facet_grid behaviour:

[ 1 ][ 2 ][ 2 ]
[ 3 ][ 3 ][ 4 ]

What it does now:

[ 1 ][    2    ]
[    3    ][ 4 ]

What it should do:

[ 1 ][    2   ]
[ 3 ][ 3 ][ 4 ]

Should set defaults to do third option, give argument to do second option.

to_poly is not working as expected

Figure out why, fix it and write some tests.

Error in data.frame(x = c(1, base::rbind(getMethod("start", "Rle")(object), :
argument is missing, with no default

Import bigwig as polygon

Should write a helper function to import bigwig tracks as a polygon, which would probably be general for converting any RleList to polygons.

Hi-C triangles as position function

The 45 degree angle rotation could be a position function. Could add options such as clip = c("lower", "upper", "neither") or sawtooth = FALSE. Should convert raster-like data to polygon style parametrisation.

geom_genemodel

A function that accepts GRanges contructed from GTF/GFF files as input and formats it such that it would display the gene models appropriately. Combination of rectangles and segments.

better ggsubset

ggsubset <- function(rowtest = NULL, omit = NULL) {
rowtest <- substitute(rowtest)
if (is.null(rowtest)) {
rowtest <- substitute(TRUE)
}
omit <- substitute(omit)
if (is.null(omit)) {
omit <- substitute(TRUE)
}
function(x) subset.data.frame(x, eval(rowtest), -eval(omit))
}

Facets for Hi-C annotation

To add bigwig tracks, bed annotation, position annotation and whatnot. Should by default reverse the y-axis of the Hi-C layer.

Should non-genomics related functions move to a seperate package?

I have the feeling that people sometimes choose to use this package for other things than plotting genomics related data (and there is nothing wrong with that). The following functions are not specifically related to genomics:

  • facet_nested()
  • facetted_pos_scales()
  • force_panelsizes()
  • ggsubset()
  • geom_pointpath()
  • scale_listed()
  • scale_fill/colour_multi()
  • stat_theodensity()

Would it make sense to move these to a seperate repository? Any name suggestions for that repository? I'm mainly asking so that people that don't work with genomics data don't accidentally step in a dependency minefield (see also #11 ). Feel free to leave an opinion as comment if you've used the ggnomics package!

geom_rectrug

Like geom_rug(), but for rectangles. This might be convenient for annotating peaks when plotting genomic tracks.

Rotated Raster

Would probably be nice if one could give the input of geom_raster() to a geom function, and specify a rotation angle, shear or 2x2 matrix to transform the output using linear algebra, outputting the pixels as small polygons.

Fixed x-axis labels per nested grid

Hi,

I have been using facet_nested() quite a lot recently. Thank you for creating such a useful tool! I was wondering if it was possible to create a fixed x-axis per nested grid. Currently, the plot looks like this:

image

This is the code that I used (displaying only the relevant grid parameters):

ggplot(KEGG_df) +  
  facet_nested(~ Enrichment + ControlDesign, nest_line = TRUE,
               scale = "free", space = "free_x") +
  geom_point(mapping = aes(x = IncubationTime, y = KEGGdescr, 
                           color = -log10(FDR), size = EnrichmentScore)) +
  theme(strip.text = element_text(size = 8))

The x-axis of the grid 'Down' shows all labels. In contrast, the labels '4h' and '120h - 24h' are missing from the grid 'Up' since these conditions have no upregulated KEGG pathways. The plot layout that I would like to create is:

image

I have tried using the parameter scale = "fixed" instead of scale = "free". However, this caused that all x-axis labels are displayed in each grid:

image

Is there a way to fix the x-axis labels per nested grid? Meaning that the labels for both grids of 'Control: 0h' are identical and that the labels of both grids of 'Control: previous incubation time' are identical. If you require more information, please let me know. Thank you in advance!

Kind regards,
Michelle

Bioconductor dependencies

Currently the package seems to contain 3 dependencies from Bioconductor

  1. AnnotationDbi
  2. GenomeInfoDb
  3. GenomicFeatures

Installing these are a bit of a frustration, so adding these to the front page, might prove helpful?
The very last reply on this devtools issue seems to mention something about adding bioViews: (pkgs) to the description.

Stat functions for Hi-C

Mainly for the fill values of the matrix.

hic_obsexp: A kind of observed over expected transformation for fill values. Would be possible to add a kind of decay parameter that takes a vector of pre-computed normalisation values. For example those derived from all chromosomes or that particular chromosome arm.

hic_diff: only in case a second experiment has been defined, could take the difference between exp1 and exp2 and output that as a computed variable.

hic_eigen: performs eigenvalue decomposition on the matrix. Can have as argument which eigenvalues to retain.

hic_cor calculates the correlation matrix of the Hi-C map

hic_cov calculates the covariance matrix of the Hi-C map

Ideally there would be some elegant way to perform subsequent stat transformations such that e.g. the eigenvalue decomposition can be performed on the hic_obsexp values or hic_cov values.

General Hi-C geom

It should take up to two experiments and a GRanges region as input. Would output a matrix or polygon, depending on the parameters. Ideally, there would be a plot-wide setting for the regions that the geom could inherit and apply. Could maybe add options to allow chromosomes to be columns, for facetting purposes, and add custom facet parameters to be passed on as a named vector.

Example not working: Error in FUN(X[[i]], ...): unused argument (env = env)

Hello,

I tried the posted example but it didn't work. Can you check what went wrong?

Thanks for this pretty cool package!

library(tidyverse, warn.conflicts = FALSE)
library(ggnomics)

phi <- 2/(1 + sqrt(5))

df <- iris
df$nester <- ifelse(df$Species == "setosa",
                    "Short Leaves",
                    "Long Leaves")

g <- ggplot(df, aes(x = Sepal.Length, y = Petal.Length)) +
  geom_point(aes(sepal.width = Sepal.Width),
             ggsubset(Species == "setosa")) +
  geom_point(aes(petal.length = Petal.Length),
             ggsubset(Species == "versicolor")) +
  geom_point(aes(petal.width = Petal.Width),
             ggsubset(Species == "virginica")) +
  facet_nested(~ nester + Species, scales = "free")
#> Warning: Ignoring unknown aesthetics: sepal.width
#> Warning: Ignoring unknown aesthetics: petal.length
#> Warning: Ignoring unknown aesthetics: petal.width
g
#> Error in FUN(X[[i]], ...): unused argument (env = env)

Created on 2020-03-24 by the reprex package (v0.3.0)

facet_nested() nest_line = TRUE won't repeat

The lines indicating the nesting will return error:

 Error in gtable_add_grob(panel_table, indicator, t = switch(orient, x = pos_y +  : 
  Not all inputs have either length 1 or same length same as 'grobs' 

Probably fixable by providing a list of indicator grobs the same length as insert_here.

Ordering x-axis using facet nested

Hi! I have created a barplot and arranged the x-axis accordingly to how I want it. However, once I run it through facet_nested, it changes the order.

I've tried to get ideas and help from stackoverflow, but have received no reply so it might be an issue that hasn't been encountered before. https://stackoverflow.com/questions/58235789/how-do-i-order-x-axis-within-facet-nested?noredirect=1#comment102845843_58235789

Would there be a function within facet_nested that could work around this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.