Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
rictjo
impetuous
提交
f0486de2
I
impetuous
项目概览
rictjo
/
impetuous
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
impetuous
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f0486de2
编写于
12月 15, 2020
作者:
rictjo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
OH,TP
上级
798d2310
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
39 addition
and
41 deletion
+39
-41
setup.py
setup.py
+1
-1
src/impetuous/quantification.py
src/impetuous/quantification.py
+38
-40
未找到文件。
setup.py
浏览文件 @
f0486de2
...
...
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools
.
setup
(
name
=
"impetuous-gfa"
,
version
=
"0.3
7.1
"
,
version
=
"0.3
8.0
"
,
author
=
"Richard Tjörnhammar"
,
author_email
=
"richard.tjornhammar@gmail.com"
,
description
=
"Impetuous Quantification, a Statistical Learning library for Humans : Alignments, Clustering, Enrichments and Group Analysis"
,
...
...
src/impetuous/quantification.py
浏览文件 @
f0486de2
...
...
@@ -1066,34 +1066,44 @@ def add_kendalltau( analyte_results_df , journal_df , what='M' , sample_names =
return
(
analyte_results_df
)
def
calculate_rates
(
known_df
,
inferred_df
,
def
calculate_rates
(
journal_df
,
inferred_df
,
formula
,
inference_label
=
'owner'
,
interaction_sep
=
'-'
)
:
bHaveInteraction
=
':'
in
formula
known_set_values
=
set
(
known_df
.
values
.
reshape
(
-
1
))
bVerbose
=
False
)
:
inferred_labels
=
[]
vals
=
inferred_df
.
loc
[:,
inference_label
]
.
values
TP
,
FP
,
FN
,
TN
=
0
,
0
,
0
,
0
check
=
[]
for
idx
in
journal_df
.
index
.
values
:
if
idx
in
formula
:
check
.
append
(
idx
)
check
=
list
(
set
(
check
)
)
if
len
(
check
)
==
0
:
print
(
'Cannot assert quality'
)
results_lookup
=
dict
(
)
return
(
results_lookup
)
known_df
=
journal_df
.
loc
[
check
,:]
for
idx
in
inferred_df
.
index
.
values
:
thisSet
=
set
(
known_df
.
loc
[
idx
].
values
)
not_Set
=
known_set_values
-
thisSet
called
=
inferred_df
.
loc
[
idx
,
inference_label
]
if
bHaveInteraction
and
called
.
count
(
interaction_sep
)
==
1
:
called
=
set
(
called
.
split
(
interaction_sep
)
)
else
:
called
=
set
(
[
called
]
)
not_called
=
known_set_values
-
called
TP
+=
int
(
len
(
called
-
thisSet
)
==
0
)
FP
+=
int
(
len
(
called
-
not_Set
)
==
0
)
TN
+=
int
(
len
(
not_Set
-
not_called
)
<
len
(
not_Set
)
)
FN
+=
int
(
len
(
thisSet
-
not_called
)
<
len
(
thisSet
)
)
known_OH
=
create_encoding_journal
(
known_df
.
index
.
values
,
known_df
)
known_instances
=
known_OH
.
index
inferred_OH
=
known_OH
*
0
for
o
in
inferred_df
.
iterrows
():
for
known_instance
in
known_instances
:
inferred_OH
.
loc
[
known_instance
,
o
[
0
]]
=
int
(
known_instance
in
o
[
1
][
inference_label
]
)
OH_not
=
lambda
df
:
df
.
apply
(
lambda
x
:
1
-
x
)
not_known_OH
=
OH_not
(
known_OH
)
not_inferred_OH
=
OH_not
(
inferred_OH
)
if
bVerbose
:
print
(
known_OH
.
iloc
[:
6
,:
6
])
print
(
not_known_OH
.
iloc
[:
6
,:
6
])
print
(
inferred_OH
.
iloc
[:
6
,:
6
])
print
(
np
.
sum
(
np
.
sum
(
inferred_OH
.
iloc
[:
6
,:
6
]
*
known_OH
.
iloc
[:
6
,:
6
]
))
)
TP
=
np
.
sum
(
np
.
sum
(
inferred_OH
*
known_OH
)
)
FP
=
np
.
sum
(
np
.
sum
(
inferred_OH
*
not_known_OH
)
)
TN
=
np
.
sum
(
np
.
sum
(
not_inferred_OH
*
not_known_OH
)
)
FN
=
np
.
sum
(
np
.
sum
(
not_inferred_OH
*
known_OH
)
)
results_lookup
=
{
'TP'
:
TP
,
'TN'
:
TN
,
'FN'
:
FN
,
'FP'
:
FP
,
...
...
@@ -1108,30 +1118,18 @@ def calculate_rates( known_df , inferred_df ,
return
(
results_lookup
)
def
assign_quality_measures
(
journal
,
result_dfs
,
def
assign_quality_measures
(
journal
_df
,
result_dfs
,
formula
,
inference_label
=
'owner'
,
plabel
=
',p'
,
qlabel
=
',q'
)
:
for
label
in
[
col
for
col
in
result_dfs
[
0
].
columns
if
plabel
in
col
[
-
2
:]
]
:
result_dfs
[
0
].
loc
[:,
label
[:
-
2
]
+
',q'
]
=
[
qvs
[
0
]
for
qvs
in
qvalues
(
result_dfs
[
0
].
loc
[:,
label
].
values
)
]
check
=
[]
for
idx
in
journal_df
.
index
.
values
:
if
idx
in
formula
:
check
.
append
(
idx
)
check
=
list
(
set
(
check
)
)
if
len
(
check
)
==
0
:
print
(
'Cannot assert quality'
)
results_lookup
=
dict
(
)
else
:
results_lookup
=
calculate_rates
(
journal_df
.
loc
[
check
,:].
T
,
res_df
[
1
]
,
results_lookup
=
calculate_rates
(
journal_df
,
result_dfs
[
1
]
,
formula
,
inference_label
=
inference_label
)
return
(
results_lookup
)
if
__name__
==
'__main__'
:
test_type
=
'random'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录