当我有 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)像颜色一样为每个簇使用不同的标记?
我在 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)
但我不知道如何在用法中编写它,也不知道如何在我的脚本中编写它。
使用以下数据框:
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)