robinweide / GENOVA

GENome Organisation Visual Analytics
GNU General Public License v3.0
68 stars 15 forks source link

Error: Can't add `add_tads(tad)` to a ggplot object #314

Closed QianzhaoJ closed 6 months ago

QianzhaoJ commented 1 year ago

Hi, Thanks for developing so helpful tools! When I use pyramid function like: p=pyramid(exp = gmat1, chrom = chr, start = start - 50000, end= end+50000) It works, but when I use p+add_tads(tad), some errors ocurred Error: Can't addadd_tads(tad)to a ggplot object. Could you give some suggestions? Thanks in advance! Best, Qianzhao

YiweiNiu commented 1 year ago

Hi, any solutions? I have encountered the same problem.

Here is the session information

R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS:   /usr/local/lib64/R/lib/libRblas.so
LAPACK: /usr/local/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] GENOVA_1.0.1           GenomicRanges_1.42.0   GenomeInfoDb_1.26.2    data.table_1.13.6      UpSetR_1.4.0          
 [6] EnvStats_2.4.0         org.Mm.eg.db_3.12.0    AnnotationDbi_1.52.0   IRanges_2.24.1         S4Vectors_0.28.1      
[11] Biobase_2.50.0         BiocGenerics_0.36.0    clusterProfiler_3.18.0 ChIPseeker_1.26.0      edgeR_3.32.1          
[16] limma_3.46.0           ggsci_2.9              pheatmap_1.0.12        ComplexHeatmap_2.6.2   patchwork_1.1.1       
[21] cowplot_1.1.1          EnhancedVolcano_1.8.0  ggrepel_0.9.1          ggrastr_0.2.3          ggvenn_0.1.9          
[26] ggplotify_0.0.7        ggpubr_0.4.0           forcats_0.5.1          stringr_1.4.0          dplyr_1.0.5           
[31] purrr_0.3.4            readr_2.1.3            tidyr_1.1.2            tibble_3.1.8           ggplot2_3.4.1         
[36] tidyverse_1.3.0        workflowr_1.6.2       

loaded via a namespace (and not attached):
  [1] rappdirs_0.3.3                          rtracklayer_1.50.0                      ragg_1.1.1                             
  [4] bit64_4.0.5                             knitr_1.39                              DelayedArray_0.16.1                    
  [7] RCurl_1.98-1.2                          generics_0.1.0                          GenomicFeatures_1.42.1                 
 [10] callr_3.5.1                             RSQLite_2.2.3                           shadowtext_0.0.7                       
 [13] bit_4.0.4                               tzdb_0.3.0                              enrichplot_1.10.2                      
 [16] xml2_1.3.2                              lubridate_1.8.0                         httpuv_1.5.5                           
 [19] SummarizedExperiment_1.20.0             assertthat_0.2.1                        viridis_0.6.2                          
 [22] xfun_0.30                               hms_1.0.0                               evaluate_0.15                          
 [25] promises_1.1.1                          fansi_0.4.2                             progress_1.2.2                         
 [28] caTools_1.18.1                          dbplyr_2.1.0                            readxl_1.3.1                           
 [31] igraph_1.3.2                            DBI_1.1.1                               ellipsis_0.3.2                         
 [34] backports_1.2.1                         biomaRt_2.46.2                          MatrixGenerics_1.2.1                   
 [37] vctrs_0.5.1                             remotes_2.2.0                           here_1.0.1                             
 [40] Cairo_1.5-12.2                          abind_1.4-5                             cachem_1.0.4                           
 [43] withr_2.5.0                             ggforce_0.3.2                           GenomicAlignments_1.26.0               
 [46] prettyunits_1.1.1                       cluster_2.1.0                           DOSE_3.16.0                            
 [49] crayon_1.4.1                            pkgconfig_2.0.3                         labeling_0.4.2                         
 [52] tweenr_1.0.1                            vipor_0.4.5                             rlang_1.0.6                            
 [55] lifecycle_1.0.3                         downloader_0.4                          extrafontdb_1.0                        
 [58] BiocFileCache_1.14.0                    modelr_0.1.8                            cellranger_1.1.0                       
 [61] rprojroot_2.0.2                         polyclip_1.10-0                         matrixStats_0.58.0                     
 [64] Matrix_1.3-2                            carData_3.0-4                           boot_1.3-25                            
 [67] reprex_1.0.0                            beeswarm_0.4.0                          processx_3.4.5                         
 [70] GlobalOptions_0.1.2                     png_0.1-7                               viridisLite_0.4.1                      
 [73] rjson_0.2.20                            bitops_1.0-6                            KernSmooth_2.23-17                     
 [76] Biostrings_2.58.0                       blob_1.2.1                              shape_1.4.5                            
 [79] qvalue_2.22.0                           rstatix_0.6.0                           gridGraphics_0.5-1                     
 [82] ggsignif_0.6.0                          scales_1.2.0                            memoise_2.0.0                          
 [85] magrittr_2.0.1                          plyr_1.8.6                              gplots_3.1.1                           
 [88] zlibbioc_1.36.0                         compiler_4.0.3                          scatterpie_0.1.5                       
 [91] RColorBrewer_1.1-2                      ash_1.0-15                              plotrix_3.8-1                          
 [94] clue_0.3-58                             Rsamtools_2.6.0                         cli_3.4.1                              
 [97] XVector_0.30.0                          ps_1.5.0                                MASS_7.3-53                            
[100] tidyselect_1.1.2                        stringi_1.5.3                           textshaping_0.3.1                      
[103] proj4_1.0-11                            yaml_2.2.1                              GOSemSim_2.16.1                        
[106] askpass_1.1                             locfit_1.5-9.4                          fastmatch_1.1-0                        
[109] tools_4.0.3                             rio_0.5.16                              circlize_0.4.12                        
[112] rstudioapi_0.13                         git2r_0.28.0                            foreign_0.8-80                         
[115] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 gridExtra_2.3                           farver_2.0.3                           
[118] ggraph_2.0.4                            digest_0.6.27                           rvcheck_0.1.8                          
[121] BiocManager_1.30.10                     Rcpp_1.0.7                              car_3.0-10                             
[124] broom_0.7.4                             ggalt_0.4.0                             later_1.1.0.1                          
[127] httr_1.4.2                              colorspace_2.0-0                        rvest_0.3.6                            
[130] XML_3.99-0.5                            fs_1.5.0                                splines_4.0.3                          
[133] graphlayouts_0.7.1                      systemfonts_1.0.1                       jsonlite_1.7.2                         
[136] tidygraph_1.2.0                         R6_2.5.0                                pillar_1.7.0                           
[139] htmltools_0.5.3                         glue_1.6.2                              fastmap_1.1.0                          
[142] BiocParallel_1.24.1                     maps_3.3.0                              fgsea_1.16.0                           
[145] pkgbuild_1.2.0                          utf8_1.1.4                              lattice_0.20-41                        
[148] curl_4.3                                ggbeeswarm_0.7.0.9000                   gtools_3.8.2                           
[151] zip_2.1.1                               GO.db_3.12.1                            openxlsx_4.2.3                         
[154] openssl_1.4.3                           Rttf2pt1_1.3.8                          rmarkdown_2.17                         
[157] munsell_0.5.0                           DO.db_2.9                               GetoptLong_1.0.5                       
[160] GenomeInfoDbData_1.2.4                  haven_2.3.1                             reshape2_1.4.4                         
[163] gtable_0.3.0                            extrafont_0.17
KnessKness commented 1 year ago

I had the same problem, pyramid works well to show the TAD structure, I'm frustrated that I can't put the TAD on the map

KnessKness commented 1 year ago

I had the same problem, pyramid works well to show the TAD structure, I'm frustrated that I can't put the TAD on the map

Hi,I use myself method add TAD in pyramid:

TAD_plot<-function(chrom,start,end,tad_bed){
  tad_data<-tad_bed[tad_bed$chrom==chrom,]
  tad_data<-tad_data[(tad_data$start>=start)&(tad_data$end<=end),]
  tad_data_mean<-apply(tad_data[,c(2,3)], 1, mean)
  df<-data.frame(x_left = tad_data$start, x_left_end = tad_data_mean, 
                 y_left = 0, y_left_end = tad_data$end-tad_data$start,
                 x_right= tad_data_mean, x_right_end = tad_data$end,
                 y_right = tad_data$end-tad_data$start,y_right_end = 0
                 )
  return(df)
}

data_40k_pyramid <- pyramid(
  data_40k,
  chr = 'chr2',start = 24e6,end = 30e6,
  crop_y = c(0, 2e6),
  #colour = c(0, 300),
) 

df<-TAD_plot(chrom = 'chr2',start = 24e6,end = 30e6,tadlist$`data_40k`)

data_40k_pyramid+
  geom_segment(aes(x=x_left,y=y_left,xend=x_left_end,yend=y_left_end),colour="green",
                              data=df,size=1.5,show.legend = F)+
  geom_segment(aes(x=x_right,y=y_right,xend=x_right_end,yend=y_right_end),colour="green",
               data=df,size=1.5,show.legend = F)

Rplot01

teunbrand commented 6 months ago

Should be fixed now