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

lines extend to gene model with geom_junction_label_repel #8

Closed
srisarya opened this issue Nov 15, 2022 · 4 comments · Fixed by #14
Closed

lines extend to gene model with geom_junction_label_repel #8

srisarya opened this issue Nov 15, 2022 · 4 comments · Fixed by #14
Labels
bug Something isn't working

Comments

@srisarya
Copy link

srisarya commented Nov 15, 2022

Hi,
Firstly, thanks for this R package; it's already really useful to me, and it's quite user friendly :)
However, I'm having an issue with the geom_junction_label_repel 'geom' and getting different results from the examples in the README. I was expecting the lines coming from the labels to connect to the junction lines, but instead, they connect to the gene models. I have tried this both with the SOD gene example in the GitHub instructions and with my own data.
I have copied the resulting plot from copying the given code into R below.

sod1_201_exons %>%
  ggplot(aes(
    xstart = start,
    xend = end,
    y = transcript_name
  )) +
  geom_range(
    fill = "white", 
    height = 0.25
  ) +
  geom_range(
    data = sod1_201_cds
  ) + 
  geom_intron(
    data = to_intron(sod1_201_exons, "transcript_name")
  ) + 
  geom_junction(
    data = sod1_junctions,
    junction.y.max = 0.5
  ) +
  geom_junction_label_repel(
    data = sod1_junctions,
    aes(label = round(mean_count, 2)),
    junction.y.max = 0.5
  )

image

My session info is below:

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.5.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] forcats_0.5.2        stringr_1.4.1        purrr_0.3.5          readr_2.1.3          tidyr_1.2.1          tibble_3.1.8         tidyverse_1.3.2      patchwork_1.1.2.9000
 [9] ggsci_2.9            ggplot2_3.4.0        rtracklayer_1.54.0   GenomicRanges_1.46.1 GenomeInfoDb_1.30.1  IRanges_2.28.0       S4Vectors_0.32.4     BiocGenerics_0.40.0 
[17] dplyr_1.0.10         ggtranscript_0.99.9 

loaded via a namespace (and not attached):
 [1] bitops_1.0-7                matrixStats_0.62.0          fs_1.5.2                    lubridate_1.9.0             bit64_4.0.5                 httr_1.4.4                 
 [7] tools_4.1.2                 backports_1.4.1             utf8_1.2.2                  R6_2.5.1                    DBI_1.1.3                   colorspace_2.0-3           
[13] withr_2.5.0                 tidyselect_1.2.0            bit_4.0.4                   compiler_4.1.2              textshaping_0.3.6           cli_3.4.1                  
[19] rvest_1.0.3                 Biobase_2.54.0              xml2_1.3.3                  DelayedArray_0.20.0         labeling_0.4.2              scales_1.2.1               
[25] systemfonts_1.0.4           Rsamtools_2.10.0            XVector_0.34.0              pkgconfig_2.0.3             MatrixGenerics_1.6.0        dbplyr_2.2.1               
[31] rlang_1.0.6                 readxl_1.4.1                rstudioapi_0.14             BiocIO_1.4.0                generics_0.1.3              farver_2.1.1               
[37] jsonlite_1.8.3              BiocParallel_1.28.3         vroom_1.6.0                 googlesheets4_1.0.1         RCurl_1.98-1.9              magrittr_2.0.3             
[43] GenomeInfoDbData_1.2.7      Matrix_1.5-1                Rcpp_1.0.9                  munsell_0.5.0               fansi_1.0.3                 lifecycle_1.0.3            
[49] stringi_1.7.8               yaml_2.3.6                  SummarizedExperiment_1.24.0 zlibbioc_1.40.0             grid_4.1.2                  parallel_4.1.2             
[55] ggrepel_0.9.2               crayon_1.5.2                lattice_0.20-45             Biostrings_2.62.0           haven_2.5.1                 hms_1.1.2                  
[61] knitr_1.40                  pillar_1.8.1                rjson_0.2.21                reprex_2.0.2                XML_3.99-0.12               glue_1.6.2                 
[67] modelr_0.1.9                vctrs_0.5.0                 tzdb_0.3.0                  cellranger_1.1.0            gtable_0.3.1                assertthat_0.2.1           
[73] xfun_0.34                   broom_1.0.1                 restfulr_0.0.15             ragg_1.2.4                  googledrive_2.0.0           gargle_1.2.1               
[79] GenomicAlignments_1.30.0    timechange_0.1.1            ellipsis_0.3.2

Could you please advise what to do?
Thanks!

@dzhang32
Copy link
Owner

Hi - thanks for your feedback on ggtranscript!

I'm unable to reproduce this issue and can't spot anything wrong in the code or environment. The grey boxes representing the CDS (which should be generated by geom_range(data = sod1_201_cds)) are also missing from your plot - are you sure this is the plot generated by your attached code?

On a fresh R session, could you try running the code below and let me know if the outputted plot still has the geom_junction_label_repel issue:

library(ggtranscript)
library(ggplot2)
library(dplyr)
library(magrittr)

sod1_exons <- sod1_annotation %>% dplyr::filter(type == "exon")
sod1_cds <- sod1_annotation %>% dplyr::filter(type == "CDS")

sod1_201_exons <- sod1_exons %>% dplyr::filter(transcript_name == "SOD1-201")
sod1_201_cds <- sod1_cds %>% dplyr::filter(transcript_name == "SOD1-201")
sod1_202_exons <- sod1_exons %>% dplyr::filter(transcript_name == "SOD1-202")
sod1_202_cds <- sod1_cds %>% dplyr::filter(transcript_name == "SOD1-202")

sod1_junctions <- sod1_junctions %>%
  dplyr::mutate(transcript_name = "SOD1-201")

sod1_201_exons %>%
  ggplot(aes(
    xstart = start,
    xend = end,
    y = transcript_name
  )) +
  geom_range(
    fill = "white", 
    height = 0.25
  ) +
  geom_range(
    data = sod1_201_cds
  ) + 
  geom_intron(
    data = to_intron(sod1_201_exons, "transcript_name")
  ) + 
  geom_junction(
    data = sod1_junctions,
    junction.y.max = 0.5
  ) +
  geom_junction_label_repel(
    data = sod1_junctions,
    aes(label = round(mean_count, 2)),
    junction.y.max = 0.5
  )

@srisarya
Copy link
Author

srisarya commented Nov 29, 2022 via email

@dzhang32 dzhang32 added the bug Something isn't working label Jan 21, 2023
@davemcg
Copy link

davemcg commented Feb 11, 2024

I'm having the same issue.

@dzhang32
Copy link
Owner

Thanks for raising, this issue should now be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants