Comments (4)
Hi Håkon,
good question. It is definitely possible but as of now probably not as easy as it should be. geom_bin_label
uses data derived from the sequence table. In theory you can make any data from seqs available to geom_bin_label
.
s0 <- tibble(
seq_id = c("a1", "a2", "b1"),
bin_id = c("A", "A", "B"),
length = c(1000, 2000, 3000),
country = c("Norway", "Norway", "Sweden")
)
p1 <- gggenomes(seqs=s0) + geom_seq()
p1 + geom_bin_label()
Add additional variables from seqs to bins - granted hard to guess unless you know.
p1 + geom_bin_label(aes(label=country)) # doesn't work b/c
p1 %>% pull_bins() # country is not present in internal bin table
p1 %>% pull_bins(.group=vars(country)) # but it can be included
p1 + geom_bin_label(aes(label=country), data=bins(.group=vars(country)))
It probably would be good to implement the following in future versions. This should be closest to what you suggested. Feel free to comment!
For now, you can just copy and paste the code to make it work for you as well.
# something like
bins_with_meta <- function (..., .group = vars(), .meta = NULL){
dots <- quos(...)
function(.x, ...) {
b <- pull_bins(.x, !!!dots, .group = .group)
if(!is.null(.meta)){
b <- left_join(b, .meta)
}
b
}
}
meta <- tibble(
bin_id = c("A", "B"),
country = c("Norway", "Sweden"),
year=2022)
gggenomes(seqs=s0) + geom_seq() +
geom_bin_label(
aes(label=paste(bin_id, "\n", country, year)),
data=bins_with_meta(.meta = meta), expand_left = 0.4)
from gggenomes.
Thanks, this works well!
I would also like to know how to change the font of the text in the geom_bin_label
, as it does not seem to be affected by theme( text = element_text(family = "Open Sans"))
?
from gggenomes.
Interesting. I would have thought this would work. Internally geom_bin_label just calls geom_text. I'll need to look into it...
from gggenomes.
Ok, so changing the font is actually even easier: geom_bin_label(family = "Open Sans")
. I don't know why/how theme->text does not work, but it also does not work with a regular ggplot+geom_text. theme->text only seems to affect axis labels etc, i.e. items related to the plot theme, not the geoms...
from gggenomes.
Related Issues (20)
- how to remove link borders? HOT 2
- Error in Installation HOT 4
- read_seqs() function not working for me HOT 8
- Unused parameter in drop_feat_layout HOT 2
- Operon boxes HOT 2
- Different genome scales 2
- Show y-axis for geom_wiggle() and offset geom_feat() HOT 1
- ggsave throws error in example code HOT 8
- Gff not recognized HOT 6
- Error in eval(`_inherit`, env, NULL): object 'Guides' not found. HOT 1
- Error in guides$setup(scales, aesthetics, default = params$guide_default %||% : attempt to apply non-function HOT 1
- unexpected error on example data HOT 1
- Incorrect labels for scale with large sequences HOT 1
- read_feats error HOT 4
- Multiple coverage tracks supported? HOT 4
- How can I change the distance (spacer) between different seqs? HOT 2
- Calculate coordinates from gff file with genes in different directions HOT 1
- Error when loading emales.fna with https://github.com/thackl/gggenomes/blob/HEAD/vignettes/emales.Rmd HOT 1
- Generate blast links with NCBI blast, easy to use row.names() HOT 1
- Changing start site of seq track and keeping layout. HOT 4
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.