Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
rictjo
impetuous
提交
e2e9e172
I
impetuous
项目概览
rictjo
/
impetuous
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
e2e9e172
编写于
2月 07, 2023
作者:
rictjo
提交者:
GitHub
2月 07, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update quantification.py
上级
b9e10cfd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
8 addition
and
9 deletion
+8
-9
src/impetuous/quantification.py
src/impetuous/quantification.py
+8
-9
未找到文件。
src/impetuous/quantification.py
浏览文件 @
e2e9e172
...
...
@@ -1928,9 +1928,7 @@ def composition_assign_label_ids ( x:pd.Series , label_to_lid:dict ,
return
(
x
)
def
composition_create_contraction
(
adf
:
pd
.
DataFrame
,
jdf
:
pd
.
DataFrame
,
label
:
str
)
->
dict
:
from
impetuous.quantification
import
composition_absolute
#from impetuous.quantification import composition_sorted_fraction
cdf
=
composition_absolute
(
adf
=
adf
,
jdf
=
jdf
,
label
=
alignment_label
)
cdf
=
composition_absolute
(
adf
=
adf
,
jdf
=
jdf
,
label
=
label
)
sf_df
=
composition_sorted_fraction
(
cdf
)
cumulative_cdf
=
sf_df
.
T
.
apply
(
lambda
x
:
composition_cumulative
(
x
)
)
label_transform
=
lambda
x
:
'.'
.
join
(
sorted
(
list
(
x
)))
...
...
@@ -1957,15 +1955,14 @@ def composition_contraction_to_hierarchy ( contracted_df , TOL=1E-10 ,
if
level
>
TOL
:
level_segmentation
=
[
q
[
0
][
1
]
if
len
(
q
)
>
1
else
default_label
for
q
in
[
v
[
[
w
[
0
]
>=
level
for
w
in
v
]
]
for
v
in
contracted_df
.
values
]
]
nlabels
=
len
(
set
(
level_segmentation
))
#print ( nlabels , level ,contracted_df.index.values )
solution
.
append
(
pd
.
Series
(
[
*
level_segmentation
,
nlabels
,
level
]
,
index
=
[
*
contracted_df
.
index
.
values
,
'h.N'
,
'h.lv'
]
,
name
=
str
(
I
)
)
)
I
+=
1
return
(
pd
.
DataFrame
(
solution
).
T
)
def
composition_create_hierarchy
(
adf
:
pd
.
DataFrame
,
jdf
:
pd
.
DataFrame
,
label
:
str
,
levels
:
list
[
int
]
=
None
)
->
dict
:
contr_d
=
composition_create_contraction
(
adf
=
adf
,
jdf
=
jdf
,
label
=
alignment_
label
)
levels
:
list
[
int
]
=
None
,
bFull
:
bool
=
False
)
->
dict
:
contr_d
=
composition_create_contraction
(
adf
=
adf
,
jdf
=
jdf
,
label
=
label
)
contracted_df
=
contr_d
[
'contraction'
]
lookup_l2i
=
contr_d
[
'label_to_id'
]
lookup_i2l
=
contr_d
[
'id_to_label'
]
...
...
@@ -1975,13 +1972,15 @@ def composition_create_hierarchy ( adf:pd.DataFrame , jdf:pd.DataFrame , label:s
lmax
=
int
(
np
.
max
(
res_df
.
loc
[
'h.N'
].
values
.
tolist
()
))
# UNRELIABLE AT LOW VALUES
lmin
=
int
(
np
.
min
(
res_df
.
loc
[
'h.N'
].
values
.
tolist
()
))
# REDUNDANT AT HIGH VALUES
iA
=
np
.
min
(
np
.
where
(
res_df
.
loc
[
'h.N'
,:].
values
==
lmax
)[
0
])
iB
=
np
.
min
(
np
.
where
(
res_df
.
loc
[
'h.N'
,:].
values
==
lmin
)[
0
])
return
(
{
'composition hierarchy'
:
res_df
.
iloc
[:,
iA
:
iB
+
1
]
,
'id to label'
:
lookup_i2l
}
)
iB
=
np
.
min
(
np
.
where
(
res_df
.
loc
[
'h.N'
,:].
values
==
lmin
)[
0
])
+
1
if
bFull
:
iA
,
iB
=
0
,
None
return
(
{
'composition hierarchy'
:
res_df
.
iloc
[:,
iA
:
iB
]
,
'id to label'
:
lookup_i2l
}
)
def
multivariate_aligned_pca
(
analytes_df
,
journal_df
,
sample_label
=
'Sample ID'
,
align_to
=
'Modulating group'
,
n_components
=
None
,
add_labels
=
[
'Additional information'
]
,
e2s
=
None
,
color_lookup
=
None
,
ispec
=
None
)
:
# SAIGA PROJECTIONS
# SAIGA PROJECTIONS
RICHARD TJÖRNHAMMAR
what
=
align_to
analytes_df
=
analytes_df
.
loc
[:,
journal_df
.
columns
.
values
]
dict_actual
=
{
sa
:
di
for
sa
,
di
in
zip
(
*
journal_df
.
loc
[[
sample_label
,
what
],:].
values
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录