<p>I am trying to use the following function in R:</p>
<pre><code>DBR1 &lt;- readDNAStringSet(file = 'DBR1.fasta')
DBR1.string &lt;- as.character(DBR1)
RepeatMatchOutput &lt;- motif_detection(seqName = DBR1, chrs = '', start.position = NA,
                                     end.position = NA, motif = 'GAAGAA', nr.mismatch = 0,
                                     reverse.comp = F, print.status =F)
</code></pre>
<p>The error message is:</p>
<blockquote>
<p>Error in as.vector(x) : no method for coercing this S4 class to a
vector</p>
</blockquote>
<p>I must be missing something.</p>
<p>-- output of sessionInfo():</p>
<pre><code>R version 4.1.2 (2021-11-01
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

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

other attached packages:
 [1] reshape2_1.4.4                    ggplot2_3.3.5                     gquad_2.1-1                      
 [4] ape_5.6-2                         seqinr_4.2-8                      BiocManager_1.30.16              
 [7] stringr_1.4.0                     STRAH_1.0                         BSgenome.Hsapiens.UCSC.hg19_1.4.3
[10] BSgenome_1.62.0                   rtracklayer_1.54.0                GenomicRanges_1.46.1             
[13] Biostrings_2.62.0                 GenomeInfoDb_1.30.1               XVector_0.34.0                   
[16] IRanges_2.28.0                    S4Vectors_0.32.3                  BiocGenerics_0.40.0              

loaded via a namespace (and not attached):
 [1] SummarizedExperiment_1.24.0 lattice_0.20-45             colorspace_2.0-3            vctrs_0.3.8                
 [5] yaml_2.3.5                  utf8_1.2.2                  XML_3.99-0.8                rlang_1.0.2                
 [9] pillar_1.7.0                withr_2.5.0                 glue_1.6.2                  BiocParallel_1.28.3        
[13] plyr_1.8.6                  matrixStats_0.61.0          GenomeInfoDbData_1.2.7      lifecycle_1.0.1            
[17] zlibbioc_1.40.0             MatrixGenerics_1.6.0        munsell_0.5.0               gtable_0.3.0               
[21] restfulr_0.0.13             Biobase_2.54.0              parallel_4.1.2              fansi_1.0.2                
[25] Rcpp_1.0.8                  scales_1.1.1                DelayedArray_0.20.0         Rsamtools_2.10.0           
[29] rjson_0.2.21                stringi_1.7.6               BiocIO_1.4.0                grid_4.1.2                 
[33] ade4_1.7-18                 cli_3.2.0                   tools_4.1.2                 bitops_1.0-7               
[37] magrittr_2.0.2              RCurl_1.98-1.6              tibble_3.1.6                crayon_1.5.0               
[41] pkgconfig_2.0.3             MASS_7.3-54                 ellipsis_0.3.2              Matrix_1.3-4               
[45] R6_2.5.1                    GenomicAlignments_1.30.0    nlme_3.1-153                compiler_4.1.2 
<span class="math-container">```</span>
</code></pre>

CC BY-SA 4.0
2022-03-09T00:52:55.933Z
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Community
CC BY-SA 4.0
2022-04-09T23:19:58.007Z
what library does `motif_detection` come from? It looks like it might be this but hard to say from what you're doing. What type is `DBR1`? Is it what `seqName` is supposed to be? Is `chrs` the expected type?
Maximilian Press
<r>
Error in as.character.default(new("BSgenome", pkgname = "BSgenome.Hsapiens.UCSC.hg19", : no method for coercing this S4 class to a vector
# Error in as.character.default(new("BSgenome", pkgname = "BSgenome.Hsapiens.UCSC.hg19", : no method for coercing this S4 class to a vector

(Asked by: username_0 on 2022-03-09)

I am trying to use the following function in R:
DBR1 <- readDNAStringSet(file = 'DBR1.fasta')
DBR1.string <- as.character(DBR1)
RepeatMatchOutput <- motif_detection(seqName = DBR1, chrs = '', start.position = NA,
                                     end.position = NA, motif = 'GAAGAA', nr.mismatch = 0,
                                     reverse.comp = F, print.status =F)

The error message is:

Error in as.vector(x) : no method for coercing this S4 class to a
vector

I must be missing something.
-- output of sessionInfo():
R version 4.1.2 (2021-11-01
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

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

other attached packages:
 [1] reshape2_1.4.4                    ggplot2_3.3.5                     gquad_2.1-1                      
 [4] ape_5.6-2                         seqinr_4.2-8                      BiocManager_1.30.16              
 [7] stringr_1.4.0                     STRAH_1.0                         BSgenome.Hsapiens.UCSC.hg19_1.4.3
[10] BSgenome_1.62.0                   rtracklayer_1.54.0                GenomicRanges_1.46.1             
[13] Biostrings_2.62.0                 GenomeInfoDb_1.30.1               XVector_0.34.0                   
[16] IRanges_2.28.0                    S4Vectors_0.32.3                  BiocGenerics_0.40.0              

loaded via a namespace (and not attached):
 [1] SummarizedExperiment_1.24.0 lattice_0.20-45             colorspace_2.0-3            vctrs_0.3.8                
 [5] yaml_2.3.5                  utf8_1.2.2                  XML_3.99-0.8                rlang_1.0.2                
 [9] pillar_1.7.0                withr_2.5.0                 glue_1.6.2                  BiocParallel_1.28.3        
[13] plyr_1.8.6                  matrixStats_0.61.0          GenomeInfoDbData_1.2.7      lifecycle_1.0.1            
[17] zlibbioc_1.40.0             MatrixGenerics_1.6.0        munsell_0.5.0               gtable_0.3.0               
[21] restfulr_0.0.13             Biobase_2.54.0              parallel_4.1.2              fansi_1.0.2                
[25] Rcpp_1.0.8                  scales_1.1.1                DelayedArray_0.20.0         Rsamtools_2.10.0           
[29] rjson_0.2.21                stringi_1.7.6               BiocIO_1.4.0                grid_4.1.2                 
[33] ade4_1.7-18                 cli_3.2.0                   tools_4.1.2                 bitops_1.0-7               
[37] magrittr_2.0.2              RCurl_1.98-1.6              tibble_3.1.6                crayon_1.5.0               
[41] pkgconfig_2.0.3             MASS_7.3-54                 ellipsis_0.3.2              Matrix_1.3-4               
[45] R6_2.5.1                    GenomicAlignments_1.30.0    nlme_3.1-153                compiler_4.1.2 
```

**Tags:** r
> **Comments:**
> **username_1**: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.  
> **username_2**: what library does `motif_detection` come from? It looks like it might be this but hard to say from what you're doing. What type is `DBR1`? Is it what `seqName` is supposed to be? Is `chrs` the expected type?  

---

## 0 answers

