unlist changes the length?
1
0
Entering edit mode
Irene Li ▴ 30
@irene-li-820
Last seen 10.2 years ago
Hi bioconductor users, I am learning bioconductor by following the on-line short courses. This was what happened when I tried some code in "Differential expression" >library(annotate) >library(hgu95av2) >chr <- getCHR(geneNames(ALLSub), "hgu95av2") Error: couldn't find function "getCHR" >chr <- mget(geneNames(ALLSub), env=hgu95av2CHR) >ll <- getLL(geneNames(ALLSub), "hgu95av2") >ll.chr <- tapply(chr, ll, unique) Error in unique.default(X[[as.integer(1)]], ...) : unique() applies only to vectors >ll.chr <- tapply(unlist(chr), ll, unique) Error in tapply(unlist(chr), ll, unique) : arguments must have same length >length(chr) [1] 2400 >length(ll) [1] 2400 >length(unlist(chr)) [1] 2408 > Is this caused by a bug in "unlist" like an unaccessable link in google search said, or I have done something wrong here? how can I solve this problem? Thanks. Irene
• 2.1k views
ADD COMMENT
0
Entering edit mode
rgentleman ★ 5.5k
@rgentleman-7725
Last seen 9.6 years ago
United States
On Mon, Jul 05, 2004 at 11:49:07AM -0700, Irene Li wrote: > Hi bioconductor users, > > I am learning bioconductor by following the on-line short courses. This was > what happened when I tried some code in "Differential expression" > >library(annotate) > >library(hgu95av2) > >chr <- getCHR(geneNames(ALLSub), "hgu95av2") > Error: couldn't find function "getCHR" > >chr <- mget(geneNames(ALLSub), env=hgu95av2CHR) > >ll <- getLL(geneNames(ALLSub), "hgu95av2") > >ll.chr <- tapply(chr, ll, unique) > Error in unique.default(X[[as.integer(1)]], ...) : > unique() applies only to vectors > >ll.chr <- tapply(unlist(chr), ll, unique) > Error in tapply(unlist(chr), ll, unique) : > arguments must have same length > >length(chr) > [1] 2400 > >length(ll) > [1] 2400 > >length(unlist(chr)) > [1] 2408 > > > > Is this caused by a bug in "unlist" like an unaccessable link in google > search said, or I have done something wrong here? how can I solve this > problem? No, it is not a bug in unlist. If you have multiple values in one (or more) of the list elements then the resulting *vector* is longer. For other hash tables (those that encode GO or PubMed relationships) the effect is much more dramatic. Now, you might think that all genes are annotated to only one chromosome - but that is in fact not true. It is pretty straightforward to identify those genes with multiple annotations - and you must then make some decision about what you want to do. Best, Robert ps: > l1 = list(a=1:3, b=4:7) > unlist(l1) a1 a2 a3 b1 b2 b3 b4 1 2 3 4 5 6 7 > length(l1) [1] 2 > > Thanks. > > Irene > > _______________________________________________ > Bioconductor mailing list > Bioconductor@stat.math.ethz.ch > https://www.stat.math.ethz.ch/mailman/listinfo/bioconductor -- +--------------------------------------------------------------------- ------+ | Robert Gentleman phone : (617) 632-5250 | | Associate Professor fax: (617) 632-2444 | | Department of Biostatistics office: M1B20 | | Harvard School of Public Health email: rgentlem@jimmy.harvard.edu | +--------------------------------------------------------------------- ------+
ADD COMMENT

Login before adding your answer.

Traffic: 769 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