ggnomics icon indicating copy to clipboard operation
ggnomics copied to clipboard

Genomic Coordinates as position scales

Open teunbrand opened this issue 4 years ago • 4 comments

Basically to have a GRanges object (chromsome:start-end parametrisation) as the position on the x- or y-axis and have a coord_* function reflect this.

The struggle at the moment is to have a vector-like implementation of GRanges as a single column in a base R data.frame. See my related SO question: https://stackoverflow.com/questions/59370461/granges-as-column-in-basedata-frame

teunbrand avatar Dec 17 '19 09:12 teunbrand

I'm now having a decent vctrs-based (vctr_rcrd) S3 equivalent of the GRanges class, but I am having trouble marching these through the internals of ggplot. The intention is to let this be a hidden class that doesn't need to face the user but is used as a representation of genomic ranges internally.

Particularly, I can't seem to get past certain unlist operations in scale_apply(). See related SO question: https://stackoverflow.com/questions/59401011/unlist-behaviour-on-vctr-rcrd-class-objects

teunbrand avatar Dec 23 '19 07:12 teunbrand

I'm now leaning towards making a general vctrs-compatible scale and coordinate system as a seperate package, which I could then extend in ggnomics.

teunbrand avatar Jan 11 '20 11:01 teunbrand

I found out that we can have GRanges objects as columns with some workarounds, so I'll probably make a coordinate system based on the original S4 class.

teunbrand avatar Jan 28 '20 08:01 teunbrand

Update: the genomic position scale appears to be working in theory.

image

Caveat: I can't get any expression other than the plain column name to work. I'd need the compute aesthetics parts of ggplot to change and allow S4 classes in order to achieve this properly.

teunbrand avatar Feb 27 '20 08:02 teunbrand