as.numeric and NA
3
0
Entering edit mode
@mohammad-esad-djou-1159
Last seen 10.2 years ago
Hello, I would like to use for 42 experiments "as.numeric" (objects of type '"numeric"') I wrote in such a way: > library(affy) > data.raw <- ReadAffy(filenames= "./R/ME_cel/Expt1_R1.CEL", ... "./R/ME_cel/Expt14_R3.CEL") > as.numeric(sampleNames(data.raw)) [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA Warning message: NAs introduced by coercion How can I find correctly numeric values of data.raw? Thanks, Mohammad Esad-Djou
• 4.6k views
ADD COMMENT
0
Entering edit mode
@wolfgang-huber-3550
Last seen 3 months ago
EMBL European Molecular Biology Laborat…
Mohammad, have you tried exprs(data.raw) or intensity(data.raw) Also, please consider that the software is written by and the mailing list discussions are provided by volunteers. So before posting such a question, please consider reading the vignette of the affy package first, and perhaps a manual of the R language. Best wishes Wolfgang Mohammad Esad-Djou wrote: > Hello, > > I would like to use for 42 experiments "as.numeric" (objects of type '"numeric"') > I wrote in such a way: > > >>library(affy) >>data.raw <- ReadAffy(filenames= "./R/ME_cel/Expt1_R1.CEL", > > ... "./R/ME_cel/Expt14_R3.CEL") > > >>as.numeric(sampleNames(data.raw)) > > [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA > [26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA > Warning message: > NAs introduced by coercion > > > How can I find correctly numeric values of data.raw? > > Thanks, > Mohammad Esad-Djou > > Best regards Wolfgang ------------------------------------- Wolfgang Huber European Bioinformatics Institute European Molecular Biology Laboratory Cambridge CB10 1SD England Phone: +44 1223 494642 Fax: +44 1223 494486 Http: www.ebi.ac.uk/huber
ADD COMMENT
0
Entering edit mode
@mohammad-esad-djou-1159
Last seen 10.2 years ago
Thank you for your answer. > have you tried > > exprs(data.raw) or > intensity(data.raw) > Yes, I already tried exprs(data.raw). Unfortunately does not help me. I simplified my question, so that it can be answered concretely. I will read again R manual. best Regards, Mohammad Wolfgang Huber <huber@ebi.ac.uk> schrieb am 30.05.05 13:18:38: > > Mohammad, > > Also, please consider that the software is written by and the mailing > list discussions are provided by volunteers. So before posting such a > question, please consider reading the vignette of the affy package > first, and perhaps a manual of the R language. > > Best wishes > Wolfgang > > Mohammad Esad-Djou wrote: > > Hello, > > > > I would like to use for 42 experiments "as.numeric" (objects of type '"numeric"') > > I wrote in such a way: > > > > > >>library(affy) > >>data.raw <- ReadAffy(filenames= "./R/ME_cel/Expt1_R1.CEL", > > > > ... "./R/ME_cel/Expt14_R3.CEL") > > > > > >>as.numeric(sampleNames(data.raw)) > > > > [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA > > [26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA > > Warning message: > > NAs introduced by coercion > > > > > > How can I find correctly numeric values of data.raw? > > > > Thanks, > > Mohammad Esad-Djou > > > > > > > Best regards > Wolfgang > > ------------------------------------- > Wolfgang Huber > European Bioinformatics Institute > European Molecular Biology Laboratory > Cambridge CB10 1SD > England > Phone: +44 1223 494642 > Fax: +44 1223 494486 > Http: www.ebi.ac.uk/huber > -------------------------------------
ADD COMMENT
0
Entering edit mode
What Wolfgang is implying is that it is a rather strange thing you want to do. Your command was as.numeric(sampleNames(data.raw)) with data.raw an AffyBatch object. Now, sampleNames(data.raw) will return you a vector of sampleNames, which is a character vector with names associated with each sample. I believe the default is to put the filenames there. So the command sampleNames(data.raw) should return a vector of filesnames. It is not at all clear how these filenames should be converted to numbers. Compare > as.numeric(c("1","2","3")) [1] 1 2 3 > as.numeric(c("a","b","c")) [1] NA NA NA Warning message: NAs introduced by coercion Kasper On Mon, May 30, 2005 at 01:47:49PM +0200, Mohammad Esad-Djou wrote: > Thank you for your answer. > > > have you tried > > > > exprs(data.raw) or > > intensity(data.raw) > > > Yes, I already tried exprs(data.raw). > Unfortunately does not help me. I simplified my question, so that it can be answered concretely. > I will read again R manual. > > best Regards, > Mohammad > > > > Wolfgang Huber <huber@ebi.ac.uk> schrieb am 30.05.05 13:18:38: > > > > Mohammad, > > > > Also, please consider that the software is written by and the mailing > > list discussions are provided by volunteers. So before posting such a > > question, please consider reading the vignette of the affy package > > first, and perhaps a manual of the R language. > > > > Best wishes > > Wolfgang > > > > Mohammad Esad-Djou wrote: > > > Hello, > > > > > > I would like to use for 42 experiments "as.numeric" (objects of type '"numeric"') > > > I wrote in such a way: > > > > > > > > >>library(affy) > > >>data.raw <- ReadAffy(filenames= "./R/ME_cel/Expt1_R1.CEL", > > > > > > ... "./R/ME_cel/Expt14_R3.CEL") > > > > > > > > >>as.numeric(sampleNames(data.raw)) > > > > > > [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA > > > [26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA > > > Warning message: > > > NAs introduced by coercion > > > > > > > > > How can I find correctly numeric values of data.raw? > > > > > > Thanks, > > > Mohammad Esad-Djou > > > > > > > > > > > > Best regards > > Wolfgang > > > > ------------------------------------- > > Wolfgang Huber > > European Bioinformatics Institute > > European Molecular Biology Laboratory > > Cambridge CB10 1SD > > England > > Phone: +44 1223 494642 > > Fax: +44 1223 494486 > > Http: www.ebi.ac.uk/huber > > ------------------------------------- > > _______________________________________________ > Bioconductor mailing list > Bioconductor@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor -- Kasper Daniel Hansen, Research Assistant Department of Biostatistics, University of Copenhagen
ADD REPLY
0
Entering edit mode
@adaikalavan-ramasamy-675
Last seen 10.2 years ago
See comments below. On Mon, 2005-05-30 at 13:08 +0200, Mohammad Esad-Djou wrote: > Hello, > > I would like to use for 42 experiments "as.numeric" (objects of type '"numeric"') > I wrote in such a way: > > > library(affy) > > data.raw <- ReadAffy(filenames= "./R/ME_cel/Expt1_R1.CEL", > ... "./R/ME_cel/Expt14_R3.CEL") Can you try to use the following instead please raw <- ReadAffy( filenames=c("Expt1_R1.CEL", "Expt14_R3.CEL"), celfile.path="./R/ME_cel/" ) I am aware that you do not need the "c" for ReadAffy() to work but it is conventional with R when quote it as an array. > > as.numeric(sampleNames(data.raw)) > [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA > [26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA > Warning message: > NAs introduced by coercion As the warning says and as demonstrated by Kasper, the NA's you get is from coercion of string characters. > How can I find correctly numeric values of data.raw? It would have helped if you shown the output of sampleNames(data.raw) or what you mean by numeric values. Assuming you want to extract the value of "14" from Expt14_R3.CEL, try cn <- c("Expt1_R1.CEL", "Expt14_R3.CEL") # replace this with cn <- sampleNames(data.raw) tmp <- strsplit( cn, split="_" ) tmp <- sapply( cn, function(x) unlist(strsplit(x, split="_"))[[1]] ) gsub("Expt", "", tmp) [1] "1" "14" as.numeric( gsub("Expt", "", tmp) ) [1] 1 14 If I assume that you want to extract "3" from Expt14_R3.CEL, try instead tmp <- strsplit( cn, split="_" ) tmp <- sapply( cn, function(x) unlist(strsplit(x, split="_"))[[2]] ) as.numeric( gsub( "R", "", gsub(".CEL", "", tmp) ) ) Next time, please learn to ask the question more clearly (with example of the desired output) to avoid the rest of guessing (e.g. what do you mean by "correctly finding numeric values"). > Thanks, > Mohammad Esad-Djou > > _______________________________________________ > Bioconductor mailing list > Bioconductor@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor >
ADD COMMENT

Login before adding your answer.

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