利用Python【Orange】结合DNA序列进行人种预测
http://blog.csdn.net/jj12345jj198999/article/details/8951120
coursera上 web intelligence and big data 终于布置了HW7,这一次的要求是对一系列DNA序列进行预测,具体说明如下:
Data Analytics Assignment (for HW7)
============================================
individual at a reasonable cost. An individual's genetic make-up
determines a number
diseases, response to treatment and so on. In this problem, you are
given a subset of genetic information for several individuals. For some
of the individuals you are also told their ethinicity.
Your task is to figure out the ethnicity of the other individuals.
genetic variation at a particular position on chromosome 6
is provided. In some cases, information for an individual at a
particular position is not available and this represented as
? (missing).
You have to predict the ethnicity for these individuals and enter your
answers via HW7.
Data Sets
-----------
The training set is available here: genestrain.tab.zip (6.2
Mb)
The test set is available here: genesblind.tab.zip (1.2
Mb)
(Note: Data sets are .tab files in the tab-separated format that can be read into Orange):
which is a tab-separated line of column/feature names: For example
'6_10000005' indicates that the column describes the presence or absence
of variations at position 10000005 on chromosome
#6.
Entries in the second header line indicate the type of column (in this case all features are 'discrete').
Entries in the third header line indicate the nature of each column:
A ' ' for most columns that contain a feature, and 'class' for the first
column as it contains the actual class labels (i.e., ethnicities of the
individuals in each row).
In the training set file the first column, which denotes the class
label, is a three-letter code with one of the following values:
o GIH is Gujarati Indian from Houston
o JPT is Japanese in Tokyo
o ASW is Americans of African Ancestry
o YRI is Yoruba in Ibadan, Nigera
=========================
For the purposes of your HW answer alone, each three letter code is to be marked with a NUMERIC VALUE as indicated in the table below:
o CEU is Northern and Western European - 0
o GIH is Gujarati Indian from Houston - 1
o JPT is Japanese in Tokyo - 2
o ASW is Americans of African Ancestry - 3
o YRI is Yoruba in Ibadan, Nigera - 4
YOU MUST USE THE ABOVE NUMERIC VALUES TO ENCODE YOUR ANSWER. Note: This
numeric value has no presence in the test or training data.
the test file, predict their ethnicity as CEU, GIH, JPT, ASW or YRI and
enter your answers in HW7 in exactly the order that the 11 individuals appear in the test file.
So, for example, if your prediction is CEU, GIH, JPT, ASW, YRI CEU, GIH, JPT, ASW, YRI, CEU, you should enter your answer as 0 1 2 3 4 0 1 2 3 4 0 (i.e. numbers separated
by a space - no commas, tabs or anything else, just as space between single digit numbers).
不过很多人在discussion form里面反映着印度老师在描述的时候没有把问题讲明白(主要是没告诉他们该怎么做),也没在video里面给个指导视频啥的。好在把数据下下来以后,发现其中有一个训练集,一个预测集,估计也只能是先训练,再预测而已。
训练集是一个tab文件,格式如下:
横坐标class代表人种(这里有139行,代表139个训练数据),纵坐标代表DNA片段(约有20万个,后面n列未列出)
预测集如下:
这里第一列加 问号 的就是要预测的,总共为11个人种信息。
了解完数据的情况后,下一步就是看如何来训练和预测了,discussion form中有人提出了用Orange这个库,基友Python,使用起来很方便,地址是 http://orange.biolab.si/doc/ofb/c_basics.htm ,更详细的可以看 http://orange.biolab.si/docs/latest/tutorial/rst/classification/
针对这个问题,贝叶斯分类器就能搞定了,代码很短如下:
- # Description: Read data, build naive Bayesian classifier and classify first few instances
- # Category: modelling
- # Uses: genestrain.tab
- # Predict: genesblind.tab
- # Referenced: c_basics.htm
- import orange
- data = orange.ExampleTable("genestrain")
- data2= orange.ExampleTable("genesblind")
- classifier = orange.BayesLearner(data)
- i = 0
- for item in data2:
- c = classifier(item)
- print "%d: %s " % (i, c)
- i = i + 1
可以看到这里先用训练数据进行训练,得到分类器,然后用分类器对预测数据的每一行进行预测,输出结果,思想还是比较清晰的,不过唯一的缺点是在数据量稍大一点时,运行速度和消耗资源很大,针对这题要使用1G内存,运行10分钟:
最终输出结果如下:
这样就得到了有待预测的11个人种,填写答案搞定。
估计这是这门课最后一次编程作业了,还剩一个在线的final exam,赶紧结课吧。
利用Python【Orange】结合DNA序列进行人种预测的更多相关文章
- 利用Needleman–Wunsch算法进行DNA序列全局比对
生物信息学原理作业第二弹:利用Needleman–Wunsch算法进行DNA序列全局比对. 具体原理:https://en.wikipedia.org/wiki/Needleman%E2%80%93W ...
- 利用python实现二分法和斐波那契序列
利用python实现二分法:我的实现思路如下 1.判断要查找的值是否大于最大值,如果大于则直接返回False 2.判断要查找的值是否小于最小值,如果小于则直接返回False 3.如果要查找的值在最大值 ...
- python实现DNA序列字符串转换,互补链,反向链,反向互补链
在生物信息学分析中,经常对DNA序列进行一系列操作,包括子序列截取,互补序列获取,反向序列获取,反向互补序列获取.在python语言中,可编写如下函数完成这些简单功能. 子序列截取 python中对序 ...
- 简单DNA序列组装(非循环子图)
生物信息学原理作业第四弹:DNA序列组装(非循环子图) 原理:生物信息学(孙啸) 大致思想: 1. 这个算法理解细节理解比较困难,建议看孙啸的生物信息学相关章节. 2. 算法要求所有序列覆盖整个目标D ...
- DNA序列局部比对(Smith–Waterman algorithm)
生物信息原理作业第三弹:DNA序列局部比对,利用Smith–Waterman算法,python3.6代码实现. 实例以及原理均来自https://en.wikipedia.org/wiki/Smith ...
- 利用Python进行数据分析(4) NumPy基础: ndarray简单介绍
一.NumPy 是什么 NumPy 是 Python 科学计算的基础包,它专为进行严格的数字处理而产生.在之前的随笔里已有更加详细的介绍,这里不再赘述. 利用 Python 进行数据分析(一)简单介绍 ...
- [LeetCode] Repeated DNA Sequences 求重复的DNA序列
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...
- 环状DNA序列
大意: 一个DNA序列是环状的,这意味着有N个碱基的序列有N种表示方法(假设无重复).而这N个序列有一种最小的表示,这个最小表示的意思是这个序列的字典序最小(字典序的意思是在字典中的大小 比如ABC& ...
- 利用Python完成一个小游戏:随机挑选一个单词,并对其进行乱序,玩家要猜出原始单词
一 Python的概述以及游戏的内容 Python是一种功能强大且易于使用的编程语言,更接近人类语言,以至于人们都说它是“以思考的速度编程”:Python具备现代编程语言所应具备的一切功能:Pytho ...
随机推荐
- 机器学习实战笔记(Python实现)-01-K近邻算法(KNN)
--------------------------------------------------------------------------------------- 本系列文章为<机器 ...
- 机器学习实战笔记(Python实现)-02-决策树
--------------------------------------------------------------------------------------- 本系列文章为<机器 ...
- 从零自学Hadoop(10):Hadoop1.x与Hadoop2.x
阅读目录 序 里程碑 Hadoop1.x与Hadoop2.x 系列索引 本文版权归mephisto和博客园共有,欢迎转载,但须保留此段声明,并给出原文链接,谢谢合作. 文章是哥(mephisto)写的 ...
- Python魔术方法-Magic Method
介绍 在Python中,所有以"__"双下划线包起来的方法,都统称为"Magic Method",例如类的初始化方法 __init__ ,Python中所有的魔 ...
- oh-my-zsh主题
什么是ZSH Zsh和bash一样,是一种Unix shell,但大多数Linux发行版本都默认使用bash shell.但Zsh有强大的自动补全参数.文件名.等功能和强大的自定义配置功能. 一.安装 ...
- 移动端报表JS开发示例--获取定位
上次分享了移动端报表JS开发的系统概念,后来我又回去摸索了一些案例.之前接触到的FineReport的APP客户端可以用来打卡签到,就好奇研究了以下,这次就来聊一聊报表移动端开发如何实现定位功能. 1 ...
- 报表软件JS开发引用HTML DOM的location和document对象
上一次提到,在报表软件FineReport的JavaScript开发中,可以访问并处理的HTML DOM对象有windows.location.document三种.这次就继续介绍后两种,locati ...
- MMORPG大型游戏设计与开发(服务器 AI 基础接口)
一个模块都往往需要统一的接口支持,特别是对于非常大型的模块,基础结构的统一性非常重要,它往往决定了其扩展对象的通用性.昨天说了AI的基本概述以及组成,作为与场景模块中核心一样重要的地位,基础部分的设计 ...
- 利用QMP和QEMU虚拟机交互的几种方式
QMP是一种基于JSON格式的传输协议,我们能利用它与一个QEMU虚拟机实例进行交互,例如查询,更改虚拟机的状态,获取设备信息等等.下面是几种创建QMP的方法以及对其它的一些基本命令的使用: 1.基于 ...
- Hibernate 分组查询 子查询 原生SQL
分组查询: 使用group by关键字对数据分组,使用having关键字对分组数据设定约束条件,从而完成对数据分组和统计 1.1 聚合函数:常被用来实现数据统计功能 ① count() 统计记录条数 ...