Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
omniplate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pswain
omniplate
Commits
396a3d8c
Commit
396a3d8c
authored
Aug 2, 2024
by
pswain
Browse files
Options
Downloads
Patches
Plain Diff
change(ignorewells): takes a dict of exps
parent
b9247712
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
code/omniplate/omwells.py
+31
-61
31 additions, 61 deletions
code/omniplate/omwells.py
with
31 additions
and
61 deletions
code/omniplate/omwells.py
+
31
−
61
View file @
396a3d8c
...
@@ -127,14 +127,7 @@ def showwells(
...
@@ -127,14 +127,7 @@ def showwells(
@clogger.log
@clogger.log
def
ignorewells
(
def
ignorewells
(
self
,
exclude
=
None
):
self
,
exclude
=
[],
experiments
=
"
all
"
,
experimentincludes
=
False
,
experimentexcludes
=
False
,
clearall
=
False
,
):
"""
"""
Ignore the wells specified in any future processing.
Ignore the wells specified in any future processing.
...
@@ -143,53 +136,40 @@ def ignorewells(
...
@@ -143,53 +136,40 @@ def ignorewells(
Parameters
Parameters
---------
---------
exclude: list of strings
exclude: list of strings or dict
List of labels of wells on the plate to be excluded.
If there is only a single experiment, exclude is a list of labels
experiments: string or list of strings
of wells to be ignored.
The experiments to include.
If there are multiple experiments, exclude is a dict with experiment
experimentincludes: string, optional
names as keys and a list of wells as items.
Selects only experiments that include the specified string in their
name.
experimentexcludes: string, optional
Ignores experiments that include the specified string in their
name.
Example
Example
-------
-------
>>>
p
.
ignorewells
([
'
A1
'
,
'
C2
'
])
>>>
p
.
ignorewells
([
'
A1
'
,
'
C2
'
])
>>>
p
.
ignorewells
({
"
exp1
"
:
[
"
A1
"
],
"
exp2
"
:
[
"
C3
"
,
"
C4
"
]})
"""
"""
if
gu
.
islistempty
(
exclude
)
:
if
exclude
is
None
:
return
return
else
:
else
:
# exclude should be a list of lists
if
len
(
self
.
allexperiments
)
==
1
and
not
isinstance
(
exclude
,
dict
):
# make exclude a dict
if
isinstance
(
exclude
,
str
):
if
isinstance
(
exclude
,
str
):
exclude
=
[
gu
.
makelist
(
exclude
)]
exclude
=
{
self
.
allexperiments
[
0
]:
gu
.
makelist
(
exclude
)}
elif
isinstance
(
exclude
[
0
],
str
):
elif
isinstance
(
exclude
,
list
):
exclude
=
[
exclude
]
exclude
=
{
self
.
allexperiments
[
0
]:
exclude
}
# check consistency
if
len
(
self
.
allexperiments
)
==
1
:
exps
=
self
.
allexperiments
if
exps
[
0
]
==
"
combined
"
:
pass
else
:
exps
=
sunder
.
getset
(
self
,
experiments
,
experimentincludes
,
experimentexcludes
,
"
experiment
"
,
nonull
=
True
,
)
if
len
(
exclude
)
!=
len
(
exps
)
and
not
clearall
:
raise
errors
.
IgnoreWells
(
"
Either a list of wells to exclude for a particular
\n
"
"
experiment or a list of experiments must be given.
"
)
else
:
else
:
raise
errors
.
IgnoreWells
(
f
"
{
exclude
}
is in the wrong format.
"
)
if
isinstance
(
exclude
,
dict
):
# make each value a list
exclude
=
{
key
:
[
value
]
if
isinstance
(
value
,
str
)
else
value
for
key
,
value
in
exclude
.
items
()
}
# drop wells
# drop wells
for
ex
,
exp
in
zip
(
exclude
,
exps
):
for
ex
p
,
wells
in
exclude
.
items
(
):
# wells cannot be ignored twice
# wells cannot be ignored twice
wex
=
list
(
set
(
ex
)
-
set
(
self
.
progress
[
"
ignoredwells
"
][
exp
]))
wex
=
list
(
set
(
wells
)
-
set
(
self
.
progress
[
"
ignoredwells
"
][
exp
])
)
# drop data from ignored wells
# drop data from ignored wells
df
=
self
.
r
df
=
self
.
r
filt
=
(
df
[
"
experiment
"
]
==
exp
)
&
df
[
"
well
"
].
isin
(
wex
)
filt
=
(
df
[
"
experiment
"
]
==
exp
)
&
df
[
"
well
"
].
isin
(
wex
)
...
@@ -197,22 +177,12 @@ def ignorewells(
...
@@ -197,22 +177,12 @@ def ignorewells(
df
=
df
.
reset_index
(
drop
=
True
)
df
=
df
.
reset_index
(
drop
=
True
)
self
.
r
=
df
self
.
r
=
df
# store ignoredwells
# store ignoredwells
self
.
progress
[
"
ignoredwells
"
][
exp
]
+=
ex
self
.
progress
[
"
ignoredwells
"
][
exp
]
+=
w
ex
# remove any duplicates
# remove any duplicates
self
.
progress
[
"
ignoredwells
"
][
exp
]
=
list
(
self
.
progress
[
"
ignoredwells
"
][
exp
]
=
list
(
set
(
self
.
progress
[
"
ignoredwells
"
][
exp
])
set
(
self
.
progress
[
"
ignoredwells
"
][
exp
])
)
)
# give warning
# remake s data frame
anycorrections
=
np
.
count_nonzero
(
self
.
sc
[
[
col
for
col
in
self
.
sc
.
columns
if
"
correct
"
in
col
]
].
values
)
if
np
.
any
(
anycorrections
):
print
(
"
Warning: you have ignored wells after correcting
\n
"
"
the data. It is best to ignorewells first, before
\n
"
"
running any analysis.
"
)
# remake summary data
admin
.
update_s
(
self
)
admin
.
update_s
(
self
)
else
:
raise
errors
.
IgnoreWells
(
f
"
{
exclude
}
is in the wrong format.
"
)
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
sign in
to comment