Urmi Trivedi
2007-Aug-07 13:33 UTC
[R] Error in as.double.default(x) : (list) object cannot be coerced to 'double'
Dear experts, I have in all 14 matrices which stands for gene expression divergence and 14 matrices which stands for gene sequence divergence. I have tried joining them by using the concatanation function giving SequenceDivergence <- c(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,X13,X14) ExpressionDivergence <- c(Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8,Y9,Y10,Y11,Y12,Y13,Y14) where X1,X2..X14 are the expression matrices containing r-values and Y1,Y2..Y14 are the ones with patristic distances Now, I want to plot SequenceDivergence vs. Expression Divergence Tried doing that using plot (Sequence Divergence vs. Expression Divergence) But then getting the error Error in as.double.default(x) : (list) object cannot be coerced to 'double' Note: The diagonal values for X1 was neglected as its seems to give some bias in my results. Code to derive X1,X2,X3..and Y1,Y2,Y3 is given as:> EDant <- read.table("C:/ant.txt",sep="\t") > ED1 <- as.matrix(EDant) > X1 <- lapply(1:ncol(ED15), function(a) ED15[-a, a]) # to neglect diagonal valuesI am attaching couple of matrices for your reference. ANT.txt is X1 after deleting the diagnol values, similarly,ANTEXP.TXT is Y1, apetella.txt is X2 and apetellaexp.txt is Y2 I tried reading R-manual and other sources but have'nt cracked it yet. Can anyone please help me regarding that? Thanks very much Yours sincerely, Urmi Trivedi. --------------------------------- Once upon a time there was 1 GB storage in your inbox. Click here for happy ending. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ANT.txt Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070807/a3c5cb84/attachment.txt -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ANTEXP.txt Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070807/a3c5cb84/attachment-0001.txt -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: apetella.txt Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070807/a3c5cb84/attachment-0002.txt -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: apetellaexp.txt Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070807/a3c5cb84/attachment-0003.txt
Petr PIKAL
2007-Aug-08 09:54 UTC
[R] Odp: Error in as.double.default(x) : (list) object cannot be coerced to 'double'
Hi Far from beeing an expert I can decide from your post that you probably mix R objects matrix x data frame x list. All of them have specific features and you sometimes cannot convert one to another easily. See what your objects are and how they look like by e.g. str(X1) or mode or typeof I suspect that your X are lists and using c(some lists) result again into list. Plot expect x and y values usually as vectors but there are plot methods for other objects (data.frames, functions, ...) Best starting point would be help page for plot. Regards Petr r-help-bounces at stat.math.ethz.ch napsal dne 07.08.2007 15:33:41:> Dear experts, > > I have in all 14 matrices which stands for gene expression divergenceand 14> matrices which stands for gene sequence divergence. I have tried joiningthem> by using the concatanation function giving > > SequenceDivergence <- c(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,X13,X14) > ExpressionDivergence <-c(Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8,Y9,Y10,Y11,Y12,Y13,Y14)> > where X1,X2..X14 are the expression matrices containing r-values and > Y1,Y2..Y14 are the ones with patristic distances > > Now, I want to plot SequenceDivergence vs. Expression Divergence > > Tried doing that using plot (Sequence Divergence vs. ExpressionDivergence)> > But then getting the error > > Error in as.double.default(x) : (list) object cannot be coerced to'double'> > Note: The diagonal values for X1 was neglected as its seems to give somebias> in my results. Code to derive X1,X2,X3..and Y1,Y2,Y3 is given as: > > > EDant <- read.table("C:/ant.txt",sep="\t") > > ED1 <- as.matrix(EDant) > > X1 <- lapply(1:ncol(ED15), function(a) ED15[-a, a]) # to neglectdiagonal values> > I am attaching couple of matrices for your reference. ANT.txt is X1after> deleting the diagnol values, similarly,ANTEXP.TXT is Y1, apetella.txtis X2 and> apetellaexp.txt is Y2 > > I tried reading R-manual and other sources but have'nt cracked it yet.Can> anyone please help me regarding that? > > Thanks very much > > Yours sincerely, > > Urmi Trivedi. > > > > --------------------------------- > Once upon a time there was 1 GB storage in your inbox. Click here forhappy> ending.0 1.21133 1.420221 1.499358 1.475149 1.513886 1.6088161.> 675916 1.859038 1.992958 2.420123 2.309414 2.413222 > 1.21133 0 1.463585 1.542722 1.518513 1.55725 1.65218 1.71928> 1.902402 2.036322 2.463487 2.352778 2.456586 > 1.420221 1.463585 0 1.418619 1.39441 1.433147 1.5280771.595177> 1.778299 1.912219 2.339384 2.228675 2.332483 > 1.499358 1.542722 1.418619 0 0.931235 0.969972 1.3544981.421598> 1.60472 1.73864 2.165805 2.055096 2.158904 > 1.475149 1.518513 1.39441 0.931235 0 0.206013 1.3302891.397389> 1.580511 1.714431 2.141596 2.030887 2.134695 > 1.513886 1.55725 1.433147 0.969972 0.206013 0 1.3690261.436126> 1.619248 1.753168 2.180333 2.069624 2.173432 > 1.608816 1.65218 1.528077 1.354498 1.330289 1.369026 00.604972> 1.537696 1.671616 2.098781 1.988072 2.09188 > 1.675916 1.71928 1.595177 1.421598 1.397389 1.436126 0.6049720> 1.604796 1.738716 2.165881 2.055172 2.15898 > 1.859038 1.902402 1.778299 1.60472 1.580511 1.619248 1.5376961.> 604796 0 1.09121 1.968427 1.857718 1.961526 > 1.992958 2.036322 1.912219 1.73864 1.714431 1.753168 1.6716161.> 738716 1.09121 0 2.102347 1.991638 2.095446 > 2.420123 2.463487 2.339384 2.165805 2.141596 2.180333 2.098781> 2.165881 1.968427 2.102347 0 1.128701 1.232509 > 2.309414 2.352778 2.228675 2.055096 2.030887 2.069624 1.988072> 2.055172 1.857718 1.991638 1.128701 0 0.91546 > 2.413222 2.456586 2.332483 2.158904 2.134695 2.173432 2.091882.> 15898 1.961526 2.095446 1.232509 0.91546 0 > 1 -0.046373 -0.033044 0.003902 0.466827 0.389327 0.131989-0.> 063346 -0.118093 0.016386 -0.140215 0.34511 0.233074 > -0.046373 1 0.000717 0.832227 0.077053 -0.106815 -0.0508380.> 936431 0.297387 0.031358 -0.127265 0.31245 -0.053169 > -0.033044 0.000717 1 0.011265 -0.018602 -0.023669 -0.028744-0.> 007588 0.148827 -0.007067 0.005362 -0.029172 -0.017367 > 0.003902 0.832227 0.011265 1 0.071247 -0.101225 0.097117 0. > 829167 0.294396 0.017809 -0.129199 0.278831 -0.106427 > 0.466827 0.077053 -0.018602 0.071247 1 0.078241 0.140679 0. > 070069 0.055744 0.013194 -0.196092 -0.027692 0.028857 > 0.389327 -0.106815 -0.023669 -0.101225 0.078241 1 0.140146-0.> 086806 0.079 0.194904 0.068378 0.213288 0.194006 > 0.131989 -0.050838 -0.028744 0.097117 0.140679 0.140146 1-0.> 075079 0.137652 0.065127 -0.072768 -0.120751 -0.101777 > -0.063346 0.936431 -0.007588 0.829167 0.070069 -0.086806-0.075079> 1 0.312154 0.023108 -0.122502 0.331402 -0.042298 > -0.118093 0.297387 0.148827 0.294396 0.055744 0.079 0.1376520.> 312154 1 0.300515 -0.178301 0.033663 -0.057139 > 0.016386 0.031358 -0.007067 0.017809 0.013194 0.1949040.065127> 0.023108 0.300515 1 -0.096451 0.033663 -0.039394 > -0.140215 -0.127265 0.005362 -0.129199 -0.196092 0.068378 -0. > 072768 -0.122502 -0.178301 -0.096451 1 -0.01748 0.253667 > 0.34511 0.31245 -0.029172 0.278831 -0.027692 0.213288-0.120751> 0.331402 0.033663 0.033663 -0.01748 1 0.201202 > 0.233074 -0.053169 -0.017367 -0.106427 0.028857 0.194006-0.101777> -0.042298 -0.057139 -0.039394 0.253667 0.201202 1 > 0 1.936157 2.266211 3.072091 3.273938 3.486342 > 1.936157 0 2.174716 2.980596 3.182443 3.394847 > 2.266211 2.174716 0 2.935008 3.136855 3.349259 > 3.072091 2.980596 2.935008 0 1.888593 2.100997 > 3.273938 3.182443 3.136855 1.888593 0 1.383438 > 3.486342 3.394847 3.349259 2.100997 1.383438 0 > 1 0.179826 -0.009544 -0.3113 0.149974 -0.204895 > 0.179826 1 0.100759 0.276355 0.098351 0.221849 > -0.009544 0.100759 1 -0.128468 0.032579 -0.212893 > -0.3113 0.276355 -0.128468 1 -0.118107 0.780792 > 0.149974 0.098351 0.032579 -0.118107 1 -0.120811 > -0.204895 0.221849 -0.212893 0.780792 -0.120811 1 > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.