【问题标题】:PCA or MDS for groups in RR 中组的 PCA 或 MDS
【发布时间】:2017-05-11 14:17:45
【问题描述】:

我有一个具有特定列和行组的数据矩阵。

Promoters Exons Introns Intergenic  UTR5  UTR3 EncodeDnase   TFBS CpGislands CpGshores CpGshelf Enhancer Valley umrs canyons genebodies enhancer34 groups
44905 34778   49182      32420 21190  6537       75693  61543      54879     13759     3666   103839    544    8    9148      63403       7366   none
78256 63745   91197      57814 34416 13868      148583 130801     105784     28060     6529   189413   1714    5   18539     116294       8381    RTK
143570 98141  138767      71540 67754 16907      229364 217258     173782     40134     7885   269992   2284   26   29641     176748      17150    IDH
45056 37201   58839      38119 21086  8157       86207  70401      55729     18749     4970   120537    960   14   10717      72760       5439   none
107204 75309  107776      65783 48986 12059      179100 163906     138259     30409     5969   220463   1951   30   23413     136981      13742  CEBPA
106545 75721  109299      67453 47773 13183      180403 163493     134882     32027     6524   224426   1933   25   23011     138924      13242  CEBPA

这里的 Col 名称是“Promoters”、“Exons”……而 Groups 是“none”、“RTK”等。

我需要做一些 PCA 来查看例如促销员如何在众多组中分配。我一直在尝试使用 ggfortify 和其他 R 包,但无法获得清晰的图片。非常感谢任何帮助。

这是我得到的错误:

> autoplot(prcomp(df[,1:17], scale=TRUE)$rotation[,1], color='groups')

Error: Objects of type numeric not supported by autoplot.

使用:

autoplot(prcomp(df[,1:17], scale=TRUE), color='groups')

该组没有颜色,我也没有收到任何消息。

Marco Sandri 解决方案:

library(ggfortify)
autoplot(prcomp(df[,1:17], scale=TRUE), loadings = TRUE, loadings.label = TRUE,
         data = df, colour = 'groups')

【问题讨论】:

  • autoplot的第一个参数应该是prcomp对象,而不是旋转;试试autoplot(prcomp(df[,1:17], scale=TRUE), color='groups')

标签: r pca mds


【解决方案1】:

autoplot 中为 prcomp 对象提供了以下选项:

library(ggfortify)
autoplot(prcomp(df[,1:17], scale=TRUE), loadings = TRUE, loadings.label = TRUE,
         data = df, colour = 'groups')

【讨论】:

  • 感谢这项工作。是否可以仅在 df 上取第一列并查看分发库 don 组。例如,我希望看到发起人在群体中的分布。
  • prcomp(df[,1], scale=TRUE) 表示您正在尝试对单个变量进行 PCA。这没有任何意义。
  • 是的。我想看看促销员的分布到另一个上校。价值。我通过对 df 进行子集化来做到这一点。谢谢。
猜你喜欢
  • 2019-08-04
  • 1970-01-01
  • 2014-08-08
  • 1970-01-01
  • 1970-01-01
  • 2019-12-13
  • 1970-01-01
  • 1970-01-01
  • 2016-07-19
相关资源
最近更新 更多