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

Documentation says "genome" can be a string but code does not support it #1437

Closed
RamRS opened this issue Jun 27, 2023 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@RamRS
Copy link

RamRS commented Jun 27, 2023

The documentation for AddMotifs suggests the genome parameter can be "A BSgenome, DNAStringSet, FaFile, or string stating the genome build recognized by getBSgenome." (emphasis added by me).

However, if we use 'hg19' or 'hg38' as the value, we run into an error stating:

Error in hCsimpleError(msg, call)) :

error in evaluating the argument 'x' in selecting a method for function 'seqlevels':
unable to find an inherited method for function 'seqinfo' for signature '"character"'

I dug through the code and this probably happens here: https://github.com/stuart-lab/signac/blob/master/R/motifs.R#L45

The string is recognized and processed by CreateMotifMatrix:

https://github.com/stuart-lab/signac/blob/master/R/preprocessing.R#L142

but the new genome object (BSgenome) is not available to the parent function. The assignment needs to happen using a global assignment operator (<<-) or the genome variable needs to be returned to the calling function for the change to reflect.

Code to reproduce this from your vignette:

library(Signac)
library(Seurat)
library(JASPAR2020)
library(TFBSTools)
library(BSgenome.Mmusculus.UCSC.mm10)
library(patchwork)

mouse_brain <- readRDS("../vignette_data/adult_mouse_brain.rds")

# Get a list of motif position frequency matrices from the JASPAR database
pfm <- getMatrixSet(
  x = JASPAR2020,
  opts = list(collection = "CORE", tax_group = 'vertebrates', all_versions = FALSE)
)

# add motif information
mouse_brain <- AddMotifs(
  object = mouse_brain,
  genome = 'mm10',
  pfm = pfm
)

However, this works:

# add motif information
mouse_brain <- AddMotifs(
  object = mouse_brain,
  genome = BSgenome.Mmusculus.UCSC.mm10,
  pfm = pfm
)

I have not tested the code above but @esouto6 has been running your vignette code on our human data and ran into the error mentioned above, which I think you should be able to reproduce on your vignette data.

As this issue was originally reported by my colleague @esouto6, he will provide his sessionInfo() in a comment below.

EDIT: I've run the vignettes on mouse brain and adding motifs and verified this error.

@RamRS RamRS added the bug Something isn't working label Jun 27, 2023
@esouto6
Copy link

esouto6 commented Jun 27, 2023

Session info:

> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.5.1

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

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

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

other attached packages:
 [1] BSgenome.Hsapiens.UCSC.hg38_1.4.5 BSgenome.Hsapiens.UCSC.hg19_1.4.3
 [3] JASPAR2020_0.99.10                future_1.32.0                    
 [5] patchwork_1.1.2                   ggplot2_3.4.2                    
 [7] EnsDb.Hsapiens.v75_2.99.0         ensembldb_2.22.0                 
 [9] AnnotationFilter_1.22.0           GenomicFeatures_1.50.4           
[11] AnnotationDbi_1.60.2              Biobase_2.58.0                   
[13] SeuratObject_4.1.3                Seurat_4.3.0.1                   
[15] TFBSTools_1.36.0                  Signac_1.10.0                    
[17] BSgenome_1.66.3                   rtracklayer_1.58.0               
[19] Biostrings_2.66.0                 XVector_0.38.0                   
[21] GenomicRanges_1.50.2              GenomeInfoDb_1.34.9              
[23] IRanges_2.32.0                    S4Vectors_0.36.2                 
[25] BiocGenerics_0.44.0              

loaded via a namespace (and not attached):
  [1] utf8_1.2.3                  spatstat.explore_3.2-1     
  [3] reticulate_1.30             R.utils_2.12.2             
  [5] tidyselect_1.2.0            poweRlaw_0.70.6            
  [7] RSQLite_2.3.1               htmlwidgets_1.6.2          
  [9] grid_4.2.2                  BiocParallel_1.32.6        
 [11] Rtsne_0.16                  munsell_0.5.0              
 [13] codetools_0.2-19            ica_1.0-3                  
 [15] miniUI_0.1.1.1              withr_2.5.0                
 [17] spatstat.random_3.1-5       colorspace_2.1-0           
 [19] progressr_0.13.0            filelock_1.0.2             
 [21] knitr_1.43                  rstudioapi_0.14            
 [23] ROCR_1.0-11                 tensor_1.5                 
 [25] listenv_0.9.0               labeling_0.4.2             
 [27] MatrixGenerics_1.10.0       GenomeInfoDbData_1.2.9     
 [29] polyclip_1.10-4             farver_2.1.1               
 [31] bit64_4.0.5                 parallelly_1.36.0          
 [33] vctrs_0.6.3                 generics_0.1.3             
 [35] xfun_0.39                   biovizBase_1.46.0          
 [37] BiocFileCache_2.6.1         R6_2.5.1                   
 [39] ggbeeswarm_0.7.2            bitops_1.0-7               
 [41] spatstat.utils_3.0-3        cachem_1.0.8               
 [43] DelayedArray_0.24.0         promises_1.2.0.1           
 [45] BiocIO_1.8.0                scales_1.2.1               
 [47] nnet_7.3-19                 beeswarm_0.4.0             
 [49] gtable_0.3.3                globals_0.16.2             
 [51] goftest_1.2-3               seqLogo_1.64.0             
 [53] rlang_1.1.1                 RcppRoll_0.3.0             
 [55] splines_4.2.2               lazyeval_0.2.2             
 [57] dichromat_2.0-0.1           checkmate_2.2.0            
 [59] spatstat.geom_3.2-1         yaml_2.3.7                 
 [61] reshape2_1.4.4              abind_1.4-5                
 [63] backports_1.4.1             httpuv_1.6.11              
 [65] Hmisc_5.1-0                 tools_4.2.2                
 [67] ellipsis_0.3.2              RColorBrewer_1.1-3         
 [69] ggridges_0.5.4              Rcpp_1.0.10                
 [71] plyr_1.8.8                  base64enc_0.1-3            
 [73] progress_1.2.2              zlibbioc_1.44.0            
 [75] purrr_1.0.1                 RCurl_1.98-1.12            
 [77] prettyunits_1.1.1           rpart_4.1.19               
 [79] deldir_1.0-9                pbapply_1.7-0              
 [81] cowplot_1.1.1               zoo_1.8-12                 
 [83] SummarizedExperiment_1.28.0 ggrepel_0.9.3              
 [85] cluster_2.1.4               motifmatchr_1.20.0         
 [87] magrittr_2.0.3              data.table_1.14.8          
 [89] scattermore_1.2             lmtest_0.9-40              
 [91] RANN_2.6.1                  ProtGenerics_1.30.0        
 [93] fitdistrplus_1.1-11         matrixStats_1.0.0          
 [95] evaluate_0.21               hms_1.1.3                  
 [97] mime_0.12                   xtable_1.8-4               
 [99] XML_3.99-0.14               gridExtra_2.3              
[101] compiler_4.2.2              biomaRt_2.54.1             
[103] tibble_3.2.1                KernSmooth_2.23-21         
[105] crayon_1.5.2                R.oo_1.25.0                
[107] htmltools_0.5.5             later_1.3.1                
[109] tzdb_0.4.0                  Formula_1.2-5              
[111] tidyr_1.3.0                 DBI_1.1.3                  
[113] dbplyr_2.3.2                rappdirs_0.3.3             
[115] MASS_7.3-60                 Matrix_1.5-4.1             
[117] readr_2.1.4                 cli_3.6.1                  
[119] R.methodsS3_1.8.2           parallel_4.2.2             
[121] igraph_1.5.0                pkgconfig_2.0.3            
[123] GenomicAlignments_1.34.1    TFMPvalue_0.0.9            
[125] foreign_0.8-84              sp_2.0-0                   
[127] plotly_4.10.2               spatstat.sparse_3.0-2      
[129] xml2_1.3.4                  annotate_1.76.0            
[131] vipor_0.4.5                 DirichletMultinomial_1.40.0
[133] VariantAnnotation_1.44.1    stringr_1.5.0              
[135] digest_0.6.31               sctransform_0.3.5          
[137] RcppAnnoy_0.0.20            pracma_2.4.2               
[139] CNEr_1.34.0                 spatstat.data_3.0-1        
[141] rmarkdown_2.22              leiden_0.4.3               
[143] fastmatch_1.1-3             htmlTable_2.4.1            
[145] uwot_0.1.15                 curl_5.0.1                 
[147] restfulr_0.0.15             shiny_1.7.4                
[149] Rsamtools_2.14.0            gtools_3.9.4               
[151] rjson_0.2.21                lifecycle_1.0.3            
[153] nlme_3.1-162                jsonlite_1.8.5             
[155] viridisLite_0.4.2           fansi_1.0.4                
[157] pillar_1.9.0                lattice_0.21-8             
[159] ggrastr_1.0.2               KEGGREST_1.38.0            
[161] fastmap_1.1.1               httr_1.4.6                 
[163] survival_3.5-5              GO.db_3.16.0               
[165] glue_1.6.2                  png_0.1-8                  
[167] bit_4.0.5                   stringi_1.7.12             
[169] blob_1.2.4                  caTools_1.18.2             
[171] memoise_2.0.1               dplyr_1.1.2                
[173] irlba_2.3.5.1               future.apply_1.11.0

@timoast
Copy link
Collaborator

timoast commented Jun 28, 2023

Thanks, this should be fixed now on the develop branch

@RamRS
Copy link
Author

RamRS commented Jun 28, 2023

Thank you for the really quick response on this!

@RamRS RamRS closed this as completed Jun 28, 2023
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
Status: Q3 2023
Development

No branches or pull requests

3 participants