• PLINK pca


    #coding:utf-8
    __author__ = 'similarface'
    import os
    import pandas as pd
    import matplotlib.pyplot as plt
    
    path='plink.eigenvec'
    
    def plinkPca(filepath,header=""):
        data=pd.read_table(path,header=None,sep=' ')
        filterdata=data.loc[:,0:5]
        label=filterdata[0].tolist()
        label_uniq = list(set(label))
        label_uniq.sort(key=label.index)
        filterdata.columns=['pop','human','pca0','pca1','pca2','pca3']
        colors=['gold', 'red', 'blue', 'green', 'black', 'yellow', 'orangered', 'sienna', 'tomato', 'silver', 'fuchsia', 'orange', 'coral', 'orchid', 'magenta', 'chartreuse', 'navy', 'violet', 'beige', 'khaki', 'tan', 'indigo', 'cyan', 'azure', 'teal']
        colors=colors[0:len(label_uniq)]
        markers = ['o', 'x', 's', 'p', '^', '>', '+', 'D', '*', '<', '2','_']*10
        markers=markers[0:len(label_uniq)]
        #调整画布大小
        fig = plt.figure(figsize=(8,8),dpi=100)
        plt.clf()
        for i,targer_name,color,marker in zip(range(len(label_uniq)),label_uniq,colors,markers):
            plt.scatter(filterdata[filterdata['pop']==targer_name]['pca0'],filterdata[filterdata['pop']==targer_name]['pca1'], s=20, edgecolor='k',c=color,marker=marker)
        plt.legend(labels = label_uniq, bbox_to_anchor=(1.0,0.95))
        plt.title(header)
        plt.show()
    
        
    plinkPca(path,header="EUR PCA")

  • 相关阅读:
    可运行的Java RMI示例和踩坑总结
    JS异步与同步
    Github作为Maven仓库
    Jmeter笔记
    nodeJS生成xlsx以及设置样式
    double运算的坑
    mysql零散操作
    go包的理解
    nodeJS 服务端文件上传
    webpack+thymeleaf实现数据直出
  • 原文地址:https://www.cnblogs.com/similarface/p/9171811.html
Copyright © 2020-2023  润新知