Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
rictjo
impetuous
提交
fa5aefc0
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 搜索 >>
提交
fa5aefc0
编写于
12月 18, 2020
作者:
rictjo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
coordination/segregation test
上级
698d6fee
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
15 deletion
+30
-15
setup.py
setup.py
+1
-1
src/impetuous/hierarchical.py
src/impetuous/hierarchical.py
+27
-12
src/impetuous/visualisation.py
src/impetuous/visualisation.py
+2
-2
未找到文件。
setup.py
浏览文件 @
fa5aefc0
...
...
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools
.
setup
(
name
=
"impetuous-gfa"
,
version
=
"0.40.
2
"
,
version
=
"0.40.
3
"
,
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/hierarchical.py
浏览文件 @
fa5aefc0
...
...
@@ -116,7 +116,7 @@ def HierarchicalEnrichment (
def
calculate_hierarchy_matrix
(
data_frame
=
None
,
distance_matrix
=
None
,
bVerbose
=
False
)
:
info__
=
""" This is the saiga you are looking for """
info__
=
""" This is the saiga
/pelican/panda
you are looking for """
from
impetuous.clustering
import
connectivity
,
absolute_coordinates_to_distance_matrix
import
operator
if
not
operator
.
xor
(
data_frame
is
None
,
distance_matrix
is
None
)
:
...
...
@@ -138,15 +138,21 @@ def calculate_hierarchy_matrix ( data_frame = None ,
print
(
distance_matrix
)
uco_v
=
sorted
(
list
(
set
(
distance_matrix
.
reshape
(
-
1
))))
hierarchy_matrix
=
None
hsers
=
[]
level_distance_lookup
=
{}
for
icut
in
range
(
len
(
uco_v
))
:
cutoff
=
uco_v
[
icut
]
clusternames
,
nclustercontacts
=
connectivity
(
distance_matrix
,
cutoff
,
# clustercontacts : clusterid to particleid
# clustercontent : clusterid to number of particles in range
clustercontent
,
clustercontacts
=
connectivity
(
distance_matrix
,
cutoff
,
bVerbose
=
bVerbose
)
pid2clusterid
=
nclustercontacts
[:,
0
]
level_distance_lookup
[
'level'
+
str
(
icut
)]
=
[
icut
,
cutoff
]
#
# internal ordering is a range so this does not need to be a dict
pid2clusterid
=
clustercontacts
[:,
0
]
if
icut
==
10
and
False
:
print
(
clustercontent
,
clustercontacts
,
np
.
mean
(
clustercontent
))
exit
(
1
)
level_distance_lookup
[
'level'
+
str
(
icut
)]
=
[
icut
,
cutoff
,
np
.
mean
(
clustercontent
)
]
hser
=
pd
.
Series
(
pid2clusterid
,
name
=
'level'
+
str
(
icut
),
index
=
range
(
len
(
distance_matrix
)))
hsers
.
append
(
hser
)
if
len
(
set
(
hser
.
values
))
==
1
:
...
...
@@ -158,19 +164,21 @@ def calculate_hierarchy_matrix ( data_frame = None ,
names
=
range
(
len
(
distance_matrix
))
res_df
=
pd
.
DataFrame
(
hsers
)
res_df
.
columns
=
names
hierarchy_matrix
=
res_df
if
bVerbose
:
print
()
print
(
"TAKE NOTE THAT THE CLUSTER INDEXING BETWEEN LEVELS MIGHT NOT BE THE SAME"
)
print
(
"YOU HAVE TO USE THE CLUSTER ID NUMBERS ACROSS A LEVEL TO DEDUCE WHICH PARTICLES"
)
print
(
"BELONG TOGETHER IN A CLUSTER. THAT IS: I.E. CLUSTER 0 ON LEVEL 12 MIGHT NOT CORRESPOND"
)
print
(
"TO CLUSTER 0 ON LEVEL 13. THE CALCULATED CLUSTER MATRIX IS: "
)
print
(
res_df
)
print
(
hierarchy_matrix
)
print
(
"AND THESE ARE THE DISTANCES THE HIERARCHY LEVELS CORRESPOND TO:"
)
print
(
level_distance_lookup
)
return
(
res_df
,
level_distance_lookup
)
return
(
hierarchy_matrix
,
level_distance_lookup
)
if
__name__
==
'__main__'
:
print
(
"hierarchy matrix test"
)
R
=
np
.
random
.
rand
(
90
).
reshape
(
30
,
3
)
P
=
np
.
zeros
(
90
).
reshape
(
30
,
3
)
...
...
@@ -186,11 +194,18 @@ if __name__ == '__main__':
M
,
L
=
calculate_hierarchy_matrix
(
pdf
)
print
(
M
)
from
impetuous.visualisation
import
*
X
,
Y
=
[],[]
X
,
Y
,
W
,
Z
=
[],[],
[],[]
for
item
in
L
.
items
():
X
.
append
(
item
[
1
][
1
])
W
.
append
(
item
[
1
][
1
])
Z
.
append
(
item
[
1
][
2
])
Y
.
append
(
len
(
set
(
M
.
loc
[
item
[
0
]].
values
)))
from
bokeh.plotting
import
show
show
(
bscatter
(
X
,
Y
,
title
=
'cluster coordination function'
)
)
#
# SHOW THE COODINATION AND SEGREGATION FUNCTIONS
# BOTH ARE WELL KNOWN FROM STATISTICAL PHYSICS
show
(
plotter
(
[
X
,
W
]
,
[
Y
,
Z
]
,
[
nice_colors
[
0
],
nice_colors
[
2
]]
,
legends
=
[
'segregation'
,
'coordination'
],
axis_labels
=
[
'distance'
,
'Number'
])
)
src/impetuous/visualisation.py
浏览文件 @
fa5aefc0
...
...
@@ -77,7 +77,7 @@ def bscatter ( X , Y , additional_dictionary=None , title='' , color='#ff0000' ,
return
(
p
)
def
plotter
(
x
=
np
.
random
.
rand
(
10
)
,
y
=
np
.
random
.
rand
(
10
)
,
colors
=
'#ff0000'
,
def
plotter
(
x
=
np
.
random
.
rand
(
10
)
,
y
=
np
.
random
.
rand
(
10
)
,
colors
=
'#ff0000'
,
title
=
''
,
legends
=
None
,
axis_labels
=
None
,
bSave
=
False
,
name
=
'scatter.html'
):
from
bokeh.plotting
import
output_file
,
show
,
save
...
...
@@ -91,7 +91,7 @@ def plotter ( x = np.random.rand(10) , y = np.random.rand(10) , colors = '#ff000
x_
,
y_
,
color
=
x
[
i
]
,
y
[
i
]
,
colors
[
i
]
if
list_typecheck
([
legends
,
axis_labels
],
'list'
,
all
):
label
=
legends
[
i
]
p
=
bscatter
(
x_
,
y_
,
color
=
color
,
p
=
p
,
legend_label
=
label
,
axis_labels
=
axis_labels
)
p
=
bscatter
(
x_
,
y_
,
color
=
color
,
p
=
p
,
legend_label
=
label
,
axis_labels
=
axis_labels
)
else
:
p
=
bscatter
(
x_
,
y_
,
color
=
color
,
p
=
p
)
outp
(
p
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录