育种数据分析之放飞自我分享 http://blog.sciencenet.cn/u/yijiaobai 关注:生物统计,数量遗传,混合线性模型,生物信息,R,Perl,Python,GWAS,GS相关方法,文章及代码

博文

聚类分析---R语言

已有 2147 次阅读 2018-8-8 20:42 |个人分类:R语言|系统分类:科研笔记

1,原始数据,是矩阵,有行头和列名:
data

2,amap包的聚类分析:

library(amap)
clu <- hclusterpar(matx)
plot(clu,sub="",hang = -1,xlab = NA,ylab = NA,main = NA)

cluster

用法:
hcluster(x, method = “euclidean”, diag = FALSE, upper = FALSE,
        link = “complete”, members = NULL, nbproc = 2,
        doubleprecision = TRUE)

3,cluster包

library(cluster)
agnx <- agnes(matx,method = "complete")
pltree(agnx)

agnes(x, diss = inherits(x, “dist”), metric = “euclidean”,
     stand = FALSE, method = “average”, par.method,
     keep.diss = n < 100, keep.data = !diss, trace.lev = 0)
默认方法不一样,这里改为complete

cluster2

转化为横着排放的格式:

dagn  <- as.dendrogram(as.hclust(agnx))
plot(dagn, horiz = TRUE, center = TRUE,
     nodePar = list(lab.cex = 0.6, lab.col = "forest green", pch = NA),
     main = deparse(agn$call))

图片.png



https://wap.sciencenet.cn/blog-2577109-1128259.html

上一篇:安装JuliaPro 并配置VS code
下一篇:MiXBLUP说明文档目录-翻译

0

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

数据加载中...
扫一扫,分享此博文

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

GMT+8, 2021-10-17 22:01

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部