在R语言中找到了计算遗传距离的函数dist.dna();但是不知道在R里面如何利用循环批量处理文件计算遗传距离。想到了利用python来调用R函数的方法,查找相关教程发现需要用到rpy2模块。
easy_install rpy2
报错(看不懂报错内容);
pip install rpy2
报错(提示需要更新pip到pip19.0.3);
利用python -m pip install --upgrade pip
更新pip报错(看不懂报错内容);
利用https://pip.pypa.io/en/stable/installing/教程安装pip成功更新。
使用pip install rpy2
安装依旧报错(看不懂报错内容);
尝试教程https://blog.csdn.net/suzyu12345/article/details/51476321安装rpy2,提示rpy2-2.9.5-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform
在rpy2主页https://rpy2.bitbucket.io/ 发现一句话 Releasend source packages are available on PyPi. Installing should be as easy* as
pip install rpy2
(*:except on Windows)
这意思是在windows系统使用pip安装不太容易吗?
找到了教程rpy2:在python中调用R函数的一个实例;发现其中rpy2的安装使用的是conda,自己也尝试在windows的DOS窗口下使用conda install rpy2
成功。但是结尾处提示了一句此时不应有do
不明白是什么意思
在python中加载R包查到可以使用
from rpy2 import robjects
stats = robjects.packages.importr('stats')
加载R语言自带的包时没有遇到问题;但是加载需要额外安装的包时遇到了报错
ggplot2 = robjects.importr('ggplot2')
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-13-7aaf441ce193> in <module>()
----> 1 ggplot2 = robjects.packages.importr('ggplot2')
AttributeError: module 'rpy2.robjects' has no attribute 'importr'
ggplot2 = robjects.packages.importr('ggplot2')
---------------------------------------------------------------------------
RRuntimeError Traceback (most recent call last)
<ipython-input-14-8cfe96f484c7> in <module>()
----> 1 ggplot2 = robjects.packages.importr('ggplot2')
~\AppData\Local\Continuum\anaconda3\lib\site-packages\rpy2-2.9.4-py3.6-win-amd64.egg\rpy2\robjects\packages.py in importr(name, lib_loc, robject_translations, signature_translation, suppress_messages, on_conflict, symbol_r2python, symbol_check_after, data)
451 if _package_has_namespace(rname,
452 _system_file(package = rname)):
--> 453 env = _get_namespace(rname)
454 version = _get_namespace_version(rname)[0]
455 exported_names = set(_get_namespace_exports(rname))
RRuntimeError:
按照教程https://blog.csdn.net/arcers/article/details/79109535使用conda install -c r r-ggplot2
安装需要用到的包解决问题
《分子进化与系统发育》 Molecular Evolution and Phylogenetics
第三章:DNA序列的进化演变
DNA序列的进化演变比蛋白质序列的演变更加复杂,因为存在多种多样的DNA区域:如蛋白质编码区,非编码区、外显子、内含子、侧翼区、重复DNA序列和插入序列等。某些区域相比于其他区更容易受到自然选择的作用,使得DNA在不同区呈现不同的进化模式。
一个简便描述序列分歧大小的测度是两条核苷酸序列中不同核苷酸位点的比例 P = nd/n;
nd为检测两条序列间不同核苷酸数;n为配对总数;P成为核苷酸间的p距离
- ape has two functions to calculate evolutionary distances: dist.gene and dist.dna. The handle allelic data and DNA sequences, respectively.
dist.dna provides a comprehensive function for the estimation of distances from aligned DNA sequences using substitution models.
The dist.dna() function requires the input alignment to be in a special format known as "DNAbin" format, so we must use the as.DNAbin() function to convert our DNA alignment into this format before using the dist.dna() function.
参考文献
- https://a-little-book-of-r-for-bioinformatics.readthedocs.io/en/latest/src/chapter5.html Multiple Alignment and Phylogenetic trees
网友评论