小编Ely*_*ire的帖子

条件标记 matplotlib

当我有 3 种类型的点由预测确定时,我绘制高斯混合的结果。我对预测的每个簇都有不同的颜色,现在我想要有不同的标记而不是颜色。

colors=['pink' if i==0 else 'skyblue' if i==1 else 'lightgreen' for i in resultGM]
markers=['c' if i==0 else 'o' if i==1 else 'D' for i in resultGM]
ax=plt.gca()
ax.scatter(datas[:, 0], datas[:, 1], alpha=0.8, c=colors, marker=markers)   
plt.title("Calling " + name_snp)
plt.xlabel('LogRatio')
plt.ylabel('Strength')
plt.show()
Run Code Online (Sandbox Code Playgroud)

它非常适合这样的颜色:

在此输入图像描述

但我不能用不同的标记做同样的事情,它不能识别标记列表。

我怎样才能(0,1,2)像颜色一样为每个簇使用不同的标记?

python matplotlib markers

5
推荐指数
1
解决办法
8720
查看次数

docopt 布尔 arg python

我在 doctopt 脚本中使用以下参数

Usage:
GaussianMixture.py --snpList=File --callingRAC=File

Options:
-h --help     Show help.
snpList     list snp txt
callingRAC      results snp
Run Code Online (Sandbox Code Playgroud)

我想添加一个对我的脚本有条件结果的参数:更正我的数据或不更正我的数据。就像是 :

Usage:
GaussianMixture.py --snpList=File --callingRAC=File  correction(--0 | --1)

Options:
-h --help     Show help.
snpList     list snp txt
callingRAC      results snp
correction      0 : without correction | 1 : with correction 
Run Code Online (Sandbox Code Playgroud)

我想在我的脚本中添加if一些函数

def func1():
  if args[correction] == 0:
      datas = non_corrected_datas
  if args[correction] == 1:
      datas = corrected_datas
Run Code Online (Sandbox Code Playgroud)

但我不知道如何在用法中编写它,也不知道如何在我的脚本中编写它。

python docopt

4
推荐指数
1
解决办法
2665
查看次数

熊猫-合并行并使用'get_dummies'添加列

使用以下数据框:

import pandas as pd
df=pd.DataFrame(data=[[1,5179530,'rs10799170',8.1548,'E001'], [1,5179530,'rs10799170',8.1548,'E002'], [1,5179530,'rs10799170',8.1548,'E003'], [1,455521,'rs235884',2.584,'E003'], [1,455521,'rs235884',2.584,'E007']], col    umns=['CHR','BP','SNP','CM','ANNOT'])

   CHR       BP         SNP      CM ANNOT
0    1  5179530  rs10799170  8.1548  E001
1    1  5179530  rs10799170  8.1548  E002
2    1  5179530  rs10799170  8.1548  E003
3    1   455521    rs235884  2.5840  E003
4    1   455521    rs235884  2.5840  E007
Run Code Online (Sandbox Code Playgroud)

我想获得

   CHR       BP         SNP      CM  E001  E002  E003  E007
0    1  5179530  rs10799170  8.1548     1     1     1     0  
1    1   455521    rs235884  2.5840     0     0     1     1
Run Code Online (Sandbox Code Playgroud)

我想groupby()get_dummies()分别

df.groupby(['CHR','BP','SNP','CM']).sum() …
Run Code Online (Sandbox Code Playgroud)

python dataframe pandas

3
推荐指数
2
解决办法
2912
查看次数

标签 统计

python ×3

dataframe ×1

docopt ×1

markers ×1

matplotlib ×1

pandas ×1