Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alibylite
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
aliby
alibylite
Commits
5cf6da46
Commit
5cf6da46
authored
1 year ago
by
pswain
Browse files
Options
Downloads
Patches
Plain Diff
minor doc changes
parent
90a06eec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/postprocessor/core/lineageprocess.py
+5
-5
5 additions, 5 deletions
src/postprocessor/core/lineageprocess.py
src/postprocessor/core/reshapers/buddings.py
+16
-24
16 additions, 24 deletions
src/postprocessor/core/reshapers/buddings.py
with
21 additions
and
29 deletions
src/postprocessor/core/lineageprocess.py
+
5
−
5
View file @
5cf6da46
...
@@ -12,7 +12,7 @@ from postprocessor.core.abc import PostProcessABC
...
@@ -12,7 +12,7 @@ from postprocessor.core.abc import PostProcessABC
class
LineageProcessParameters
(
ParametersABC
):
class
LineageProcessParameters
(
ParametersABC
):
"""
Parameters.
"""
"""
Parameters
- none are necessary
.
"""
_defaults
=
{}
_defaults
=
{}
...
@@ -21,7 +21,7 @@ class LineageProcess(PostProcessABC):
...
@@ -21,7 +21,7 @@ class LineageProcess(PostProcessABC):
"""
"""
To analyse lineage data.
To analyse lineage data.
Currently bare bones, but extracts lineage information from a
s
ignal or
a
Cells object.
Currently bare bones, but extracts lineage information from a
S
ignal or Cells object.
"""
"""
def
__init__
(
self
,
parameters
:
LineageProcessParameters
):
def
__init__
(
self
,
parameters
:
LineageProcessParameters
):
...
@@ -35,7 +35,7 @@ class LineageProcess(PostProcessABC):
...
@@ -35,7 +35,7 @@ class LineageProcess(PostProcessABC):
lineage
:
np
.
ndarray
,
lineage
:
np
.
ndarray
,
*
args
,
*
args
,
):
):
"""
Implement method required by PostProcessABC.
"""
"""
Implement method required by PostProcessABC
- undefined
.
"""
pass
pass
@classmethod
@classmethod
...
@@ -47,9 +47,9 @@ class LineageProcess(PostProcessABC):
...
@@ -47,9 +47,9 @@ class LineageProcess(PostProcessABC):
**
kwargs
,
**
kwargs
,
):
):
"""
"""
Override PostProces
s
.as_function
class
method.
Override PostProces
ABC
.as_function method.
Lineage functions require lineage information to be
passed if
run as functions.
Lineage functions require lineage information to be run as functions.
"""
"""
parameters
=
cls
.
default_parameters
(
**
kwargs
)
parameters
=
cls
.
default_parameters
(
**
kwargs
)
return
cls
(
parameters
=
parameters
).
run
(
return
cls
(
parameters
=
parameters
).
run
(
...
...
This diff is collapsed.
Click to expand it.
src/postprocessor/core/reshapers/buddings.py
+
16
−
24
View file @
5cf6da46
...
@@ -13,16 +13,10 @@ from postprocessor.core.lineageprocess import (
...
@@ -13,16 +13,10 @@ from postprocessor.core.lineageprocess import (
class
buddingsParameters
(
LineageProcessParameters
):
class
buddingsParameters
(
LineageProcessParameters
):
"""
Parameter class to obtain budding events.
"""
Parameter class to obtain budding events.
Parameters
----------
LineageProcessParameters : lineage_location
Location of lineage matrix to be used for calculations.
Examples
Define the location of lineage information in the h5 file.
--------
FIXME: Add docs.
"""
"""
...
@@ -31,45 +25,44 @@ class buddingsParameters(LineageProcessParameters):
...
@@ -31,45 +25,44 @@ class buddingsParameters(LineageProcessParameters):
class
buddings
(
LineageProcess
):
class
buddings
(
LineageProcess
):
"""
"""
Calculate buddings in a trap assuming one mother per trap
Calculate buddings in a trap assuming one mother per trap.
returns a pandas series with the buddings.
Return a pandas series with the buddings.
We define a budding event as
t
he
moment in which a bud was
identified
for
We define a budding event as
w
he
n a bud is first
identified
.
the first time, even if the bud is not considered one until later
in the experiment.
This bud may not be considered a bud until later
in the experiment.
"""
"""
def
__init__
(
self
,
parameters
:
buddingsParameters
):
def
__init__
(
self
,
parameters
:
buddingsParameters
):
"""
Initialise buddings.
"""
super
().
__init__
(
parameters
)
super
().
__init__
(
parameters
)
def
run
(
def
run
(
self
,
signal
:
pd
.
DataFrame
,
lineage
:
np
.
ndarray
=
None
self
,
signal
:
pd
.
DataFrame
,
lineage
:
np
.
ndarray
=
None
)
->
pd
.
DataFrame
:
)
->
pd
.
DataFrame
:
"""
TODO.
"""
lineage
=
lineage
or
self
.
lineage
lineage
=
lineage
or
self
.
lineage
# select traps and mother cells in a given signal
# Get time of first appearance for all cells
fvi
=
signal
.
apply
(
lambda
x
:
x
.
first_valid_index
(),
axis
=
1
)
# Select mother cells in a given dataset
traps_mothers
:
t
.
Dict
[
tuple
,
list
]
=
{
traps_mothers
:
t
.
Dict
[
tuple
,
list
]
=
{
tuple
(
mo
):
[]
for
mo
in
lineage
[:,
:
2
]
if
tuple
(
mo
)
in
signal
.
index
tuple
(
mo
):
[]
for
mo
in
lineage
[:,
:
2
]
if
tuple
(
mo
)
in
signal
.
index
}
}
for
trap
,
mother
,
daughter
in
lineage
:
for
trap
,
mother
,
daughter
in
lineage
:
if
(
trap
,
mother
)
in
traps_mothers
.
keys
():
if
(
trap
,
mother
)
in
traps_mothers
.
keys
():
traps_mothers
[(
trap
,
mother
)].
append
(
daughter
)
traps_mothers
[(
trap
,
mother
)].
append
(
daughter
)
mothers
=
signal
.
loc
[
mothers
=
signal
.
loc
[
set
(
signal
.
index
).
intersection
(
traps_mothers
.
keys
())
set
(
signal
.
index
).
intersection
(
traps_mothers
.
keys
())
]
]
#
C
reate a new dataframe with dimensions (n_mother_cells * n_timepoints)
#
c
reate a new dataframe with dimensions (n_mother_cells * n_timepoints)
buddings
=
pd
.
DataFrame
(
buddings
=
pd
.
DataFrame
(
np
.
zeros
((
mothers
.
shape
[
0
],
signal
.
shape
[
1
])).
astype
(
bool
),
np
.
zeros
((
mothers
.
shape
[
0
],
signal
.
shape
[
1
])).
astype
(
bool
),
index
=
mothers
.
index
,
index
=
mothers
.
index
,
columns
=
signal
.
columns
,
columns
=
signal
.
columns
,
)
)
buddings
.
columns
.
names
=
[
"
timepoint
"
]
buddings
.
columns
.
names
=
[
"
timepoint
"
]
# get time of first appearance for every cell using Pandas
# Fill the budding events
fvi
=
signal
.
apply
(
lambda
x
:
x
.
first_valid_index
(),
axis
=
1
)
# fill the budding events
for
mother_id
,
daughters
in
traps_mothers
.
items
():
for
mother_id
,
daughters
in
traps_mothers
.
items
():
daughters_idx
=
set
(
daughters_idx
=
set
(
fvi
.
loc
[
fvi
.
loc
[
...
@@ -82,5 +75,4 @@ class buddings(LineageProcess):
...
@@ -82,5 +75,4 @@ class buddings(LineageProcess):
mother_id
,
mother_id
,
daughters_idx
,
daughters_idx
,
]
=
True
]
=
True
return
buddings
return
buddings
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