ZarnackGroup / BindingSiteFinder

Package for the definition of biniding sites for iCLIP data
https://www.bioconductor.org/packages/release/bioc/html/BindingSiteFinder.html
6 stars 1 forks source link

Errors related to calculateBsBackground #9

Closed jewon-yang closed 2 months ago

jewon-yang commented 4 months ago

Hi, I am trying to use calculateBsBackground() function but getting an error:

Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'i' in selecting a method for function '[': 'match' requires vector arguments

I've also tried with the example code provided in help page, but is still giving the same error. This is the code that I've used.

# load clip data
files <- system.file("extdata", package="BindingSiteFinder")
load(list.files(files, pattern = ".rda$", full.names = TRUE))

# make binding sites
bds = makeBindingSites(bds, bsSize = 7)
bds = assignToGenes(bds, anno.genes = gns)

# change meta data
m = getMeta(bds)
m$condition = factor(c("WT", "WT", "KO", "KO"), levels = c("WT", "KO"))
bds = setMeta(bds, m)

# change signal
s = getSignal(bds)
names(s$signalPlus) = paste0(m$id, "_", m$condition)
names(s$signalMinus) = paste0(m$id, "_", m$condition)
bds = setSignal(bds, s)

# make background
bds.b1 = calculateBsBackground(bds, anno.genes = gns)

I'm not sure what the problem is. The codes work perfectly fine for finding binding sites. Can you help me debugging this error?

Maybe the error could be related to the version of packages I'm using. Here is my sessionInfo, and let me know if you need any other information for fixing this error.

R version 4.3.2 (2023-10-31)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux 8.9 (Ootpa)

Matrix products: default
BLAS/LAPACK: /home/jy656/.conda/envs/BindingSiteFinder/lib/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0

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

time zone: Etc/UTC
tzcode source: system (glibc)

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

other attached packages:
 [1] viridis_0.6.5           viridisLite_0.4.2       GGally_2.2.1            ggplot2_3.4.4           dplyr_1.1.4             GenomicFeatures_1.54.1  AnnotationDbi_1.64.1    Biobase_2.62.0         
 [9] rtracklayer_1.62.0      BindingSiteFinder_2.0.0 GenomicRanges_1.54.1    GenomeInfoDb_1.38.1     IRanges_2.36.0          S4Vectors_0.40.2        BiocGenerics_0.48.1     BiocManager_1.30.22    

loaded via a namespace (and not attached):
  [1] DBI_1.2.1                   bitops_1.0-7                gridExtra_2.3               biomaRt_2.58.0              rlang_1.1.3                 magrittr_2.0.3             
  [7] clue_0.3-65                 GetoptLong_1.0.5            matrixStats_1.2.0           compiler_4.3.2              RSQLite_2.3.4               systemfonts_1.0.5          
 [13] png_0.1-8                   vctrs_0.6.5                 stringr_1.5.1               pkgconfig_2.0.3             shape_1.4.6                 crayon_1.5.2               
 [19] fastmap_1.1.1               dbplyr_2.4.0                XVector_0.42.0              utf8_1.2.4                  Rsamtools_2.18.0            rmarkdown_2.25             
 [25] purrr_1.0.2                 bit_4.0.5                   xfun_0.42                   zlibbioc_1.48.0             cachem_1.0.8                progress_1.2.3             
 [31] blob_1.2.4                  DelayedArray_0.28.0         tweenr_2.0.3                BiocParallel_1.36.0         parallel_4.3.2              prettyunits_1.2.0          
 [37] cluster_2.1.6               R6_2.5.1                    stringi_1.8.3               RColorBrewer_1.1-3          Rcpp_1.0.12                 SummarizedExperiment_1.32.0
 [43] iterators_1.0.14            knitr_1.45                  Matrix_1.6-5                tidyselect_1.2.0            rstudioapi_0.15.0           abind_1.4-5                
 [49] yaml_2.3.8                  doParallel_1.0.17           codetools_0.2-19            curl_5.1.0                  plyr_1.8.9                  lattice_0.22-5             
 [55] tibble_3.2.1                withr_3.0.0                 KEGGREST_1.42.0             evaluate_0.23               ggstats_0.5.1               polyclip_1.10-6            
 [61] BiocFileCache_2.10.1        ggdist_3.3.1                xml2_1.3.6                  circlize_0.4.16             Biostrings_2.70.1           pillar_1.9.0               
 [67] filelock_1.0.3              MatrixGenerics_1.14.0       foreach_1.5.2               distributional_0.4.0        generics_0.1.3              RCurl_1.98-1.14            
 [73] hms_1.1.3                   munsell_0.5.0               scales_1.3.0                glue_1.7.0                  tools_4.3.2                 BiocIO_1.12.0              
 [79] data.table_1.14.10          GenomicAlignments_1.38.0    XML_3.99-0.16.1             grid_4.3.2                  tidyr_1.3.1                 colorspace_2.1-0           
 [85] GenomeInfoDbData_1.2.11     ggforce_0.4.2               restfulr_0.0.15             cli_3.6.2                   rappdirs_0.3.3              kableExtra_1.4.0           
 [91] fansi_1.0.6                 S4Arrays_1.2.0              svglite_2.1.3               ComplexHeatmap_2.18.0       gtable_0.3.4                digest_0.6.34              
 [97] SparseArray_1.2.2           farver_2.1.1                rjson_0.2.21                htmlwidgets_1.6.4           memoise_2.0.1               htmltools_0.5.7            
[103] lifecycle_1.0.4             httr_1.4.7                  GlobalOptions_0.1.2         MASS_7.3-60                 bit64_4.0.5       
MirkoBr commented 4 months ago

Hi, thanks for pointing out the error. I'll be looking into it and let you know what we found as soon as possible.

MirkoBr commented 4 months ago

I looked into your error and I can't reproduce the error.

I've tested the example from the help that you've posted with your R version (4.3.2) and it works just fine.

Could you please try to setup a clean version of your environment and try to run the example again. If that does not help, then make sure that you have only packages relevant for BindingSiteFinder installed. This helps to further isolate the error.

jewon-yang commented 3 months ago

Hi, I found why the error happened during calculateBsBackground. It was a problem on my gns (gene annotation) object.

This was the function I used for making a gene annotation object. `create_gns_object <- function(file) { annoDb = GenomicFeatures::makeTxDbFromGFF(file = file, format = "gtf") annoInfo = rtracklayer::import(file, format = "gtf") gns = genes(annoDb) idx = match(gns$gene_id, annoInfo$gene_id) elementMetadata(gns) = cbind(elementMetadata(gns), elementMetadata(annoInfo)[idx,])

gns }`

Since my annotation file was a gtf format, I used a similar code but imported with format = gtf Then, I had two columns of gene_id, leading to an error in the downstream functions such as calculateBsBackground. Screenshot 2024-04-09 at 15 50 32

I fixed the problem with erasing one of the gene_id column. Then, the code worked perfectly fine after I fixed my annotation object.

Thanks for your help!

MelinaKlostermann commented 3 months ago

Perfect thanks for reporting this. We should include a specific error message for duplication of the gene_id column!