[BioC] no method for coercing this S4 class to a vector
Martin Morgan
mtmorgan at fhcrc.org
Mon Mar 11 14:54:33 CET 2013
On 03/11/2013 06:43 AM, Thiago Maia wrote:
> Ops... sorry I just found (after many hours), it was so simple, how could take
> that long.. heheh
>
> nchar(as.character(seq2[i]))
I do not think you've identified your problem correctly; please provide a
reproducible example -- what is 'l' ? For instance, after
library(Biostrings)
example(readDNAStringSet)
I can
> seq2 = readDNAStringSet(filepath, format="fastq")
> fn1 = function(N) nchar(seq2[l])
> l = 2
> fn1(l)
[1] 36
(but the function doesn't make much sense, usually the body of the function
references arguments passed in to it). This is with
> sessionInfo()
R version 2.15.2 Patched (2012-12-23 r61401)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] 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
[7] LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] BSgenome.Celegans.UCSC.ce2_1.3.19 BSgenome_1.26.1
[3] GenomicRanges_1.10.7 Biostrings_2.26.3
[5] IRanges_1.16.6 BiocGenerics_0.4.0
[7] BiocInstaller_1.8.3
loaded via a namespace (and not attached):
[1] parallel_2.15.2 stats4_2.15.2 tools_2.15.2
Martin
>
> thanks
>
> Thiago Maia
>> Hello
>>
>> - Sorry if this message appear twice, before I sent from the wrong
>> e-mail address(not registered)
>>
>> I trying to make a function in R but I couldnt figure out whats
>> happening.
>>
>> I loadded a fasta file.
>> seq2 <- readDNAStringSet("c:/teste/testfile.txt","fasta")
>>
>> I would like to get the length.
>> If I execute directly all works
>>
>> > nchar(seq2[1])
>> Test_4489
>> 90
>>
>> But if I create a function
>> function (N) {
>> nchar(seq2[1])
>> }
>>
>> when I execute
>> > fn1(1)
>> Error in nchar(seq2[1]) :
>> no method for coercing this S4 class to a vector
>>
>> I tried things like as.vector(nchar(seq2[1])) but got the same
>> message.
>>
>> Does anybody have a suggestion what I have to do or read.
>>
>> thanks a lot
>>
>> Thiago Maia
>>
>>
>> --
>>
>> _______________________________________________
>> Bioconductor mailing list
>> Bioconductor at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>> Search the archives:
>> http://news.gmane.org/gmane.science.biology.informatics.conductor
>
>
> --
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M1 B861
Phone: (206) 667-2793
More information about the Bioconductor
mailing list