Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
rictjo
impetuous
提交
202df831
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,发现更多精彩内容 >>
未验证
提交
202df831
编写于
3月 07, 2023
作者:
rictjo
提交者:
GitHub
3月 07, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more dag info
cosmetic change does not affect stats
上级
52240e80
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
7 deletion
+46
-7
src/impetuous/hierarchical.py
src/impetuous/hierarchical.py
+46
-7
未找到文件。
src/impetuous/hierarchical.py
浏览文件 @
202df831
...
...
@@ -37,16 +37,55 @@ def pathway_frame_from_file ( filename ,
def
create_dag_representation_df
(
pathway_file
:
str
=
'../data/GROUPDEFINITIONS.gmt'
,
pcfile
:
str
=
'../data/PCLIST.txt'
,
identifier
:
str
=
'R-HSA'
pcfile
:
str
=
'../data/PCLIST.txt'
,
identifier
:
str
=
'R-HSA'
,
item_sep
:
str
=
','
)
:
pc_list_file
=
pcfile
tree
,
ance
,
desc
=
parent_child_to_dag
(
pc_list_file
,
identifier
=
identifier
)
pdf
=
make_pathway_ancestor_data_frame
(
ance
)
tree
,
ance
,
desc
=
parent_child_to_dag
(
pc_list_file
,
identifier
=
identifier
)
pdf_
=
pathway_frame_from_file
(
pathway_file
)
pdf
.
index
=
[
v
.
replace
(
' '
,
''
)
for
v
in
pdf
.
index
.
values
]
pdf_
.
index
=
[
v
.
replace
(
' '
,
''
)
for
v
in
pdf_
.
index
.
values
]
dag_df
=
pd
.
concat
([
pdf
.
T
,
pdf_
.
T
]).
T
return
(
dag_df
,
tree
)
root
=
tree
.
get_root_id
()
lost
=
set
(
tree
.
keys
())
-
set
(
pdf_
.
index
.
values
.
tolist
())
for
l
in
lost
:
pdf_
.
loc
[
l
]
=
[
'NA'
,
''
]
DF
=
[]
for
idx
in
pdf_
.
index
.
values
:
ord_ascendants
=
tree
.
search
(
root_id
=
idx
,
linktype
=
'ascendants'
,
order
=
'depth'
)[
'path'
]
level
=
len
(
ord_ascendants
)
-
1
ord_descendants
=
tree
.
search
(
root_id
=
idx
,
linktype
=
'descendants'
,
order
=
'depth'
)[
'path'
]
ord_ascendants
=
[
a
for
a
in
ord_ascendants
if
not
(
a
==
idx
)
]
ord_descendants
=
[
d
for
d
in
ord_descendants
if
not
(
d
==
idx
)
]
if
len
(
ord_ascendants
)
>
0
:
parent
=
ord_ascendants
[
0
]
else
:
parent
=
''
dag_anscestors
=
item_sep
.
join
(
ord_ascendants
)
dag_descendants
=
item_sep
.
join
(
ord_descendants
)
DF
.
append
(
[
level
,
dag_anscestors
,
dag_descendants
,
parent
,
*
pdf_
.
loc
[
idx
].
values
]
)
ndag_df
=
pd
.
DataFrame
(
DF
,
columns
=
[
*
[
'DAG,level'
,
'DAG,ancestors'
,
'DAG,descendants'
,
'DAG,parent'
],
*
pdf_
.
columns
.
values
],
index
=
pdf_
.
index
.
values
)
return
(
ndag_df
,
tree
)
def
fill_in_full_hierarchy
(
df
:
pd
.
DataFrame
=
None
,
gmtfile
:
str
=
'/home/USER/data/Reactome/reactome_v71.gmt'
,
pcfile
:
str
=
'/home/USER/data/Reactome/NewestReactomeNodeRelations.txt'
,
fields
:
list
[
float
]
=
[
'p-value'
]
)
->
pd
.
DataFrame
:
dag_df
,
tree
=
create_dag_representation_df
(
pathway_file
=
gmtfile
,
pcfile
=
pcfile
)
for
field
in
fields
:
dag_df
.
loc
[:,
field
]
=
1.
for
idx
in
df
.
index
.
values
:
dag_df
.
loc
[
idx
,
fields
]
=
df
.
loc
[
idx
,
fields
]
dag_df
.
loc
[:,
'parent'
]
=
dag_df
.
loc
[:,
'DAG,parent'
]
for
idx
in
dag_df
.
index
.
values
:
if
idx
in
set
(
df
.
index
.
values
)
:
dag_df
.
loc
[
idx
,
fields
]
=
df
.
loc
[
idx
,
fields
]
dag_df
.
loc
[:,
'name'
]
=
dag_df
.
index
.
values
return
(
dag_df
)
def
HierarchalEnrichment
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录