Is there a way to convert “dist” to “data.frame”?
Hi, all.
I will output MDS plot with ggplot2.
But, I couldn’t read the data because the class of the data wasn’t support in ggplot2. Is there a way to convert “dist” to “data.frame”?
Although I tried “as.data.frame()“, I was not able to do. The following error messages was outputed.
> as.data.frame(d)
Error in as.data.frame.default(d) :
cannot coerce class ‘"dist"’ to a data.frame
I'm a beginner in bioinformatics, so sorry for the basic question. Could you please advise me? Thank you very much for your appreciated!
• 6,825 views
•
link
1 answer
Log in to answer this question.
Note that there are
plotMDSfunctions also in limma and edgeR that can make these plots directly from the normalized count data, but of course ggplot2 has the most appealing graphics.I'd say the short answer is that you need to pass by
as.matrixfirst:as.data.frame(as.matrix(d))I was able to do it.
But, I can't make a graph Converting the distance matrix to dataframe type by this operation was not enough to output the MDS plot.
I will try another method. Thank you for your answer!