ncborcherding / scRepertoire

A toolkit for single-cell immune profiling
https://www.borch.dev/uploads/screpertoire/
MIT License
309 stars 54 forks source link

Issue with "group.by" for clonalOverlap and clonalCompare #409

Closed tonypanx closed 1 month ago

tonypanx commented 1 month ago

I'm encountering issues with the group.by parameter for clonalOverlap and clonalCompare. When I supply a group.by variable, the plots still default to grouping by sample. This happens both in v2.0.5 and v2.0.6

ncborcherding commented 1 month ago

Thanks for reaching out.

Please make a reproducible example for this issue so I know what you are experiencing.

Also with the example, please make sure to include the output of sessionInfo()

Thanks, Nick

bshim181 commented 1 month ago

Experiencing the same issue.

clonalOverlap(combined_TCR, cloneCall = "aa", method = "raw", group.by = "cluster", palette = "Reds") + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))

I am grouping.by a variable called cluster, but it spits it out in sample labels. Thank you for the assistance!

Screenshot 2024-09-25 at 2 53 29 PM
R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Rocky Linux 8.10 (Green Obsidian)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.15.so;  LAPACK version 3.9.0

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       

time zone: America/New_York
tzcode source: system (glibc)

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

other attached packages:
 [1] scRepertoire_2.0.6                      cellXY_0.99.0                           scDblFinder_1.18.0                     
 [4] harmony_1.2.1                           alevinQC_1.20.0                         vctrs_0.6.5                            
 [7] patchwork_1.2.0                         scater_1.30.1                           scuttle_1.12.0                         
[10] speckle_1.4.0                           Matrix_1.6-5                            fishpond_2.10.0                        
[13] readxl_1.4.3                            SingleCellExperiment_1.24.0             flexmix_2.3-19                         
[16] lattice_0.22-6                          SeuratWrappers_0.3.19                   miQC_1.12.0                            
[19] Seurat_5.1.0                            SeuratObject_5.0.2                      sp_2.1-4                               
[22] sctransform_0.4.1                       glmGamPoi_1.16.0                        presto_1.0.0                           
[25] Rcpp_1.0.12                             data.table_1.15.4                       viridis_0.6.5                          
[28] viridisLite_0.4.2                       lubridate_1.9.3                         forcats_1.0.0                          
[31] purrr_1.0.2                             readr_2.1.5                             tidyr_1.3.1                            
[34] tibble_3.2.1                            tidyverse_2.0.0                         stringr_1.5.1                          
[37] dplyr_1.1.4                             TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 riboWaltz_2.0                          
[40] devtools_2.4.5                          usethis_2.2.3                           RSQLite_2.3.7                          
[43] GenomicFeatures_1.54.4                  AnnotationDbi_1.64.1                    hrbrthemes_0.8.7                       
[46] ggplot2_3.5.1                           GenomicAlignments_1.38.2                Rsamtools_2.18.0                       
[49] SummarizedExperiment_1.32.0             Biobase_2.62.0                          MatrixGenerics_1.14.0                  
[52] matrixStats_1.3.0                       GenomicRanges_1.54.1                    GenomicState_0.99.15                   
[55] AnnotationHub_3.10.1                    BiocFileCache_2.10.2                    dbplyr_2.5.0                           
[58] RiboProfiling_1.32.0                    Biostrings_2.70.3                       GenomeInfoDb_1.38.8                    
[61] XVector_0.42.0                          IRanges_2.36.0                          S4Vectors_0.40.2                       
[64] BiocGenerics_0.48.1                    

loaded via a namespace (and not attached):
  [1] hash_2.2.6.3                  igraph_2.0.3                  graph_1.82.0                  ica_1.0-3                    
  [5] plotly_4.10.4                 Formula_1.2-5                 zlibbioc_1.48.2               tidyselect_1.2.1             
  [9] bit_4.0.5                     rjson_0.2.21                  evmix_2.12                    blob_1.2.4                   
 [13] urlchecker_1.0.1              S4Arrays_1.2.1                parallel_4.3.2                dichromat_2.0-0.1            
 [17] png_0.1-8                     cli_3.6.2                     ProtGenerics_1.34.0           goftest_1.2-3                
 [21] BiocIO_1.12.0                 bluster_1.12.0                org.Mm.eg.db_3.18.0           BiocNeighbors_1.20.2         
 [25] stringdist_0.9.12             tximport_1.32.0               uwot_0.2.2                    curl_5.2.1                   
 [29] mime_0.12                     evaluate_0.24.0               leiden_0.4.3.1                gsubfn_0.7                   
 [33] stringi_1.8.4                 desc_1.4.3                    backports_1.5.0               gsl_2.1-8                    
 [37] XML_3.99-0.16.1               httpuv_1.6.15                 magrittr_2.0.3                rappdirs_0.3.3               
 [41] splines_4.3.2                 ggraph_2.2.1                  org.Hs.eg.db_3.19.1           DT_0.33                      
 [45] ggbeeswarm_0.7.2              sessioninfo_1.2.2             DBI_1.2.3                     withr_3.0.0                  
 [49] svMisc_1.2.3                  systemfonts_1.1.0             xgboost_1.7.7.1               lmtest_0.9-40                
 [53] RBGL_1.78.0                   tidygraph_1.3.1               rtracklayer_1.62.0            BiocManager_1.30.23          
 [57] htmlwidgets_1.6.4             fs_1.6.4                      biomaRt_2.58.2                ggrepel_0.9.5                
 [61] labeling_0.4.3                SparseArray_1.2.4             cellranger_1.1.0              extrafont_0.19               
 [65] reticulate_1.37.0             VariantAnnotation_1.48.1      zoo_1.8-12                    GGally_2.2.1                 
 [69] knitr_1.47                    timechange_0.3.0              fansi_1.0.6                   grid_4.3.2                   
 [73] quantreg_5.98                 R.oo_1.26.0                   RSpectra_0.16-1               irlba_2.3.5.1                
 [77] extrafontdb_1.0               fastDummies_1.7.3             ellipsis_0.3.2                lazyeval_0.2.2               
 [81] yaml_2.3.8                    survival_3.7-0                scattermore_1.2               BiocVersion_3.18.1           
 [85] crayon_1.5.2                  RcppAnnoy_0.0.22              tweenr_2.0.3                  RColorBrewer_1.1-3           
 [89] progressr_0.14.0              later_1.3.2                   gfonts_0.2.0                  ggridges_0.5.6               
 [93] codetools_0.2-20              base64enc_0.1-3               GlobalOptions_0.1.2           profvis_0.3.8                
 [97] KEGGREST_1.42.0               Rtsne_0.17                    shape_1.4.6.1                 limma_3.58.1                 
[101] gdtools_0.3.7                 filelock_1.0.3                foreign_0.8-86                sqldf_0.4-11                 
[105] pkgconfig_2.0.3               xml2_1.3.6                    evd_2.3-7                     iNEXT_3.0.1                  
[109] spatstat.sparse_3.0-3         BSgenome_1.70.2               biovizBase_1.50.0             xtable_1.8-4                 
[113] plyr_1.8.9                    httr_1.4.7                    tools_4.3.2                   globals_0.16.3               
[117] pkgbuild_1.4.4                beeswarm_0.4.0                htmlTable_2.4.2               checkmate_2.3.1              
[121] nlme_3.1-165                  MatrixModels_0.5-3            assertthat_0.2.1              digest_0.6.35                
[125] farver_2.1.2                  tzdb_0.4.0                    AnnotationFilter_1.26.0       reshape2_1.4.4               
[129] rpart_4.1.23                  crul_1.4.2                    glue_1.7.0                    cachem_1.1.0                 
[133] polyclip_1.10-6               Hmisc_5.1-3                   generics_0.1.3                ggalluvial_0.12.5            
[137] proto_1.0.0                   parallelly_1.37.1             pkgload_1.3.4                 statmod_1.5.0                
[141] RcppHNSW_0.6.0                ScaledMatrix_1.10.0           fontBitstreamVera_0.1.1       pbapply_1.7-2                
[145] spam_2.10-0                   ggbio_1.50.0                  dqrng_0.4.1                   utf8_1.2.4                   
[149] graphlayouts_1.1.1            gtools_3.9.5                  httpcode_0.3.0                gridExtra_2.3                
[153] shiny_1.8.1.1                 GenomeInfoDbData_1.2.11       R.utils_2.12.3                RCurl_1.98-1.14              
[157] memoise_2.0.1                 rmarkdown_2.27                scales_1.3.0                  R.methodsS3_1.8.2            
[161] future_1.33.2                 RANN_2.6.1                    fontLiberation_0.1.0          OrganismDbi_1.44.0           
[165] spatstat.data_3.0-4           rstudioapi_0.16.0             cluster_2.1.6                 spatstat.utils_3.0-4         
[169] hms_1.1.3                     fitdistrplus_1.1-11           munsell_0.5.1                 cowplot_1.1.3                
[173] colorspace_2.1-0              ggdendro_0.2.0                rlang_1.1.4                   DelayedMatrixStats_1.24.0    
[177] sparseMatrixStats_1.14.0      truncdist_1.0-2               dotCall64_1.1-1               shinydashboard_0.7.2         
[181] ggforce_0.4.2                 circlize_0.4.16               xfun_0.44                     remotes_2.5.0                
[185] modeltools_0.2-23             abind_1.4-5                   interactiveDisplayBase_1.40.0 ps_1.7.6                     
[189] bitops_1.0-7                  promises_1.3.0                DelayedArray_0.28.0           compiler_4.3.2               
[193] prettyunits_1.2.0             beachmat_2.18.1               SparseM_1.83                  listenv_0.9.1                
[197] Rttf2pt1_1.3.12               fontquiver_0.2.1              edgeR_4.0.16                  BiocSingular_1.18.0          
[201] tensor_1.5                    MASS_7.3-60.0.1               progress_1.2.3                BiocParallel_1.36.0          
[205] cubature_2.1.1                spatstat.random_3.2-3         R6_2.5.1                      fastmap_1.2.0                
[209] vipor_0.4.7                   ensembldb_2.26.0              ROCR_1.0-11                   ggstats_0.6.0                
[213] rsvd_1.0.5                    nnet_7.3-19                   gtable_0.3.5                  KernSmooth_2.23-24           
[217] miniUI_0.1.1.1                deldir_2.0-4                  htmltools_0.5.8.1             bit64_4.0.5                  
[221] spatstat.explore_3.2-7        lifecycle_1.0.4               processx_3.8.4                callr_3.7.6                  
[225] restfulr_0.0.15               rsconnect_1.3.1               VGAM_1.1-11                   spatstat.geom_3.2-9          
[229] scran_1.30.2                  future.apply_1.11.2           pillar_1.9.0                  metapod_1.10.1               
[233] locfit_1.5-9.9                jsonlite_1.8.8                chron_2.3-61                 
ncborcherding commented 1 month ago

@bshim181

Is combined_TCR the output of combineTCR()? You might not have a cluster variable to "group.by"?

If not please provide the column names of your single cell object meta data.

Thanks, Nick

bshim181 commented 1 month ago

Thank you so much. I was inputting outputs of combineTCR into the function. It is resolved now on my part.

tonypanx commented 1 month ago

I am working with all_combined, the result of combineTCR. I use addVariable to add a type variable to all_combined:

image

When I use group.by in clonalQuant to plot across type it works fine, but doesn't seem to have an effect for clonalOverlap or clonalCompare.

I think the cause of the issue may be missing handlers when group.by != NULL from clonalOverlap and clonalCompare that is present in clonalQuant such as :

if (!is.null(group.by) & !sco) { input.data <- .groupList(input.data, group.by) }

R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 8

Matrix products: default
BLAS/LAPACK: /software/openblas-0.3.13-el8-x86_64/lib/libopenblas_skylakexp-r0.3.13.so

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

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

other attached packages:
 [1] scRepertoire_2.0.5          scales_1.3.0                ggrepel_0.9.3               scater_1.26.1               scuttle_1.8.4              
 [6] SingleCellExperiment_1.20.1 SummarizedExperiment_1.28.0 Biobase_2.58.0              GenomicRanges_1.50.2        GenomeInfoDb_1.34.9        
[11] IRanges_2.32.0              S4Vectors_0.36.2            BiocGenerics_0.44.0         MatrixGenerics_1.10.0       matrixStats_1.1.0          
[16] rlist_0.4.6.2               reshape2_1.4.4              ggraph_2.1.0                tidygraph_1.2.3             igraph_1.6.0               
[21] RColorBrewer_1.1-3          ggthemes_4.2.4              ComplexHeatmap_2.14.0       cowplot_1.1.1               ggplotify_0.1.0            
[26] SCpubr_2.0.1                rstatix_0.7.2               sctransform_0.4.1           patchwork_1.2.0             clusterProfiler_4.6.2      
[31] harmony_1.2.0               Rcpp_1.0.12                 stringr_1.5.1               R.utils_2.11.0              R.oo_1.24.0                
[36] R.methodsS3_1.8.1           ggpubr_0.6.0                dplyr_1.1.4                 plyr_1.8.9                  ggplot2_3.5.1              
[41] Seurat_5.0.0                SeuratObject_5.0.1          sp_1.6-0                   

loaded via a namespace (and not attached):
  [1] rsvd_1.0.5                    stringdist_0.9.10             ica_1.0-2                     foreach_1.5.2                 lmtest_0.9-40                
  [6] crayon_1.5.1                  MASS_7.3-58.3                 rhdf5filters_1.10.1           nlme_3.1-157                  backports_1.4.1              
 [11] GOSemSim_2.24.0               rlang_1.1.2                   XVector_0.38.0                HDO.db_0.99.1                 ROCR_1.0-11                  
 [16] irlba_2.3.5.1                 SparseM_1.81                  filelock_1.0.2                BiocParallel_1.32.6           rjson_0.2.21                 
 [21] bit64_4.0.5                   evmix_2.12                    glue_1.6.2                    parallel_4.2.0                vipor_0.4.5                  
 [26] spatstat.sparse_3.0-0         AnnotationDbi_1.60.2          dotCall64_1.0-1               DOSE_3.24.2                   spatstat.geom_3.0-6          
 [31] VGAM_1.1-9                    tidyselect_1.2.0              fitdistrplus_1.1-8            tidyr_1.3.0                   zoo_1.8-11                   
 [36] bioc2020trajectories_0.0.0.93 xtable_1.8-4                  RcppHNSW_0.4.1                MatrixModels_0.5-0            magrittr_2.0.3               
 [41] cli_3.6.2                     zlibbioc_1.44.0               rstudioapi_0.14               miniUI_0.1.1.1                fastmatch_1.1-3              
 [46] treeio_1.22.0                 fastDummies_1.7.3             tinytex_0.38                  shiny_1.7.1                   BiocSingular_1.14.0          
 [51] xfun_0.38                     clue_0.3-65                   gson_0.1.0                    cluster_2.1.3                 KEGGREST_1.38.0              
 [56] tibble_3.2.1                  quantreg_5.93                 ape_5.7-1                     listenv_0.8.0                 Biostrings_2.66.0            
 [61] png_0.1-7                     future_1.25.0                 withr_2.5.0                   bitops_1.0-7                  ggforce_0.4.1                
 [66] pillar_1.9.0                  GlobalOptions_0.1.2           cachem_1.0.6                  GetoptLong_1.0.5              hash_2.2.6.2                 
 [71] DelayedMatrixStats_1.20.0     vctrs_0.6.5                   ellipsis_0.3.2                generics_0.1.3                tools_4.2.0                  
 [76] beeswarm_0.4.0                munsell_0.5.0                 tweenr_1.0.2                  fgsea_1.24.0                  DelayedArray_0.24.0          
 [81] fastmap_1.1.0                 compiler_4.2.0                abind_1.4-5                   httpuv_1.6.5                  plotly_4.10.0                
 [86] truncdist_1.0-2               GenomeInfoDbData_1.2.9        gridExtra_2.3                 lattice_0.20-45               deldir_1.0-6                 
 [91] utf8_1.2.2                    later_1.3.0                   BiocFileCache_2.6.1           jsonlite_1.8.8                princurve_2.1.6              
 [96] ScaledMatrix_1.6.0            tidytree_0.4.2                pbapply_1.7-2                 carData_3.0-5                 sparseMatrixStats_1.10.0     
[101] lazyeval_0.2.2                promises_1.2.0.1              car_3.1-2                     doParallel_1.0.17             goftest_1.2-3                
[106] spatstat.utils_3.0-1          reticulate_1.24               Rtsne_0.16                    downloader_0.4                uwot_0.1.14                  
[111] HDF5Array_1.26.0              survival_3.3-1                htmltools_0.5.7               memoise_2.0.1                 graphlayouts_1.0.1           
[116] viridisLite_0.4.0             assertthat_0.2.1              digest_0.6.29                 mime_0.12                     rappdirs_0.3.3               
[121] spam_2.8-0                    RSQLite_2.3.1                 yulab.utils_0.0.6             future.apply_1.9.0            data.table_1.14.10           
[126] blob_1.2.3                    splines_4.2.0                 labeling_0.4.2                Rhdf5lib_1.20.0               RCurl_1.98-1.12              
[131] broom_1.0.4                   rhdf5_2.42.1                  colorspace_2.0-3              ggbeeswarm_0.7.1              shape_1.4.6                  
[136] aplot_0.1.10                  ggrastr_1.0.2                 RANN_2.6.1                    circlize_0.4.15               enrichplot_1.18.4            
[141] fansi_1.0.3                   parallelly_1.31.1             R6_2.5.1                      ggridges_0.5.3                lifecycle_1.0.4              
[146] curl_4.3.2                    ggsignif_0.6.3                leiden_0.3.10                 Matrix_1.6-4                  qvalue_2.32.0                
[151] RcppAnnoy_0.0.19              iterators_1.0.14              spatstat.explore_3.0-6        htmlwidgets_1.6.2             beachmat_2.14.2              
[156] polyclip_1.10-0               purrr_1.0.1                   iNEXT_3.0.0                   shadowtext_0.1.2              gridGraphics_0.5-1           
[161] mgcv_1.8-40                   globals_0.14.0                spatstat.random_3.1-3         slingshot_2.7.0               progressr_0.10.0             
[166] codetools_0.2-18              GO.db_3.16.0                  dbplyr_2.3.2                  RSpectra_0.16-1               gtable_0.3.0                 
[171] DBI_1.2.3                     ggalluvial_0.12.5             ggfun_0.1.4                   tensor_1.5                    httr_1.4.5                   
[176] KernSmooth_2.23-20            stringi_1.8.3                 farver_2.1.0                  cubature_2.1.0                viridis_0.6.2                
[181] ggtree_3.9.0.001              ggdendro_0.1.23               BiocNeighbors_1.16.0          scattermore_1.2               bit_4.0.5                    
[186] scatterpie_0.2.1              spatstat.data_3.0-0           pkgconfig_2.0.3               TrajectoryUtils_1.6.0         gsl_2.1-8                    
[191] evd_2.3-6   
ncborcherding commented 1 month ago

Got the fix implemented thanks @tonypanx. For now it is in the dev branch, but will have it in the main by Friday.

Nick

tonypanx commented 1 month ago

Works now, thanks for the prompt reply and fix!