Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gene Orientation not correct #68

Closed
xyz0o opened this issue Nov 8, 2023 · 1 comment
Closed

Gene Orientation not correct #68

xyz0o opened this issue Nov 8, 2023 · 1 comment

Comments

@xyz0o
Copy link

xyz0o commented Nov 8, 2023

I have specified the strand orientation in the table as forward= 1 and reverse= -1 and I use below command to draw my genes

ggplot(dfg, aes(xmin = start, xmax = end, y = Gene, fill = element, label = element,
                          forward = orientation)) +
  geom_gene_arrow() +
  facet_wrap(~ Gene, scales = "free", ncol = 1) +
  scale_fill_brewer(palette = "Set3") +
  geom_blank(data = dfg, aes(forward = 1)) +
  theme_genes()

my problem is the figure returns incorrect orientation in relation to the upstream, downstream elements that I have. For example:

<style> </style>
Ltn1 stop_codon 16353834 16353837 reverse -1
Ltn1 exon 16353837 16353954 reverse -1
Ltn1 intron 16353954 16354032 reverse -1
Ltn1 exon 16354032 16354473 reverse -1
Ltn1 intron 16354473 16354532 reverse -1
Ltn1 exon 16354532 16354808 reverse -1
Ltn1 intron 16354808 16354878 reverse -1
Ltn1 exon 16354878 16355062 reverse -1
Ltn1 intron 16355062 16355118 reverse -1
Ltn1 exon 16355118 16355351 reverse -1
Ltn1 intron 16355351 16355406 reverse -1
Ltn1 exon 16355406 16356726 reverse -1
Ltn1 intron 16356726 16357235 reverse -1
Ltn1 exon 16357235 16358277 reverse -1
Ltn1 intron 16358277 16358363 reverse -1
Ltn1 exon 16358363 16358543 reverse -1
Ltn1 intron 16358543 16358602 reverse -1
Ltn1 exon 16358602 16359381 reverse -1
Ltn1 intron 16359381 16359443 reverse -1
Ltn1 exon 16359443 16359491 reverse -1
Ltn1 start_codon 16359488 16359491 reverse -1
Ltn1 TE 16353156 16353284 reverse -1

TE should be placed before the first exon based on the coordinates (downstream) but instead it is drawn as an "upstream" element:

image

I got this problem since I had to re-install the package.

@wilkox
Copy link
Owner

wilkox commented Nov 14, 2023

Because -1 coerces to the logical value TRUE, setting orientation as -1 is the same as setting forward = TRUE. If you replace it with 0, you should get the expected result:

library(tidyverse)
library(gggenes)

dfg <- tribble(
  ~gene, ~element, ~start, ~end, ~strand, ~orientation,
  "Ltn1",   "stop_codon",   16353834,   16353837,   "reverse",  0,
  "Ltn1",   "exon", 16353837,   16353954,   "reverse",  0,
  "Ltn1",   "intron",   16353954,   16354032,   "reverse",  0,
  "Ltn1",   "exon", 16354032,   16354473,   "reverse",  0,
  "Ltn1",   "intron",   16354473,   16354532,   "reverse",  0,
  "Ltn1",   "exon", 16354532,   16354808,   "reverse",  0,
  "Ltn1",   "intron",   16354808,   16354878,   "reverse",  0,
  "Ltn1",   "exon", 16354878,   16355062,   "reverse",  0,
  "Ltn1",   "intron",   16355062,   16355118,   "reverse",  0,
  "Ltn1",   "exon", 16355118,   16355351,   "reverse",  0,
  "Ltn1",   "intron",   16355351,   16355406,   "reverse",  0,
  "Ltn1",   "exon", 16355406,   16356726,   "reverse",  0,
  "Ltn1",   "intron",   16356726,   16357235,   "reverse",  0,
  "Ltn1",   "exon", 16357235,   16358277,   "reverse",  0,
  "Ltn1",   "intron",   16358277,   16358363,   "reverse",  0,
  "Ltn1",   "exon", 16358363,   16358543,   "reverse",  0,
  "Ltn1",   "intron",   16358543,   16358602,   "reverse",  0,
  "Ltn1",   "exon", 16358602,   16359381,   "reverse",  0,
  "Ltn1",   "intron",   16359381,   16359443,   "reverse",  0,
  "Ltn1",   "exon", 16359443,   16359491,   "reverse",  0,
  "Ltn1",   "start_codon",  16359488,   16359491,   "reverse",  0,
  "Ltn1",   "TE",   16353156,   16353284,   "reverse",  0)

ggplot(dfg, aes(xmin = start, xmax = end, y = gene, fill = element, label = element, forward = orientation)) +
  geom_gene_arrow() +
  facet_wrap(~ gene, scales = "free", ncol = 1) +
  scale_fill_brewer(palette = "Set3") +
  geom_blank(data = dfg, aes(forward = 1)) +
  theme_genes()

Created on 2023-11-14 with reprex v2.0.2

@wilkox wilkox closed this as completed Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants