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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pswain
omniplate
Commits
396a3d8c
Commit
396a3d8c
authored
7 months ago
by
pswain
Browse files
Options
Downloads
Patches
Plain Diff
change(ignorewells): takes a dict of exps
parent
b9247712
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
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(
@clogger.log
def
ignorewells
(
self
,
exclude
=
[],
experiments
=
"
all
"
,
experimentincludes
=
False
,
experimentexcludes
=
False
,
clearall
=
False
,
):
def
ignorewells
(
self
,
exclude
=
None
):
"""
Ignore the wells specified in any future processing.
...
...
@@ -143,53 +136,40 @@ def ignorewells(
Parameters
---------
exclude: list of strings
List of labels of wells on the plate to be excluded.
experiments: string or list of strings
The experiments to include.
experimentincludes: string, optional
Selects only experiments that include the specified string in their
name.
experimentexcludes: string, optional
Ignores experiments that include the specified string in their
name.
exclude: list of strings or dict
If there is only a single experiment, exclude is a list of labels
of wells to be ignored.
If there are multiple experiments, exclude is a dict with experiment
names as keys and a list of wells as items.
Example
-------
>>>
p
.
ignorewells
([
'
A1
'
,
'
C2
'
])
>>>
p
.
ignorewells
({
"
exp1
"
:
[
"
A1
"
],
"
exp2
"
:
[
"
C3
"
,
"
C4
"
]})
"""
if
gu
.
islistempty
(
exclude
)
:
if
exclude
is
None
:
return
else
:
# exclude should be a list of lists
if
isinstance
(
exclude
,
str
):
exclude
=
[
gu
.
makelist
(
exclude
)]
elif
isinstance
(
exclude
[
0
],
str
):
exclude
=
[
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
:
if
len
(
self
.
allexperiments
)
==
1
and
not
isinstance
(
exclude
,
dict
):
# make exclude a dict
if
isinstance
(
exclude
,
str
):
exclude
=
{
self
.
allexperiments
[
0
]:
gu
.
makelist
(
exclude
)}
elif
isinstance
(
exclude
,
list
):
exclude
=
{
self
.
allexperiments
[
0
]:
exclude
}
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
for
ex
,
exp
in
zip
(
exclude
,
exps
):
for
ex
p
,
wells
in
exclude
.
items
(
):
# 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
df
=
self
.
r
filt
=
(
df
[
"
experiment
"
]
==
exp
)
&
df
[
"
well
"
].
isin
(
wex
)
...
...
@@ -197,22 +177,12 @@ def ignorewells(
df
=
df
.
reset_index
(
drop
=
True
)
self
.
r
=
df
# store ignoredwells
self
.
progress
[
"
ignoredwells
"
][
exp
]
+=
ex
self
.
progress
[
"
ignoredwells
"
][
exp
]
+=
w
ex
# remove any duplicates
self
.
progress
[
"
ignoredwells
"
][
exp
]
=
list
(
set
(
self
.
progress
[
"
ignoredwells
"
][
exp
])
)
# give warning
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
)
# remake s data frame
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
register
or
sign in
to comment