Comments (4)
I have figured out a hacky solution in the meantime using trace to temporarily modify the geom_link function by changing the line
default_aes <- aes(y = y, x = x, xend = xend, yend = yend, xmin = xmin, xmax = xmax)
to
default_aes <- aes(y = y, x = x, xend = x, yend = yend, xmin = xmax, xmax = xmax)
then specifying linetype, offset and color with the function itself
geom_link(linetype=3, color="black", offset=0.1)
seems ok but not ideal as the lines are not centered to the middle of the genes. Please let me know if there is a better alternative? Thank you
from gggenomes.
Hi,
interesting question. You can use base ggplot::geom_segment
to draw just lines between genes:
library(gggenomes)
p1 <- gggenomes(emale_genes, emale_seqs) |> add_clusters(emale_cogs) +
geom_seq() + geom_gene()
# classic polygon links
p1 + geom_link()
# line link with use standard ggplot geom_segment
# need to explicitly set aes() and data=links() here!
# x/xend: link start/end on seq1
# xmin/xmax: link start/end on seq2
p1 + geom_segment(aes(y=y, yend=yend, x=(x+xend)/2, xend=(xmin+xmax)/2), data=links())
Hope that helps!
Thomas
from gggenomes.
Or even a bit more elegantly by defining a new geom_link_line
function based on geom_segment
.
geom_link_line <- function(mapping = NULL, data = links(), stat = "identity",
position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE,
...){
default_aes <- aes(y=y, yend=yend, x=(x+xend)/2, xend=(xmin+xmax)/2)
mapping <- gggenomes:::aes_intersect(mapping, default_aes)
layer(geom = GeomSegment, mapping = mapping, data = data, stat = stat,
position = position, show.legend = show.legend, inherit.aes = inherit.aes,
params = list(na.rm = na.rm, ...))
}
p1 + geom_link_line(aes(color=cluster_id))
from gggenomes.
Thanks for this great answer. Does exactly what I was looking for and makes the plots much easier to interpret. The geom_link_line function is very convenient. Many thanks!
from gggenomes.
Related Issues (20)
- Error in `geom_link()`: HOT 7
- geom_feat size and position not responding HOT 3
- geom_link new error HOT 2
- Strand error when call gggenome()
- Submission for JOSS?
- Errror while installing HOT 1
- ggplot2 error using example data HOT 6
- Installation error HOT 3
- fill and fontface otions for geom_gene_label HOT 4
- Move deps from Depends to Imports? HOT 1
- Adding UTRs in the plot HOT 3
- Genes do not start and end at the expected positions HOT 2
- Setting coordinates to visualise part of the genome HOT 1
- shitf() "unused argument" HOT 2
- geom_gene() doesn't work HOT 5
- Errors when running read_feats command HOT 3
- Change space between seqs within the same bin HOT 5
- Changing gene colours HOT 2
- ! Required column(s) missing: • length HOT 2
- breaks to sequences with geom_break() HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gggenomes.