GreenleafLab / ArchR

ArchR : Analysis of Regulatory Chromatin in R (www.ArchRProject.com)
MIT License
385 stars 138 forks source link

Troubles in the tutorial with rank plots labels #2227

Open alekseybelikov opened 5 hours ago

alekseybelikov commented 5 hours ago

Attach your log file None available. See session info below.

Describe the bug

All rank plots in the manual are plotted without the text in the labels

Example 1 The code suggested in the manual:

ggUp <- ggplot(df, aes(rank, mlog10Padj, color = mlog10Padj)) + 
  geom_point(size = 1) +
  ggrepel::geom_label_repel(
        data = df[rev(seq_len(30)), ], aes(x = rank, y = mlog10Padj, label = TF), 
        size = 1.5,
        nudge_x = 2,
        color = "black"
  ) + theme_ArchR() + 
  ylab("-log10(P-adj) Motif Enrichment") + 
  xlab("Rank Sorted TFs Enriched") +
  scale_color_gradientn(colors = paletteContinuous(set = "comet"))

ggUp

Results in the unlabeled plot:

Screenshot 2024-10-25 at 21 09 14

To Reproduce Reproduced multiple time throughout the manual, e.g.

1)

plotVarDev <- getVarDeviations(projHeme5, name = "MotifMatrix", plot = TRUE)
plotVarDev
Screenshot 2024-10-25 at 21 17 42

2)

plotVarDev <- getVarDeviations(projHeme5, plot = TRUE, name = "EncodeTFBSMatrix")
plotVarDev
Screenshot 2024-10-25 at 21 24 06

3)

plotVarDev <- getVarDeviations(projHeme5, plot = TRUE, name = "ATACMatrix")
plotVarDev
Screenshot 2024-10-25 at 21 25 37

4)

plotVarDev <- getVarDeviations(projHeme5, plot = TRUE, name = "ChIPMatrix")
plotVarDev
Screenshot 2024-10-25 at 21 26 36

Expected behavior Plots with labels. See workaround below.

Workaround 1)This modified code seems to work:

ggUp <- ggplot(df, aes(rank, mlog10Padj, color = mlog10Padj)) + 
  geom_point(size = 1) +
  ggrepel::geom_label_repel(
        data = df[rev(seq_len(30)), ], aes(x = rank, y = mlog10Padj, label = TF), 
        size = 2,  # Increase font size for readability
        nudge_x = 2,
        color = "black",  # Ensure the label text is black
        fill = "white",   # Set the label box background to white for better contrast
        max.overlaps = 15
  ) + theme_ArchR() + 
  ylab("-log10(P-adj) Motif Enrichment") + 
  xlab("Rank Sorted TFs Enriched") +
  scale_color_gradientn(colors = paletteContinuous(set = "comet"))

ggUp
Screenshot 2024-10-25 at 21 09 55

2) Workaround for the second example:

VarDev <- getVarDeviations(projHeme5, name = "MotifMatrix", plot = FALSE)
VarDev_df <- as.data.frame(VarDev)
plotVarDev_df <- ggplot(VarDev_df, aes(rank, combinedVars, color = combinedVars)) + 
  geom_point(size = 1) +
   ggrepel::geom_label_repel(
        data = VarDev_df[rev(seq_len(30)), ], aes(x = rank, y = combinedVars, label = name), 
        size = 2,  # Increase font size for readability
        nudge_x = 2,
        color = "black",  # Ensure the label text is black
        fill = "white",   # Set the label box background to white for better contrast
        max.overlaps = 15
  ) + theme_ArchR() + 
  ylab("Variability") + 
  xlab("Rank Sorted Annotations") +
  scale_color_gradientn(colors = paletteContinuous(set = "comet"))
plotVarDev_df
Screenshot 2024-10-25 at 21 21 32

Session Info

R version 4.3.2 (2023-10-31) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS Sonoma 14.5

Matrix products: default BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0

Random number generation: RNG: L'Ecuyer-CMRG Normal: Inversion Sample: Rejection

locale: [1] C

time zone: Europe/London tzcode source: internal

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

other attached packages: [1] hexbin_1.28.4 ggridges_0.5.6
[3] chromVAR_1.24.0 BSgenome.Hsapiens.UCSC.hg19_1.4.3 [5] BSgenome_1.70.2 rtracklayer_1.62.0
[7] BiocIO_1.12.0 Biostrings_2.70.3
[9] XVector_0.42.0 motifmatchr_1.24.0
[11] presto_1.0.0 ggrepel_0.9.5
[13] nabor_0.5.0 rhdf5_2.46.1
[15] SummarizedExperiment_1.32.0 Biobase_2.62.0
[17] MatrixGenerics_1.14.0 Rcpp_1.0.12
[19] Matrix_1.6-5 GenomicRanges_1.54.1
[21] GenomeInfoDb_1.38.8 IRanges_2.36.0
[23] S4Vectors_0.40.2 BiocGenerics_0.48.1
[25] matrixStats_1.3.0 data.table_1.15.4
[27] stringr_1.5.1 plyr_1.8.9
[29] magrittr_2.0.3 ggplot2_3.4.1
[31] gtable_0.3.5 gtools_3.9.5
[33] gridExtra_2.3 ArchR_1.0.2
[35] circlize_0.4.16 ComplexHeatmap_2.18.0

loaded via a namespace (and not attached): [1] RColorBrewer_1.1-3 jsonlite_1.8.8
[3] shape_1.4.6.1 magick_2.8.5
[5] farver_2.1.2 GlobalOptions_0.1.2
[7] zlibbioc_1.48.2 vctrs_0.6.5
[9] memoise_2.0.1 Cairo_1.6-2
[11] Rsamtools_2.18.0 RCurl_1.98-1.16
[13] base64enc_0.1-3 htmltools_0.5.8.1
[15] S4Arrays_1.2.1 Rhdf5lib_1.24.2
[17] CNEr_1.38.0 SparseArray_1.2.4
[19] pracma_2.4.4 htmlwidgets_1.6.4
[21] plotly_4.10.4 cachem_1.1.0
[23] uuid_1.2-0 GenomicAlignments_1.38.2
[25] mime_0.12 lifecycle_1.0.4
[27] iterators_1.0.14 pkgconfig_2.0.3
[29] R6_2.5.1 fastmap_1.2.0
[31] shiny_1.8.1.1 GenomeInfoDbData_1.2.11
[33] clue_0.3-65 digest_0.6.36
[35] colorspace_2.1-0 TFMPvalue_0.0.9
[37] AnnotationDbi_1.64.1 RSQLite_2.3.7
[39] seqLogo_1.68.0 labeling_0.4.3
[41] fansi_1.0.6 mgcv_1.9-1
[43] httr_1.4.7 abind_1.4-5
[45] compiler_4.3.2 bit64_4.0.5
[47] withr_3.0.0 doParallel_1.0.17
[49] BiocParallel_1.36.0 DBI_1.2.3
[51] R.utils_2.12.3 poweRlaw_0.80.0
[53] DelayedArray_0.28.0 rjson_0.2.21
[55] caTools_1.18.2 tools_4.3.2
[57] httpuv_1.6.15 R.oo_1.26.0
[59] glue_1.7.0 restfulr_0.0.15
[61] nlme_3.1-165 promises_1.3.0
[63] rhdf5filters_1.14.1 pbdZMQ_0.3-11
[65] cluster_2.1.6 reshape2_1.4.4
[67] TFBSTools_1.40.0 generics_0.1.3
[69] tzdb_0.4.0 R.methodsS3_1.8.2
[71] tidyr_1.3.1 hms_1.1.3
[73] utf8_1.2.4 foreach_1.5.2
[75] pillar_1.9.0 IRdisplay_1.1
[77] later_1.3.2 splines_4.3.2
[79] dplyr_1.1.4 lattice_0.22-6
[81] bit_4.0.5 annotate_1.80.0
[83] tidyselect_1.2.1 DirichletMultinomial_1.44.0 [85] GO.db_3.18.0 miniUI_0.1.1.1
[87] DT_0.33 stringi_1.8.4
[89] lazyeval_0.2.2 yaml_2.3.9
[91] evaluate_0.24.0 codetools_0.2-20
[93] tibble_3.2.1 cli_3.6.3
[95] IRkernel_1.3.2 xtable_1.8-4
[97] repr_1.1.7 munsell_0.5.1
[99] png_0.1-8 XML_3.99-0.17
[101] readr_2.1.5 blob_1.2.4
[103] bitops_1.0-7 viridisLite_0.4.2
[105] scales_1.3.0 purrr_1.0.2
[107] crayon_1.5.3 GetoptLong_1.0.5
[109] rlang_1.1.4 cowplot_1.1.3
[111] KEGGREST_1.42.0

rcorces commented 5 hours ago

Hi @alekseybelikov! Thanks for using ArchR! Lately, it has been very challenging for me to keep up with maintenance of this package and all of my other responsibilities as a PI. I have not been responding to issue posts and I have not been pushing updates to the software. We are actively searching to hire a computational biologist to continue to develop and maintain ArchR and related tools. If you know someone who might be a good fit, please let us know! In the meantime, your issue will likely go without a reply. Most issues with ArchR right not relate to compatibility. Try reverting to R 4.1 and Bioconductor 3.15. Newer versions of Seurat and Matrix also are causing issues. Sorry for not being able to provide active support for this package at this time.