Git Product home page Git Product logo

Comments (2)

thackl avatar thackl commented on June 20, 2024

Here's how I would approach this. For starters, you can use geom_feat(). The coordinates can come from a simple dataframe.

library(tidyverse)
library(gggenomes)

genes <- tibble(
  seq_id = rep(c("s1", "s2"), each=5), # five genes per sequence
  start = c(50, 250, 500, 1000, 1300, 50, 450, 700, 1200, 1500),
  end = c(150, 450, 950, 1200, 1800, 350, 650, 1150, 1400, 2000) 
)
  
operons <-  tibble(
  seq_id = c("s1", "s2"),
  start = c(225, 425),
  end = c(1225,1425),
  name= c("operon X", "operon Y"),
)

gggenomes(genes, feats=operons) +
  geom_feat(size=5) +
  geom_feat_note(aes(label=name), nudge_y = -.1) +
  geom_gene()

image

Or you can just as well read them from a file

# write example data to file for demonstation
# bed format: seq_id start end strand score name ...
write_tsv(operons, "operons.bed", col_names=FALSE)

# read a coordinate file (such as .bed, .gff, .gbk)
operons.bed <- read_feats("operons.bed")

gggenomes(genes, feats=operons.bed) +
  geom_feat(size=5) +
  geom_feat_note(aes(label=name), nudge_y = -.1) +
  geom_gene()

image

If you want an actual box, you can use the standart ggplot geoms in gggenomes as well. The only thing in that case is that you need to set x,y and the data track mappings explicitly.

gggenomes(genes, feats=operons) +
  geom_rect(
    aes(xmin=x, xmax=xend, ymin=y+.1, ymax=y+-.1), # explicitly map aesthetics
    data=feats(), # explicitly set track
    fill="cornflowerblue", color="black") +
  geom_feat_note(aes(label=name), nudge_y = -.12) +
  geom_gene()

image

Let me know if that helps of if you had something different in mind. And in case you struggle to implement this with your own data, ideally upload some example data.

from gggenomes.

waltercostamb avatar waltercostamb commented on June 20, 2024

Thank you so much for the prompt answer. The first implementation solves my problem. I can easily see the operons now.

from gggenomes.

Related Issues (20)

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.