could not find symbol "keepNA" in environment of the generic function
3
2
Entering edit mode
Assa Yeroslaviz ★ 1.5k
@assa-yeroslaviz-1597
Last seen 17 days ago
Germany

Hi,

i am trying to count bam files on a specific bed file with the following script. Unfortunately, the same snippet, which worked good a only last week, is not running any more.

I keep getting error messages like the one mentioned above, but interestingly only when I call the object, not when I am running the command. When I run this snippet:

chromLength <- seqinfo(Scerevisiae)

# create the Granges obejct with 500 bases width windows
bins1 <- tileGenome(seqinfo(Scerevisiae), tilewidth=500, cut.last.tile.in.chrom=TRUE)
seqlevelsStyle(bins1)

seqlevelsStyle(bins1) <- "NCBI"
# read the bam files into R
Rad51 <- readGAlignments("1.Ensembl.sorted.bam")
In <- readGAlignments("2.Ensembl.sorted.bam")
seqlevelsStyle(In)


it doesn't show any error/warnings

but when I try to call the objects:

> chromLength
Seqinfo object with 17 sequences (1 circular) from sacCer3 genome:
Error in nchar(rownames.label) :
  could not find symbol "keepNA" in environment of the generic function
> Rad51
GAlignments object with 2057068 alignments and 0 metadata columns:
Error in nchar(x, type = "width") :
  could not find symbol "keepNA" in environment of the generic function
> In
GAlignments object with 2099495 alignments and 0 metadata columns:
Error in nchar(x, type = "width") :
  could not find symbol "keepNA" in environment of the generic function

What is happening here?

another problem occurs when I try to run summarizeOverlaps and count the reads on specific regions in a bed file

bamFiles <- list.files(path = "~/Projects/Claudio_ChIPSeq/", pattern = ".bam$", full.names = TRUE)

> bins1
GRanges object with 24322 ranges and 0 metadata columns:
          seqnames         ranges strand
             <Rle>      <IRanges>  <Rle>
      [1]        I   [   1,  500]      *
      [2]        I   [ 501, 1000]      *
      [3]        I   [1001, 1500]      *
      [4]        I   [1501, 2000]      *
      [5]        I   [2001, 2500]      *
      ...      ...            ...    ...
  [24318]       MT [83501, 84000]      *
  [24319]       MT [84001, 84500]      *
  [24320]       MT [84501, 85000]      *
  [24321]       MT [85001, 85500]      *
  [24322]       MT [85501, 85779]      *
  -------
  seqinfo: 17 sequences (1 circular) from sacCer3 genome
> bamFiles
[1] "/Users/ayeroslaviz/Projects/Claudio_ChIPSeq/In.Ensembl.sorted.bam"   
[2] "/Users/ayeroslaviz/Projects/Claudio_ChIPSeq/Rad51.Ensembl.sorted.bam"

but than:

> olapTable <- summarizeOverlaps(bins1, bamFiles, inter.feature=FALSE)
Error in SummarizedExperiment(assays = SimpleList(counts = counts), rowRanges = features,  :
  error in evaluating the argument 'assays' in selecting a method for function 'SummarizedExperiment': Error in validObject(.Object) :
  invalid class “SimpleList” object: invalid object for slot "listData" in class "SimpleList": got class "matrix", should be or extend class "list"

thanks

Assa

 

> sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.3 (Yosemite)

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    parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] csaw_1.2.1                              BSgenome.Scerevisiae.UCSC.sacCer3_1.4.0
 [3] BSgenome_1.36.1                         rtracklayer_1.28.5                     
 [5] GenomicAlignments_1.4.1                 Rsamtools_1.20.4                       
 [7] Biostrings_2.36.1                       XVector_0.8.0                          
 [9] GenomicRanges_1.20.5                    GenomeInfoDb_1.4.1                     
[11] IRanges_2.2.5                           S4Vectors_0.6.1                        
[13] BiocGenerics_0.14.0                    

loaded via a namespace (and not attached):
 [1] AnnotationDbi_1.30.1   edgeR_3.10.2           zlibbioc_1.14.0        BiocParallel_1.2.6    
 [5] tools_3.2.0            Biobase_2.28.0         DBI_0.3.1              lambda.r_1.1.7        
 [9] futile.logger_1.4.1    futile.options_1.0.0   bitops_1.0-6           biomaRt_2.24.0        
[13] RCurl_1.95-4.7         RSQLite_1.0.0          limma_3.24.12          GenomicFeatures_1.20.1
[17] XML_3.98-1.3         

> RStudio.Version()
$citation

To cite RStudio in publications use:

  RStudio Team (2015). RStudio: Integrated Development for R. RStudio, Inc., Boston, MA URL
  http://www.rstudio.com/.

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {RStudio: Integrated Development Environment for R},
    author = {{RStudio Team}},
    organization = {RStudio, Inc.},
    address = {Boston, MA},
    year = {2015},
    url = {http://www.rstudio.com/},
  }


$mode
[1] "desktop"

$version
[1] ‘0.99.447’

 

R function genomicalignments genomicranges summarizeoverlaps • 6.3k views
ADD COMMENT
0
Entering edit mode

I have checked it on a different version of R and Rstudio and it works perfectly.

the working version:

> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)

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    parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] BiocParallel_1.0.3                      BSgenome.Scerevisiae.UCSC.sacCer3_1.4.0 BSgenome_1.34.1                        
 [4] rtracklayer_1.26.3                      BiocInstaller_1.16.5                    edgeR_3.8.6                            
 [7] limma_3.22.7                            GenomicAlignments_1.2.2                 Rsamtools_1.18.3                       
[10] Biostrings_2.34.1                       XVector_0.6.0                           GenomicRanges_1.18.4                   
[13] GenomeInfoDb_1.2.5                      IRanges_2.0.1                           S4Vectors_0.4.0                        
[16] BiocGenerics_0.12.1                    

loaded via a namespace (and not attached):
 [1] base64enc_0.1-2  BatchJobs_1.6    BBmisc_1.9       bitops_1.0-6     brew_1.0-6       checkmate_1.5.2  codetools_0.2-11
 [8] DBI_0.3.1        digest_0.6.8     fail_1.2         foreach_1.4.2    iterators_1.0.7  RCurl_1.95-4.5   RSQLite_1.0.0   
[15] sendmailR_1.2-1  stringr_0.6.2    tools_3.1.1      XML_3.98-1.1     zlibbioc_1.12.0

on RStudio Version 0.98.1091

ADD REPLY
6
Entering edit mode
Assa Yeroslaviz ★ 1.5k
@assa-yeroslaviz-1597
Last seen 17 days ago
Germany

solved!

There were some inconsistencies between the new packages and the R base version.

I have updated R to 3.2.1 and now it works again.

ADD COMMENT
0
Entering edit mode

I looked into this a bit. Under R-3.2.0, Bioconductor 3.1 and up-to-date packages, a simple way to reproduce this is

> library(IRanges)
Warning message:
package ‘IRanges’ was built under R version 3.2.1 
> nchar("foo")
Error in nchar("foo") : 
  could not find symbol "keepNA" in environment of the generic function

As mentioned, updating to R-3.2.1 solves the problem. Another workaround is the following

> setMethod("nchar", "ANY", base::nchar)
[1] "nchar"
> nchar("foo")
[1] 3

The technical details are that the 'keepNA' argument was added to the nchar() function in R version 3.2.1. S4Vectors and IRanges 'promote' nchar() to an S4 generic, and in the process create a default nchar,ANY-method. Bioconductor 3.1 packages are build under R-3.2.1, and binary packages (like those distributed for Mac and Windows) capture the S4 method as part of the package. The end result is that the generic and method have different signatures

> nchar
standardGeneric for "nchar" defined from package "base"

function (x, type = "chars", allowNA = FALSE) 
standardGeneric("nchar")
<environment: 0x0000000045c13868>
Methods may be defined for arguments: x, type, allowNA
Use  showMethods("nchar")  for currently available ones.
> selectMethod("nchar", "ANY")
Method Definition (Class "derivedDefaultMethod"):

function (x, type = "chars", allowNA = FALSE, keepNA = FALSE) 
.Internal(nchar(x, type, allowNA, keepNA))
<bytecode: 0x0000000015dc7018>
<environment: namespace:base>

Signatures:
        x    
target  "ANY"
defined "ANY"

In particular the method has the symbol keepNA, whereas the generic does not. It is this mismatch that causes the error.

This can be addressed using S4Vectors 0.6.2 on R.3.2.0 (via biocLite()), or by updating to a more recent R.

ADD REPLY
0
Entering edit mode
@reedssorenson-8325
Last seen 7.3 years ago
United States

I encountered the same error message when I used a script that worked well on one computer and not on a second. Similar to your problem The problem computer is using Biostrings 2.36.1, and the one that works is using Biostrings 2.34.1.

In my case, I got the error when using the function: readDNAStringSet() to read in a fasta file. I'm trying to figure out how to roll back the Biostrings package version to see if this will help. 

Reed

 

ADD COMMENT
0
Entering edit mode
Mathilde • 0
@mathilde-8405
Last seen 3.8 years ago
Denmark/Germany

Hi,

I am new in R and I get a similar error:

Error in nchar(x, type = "bytes") : 
  could not find symbol "keepNA" in environment of the generic function

When I try to follow the guideline scipt here: 

http://rstudio-pubs-static.s3.amazonaws.com/12097_1352791b169f423f910d93222a4c2d85.html

I tried to install an older version of the package, but this was not possible, error:

Warning message:
package ‘Biostrings_2.30.1’ is not available (for R version 3.2.0) 

I really would like to get this command to work, I haven't been able to find another (updated) R-script on the web, so if anyone knows what I need to do, I will be very happy to hear from you.

Best wishes,

Mathilde

 

 

ADD COMMENT
0
Entering edit mode

You should try and write more about what you're doing.

Where do you encounter the error, what function ?

What is your sessionInfo()?

try to update to the latest R version. than update also the packages. This is basically what I did and it solved the problem.

ADD REPLY
0
Entering edit mode

Thank you for replying :)

So I fixed my first problem by updating R (thought I had done that, but turned out I hadn't).

Now a new problem arises - same function.

What I am trying to do is the BLAST my DNA seq via R using the package "Biostring" and this function here (by K. Keenan): http://rstudio-pubs-static.s3.amazonaws.com/12097_1352791b169f423f910d93222a4c2d85.html

my sessionInfo() is this:
R version 3.2.1 (2015-06-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

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

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

other attached packages:
[1] Biostrings_2.36.1    XVector_0.8.0        IRanges_2.2.5       
[4] S4Vectors_0.6.1      BiocGenerics_0.14.0  XML_3.98-1.3        
[7] seqinr_3.1-3         ade4_1.7-2           BiocInstaller_1.18.3

loaded via a namespace (and not attached):
[1] zlibbioc_1.14.0 tools_3.2.1  

The error I get is this:

res <- lapply(mySeq, function(x){
+   # collapse seq into string
+   seqCollapse <- paste(toupper(as.character(x)), collapse = "")
+   # run blast
+   blastRes <- blastSeqKK(x = seqCollapse, database = "nr", hitListSize = 2,
+                          attempts = 5)
+   return(blastRes)
+ })

Error in .tryParseResult(url1, attempts) : 
  no results after 5 attempts; please try again later

 

Any suggestions on what is wrong?

Thanks a lot,

Mathilde

 

ADD REPLY
0
Entering edit mode

this is from the site you're working with:

"The blastSequences function appears to work well in most instances. For slow web connections or for large query sequences, it appears to fail. This seem to be due to either a low number of attempts to retrieve hits from the ncbi server, or the short time the routine waits before it throws an error in R. It seem that if we increase the number of attempts to retrieve hits, generally, we can successfully run our BLAST."

Can you try the same process, but also with 20 attempts,as they show in the example?

This doesn't seem to be an R problem.

 

ADD REPLY
0
Entering edit mode

So sorry I didn't see that myself! - Thanks again for replying

I will try, however I did already try with 20 attempts but put it down to 5 - to make it faster as I was trying different changes to make it work. I will put the number of attempts up instead :) 

ADD REPLY

Login before adding your answer.

Traffic: 930 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6