利用RNAseq数据做聚类分析
library(ConsensusClusterPlus)
library(factoextra)
library(cluster)
library(NbClust)
# 读入数据
data = read.table("T_405_ex.txt",header = T, row.names = 1)
b = matrix(data, nrow = 1, ncol = 1)
new<-as.matrix(t(data))
is.matrix(new)
#标准化
my_data <- na.omit(new)
my_data <- scale(my_data)
head(my_data, n = 3)

get_clust_tendency(my_data, n = 50,gradient = list(low = "steelblue", high = "white"))
#n:the number of points selected from sample space which is also the number of points selected from the given sample(data).(不能大于样本个数)
$hopkins_stat
[1] 0.2837771
# If the value of Hopkins statistic is close to zero (far below 0.5), then we can conclude that the dataset is significantly clusterable.(本次结果小于0.5,证明样本之间有一定的聚类特性。)
$plot

#选择最好的分类K
library("NbClust")
res.nbclust <- NbClust(my_data, distance = "euclidean", min.nc = 2, max.nc = 10, method = "complete", index ="all")



*** : The Hubert index is a graphical method of determining the number of clusters.
In the plot of Hubert index, we seek a significant knee that corresponds to a
significant increase of the value of the measure i.e the significant peak in Hubert
index second differences plot.
*** : The D index is a graphical method of determining the number of clusters.
In the plot of D index, we seek a significant knee (the significant peak in Dindex
second differences plot) that corresponds to a significant increase of the value of
the measure.
*******************************************************************
* Among all indices:
* 11 proposed 2 as the best number of clusters
* 5 proposed 3 as the best number of clusters
* 3 proposed 4 as the best number of clusters
* 4 proposed 6 as the best number of clusters
***** Conclusion *****
* According to the majority rule, the best number of clusters is 2
#样本聚类
factoextra::fviz_nbclust(res.nbclust) + theme_minimal()
res.hc <- eclust(my_data, "hclust", k = 2, graph = FALSE)
fviz_dend(res.hc, rect = TRUE, show_labels = FALSE)

fviz_silhouette(res.hc)

res.hc
#计算标签基因
library(pamr)
stad.data <- pamr.from.excel("k2_ex.txt", 417, sample.labels=TRUE)
#如果有缺失值
stad.data2 <- pamr.knnimpute(stad.data)
model <- pamr.train(stad.data2)
model
#You get a table with 3 columns and 30 rows.
#The rows correspond to threshold values (first column).
#For each threshold you see the number of surviving genes (second column)
#and the number of misclassifications on the training set (third column).
#验证
model.cv <- pamr.cv(model, stad.data2, nfold = 10)
model.cv
pamr.plotcv(model.cv)
#Using the results of cross validation, choose a threshold value Delta as a tradeoff
#between a small number of genes and a good generalization accuracy.

Delta = 11
pamr.plotcen(model, stad.data2, Delta)

dev.print(file = "MYcentroids_k2.ps")
dev.print(device = pdf, file = "MYcentroids_k2.pdf")
#The next function prints a 2 × 2 confusion table,
#which tells us how many samples in each class were predicted correctly.
pamr.confusion(model.cv, Delta)
#To get a visual impression of how clearly the two classes are separated by PAM
pamr.plotcvprob(model, stad.data2, Delta)

#The following command plots for each gene surviving the threshold a figure showing the expression levels of this gene over the whole set of samples.
#You will see which genes are up- or downregulated and how variable they are.
pamr.geneplot(model, stad.data2, Delta)

#导出标签基因
result <- pamr.listgenes(model, stad.data2, Delta, genenames = TRUE)
write.table(result,file="k2_result_gene.txt")
利用RNAseq数据做聚类分析的更多相关文章
- 以P2P网贷为例互联网金融产品如何利用大数据做风控?
以P2P网贷为例互联网金融产品如何利用大数据做风控? 销售环节 了解客户申请意愿和申请信息的真实性:适用于信贷员模式. 风控关键点 亲见申请人,亲见申请人证件,亲见申请人签字,亲见申请人单位. 审 ...
- Differential expression analysis for paired RNA-seq data 成对RNA-seq数据的差异表达分析
Differential expression analysis for paired RNA-seq data 抽象背景:RNA-Seq技术通过产生序列读数并在不同生物条件下计数其频率来测量转录本丰 ...
- 利用大数据技术处理海量GPS数据
我秀中国物联网地图服务平台目前接入的监控车辆近百万辆,每天采集GPS数据7亿多条,产生日志文件70GB,使用传统的数据处理方式非常耗时. 比如,仅仅对GPS做一些简单的统计分析,程序就需要几个小时才能 ...
- nginx利用geo模块做限速白名单以及geo实现全局负载均衡的操作记录
geo指令使用ngx_http_geo_module模块提供的.默认情况下,nginx有加载这个模块,除非人为的 --without-http_geo_module.ngx_http_geo_modu ...
- Python 数据分析(二 本实验将学习利用 Python 数据聚合与分组运算,时间序列,金融与经济数据应用等相关知识
Python 数据分析(二) 本实验将学习利用 Python 数据聚合与分组运算,时间序列,金融与经济数据应用等相关知识 第1节 groupby 技术 第2节 数据聚合 第3节 分组级运算和转换 第4 ...
- 利用 yEd 软件做元数据管理
利用 yEd 软件做元数据管理 yEd Diagram editor 是我常用的 flow chart 制图工具, 另外我也用它画 ER 和 use case 图. 总结一下我喜欢 yEd 的原因:1 ...
- RNA-seq数据综合分析教程 AKAP95
https://blog.csdn.net/l_yivs?t=1 RNA-seq数据综合分析教程 2 4,055 A+ 所属分类:Transcriptomics 收 藏 2 RNA-se ...
- 关于RNA-Seq数据去接头(Adapter)这事需要讲一讲
关于RNA-Seq数据去接头(Adapter)这事需要讲一讲 RNA-Seq adapter barcode cutadapt 首先来了解一下三个概念: 1.adapter是一段短的序列已知的核酸链, ...
- 实战--利用HierarchicalClustering 进行基因表达聚类分析
利用建立分级树对酵母基因表达数据进行聚类分析 一.原理 根据基因表达数据,得出距离矩阵 ↓ 最初,每个点都是一个集合 每次选取距离最小的两个集合,将他们合并,然后更新这个新集合与其它点的距离 新集合与 ...
随机推荐
- ListView的深入学习
ListView通常有两个职责: 将数据填充到布局 : 处理用户的点击选择操作 二.创建ListView需要3个元素 ListView的每一列的View View的数据或者图片 连接数据与ListVi ...
- chomre常用快捷键
Ctrl+T 打开新标签页. 按住 Ctrl 键的同时点击链接.或用鼠标中键(或鼠标滚轮)点击链接. 从后台在新标签页中打开链接. ...
- Spark on YARN两种运行模式介绍
本文出自:Spark on YARN两种运行模式介绍http://www.aboutyun.com/thread-12294-1-1.html(出处: about云开发) 问题导读 1.Spark ...
- 服务设计模式一:Web服务概述
目录 1. Web服务是什么 2.为什么要使用Web服务 3.Web服务考虑的因素和替代方案 4.SOA是什么 Web服务是什么? 所谓服务,通俗的理解就是别人帮你做一些事情,比如说,腰酸背痛了,找个 ...
- win7下VS2015+opencv3.1.0配置
由于opencv与vs的适配版本不同,本人在官网下载opencv3.1.0,其可以和VS2013.VS2015适配,文中以VS2015为例 opencv2.4.13-----vc11;vc12 ope ...
- 升级到Xcode6.2后 免证书真机调试出错的问题
我的本来是Xcode6.1 可以正常免证书真机调试,升级到Xcode6.2以后,真机调试就报错,然后就又按照这篇文章http://www.cnblogs.com/liuliuliu/p/4030524 ...
- PRAGMA AUTONOMOUS_TRANSACTION
转自 http://blog.csdn.net/pan_tian/article/details/7675800 这段时间遇到一个问题,程序里明明插入了一条记录,但在后边的一段Procedure中却查 ...
- Unit03 - 对象内存管理 、 继承的意义(上)
Unit03 - 对象内存管理 . 继承的意义(上) 1.内存管理:由JVM来管理的 1)堆: 1.1)存储所有new出来的对象(包含成员变量) 1.2)没有任何引用所指向的对象就是垃圾 ...
- 作为团队leader,怎样激发每个人的最大战斗力
之前总在讨论怎么做运营,也就是业务本身,这次聊聊管理. 有人说,我还没带团队. 也没关系,现在从业者都很年轻,可能用不了一两年你也会开始面试别人和带团队,即使2个人也算团队. 另外,其他同事即使不是你 ...
- 字节流和字符流(InputStream类和OutputStream类)
java流包括字节流和字符流,字节流通过I/O设备以字节数据的方式读入,而字符流则是通过字节流读入数据转换成字符"流"的形式由用户驱使. InputStream是所有字节输入流的父 ...