BradyAJohnston / plasmapR

Creating plasmid maps inside ggplot.
https://bradyajohnston.github.io/plasmapR/
Other
77 stars 8 forks source link

Overlapping annotations and promoters #13

Open bryantmurphy opened 4 months ago

bryantmurphy commented 4 months ago

Excellent work on this! The ability to plot data.frame objects is incredibly efficient for feature selection and making edits as desired. Just a few major improvement requests:

  1. When multiple features are overlapping (as in the data frame below), the arrows are correctly stacked, but the labels all fall to the central arrow rather than associating with their corresponding stacked arrows.

    index   name    type    start   end direction
    1   other DNA   source  1   7276    1
    3   pQE30 promoter  misc_feature    224 336 1
    7   BB0346-FLAG CDS 338 1012    1
    10  PflaB   promoter    1032    1279    1
    11  BBLacI(Leu) CDS 1280    2362    1
    12  PflgB   promoter    2373    2521    1
    13  SmR CDS 2522    3313    1
    14  ori rep_origin  3436    4024    1
    15  Bb-ORF123-IRS   CDS 4102    7276    -1
    16  ORF3    CDS 4543    5103    -1
    17  ORF2    CDS 5155    5706    -1
    18  ORF1    CDS 5716    6843    -1
  2. Can you make it so the user is able to set direction == 0 for certain features, resulting in a rectangle as opposed to an arrow? This would be ideal for features like promoters and terminators to help distinguish them from CDSs.

BradyAJohnston commented 4 months ago

Thanks for the kind words, and I'm glad the package is useful! I haven't spent much time on maintaining it recently.

I've implemented the requested changes, which are currently not in the main branch but in dev-feature-shapes].

This gives 'rectangular' feature shapes if direction == 0 and properly offsets the labels if there are multiple overlaps.

You can install it with devtools::install_github("bradyajohnston/plasmapR@dev-feature-shapes").

I may merge into main after having some time to add some tests for it.

tibble::tribble(
  ~index,            ~name,          ~type, ~start,  ~end, ~direction,
      1L,      "other DNA",       "source",     1L, 7276L,         1L,
      3L, "pQE30 promoter", "misc_feature",   224L,  336L,         1L,
      7L,    "BB0346-FLAG",          "CDS",   338L, 1012L,         1L,
     10L,          "PflaB",     "promoter",  1032L, 1279L,         1L,
     11L,    "BBLacI(Leu)",          "CDS",  1280L, 2362L,         1L,
     12L,          "PflgB",     "promoter",  2373L, 2521L,         1L,
     13L,            "SmR",          "CDS",  2522L, 3313L,         0L,
     14L,            "ori",   "rep_origin",  3436L, 4024L,         1L,
     15L,  "Bb-ORF123-IRS",          "CDS",  4102L, 7276L,        -1L,
     16L,           "ORF3",          "CDS",  4543L, 5103L,        -1L,
     17L,           "ORF2",          "CDS",  5155L, 5706L,        -1L,
     18L,           "ORF1",          "CDS",  5716L, 6843L,        -1L
  ) -> dat

dat |> 
  plot_plasmid(
    name = 'test',
    name_size = 8
    )

CleanShot 2024-03-26 at 15 30 52@2x

bryantmurphy commented 4 months ago

Of course -- I really wish I had the package development skills to help maintain it. Those additions (along with the plot customization parameters you're adding) seem to be working perfectly, though, thank you!

BradyAJohnston commented 4 months ago

I'm glad it's working! If you did want to try and contribute to the package (package development is easier than you think, I promise!) then I would happily provide lots of guidance on that front. I've move away from doing lab work / working with plasmids so having someone else help to maintain the package would be ideal going into the future.

bryantmurphy commented 4 months ago

Okay, I'm convinced haha. Especially for microbiologists, I think this package will be well worth the effort to maintain and continue enhancing. I'll reach out in a few months after I've finished up my busy end to grad school and had time to thoroughly review your code along with the R packages book!

BradyAJohnston commented 4 months ago

It's a great book, and it taught me lots. I look forward to hearing from you :)