[BioC] an apparently strange case of 'Warning: number of items to replace is not a multiple of replacement length'

James W. MacDonald jmacdon at med.umich.edu
Mon Oct 19 15:13:06 CEST 2009


Hi Massimo,

Massimo Pinto wrote:
> Greetings,
> 
> I have encountered a series of warning messages when copying indices
> into a vector of integers. Specifically:
> 
>> Geni_GO_0033554_CM3.ctr3 <- as.integer(unlist(geneIdsByCategory(hgOver.6, "GO:0033554"), use.names = FALSE))
> 
> [1] 100133315     10714      1112     11198      1643      2237
> 26057     27113      4913     50484      5429     57697      5796
> 5885      7516      8445
> 
>> myrows<- integer(length=length(Geni_GO_0033554_CM3.ctr3))
> + for (i in 0:length(Geni_GO_0033554_CM3.ctr3)) {
> + myrows[i] <- which(Age_LNGSVsISS.topTable.2k[,
> "mappings.Sub.ENTREZID"] == Geni_GO_0033554_CM3.ctr3[i])
> + }
> 
> Warning messages:
> 1: In myrows[i] <- which(Age_LNGSVsISS.topTable.2k[,
> "mappings.Sub.ENTREZID"] ==  :
>   number of items to replace is not a multiple of replacement length
> 2: In myrows[i] <- which(Age_LNGSVsISS.topTable.2k[,
> "mappings.Sub.ENTREZID"] ==  :
>   number of items to replace is not a multiple of replacement length
> 3: In myrows[i] <- which(Age_LNGSVsISS.topTable.2k[,
> "mappings.Sub.ENTREZID"] ==  :
>   number of items to replace is not a multiple of replacement length
> 4: In myrows[i] <- which(Age_LNGSVsISS.topTable.2k[,
> "mappings.Sub.ENTREZID"] ==  :
>   number of items to replace is not a multiple of replacement length

This is because at least 4 of the Entrez Gene IDs appear more than once 
in the vector Age_LNGSVsISS.topTable.2k[,"mappings.Sub.ENTREZID"]. When 
you use the which() function on a vector for which the equality is true 
more than once you will get a vector:

 > which(rep(3,3) == 3)
[1] 1 2 3

And you cannot put a vector into a single position of another vector:

 > a <- 1:10
 > a[1] <- 1:3
Warning message:
In a[1] <- 1:3 :
   number of items to replace is not a multiple of replacement length

Best,

Jim


> 
> I have looked into a former discussion on this list
> http://tolstoy.newcastle.edu.au/R/help/04/09/4534.html
> but could not find the reason for getting an error in my case.
> 
> Apparently, I am not missing any item of those that I wish to copy;
> still, I am getting a warning and would prefer to clarify this matter.
> 
> Thank you all in advance,
> Massimo
> 
> sessionInfo follows:
> 
>> sessionInfo()
> R version 2.9.1 (2009-06-26)
> i386-apple-darwin8.11.1
> 
> locale:
> C
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
> 
> other attached packages:
>  [1] GO.db_2.2.11        hgug4112a.db_2.2.11 limma_2.18.0
> GOstats_2.10.0      RSQLite_0.7-1       DBI_0.2-4
> graph_1.22.2        Category_2.10.0
>  [9] AnnotationDbi_1.6.0 Biobase_2.4.1
> 
> loaded via a namespace (and not attached):
> [1] GSEABase_1.6.0    RBGL_1.20.0       XML_2.3-0
> annotate_1.22.0   genefilter_1.24.0 splines_2.9.1     survival_2.35-4
>  tools_2.9.1       xtable_1.5-5
> 
> 
> Massimo Pinto
> Post Doctoral Research Fellow
> Enrico Fermi Centre and Italian Public Health Research Institute (ISS), Rome
> http://claimid.com/massimopinto
> 
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor

-- 
James W. MacDonald, M.S.
Biostatistician
Douglas Lab
University of Michigan
Department of Human Genetics
5912 Buhl
1241 E. Catherine St.
Ann Arbor MI 48109-5618
734-615-7826



More information about the Bioconductor mailing list