Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Ian Bowman
Hippocampus Gene Expression Atlas -- CIC Data Integrated Software
Commits
48633f35
Commit
48633f35
authored
7 years ago
by
Ian Bowman
Browse files
Options
Download
Email Patches
Plain Diff
Calculates matrix column totals
parent
b29529db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
src/hpf_plot.py
src/hpf_plot.py
+8
-0
tests/test_hpf_plot.py
tests/test_hpf_plot.py
+24
-0
No files found.
src/hpf_plot.py
View file @
48633f35
...
...
@@ -449,3 +449,11 @@ def new_indices(roi_name_npa, sorted_cmt_str_lst):
new_indices
.
append
(
roi_name_npa
.
tolist
().
index
(
roi_name
))
return
new_indices
#returns total numbers at various columns
def
col_totals
(
ctx_mat_npa
):
col_totals
=
[]
for
col
in
xrange
(
ctx_mat_npa
.
shape
[
1
]):
col_totals
.
append
(
np
.
sum
(
ctx_mat_npa
[:,
col
]))
return
col_totals
This diff is collapsed.
Click to expand it.
tests/test_hpf_plot.py
View file @
48633f35
...
...
@@ -3,6 +3,7 @@ from src import hpf_plot, hpf_utils
import
os
import
numpy
as
np
import
bct
import
math
class
TestHpfPlot
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
@@ -16,6 +17,29 @@ class TestHpfPlot(unittest.TestCase):
[
1
,
0
,
0
,
0
],
[
1
,
0
,
1
,
0
]])
def
test_col_totals
(
self
):
y_bounds
=
[
-
0.5
,
1.5
,
4.5
]
exp_mat_col_totals
=
[
2
,
1
,
2
,
0
]
self
.
assertEqual
(
exp_mat_col_totals
,
hpf_plot
.
col_totals
(
self
.
ctx_mat_npa
))
exp_submat_col_totals
=
[[
0
,
0
,
1
,
0
],
[
2
,
1
,
1
,
0
]]
lower_bound
=
-
1
submat_col_totals
=
[]
for
idx
,
y_bound
in
enumerate
(
y_bounds
):
upper_bound
=
int
(
math
.
floor
(
y_bound
))
if
upper_bound
>
0
:
assert
(
lower_bound
>=
0
)
submat_col_totals
.
append
(
hpf_plot
.
col_totals
(
self
.
ctx_mat_npa
[
lower_bound
:
upper_bound
,:]))
lower_bound
=
max
(
upper_bound
,
0
)
self
.
assertEqual
(
exp_submat_col_totals
,
submat_col_totals
)
def
test_sparse_mat_rep
(
self
):
exp_sparse_mat_rep
=
\
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment