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
No related tags found
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
class
LineageProcessParameters
(
ParametersABC
):
"""
Parameters.
"""
"""
Parameters
- none are necessary
.
"""
_defaults
=
{}
...
...
@@ -21,7 +21,7 @@ class LineageProcess(PostProcessABC):
"""
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
):
...
...
@@ -35,7 +35,7 @@ class LineageProcess(PostProcessABC):
lineage
:
np
.
ndarray
,
*
args
,
):
"""
Implement method required by PostProcessABC.
"""
"""
Implement method required by PostProcessABC
- undefined
.
"""
pass
@classmethod
...
...
@@ -47,9 +47,9 @@ class LineageProcess(PostProcessABC):
**
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
)
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 (
class
buddingsParameters
(
LineageProcessParameters
):
"""
Parameter class to obtain budding events.
Parameters
----------
LineageProcessParameters : lineage_location
Location of lineage matrix to be used for calculations.
"""
Parameter class to obtain budding events.
Examples
--------
FIXME: Add docs.
Define the location of lineage information in the h5 file.
"""
...
...
@@ -31,45 +25,44 @@ class buddingsParameters(LineageProcessParameters):
class
buddings
(
LineageProcess
):
"""
Calculate buddings in a trap assuming one mother per trap
returns a pandas series with the buddings.
Calculate buddings in a trap assuming one mother per trap.
Return a pandas series with the buddings.
We define a budding event as
t
he
moment in which a bud was
identified
for
the first time, even if the bud is not considered one until later
in the experiment.
We define a budding event as
w
he
n a bud is first
identified
.
This bud may not be considered a bud until later
in the experiment.
"""
def
__init__
(
self
,
parameters
:
buddingsParameters
):
"""
Initialise buddings.
"""
super
().
__init__
(
parameters
)
def
run
(
self
,
signal
:
pd
.
DataFrame
,
lineage
:
np
.
ndarray
=
None
)
->
pd
.
DataFrame
:
"""
TODO.
"""
lineage
=
lineage
or
self
.
lineage
# 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
# select traps and mother cells in a given signal
traps_mothers
:
t
.
Dict
[
tuple
,
list
]
=
{
tuple
(
mo
):
[]
for
mo
in
lineage
[:,
:
2
]
if
tuple
(
mo
)
in
signal
.
index
}
for
trap
,
mother
,
daughter
in
lineage
:
if
(
trap
,
mother
)
in
traps_mothers
.
keys
():
traps_mothers
[(
trap
,
mother
)].
append
(
daughter
)
mothers
=
signal
.
loc
[
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
(
np
.
zeros
((
mothers
.
shape
[
0
],
signal
.
shape
[
1
])).
astype
(
bool
),
index
=
mothers
.
index
,
columns
=
signal
.
columns
,
)
buddings
.
columns
.
names
=
[
"
timepoint
"
]
# Fill the budding events
# get time of first appearance for every cell using Pandas
fvi
=
signal
.
apply
(
lambda
x
:
x
.
first_valid_index
(),
axis
=
1
)
# fill the budding events
for
mother_id
,
daughters
in
traps_mothers
.
items
():
daughters_idx
=
set
(
fvi
.
loc
[
...
...
@@ -82,5 +75,4 @@ class buddings(LineageProcess):
mother_id
,
daughters_idx
,
]
=
True
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