Giter Site home page Giter Site logo

Comments (8)

qingxi586 avatar qingxi586 commented on August 10, 2024 1

Thank you wilkox, this is what I want to achieve, thank you very much for your help!

from gggenes.

wilkox avatar wilkox commented on August 10, 2024

Hi @qingxi586, it looks like you might be using the patchwork package to compose the plots? I can show you how to combine the two plots but I need access to the data stored in z and f. Please post your current code as a reprex.

from gggenes.

qingxi586 avatar qingxi586 commented on August 10, 2024

I tried to merge them using the patchwork package, but it was not successful,I will now present my data to you

> z
   net                                 TE X_start X_end direction start   end
1 Fill Alt.Os0365_LTR_Truncator#LTR/Gypsy       0   619         1     4   620
2 Fill   Alt.Os0173_LTR_Dasheng#LTR/Gypsy       0   440         0   620  1061
3 Fill   Alt.Os0173_LTR_Dasheng#LTR/Gypsy       0   440         0  7942  8383
4 Fill Alt.Os0365_LTR_Truncator#LTR/Gypsy     614  2282         1  8383 10050
5 Fill     Alt.Os0039_LTR_RIRE3#LTR/Gypsy       0  3139         0 10049 13196
6 Fill     Alt.Os0039_LTR_RIRE3#LTR/Gypsy       0  3139         0 18964 22115
7 Fill Alt.Os0365_LTR_Truncator#LTR/Gypsy    2278  2989         1 22117 22824
> f
   net                               TE X_start X_end direction start   end
1 Fill Alt.Os0173_INT_Dasheng#LTR/Gypsy     713  6310         0  1061  7071
2 Fill   Alt.Os0039_INT_RIRE3#LTR/Gypsy       0  5791         0 13196 18963

It can be observed that these coordinates are all continuous, and I want to represent LTR and INT separately with different arrows in a linear gene
and this is my code

(ggplot(z, aes(xmin = start, xmax = end,y = net, fill = TE,forward = direction,label = TE)) + geom_gene_arrow() +ggplot(f, aes(xmin = start, xmax = end,y = net, fill = TE,forward = direction,label = TE)) + geom_gene_arrow(arrowhead_height = unit(3, "mm"), arrowhead_width = unit(1, "mm")))+facet_wrap( ~ net,scales = "free", ncol = 1)+theme_genes() +
    scale_fill_brewer(palette = "Set3") +labs(title=sv_names)+theme(plot.title = element_text(hjust = 0.5,vjust = -130),axis.text.x = element_text(hjust = 0.5, vjust = 185))+geom_gene_label()

thank you for your help!

from gggenes.

wilkox avatar wilkox commented on August 10, 2024
library(tidyverse)
library(gggenes)

z <- tribble(
  ~net   , ~TE                                  , ~X_start , ~X_end , ~direction , ~start , ~end   ,
  "Fill" , "Alt.Os0365_LTR_Truncator#LTR/Gypsy" , 0        , 619    , 1          , 4      , 620    ,
  "Fill" , "Alt.Os0173_LTR_Dasheng#LTR/Gypsy"   , 0        , 440    , 0          , 620    , 1061   ,
  "Fill" , "Alt.Os0173_LTR_Dasheng#LTR/Gypsy"   , 0        , 440    , 0          , 7942   , 8383   ,
  "Fill" , "Alt.Os0365_LTR_Truncator#LTR/Gypsy" , 614      , 2282   , 1          , 8383   , 10050  ,
  "Fill" , "Alt.Os0039_LTR_RIRE3#LTR/Gypsy"     , 0        , 3139   , 0          , 10049  , 13196  ,
  "Fill" , "Alt.Os0039_LTR_RIRE3#LTR/Gypsy"     , 0        , 3139   , 0          , 18964  , 22115  ,
  "Fill" , "Alt.Os0365_LTR_Truncator#LTR/Gypsy" , 2278     , 2989   , 1          , 22117  , 22824)
z$type <- "LTR"

f <- tribble(
  ~net   , ~TE                                , ~X_start , ~X_end , ~direction , ~start , ~end   ,
  "Fill" , "Alt.Os0173_INT_Dasheng#LTR/Gypsy" , 713      , 6310   , 0          , 1061   , 7071   ,
  "Fill" , "Alt.Os0039_INT_RIRE3#LTR/Gypsy"   , 0        , 5791   , 0          , 13196  , 18963)
f$type <- "INT"

genes <- bind_rows(z, f)

ggplot(genes, aes(xmin = start, xmax = end, y = net, fill = TE,
                  forward = direction, label = TE)) + 
  geom_gene_arrow() +
  facet_wrap(~ type, scales = "free", ncol = 1) +
  theme_genes()

Created on 2024-03-15 with reprex v2.1.0

from gggenes.

qingxi586 avatar qingxi586 commented on August 10, 2024

Hi,wilkox
Maybe there are some issues with my description,The data in z and f are actually together, but I divided INT and LTR into two files. This file originally looked like this

> a
   net                                 TE X_start X_end direction start   end
1 Fill Alt.Os0365_LTR_Truncator#LTR/Gypsy       0   619         1     4   620
2 Fill   Alt.Os0173_LTR_Dasheng#LTR/Gypsy       0   440         0   620  1061
3 Fill   Alt.Os0173_INT_Dasheng#LTR/Gypsy     713  6310         0  1061  7071
4 Fill   Alt.Os0173_LTR_Dasheng#LTR/Gypsy       0   440         0  7942  8383
5 Fill Alt.Os0365_LTR_Truncator#LTR/Gypsy     614  2282         1  8383 10050
6 Fill     Alt.Os0039_LTR_RIRE3#LTR/Gypsy       0  3139         0 10049 13196
7 Fill     Alt.Os0039_INT_RIRE3#LTR/Gypsy       0  5791         0 13196 18963
8 Fill     Alt.Os0039_LTR_RIRE3#LTR/Gypsy       0  3139         0 18964 22115
9 Fill Alt.Os0365_LTR_Truncator#LTR/Gypsy    2278  2989         1 22117 22824

Using your gggenes package does draw nice arrows,like this
plot
I said before that I wanted to use two different arrows to plot my genes,LTR uses default parameters geom_gene_arrow() , INT uses another parameter geom_gene_arrow(arrowhead_height = unit(3, "mm"), arrowhead_width = unit(1, "mm"))
This way I can get the picture I want .
微信图片

from gggenes.

wilkox avatar wilkox commented on August 10, 2024

I don't think I really understand what you're trying to achieve. Is it something like this?

library(tidyverse)
library(gggenes)

z <- tribble(
  ~net   , ~TE                                  , ~X_start , ~X_end , ~direction , ~start , ~end   ,
  "Fill" , "Alt.Os0365_LTR_Truncator#LTR/Gypsy" , 0        , 619    , 1          , 4      , 620    ,
  "Fill" , "Alt.Os0173_LTR_Dasheng#LTR/Gypsy"   , 0        , 440    , 0          , 620    , 1061   ,
  "Fill" , "Alt.Os0173_LTR_Dasheng#LTR/Gypsy"   , 0        , 440    , 0          , 7942   , 8383   ,
  "Fill" , "Alt.Os0365_LTR_Truncator#LTR/Gypsy" , 614      , 2282   , 1          , 8383   , 10050  ,
  "Fill" , "Alt.Os0039_LTR_RIRE3#LTR/Gypsy"     , 0        , 3139   , 0          , 10049  , 13196  ,
  "Fill" , "Alt.Os0039_LTR_RIRE3#LTR/Gypsy"     , 0        , 3139   , 0          , 18964  , 22115  ,
  "Fill" , "Alt.Os0365_LTR_Truncator#LTR/Gypsy" , 2278     , 2989   , 1          , 22117  , 22824)
z$type <- "LTR"

f <- tribble(
  ~net   , ~TE                                , ~X_start , ~X_end , ~direction , ~start , ~end   ,
  "Fill" , "Alt.Os0173_INT_Dasheng#LTR/Gypsy" , 713      , 6310   , 0          , 1061   , 7071   ,
  "Fill" , "Alt.Os0039_INT_RIRE3#LTR/Gypsy"   , 0        , 5791   , 0          , 13196  , 18963)
f$type <- "INT"

genes <- bind_rows(z, f)

ggplot(genes, aes(xmin = start, xmax = end, y = type, fill = TE,
                  forward = direction, label = TE)) + 
  geom_gene_arrow(data = z) +
  geom_gene_arrow(data = f, arrowhead_height = unit(3, "mm"), arrowhead_width = unit(1, "mm")) +
  theme_genes()

Created on 2024-03-17 with reprex v2.1.0

If not, maybe you could draw it on paper and take a picture to show what you want?

from gggenes.

qingxi586 avatar qingxi586 commented on August 10, 2024

Sorry, my description is not accurate enough, I use Adobe illustrator to show you
微信图片
In this picture you can see Alt.Os0173_INT_Dasheng#LTR/Gypsy and Alt.Os0039_INT_RIRE3#LTR/Gypsy The parameters used are geom_gene_arrow(arrowhead_height = unit(3, "mm"), arrowhead_width = unit(1, "mm"))
While other TEs use geom_gene_arrow()
This is what I want to express, I want two different arrows to be drawn on one graph at the same time.

from gggenes.

wilkox avatar wilkox commented on August 10, 2024

Thanks for the picture. Is this what you're after?

library(tidyverse)
library(gggenes)

z <- tribble(
  ~net   , ~TE                                  , ~X_start , ~X_end , ~direction , ~start , ~end   ,
  "Fill" , "Alt.Os0365_LTR_Truncator#LTR/Gypsy" , 0        , 619    , 1          , 4      , 620    ,
  "Fill" , "Alt.Os0173_LTR_Dasheng#LTR/Gypsy"   , 0        , 440    , 0          , 620    , 1061   ,
  "Fill" , "Alt.Os0173_LTR_Dasheng#LTR/Gypsy"   , 0        , 440    , 0          , 7942   , 8383   ,
  "Fill" , "Alt.Os0365_LTR_Truncator#LTR/Gypsy" , 614      , 2282   , 1          , 8383   , 10050  ,
  "Fill" , "Alt.Os0039_LTR_RIRE3#LTR/Gypsy"     , 0        , 3139   , 0          , 10049  , 13196  ,
  "Fill" , "Alt.Os0039_LTR_RIRE3#LTR/Gypsy"     , 0        , 3139   , 0          , 18964  , 22115  ,
  "Fill" , "Alt.Os0365_LTR_Truncator#LTR/Gypsy" , 2278     , 2989   , 1          , 22117  , 22824)
z$type <- "LTR"

f <- tribble(
  ~net   , ~TE                                , ~X_start , ~X_end , ~direction , ~start , ~end   ,
  "Fill" , "Alt.Os0173_INT_Dasheng#LTR/Gypsy" , 713      , 6310   , 0          , 1061   , 7071   ,
  "Fill" , "Alt.Os0039_INT_RIRE3#LTR/Gypsy"   , 0        , 5791   , 0          , 13196  , 18963)
f$type <- "INT"

genes <- bind_rows(z, f)

ggplot(genes, aes(xmin = start, xmax = end, y = "fill", fill = TE,
                  forward = direction, label = TE)) + 
  geom_gene_arrow(data = z) +
  geom_gene_arrow(data = f, arrowhead_height = unit(3, "mm"), arrowhead_width = unit(1, "mm")) +
  theme_genes() +
  scale_fill_brewer(palette = "Set3") +
  labs(y = "net", title = "MH63.chr01_SV10298075")

Created on 2024-03-19 with reprex v2.1.0

from gggenes.

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.