Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wela
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Swain Lab
wela
Commits
8752c9ed
Commit
8752c9ed
authored
10 months ago
by
pswain
Browse files
Options
Downloads
Patches
Plain Diff
refactor(bud_to_bud_plot): changes for clarity
parent
ef809724
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/wela/plotting.py
+16
-13
16 additions, 13 deletions
src/wela/plotting.py
with
16 additions
and
13 deletions
src/wela/plotting.py
+
16
−
13
View file @
8752c9ed
...
@@ -609,7 +609,7 @@ def bud_to_bud_plot(
...
@@ -609,7 +609,7 @@ def bud_to_bud_plot(
dl
,
dl
,
colour
=
"
b
"
,
colour
=
"
b
"
,
group
=
None
,
group
=
None
,
n
bin
s
=
None
,
n
o_t_value
s
=
None
,
no_future_buddings
=
1
,
no_future_buddings
=
1
,
return_signal
=
False
,
return_signal
=
False
,
df
=
None
,
df
=
None
,
...
@@ -637,9 +637,9 @@ def bud_to_bud_plot(
...
@@ -637,9 +637,9 @@ def bud_to_bud_plot(
Colour of lines.
Colour of lines.
group: str, optional
group: str, optional
The name of the group to plot.
The name of the group to plot.
n
bin
s: int, optional
n
o_t_value
s: int, optional
The number of time
bins
to partition the interval between
the
The number of time
points into which
to partition the interval between
first and the second
budding event.
budding event
s
.
no_future_buddings: int, optional
no_future_buddings: int, optional
The number of future budding events to include. Default is 1.
The number of future budding events to include. Default is 1.
return_signal: boolean, optional
return_signal: boolean, optional
...
@@ -664,10 +664,10 @@ def bud_to_bud_plot(
...
@@ -664,10 +664,10 @@ def bud_to_bud_plot(
>>>
bud_to_bud_plot
(
4
,
"
flavin
"
,
dl
,
group
=
"
fy4
"
,
filter_func
=
butterworth_filter
)
>>>
bud_to_bud_plot
(
4
,
"
flavin
"
,
dl
,
group
=
"
fy4
"
,
filter_func
=
butterworth_filter
)
"""
"""
if
df
is
None
:
if
df
is
None
:
t
,
signal_data
=
dl
.
get_time_series
(
signal
,
group
=
group
)
_
,
signal_data
=
dl
.
get_time_series
(
signal
,
group
=
group
)
t
,
buddings
=
dl
.
get_time_series
(
"
buddings
"
,
group
=
group
)
t
,
buddings
=
dl
.
get_time_series
(
"
buddings
"
,
group
=
group
)
else
:
else
:
t
,
signal_data
=
dl
.
get_time_series
(
signal
,
group
=
group
,
df
=
df
)
_
,
signal_data
=
dl
.
get_time_series
(
signal
,
group
=
group
,
df
=
df
)
t
,
buddings
=
dl
.
get_time_series
(
"
buddings
"
,
group
=
group
,
df
=
df
)
t
,
buddings
=
dl
.
get_time_series
(
"
buddings
"
,
group
=
group
,
df
=
df
)
if
filter_func
is
not
None
:
if
filter_func
is
not
None
:
signal_data
=
filter_func
(
signal_data
)
signal_data
=
filter_func
(
signal_data
)
...
@@ -684,11 +684,14 @@ def bud_to_bud_plot(
...
@@ -684,11 +684,14 @@ def bud_to_bud_plot(
no_future_buddings_index
=
no_future_buddings
-
1
,
no_future_buddings_index
=
no_future_buddings
-
1
,
)
)
if
local_times
:
if
local_times
:
# find bins for normalised time, between 0 and no_future_buddings
# find values for normalised time between 0 and no_future_buddings
nbins
=
int
(
np
.
median
([
len
(
local_time
)
for
local_time
in
local_times
]))
if
no_t_values
is
None
:
ntbins
=
np
.
linspace
(
0
,
no_future_buddings
,
nbins
)
no_t_values
=
int
(
np
.
median
([
len
(
local_time
)
for
local_time
in
local_times
])
)
t_values
=
np
.
linspace
(
0
,
no_future_buddings
,
no_t_values
)
# interpolate each local signal to make a new signal
# interpolate each local signal to make a new signal
new_signal
=
np
.
nan
*
np
.
ones
((
len
(
local_signals
),
n
bin
s
))
new_signal
=
np
.
nan
*
np
.
ones
((
len
(
local_signals
),
n
o_t_value
s
))
for
i
in
range
(
len
(
local_signals
)):
for
i
in
range
(
len
(
local_signals
)):
s
=
local_signals
[
i
]
s
=
local_signals
[
i
]
# normalise time between 0 and no_future_buddings
# normalise time between 0 and no_future_buddings
...
@@ -696,7 +699,7 @@ def bud_to_bud_plot(
...
@@ -696,7 +699,7 @@ def bud_to_bud_plot(
nt
=
nt
/
nt
[
-
1
]
*
no_future_buddings
nt
=
nt
/
nt
[
-
1
]
*
no_future_buddings
# interpolate into the bins
# interpolate into the bins
new_signal
[
i
,
:]
=
np
.
interp
(
new_signal
[
i
,
:]
=
np
.
interp
(
ntbin
s
,
t_value
s
,
nt
[
~
np
.
isnan
(
s
)],
nt
[
~
np
.
isnan
(
s
)],
s
[
~
np
.
isnan
(
s
)],
s
[
~
np
.
isnan
(
s
)],
left
=
np
.
nan
,
left
=
np
.
nan
,
...
@@ -705,10 +708,10 @@ def bud_to_bud_plot(
...
@@ -705,10 +708,10 @@ def bud_to_bud_plot(
# plot median and percentiles
# plot median and percentiles
if
show_figure
:
if
show_figure
:
plt
.
figure
()
plt
.
figure
()
plt
.
plot
(
ntbin
s
,
np
.
nanmedian
(
new_signal
,
axis
=
0
),
f
"
{
colour
}
.-
"
)
plt
.
plot
(
t_value
s
,
np
.
nanmedian
(
new_signal
,
axis
=
0
),
f
"
{
colour
}
.-
"
)
for
lower
,
upper
in
zip
([
45
,
40
,
35
],
[
55
,
60
,
65
]):
for
lower
,
upper
in
zip
([
45
,
40
,
35
],
[
55
,
60
,
65
]):
plt
.
fill_between
(
plt
.
fill_between
(
ntbin
s
,
t_value
s
,
np
.
nanpercentile
(
new_signal
,
lower
,
axis
=
0
),
np
.
nanpercentile
(
new_signal
,
lower
,
axis
=
0
),
np
.
nanpercentile
(
new_signal
,
upper
,
axis
=
0
),
np
.
nanpercentile
(
new_signal
,
upper
,
axis
=
0
),
alpha
=
0.06
,
alpha
=
0.06
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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