与ASReml-R语法类似,ASReml-python是基于python语言开发的版本,适合python环境。应用场景包括:复杂的试验设计、空间分析、多环境数据、基因型选择、方差组分和复杂矩阵结构的模型。windows系统、Mac系统、Linux系统,安装方式一样,打开终端:python -m pip install --extra-index-url https://products.vsni.co.uk/asreml/python-package "asreml[full]"
验证是否安装成功:
python -m pip show asreml
显示版本为1.0.0.a288,说明安装成功。
2 激活license code
从VSNC获得激活码,比如AAAA-BBBB-CCCC-DDDD
python C:\Users\dave\anaconda3\Lib\site-packages\asreml\get_license.py AAAA-BBBB-CCCC-DDDD
这个get_license.py是安装路径下面的asreml中的函数,安装路径通过
python -m pip show asreml
获得。
3 使用asreml-python分析动物模型
import pandas as pdimport asremlfrom asreml import define_categorical_variablesimport matplotlib.pyplot as plt# ===================== 设置工作目录 =====================import osos.chdir("./")harvey = pd.read_csv("02-data/harvey.csv")harvey_ped = pd.read_csv("02-data/harvey_ped.csv")print(harvey.head())print(harvey_ped.head())## 变为因子harvey = define_categorical_variables(harvey,variables=["Calf", "Sire", "Line", "ageOfDam"])## 计算逆矩阵ainv = asreml.ainverse(harvey_ped)## 构建模型mod = asreml.asreml(response="y3",fixed="Line",random="vm(Calf, ainv)", residual="units",data={"data": harvey, "ainv": ainv})## 查看方差组分mod.variance_components()
结果如下:
R语言运行结果:
两个版本的计算结果是一致的。
目前ASReml-python提供免费的软件试用,可点击下方链接注册申请:
https://www.vsnc.com.cn/request-trial-version-cn/
更多ASReml-python软件详情咨询,请添加客服微信: