简体   繁体   English

在qplot(ggplot2)中制作有序的热图

[英]Making ordered heat maps in qplot (ggplot2)

I am making heat maps from correlations. 我正在根据相关性制作热图。 I have two columns that represent ID's and a third column that gives the correlation between those two datapoints. 我有两列代表ID,第三列给出了这两个数据点之间的相关性。 I am struggling to get qplot to keep the order of my data in the file. 我正在努力使qplot保持数据在文件中的顺序。 Link to data: 链接到数据:

https://www.dropbox.com/s/3l9p1od5vjt0p4d/SNPS.txt?n=7399684 https://www.dropbox.com/s/3l9p1od5vjt0p4d/SNPS.txt?n=7399684

Here is the code I am using to make the plot: 这是我用来绘制情节的代码:

test <- qplot(x=x, y=y, data=PCIT, fill = col1, geom = "tile")

I have tried several order options but they don't seem to do the trick? 我尝试了几种订购选项,但它们似乎没有解决问题的办法? Ideas? 有想法吗?

Thanks and Happy Holidays 谢谢,节日快乐

You need to set the levels of the factors x and y to be in the order you want them (as they come in from the file). 您需要将因子xy的级别设置为所需的顺序(因为它们是从文件中输入的)。 Try 尝试

PCIT$x <- factor(PCIT$x, levels=unique(as.character(PCIT$x)))

and similarly with y . y类似。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM