Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
rictjo
impetuous
提交
db80e0d8
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,发现更多精彩内容 >>
提交
db80e0d8
编写于
1月 28, 2020
作者:
rictjo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
0xe3
上级
e4e6fc7f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
18 deletion
+33
-18
setup.py
setup.py
+1
-1
src/impetuous/hierarchal.py
src/impetuous/hierarchal.py
+4
-4
src/impetuous/quantification.py
src/impetuous/quantification.py
+28
-13
未找到文件。
setup.py
浏览文件 @
db80e0d8
...
...
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools
.
setup
(
name
=
"impetuous-gfa"
,
version
=
"0.1
4
.0"
,
version
=
"0.1
5
.0"
,
author
=
"Richard Tjörnhammar"
,
author_email
=
"richard.tjornhammar@gmail.com"
,
description
=
"Impetuous Quantification, Enrichment and Group Variation Analysis"
,
...
...
src/impetuous/hierarchal.py
浏览文件 @
db80e0d8
...
...
@@ -46,9 +46,9 @@ def create_dag_representation_df ( pathway_file = '../data/GROUPDEFINITIONS.gmt'
def
HierarchalEnrichment
(
analyte_df
,
dag_df
,
dag_level_label
=
'DAG,l'
,
ancestors_id_label
=
'aid'
,
id_name
=
None
,
threshold
=
0.05
,
p_label
=
'C(Status),p'
,
analyte_name_label
=
'analytes'
,
item_delimiter
=
','
,
alexa_elim
=
False
ancestors_id_label
=
'aid'
,
id_name
=
None
,
threshold
=
0.05
,
p_label
=
'C(Status),p'
,
analyte_name_label
=
'analytes'
,
item_delimiter
=
','
,
alexa_elim
=
False
,
alternative
=
'two-sided'
)
:
#
# NEEDS AN ANALYTE SIGNIFICANCE FRAME:
...
...
@@ -83,7 +83,7 @@ def HierarchalEnrichment (
L_
=
len
(
group
)
;
str_analytes
=
','
.
join
(
group
.
index
.
values
)
if
L_
>
0
:
used_analytes
[
node
]
=
','
.
join
(
group
.
index
.
values
)
pv
,
odds
=
group_significance
(
group
,
AllAnalytes
=
AllAnalytes
,
SigAnalytes
=
SigAnalytes
,
tolerance
=
threshold
)
pv
,
odds
=
group_significance
(
group
,
AllAnalytes
=
AllAnalytes
,
SigAnalytes
=
SigAnalytes
,
tolerance
=
threshold
,
alternative
=
alternative
)
node_sig
[
node
]
=
pv
;
marked_
=
set
(
group
.
index
.
values
)
ancestors
=
df
.
loc
[
node
,
ancestors_id_label
].
replace
(
'
\n
'
,
''
).
replace
(
' '
,
''
).
split
(
item_delimiter
)
if
alexa_elim
and
pv
>
threshold
:
# USE ALEXAS ELIM ALGORITHM : IS NOT DEFAULT
...
...
src/impetuous/quantification.py
浏览文件 @
db80e0d8
"""
Copyright 20
19
RICHARD TJÖRNHAMMAR
Copyright 20
20
RICHARD TJÖRNHAMMAR
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
...
...
@@ -584,16 +584,16 @@ def quantify_groups_by_analyte_pvalues( analyte_df, grouping_file, delimiter='\t
edf
.
loc
[
l
]
=
q
return
(
edf
.
T
)
class
sPCA
(
object
)
:
class
APCA
(
object
)
:
#
# THIS CLASS PERFORMS A SPARSE PCA
# IT USES THE SPARSE SVD ALGORITHM
# FOUND IN SCIPY
#
def
__init__
(
self
,
X
,
k
=-
1
,
fillna
=
None
)
:
def
__init__
(
self
,
X
=
None
,
k
=-
1
,
fillna
=
None
,
transcending
=
True
)
:
from
scipy.sparse
import
csc_matrix
from
scipy.sparse.linalg
import
svds
self
.
svds_
,
self
.
smatrix_
=
svds
,
csc_matrix
self
.
svds_
,
self
.
smatrix_
=
svds
,
csc_matrix
self
.
components_
=
None
self
.
F_
=
None
self
.
U_
,
self
.
S_
,
self
.
V_
=
None
,
None
,
None
...
...
@@ -602,6 +602,7 @@ class sPCA( object ) :
self
.
fillna_
=
fillna
self
.
X_
=
self
.
interpret_input
(
X
)
self
.
k_
=
k
self
.
transcending_
=
transcending
def
interpret_input
(
self
,
X
)
:
if
'pandas'
in
str
(
type
(
X
))
:
...
...
@@ -612,29 +613,43 @@ class sPCA( object ) :
self
.
X_
=
X
.
values
else
:
self
.
X_
=
X
return
(
self
.
X_
)
return
(
self
.
X_
)
def
fit
(
self
,
X
=
None
)
:
self
.
fit_transform
(
X
=
X
)
def
fit_transform
(
self
,
X
=
None
)
:
X
=
self
.
X_
if
not
X
is
None
:
# DID THE USER SUPPLY NEW DATA
if
X
is
None
:
X
=
self
.
X_
if
not
X
is
None
:
X
=
self
.
interpret_input
(
X
)
Xc
=
X
-
np
.
mean
(
X
,
0
)
if
self
.
k_
<=
0
:
k_
=
np
.
min
(
np
.
shape
(
X
))
-
1
if
self
.
k_
<=
0
:
k_
=
np
.
min
(
np
.
shape
(
Xc
)
)
-
1
else
:
k_
=
self
.
k_
u
,
s
,
v
=
self
.
svds_
(
self
.
smatrix_
(
Xc
,
dtype
=
float
)
,
k
=
k_
)
if
self
.
transcending_
:
u
,
s
,
v
=
self
.
transcending_order
(
u
,
s
,
v
)
S
=
np
.
diag
(
s
)
self
.
F_
=
np
.
dot
(
u
,
S
)
self
.
var_
=
s
**
2
/
Xc
.
shape
[
0
]
self
.
explained_variance_ratio_
=
self
.
var_
/
self
.
var_
.
sum
()
self
.
U_
,
self
.
S_
,
self
.
V_
=
u
,
s
,
v
self
.
components_
=
self
.
V_
self
.
components_
=
self
.
V_
return
(
self
.
F_
)
def
transcending_order
(
self
,
u
,
s
,
v
)
:
return
(
u
[:,::
-
1
],
s
[::
-
1
],
v
[::
-
1
,:]
)
def
apply_matrix
(
self
,
R
)
:
self
.
U_
=
np
.
dot
(
self
.
U_
,
R
.
T
)
self
.
V_
=
np
.
dot
(
self
.
V_
.
T
,
R
.
T
).
T
self
.
F_
=
np
.
dot
(
self
.
F_
,
R
.
T
)
self
.
components_
=
self
.
V_
return
(
self
.
F_
)
dimred
=
PCA
()
def
quantify_groups
(
analyte_df
,
journal_df
,
formula
,
grouping_file
,
synonyms
=
None
,
...
...
@@ -685,10 +700,10 @@ def quantify_by_dictionary ( analyte_df , journal_df , formula , split_id=None,
grouping_dictionary
=
dict
()
,
synonyms
=
None
,
delimiter
=
':'
,
test_type
=
'random'
,
tolerance
=
0.05
,
supress_q
=
False
,
analyte_formula
=
None
,
use_
sparse
_pca
=
False
,
k
=-
1
)
:
use_
loc
_pca
=
False
,
k
=-
1
)
:
if
use_
sparse
_pca
:
dimred
=
s
PCA
(
X
=
analyte_df
,
k
=
k
)
if
use_
loc
_pca
:
dimred
=
A
PCA
(
X
=
analyte_df
,
k
=
k
)
if
not
'dict'
in
str
(
type
(
grouping_dictionary
))
:
print
(
'INVALID GROUPING'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录