Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aliby-mirror
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
aliby-mirror
Commits
148d92c3
Commit
148d92c3
authored
2 years ago
by
Alán Muñoz
Browse files
Options
Downloads
Patches
Plain Diff
refactor(picker): use shared function for indices
parent
894ba03e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/postprocessor/core/reshapers/picker.py
+27
-14
27 additions, 14 deletions
src/postprocessor/core/reshapers/picker.py
with
27 additions
and
14 deletions
src/postprocessor/core/reshapers/picker.py
+
27
−
14
View file @
148d92c3
from
abc
import
ABC
,
abstractmethod
#
from abc import ABC, abstractmethod
# from copy import copy
# from copy import copy
from
itertools
import
groupby
# from itertools import groupby
from
typing
import
List
,
Tuple
,
Union
# from typing import List, Tuple, Union
import
typing
as
t
from
typing
import
Union
import
igraph
as
ig
#
import igraph as ig
import
numpy
as
np
import
numpy
as
np
import
pandas
as
pd
import
pandas
as
pd
from
agora.abc
import
ParametersABC
from
agora.abc
import
ParametersABC
from
agora.io.cells
import
Cells
from
agora.io.cells
import
Cells
from
utils_find_1st
import
cmp_equal
,
find_1st
from
postprocessor.core.lineageprocess
import
LineageProcess
# from postprocessor.core.functions.tracks import max_nonstop_ntps, max_ntps
from
postprocessor.core.functions.tracks
import
max_nonstop_ntps
,
max_ntps
from
agora.utils.association
import
validate_association
from
agora.utils.association
import
validate_association
from
postprocessor.core.lineageprocess
import
LineageProcess
# from utils_find_1st import cmp_equal, find_1st
class
pickerParameters
(
ParametersABC
):
class
pickerParameters
(
ParametersABC
):
...
@@ -47,11 +51,18 @@ class picker(LineageProcess):
...
@@ -47,11 +51,18 @@ class picker(LineageProcess):
self
.
cells
=
cells
self
.
cells
=
cells
def
pick_by_lineage
(
self
,
signal
,
how
):
def
pick_by_lineage
(
self
,
signal
:
pd
.
DataFrame
,
how
:
str
,
mothers_daughters
:
t
.
Optional
[
np
.
ndarray
]
=
None
,
):
self
.
orig_signals
=
signal
self
.
orig_signals
=
signal
idx
=
np
.
array
(
signal
.
index
.
to_list
())
idx
=
np
.
array
(
signal
.
index
.
to_list
())
mothers_daughters
=
self
.
cells
.
mothers_daughters
if
mothers_daughters
is
None
:
mothers_daughters
=
self
.
cells
.
mothers_daughters
valid_indices
,
valid_lineage
=
[
slice
(
None
)]
*
2
valid_indices
,
valid_lineage
=
[
slice
(
None
)]
*
2
if
how
==
"
mothers
"
:
if
how
==
"
mothers
"
:
...
@@ -60,11 +71,11 @@ class picker(LineageProcess):
...
@@ -60,11 +71,11 @@ class picker(LineageProcess):
)
)
elif
how
==
"
daughters
"
:
elif
how
==
"
daughters
"
:
valid_lineage
,
valid_indices
=
validate_association
(
valid_lineage
,
valid_indices
=
validate_association
(
mothers_daughters
,
idx
,
match_column
=
0
mothers_daughters
,
idx
,
match_column
=
1
)
)
elif
how
==
"
families
"
:
# Mothers and daughters that are still present
elif
how
==
"
families
"
:
# Mothers and daughters that are still present
valid_lineage
,
valid_indices
=
validate_association
(
valid_lineage
,
valid_indices
=
validate_association
(
mothers_daughters
,
idx
,
match_column
=
0
mothers_daughters
,
idx
)
)
idx
=
idx
[
valid_indices
]
idx
=
idx
[
valid_indices
]
...
@@ -72,9 +83,11 @@ class picker(LineageProcess):
...
@@ -72,9 +83,11 @@ class picker(LineageProcess):
return
mothers_daughters
,
idx
return
mothers_daughters
,
idx
def
loc_lineage
(
self
,
signals
:
pd
.
DataFrame
,
how
:
str
):
def
loc_lineage
(
self
,
kymo
:
pd
.
DataFrame
,
how
:
str
,
lineage
=
None
):
_
,
valid_indices
=
self
.
pick_by_lineage
(
signals
,
how
)
_
,
valid_indices
=
self
.
pick_by_lineage
(
return
signals
.
loc
[
valid_indices
]
kymo
,
how
,
mothers_daughters
=
lineage
)
return
kymo
.
loc
[[
tuple
(
x
)
for
x
in
valid_indices
]]
def
pick_by_condition
(
self
,
signals
,
condition
,
thresh
):
def
pick_by_condition
(
self
,
signals
,
condition
,
thresh
):
idx
=
self
.
switch_case
(
signals
,
condition
,
thresh
)
idx
=
self
.
switch_case
(
signals
,
condition
,
thresh
)
...
...
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