Dear Emmanual,
Thank you for your response! I have checked your code, and I get the following: matrix_dissim_Eucl<-as.matrix(mat_dissim_Eucl) any(is.complex(matrix_dissim_Eucl)) #FALSE isSymmetric.matrix(matrix_dissim_Eucl) # Error: cannot allocate vector of size 811.1Mb So I checked by hand (I think it checks for row and column length, and for equal row and column names dim(matrix_dissim_Eucl) #14582 14582 summary(colnames(matrix_dissim_Eucl)==row.names(matrix_dissim_Eucl)) #TRUE 14582 So I guess this means that it is a symmetric matrix that enters the pcoa function, and that there are no complex values in the matrix. I hope there is one thing I did not think of yet, and you can help me figure it out. In any case, thank you for your help. I really appreciated it. Kind regards, Coline From: Emmanuel Paradis [mailto:emmanuel.para...@ird.fr] Sent: Monday, 6 April 2020 16:47 To: Coline Boonman <c.boon...@science.ru.nl> Cc: r-sig-phylo <r-sig-phylo@r-project.org> Subject: Re: [R-sig-phylo] Question on min(D.eig$values) in pcoa function of ape in R Hi Coline, Actually the test would be: any(is.complex(mat_dissim_Eucl)) And you may also test: isSymmetric(as.matrix(mat_dissim_Eucl)) But it'd very surprising this 2nd test returns FALSE. So if your matrix is real and symmetric, I don't see why you have complex eigenvalues from its decomposition. Best, Emmanuel ----- Le 6 Avr 20, à 21:16, Coline Boonman <c.boon...@science.ru.nl <mailto:c.boon...@science.ru.nl> > a écrit : Dear Emmanual, Thank you for your email. I have been trying to understand what is going on and if your suggestion is correct. However, if I test for complex numbers in my dissimilarity matrix (converted to a matrix: is.complex(as.matrix(mat_dissim_Eucl)) ) R gives me the result FALSE. That means that there are no complex numbers in the input for the pcoa, right? I hope you or someone else has another suggestion on why I get this error. Kind regards, Coline From: Emmanuel Paradis [mailto:emmanuel.para...@ird.fr] Sent: Thursday, 2 April 2020 07:43 To: Coline Boonman <c.boon...@science.ru.nl <mailto:c.boon...@science.ru.nl> > Cc: r-sig-phylo <r-sig-phylo@r-project.org <mailto:r-sig-phylo@r-project.org> > Subject: Re: [R-sig-phylo] Question on min(D.eig$values) in pcoa function of ape in R Hi Coline, This is strange: you calculate a distance matrix with daisy(), so the as.matrix() operation should return a symmetric matrix. Symmetric (real) matrices have all their eigenvalues real numbers. Maybe some complex values were produced by daisy()? Best, Emmanuel ----- Le 30 Mar 20, à 22:58, Coline Boonman <c.boon...@science.ru.nl <mailto:c.boon...@science.ru.nl> > a écrit : Dear reader, I am working with the pcoa function of ape in R and I got the error message: “min(D.eig$values) : invalid 'type' (complex) of argument” . My input data is a distance matrix, which pcoa first converts to a matrix in the first line within the code of the function. The error occurs when it wants to check for negative eigenvalues at the line ‘ min.eig <- min(D.eig$values)’ I checked D.eig$values and indeed they are complex numbers (imaginary numbers). What I don’t understand is why these are created. I never had any issues with the pcoa function before, and now I change my dataset and this happens. The distance matrix values range from 0 to 47 and I have species names as rownames and column names. In the attachment I include a small piece of the dataset and the code I run. I checked when the error occurs, and I don’t see why the extra line (2063) gives the error. I hope someone can help me. Kind regards, Coline Boonman -- PhD student Department of Environmental Science Faculty of Science Radboud University Nijmegen P.O. Box 9010, NL-6500 GL Nijmegen E: c.boon...@science.ru.nl <mailto:c.boon...@science.ru.nl> T: + 31 (0)243653270 / + 31 (0)243653281 (secr.) http://www.ru.nl/environmentalscience _______________________________________________ R-sig-phylo mailing list - R-sig-phylo@r-project.org <mailto:R-sig-phylo@r-project.org> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/ [[alternative HTML version deleted]] _______________________________________________ R-sig-phylo mailing list - R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/