chen7qi的个人博客分享 http://blog.sciencenet.cn/u/chen7qi

博文

用了这么多年的PCA可视化竟然是错的!!!

已有 3309 次阅读 2019-9-16 11:36 |个人分类:生物信息|系统分类:科研笔记| 生物信息

本文启发于上周开的单细胞转录组课程,本次课程由资深单细胞算法研究者戴老师主讲,深入浅出,各部分分析原理从理论到应用层面解释透彻,最新流程,最新代码,绝对值得学习。课程尚未结束,我就迫不及待向一位未能安排出时间参加此课程的老友及时安利了视频课。

言归正传,介绍培训课程的一张幻灯片:很多PCA可视化结果都是不合适的。

PCA或PCoA是常用的降维工具,之前有几篇文章介绍PCA的原理和可视化。

默认PCA/PCoA软件输出的图通常为正方形或立方体,比较常见的2维PCA可视化图的长宽比是1:1。虽然常见,但这是错误的

下面这张图展示了一套模拟的两簇高斯分布数据的PCA结果展示,Figure a和b是错误的长宽比,结果看上去有4簇。Figure c和d是正确的长宽比,d中的颜色是正确的分组关系。

实际上,PCA图的长宽比应该与各个维度的特征值的比值一致。因为特征值反应各个主成分所解释的原始数据的变异度(方差),需要保证在不同的主成分轴上,解释的单位长度相同,所以长宽比也要有讲究。

如果用基于ggplot2的工具绘图(ggplot2高效实用指南 (可视化脚本、工具、套路、配色)),处理起来很简单,加一个coord_fixed(1)即可。

借用PCA主成分分析实战和可视化 附R代码和测试数据中的代码

fviz_pca_ind(pca, col.ind=data_t$conditions, mean.point=F,

   addEllipses = T, legend.title="Groups") +

   coord_fixed(1) # 关键的增加

If the relationship between the height and the width of a plot is arbitrary, an adequate picture of the data cannot be attained. Two-dimensional PCA plots with equal height and width are misleading but frequently encountered because popular software programs for analyzing biological data often produce square (2D) or cubical (3D) graphics by default. Instead, the height-to-width ratio of a PCA plot should be consistent with the ratio between the corresponding eigenvalues. Because eigenvalues reflect the variance in coordinates of the associated PCs, you only need to ensure that in the plots, one “unit“ in direction of one PC has the same length as one “unit” in direction of another PC. (If you use ggplot2 R package for generating plots, adding + coord_fixed(1) will ensure a correct aspect ratio.)

参考文献:https://doi.org/10.1371/journal.pcbi.1006907.g002




https://wap.sciencenet.cn/blog-118204-1198165.html

上一篇:七龙珠 |召唤一份单细胞数据库汇总
下一篇:Bioconda软件安装神器:多版本并存、环境复制、环境导出
收藏 IP: 43.228.36.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-26 06:19

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部