Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HPyloriDegradosomeAnalysis
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IAH public
HPyloriDegradosomeAnalysis
Commits
a2bc2160
Commit
a2bc2160
authored
4 years ago
by
Dmitry Ershov
Browse files
Options
Downloads
Patches
Plain Diff
Solve issue with normalizing if total particle count is 0
parent
41752e13
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/2_test_assign_particles.py
+1
-1
1 addition, 1 deletion
examples/2_test_assign_particles.py
lib/assign_particles.py
+18
-8
18 additions, 8 deletions
lib/assign_particles.py
with
19 additions
and
9 deletions
examples/2_test_assign_particles.py
+
1
−
1
View file @
a2bc2160
...
@@ -35,7 +35,7 @@ data_dir = os.path.join( PROJECT_ROOT_DIR, 'data' )
...
@@ -35,7 +35,7 @@ data_dir = os.path.join( PROJECT_ROOT_DIR, 'data' )
datasets_df
=
pd
.
read_csv
(
data_dir
+
'
/datasets_example.csv
'
)
datasets_df
=
pd
.
read_csv
(
data_dir
+
'
/datasets_example.csv
'
)
selected_data_df
=
datasets_df
[
selected_data_df
=
datasets_df
[
(
datasets_df
[
'
data_lbl
'
]
==
'
data_set_2_od
'
)
(
datasets_df
[
'
data_lbl
'
]
==
'
data_set_2_od
'
)
&
(
datasets_df
[
'
cond
'
]
==
'
WT
'
)
#
& (datasets_df['cond']=='WT')
]
]
all_cells
,
all_particles
,
all_heatmap_data
=
al
.
assign_particles_to_nuclei
(
data_dir
,
selected_data_df
)
all_cells
,
all_particles
,
all_heatmap_data
=
al
.
assign_particles_to_nuclei
(
data_dir
,
selected_data_df
)
...
...
This diff is collapsed.
Click to expand it.
lib/assign_particles.py
+
18
−
8
View file @
a2bc2160
...
@@ -237,17 +237,27 @@ def show_quick_stats(all_cells, all_particles ):
...
@@ -237,17 +237,27 @@ def show_quick_stats(all_cells, all_particles ):
for
mut_str
in
all_particles
[
'
mut
'
].
unique
():
for
mut_str
in
all_particles
[
'
mut
'
].
unique
():
print
(
10
*
'
-
'
+
mut_str
+
10
*
'
-
'
)
print
(
10
*
'
-
'
+
mut_str
+
10
*
'
-
'
)
mut_df
=
all_particles
[
(
all_particles
[
'
mut
'
]
==
mut_str
)
]
for
tt
in
all_particles
[
'
t
'
].
unique
():
sub_df
=
all_particles
[
(
all_particles
[
'
mut
'
]
==
mut_str
)
&
(
all_particles
[
'
t
'
]
==
tt
)
]
for
tt
in
mut_df
[
'
t
'
].
unique
():
n0
=
sub_df
[
sub_df
[
'
p_rel_pos
'
]
==
0
].
shape
[
0
]
mut_t_df
=
mut_df
[
mut_df
[
'
t
'
]
==
tt
]
n1
=
sub_df
[
sub_df
[
'
p_rel_pos
'
]
==
1
].
shape
[
0
]
n0
=
mut_t_df
[
mut_t_df
[
'
p_rel_pos
'
]
==
0
].
shape
[
0
]
n1
=
mut_t_df
[
mut_t_df
[
'
p_rel_pos
'
]
==
1
].
shape
[
0
]
n
=
n0
+
n1
n
=
n0
+
n1
cur_nparticles
=
len
(
sub_df
)
cur_nparticles
=
len
(
mut_t_df
)
if
cur_nparticles
==
0
:
print
(
(
'
%s
'
%
tt
).
center
(
10
,
'
'
)
+
(
'
%s
'
%
cur_nparticles
).
center
(
20
,
'
'
)
+
(
'
%s
'
%
n
).
center
(
20
,
'
'
)
+
(
'
0 particles; cannot normalize by 0.
'
)
)
continue
# if total count is above 0, continue with normalization
fr
=
n
/
cur_nparticles
fr
=
n
/
cur_nparticles
fr_corr
=
fr
/
normalize_tip_counts_by
fr_corr
=
fr
/
normalize_tip_counts_by
cur_od
=
sub
_df
[
'
od
'
].
unique
()
cur_od
=
mut_t
_df
[
'
od
'
].
unique
()
# print( 'T: %s \t N foci total: %s \t N foci at 2 poles: %s \t fraction: %0.2f'%(tt, cur_nparticles, n, fr ) )
# print( 'T: %s \t N foci total: %s \t N foci at 2 poles: %s \t fraction: %0.2f'%(tt, cur_nparticles, n, fr ) )
print
(
(
'
%s
'
%
tt
).
center
(
10
,
'
'
)
+
print
(
(
'
%s
'
%
tt
).
center
(
10
,
'
'
)
+
(
'
%s
'
%
cur_nparticles
).
center
(
20
,
'
'
)
+
(
'
%s
'
%
cur_nparticles
).
center
(
20
,
'
'
)
+
(
'
%s
'
%
n
).
center
(
20
,
'
'
)
+
(
'
%s
'
%
n
).
center
(
20
,
'
'
)
+
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment