Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PlottingOnGenome
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Zimmermann-Kogadeeva Group
PlottingOnGenome
Commits
ee445b70
Commit
ee445b70
authored
3 weeks ago
by
Bartosz Bartmanski
Browse files
Options
Downloads
Patches
Plain Diff
Improved __repr__ for Insert class. Changed Insert.get behaviour.
parent
7971cab6
No related branches found
Branches containing commit
Tags
0.3.4
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/plotting_on_genome/insert.py
+4
-1
4 additions, 1 deletion
src/plotting_on_genome/insert.py
src/plotting_on_genome/inserts_dict.py
+14
-11
14 additions, 11 deletions
src/plotting_on_genome/inserts_dict.py
streamlit_app.py
+9
-11
9 additions, 11 deletions
streamlit_app.py
with
27 additions
and
23 deletions
src/plotting_on_genome/insert.py
+
4
−
1
View file @
ee445b70
...
...
@@ -64,9 +64,12 @@ class Insert(object):
return
(
"
Insert(
"
f
"
seq_id=
{
self
.
seq_id
}
,
"
f
"
idx=
{
self
.
idx
}
,
"
f
"
start=
{
self
.
start
}
,
"
f
"
end=
{
self
.
end
}
,
"
f
"
hit_id=
{
self
.
hit_id
}
)
"
f
"
hit_id=
{
self
.
hit_id
}
,
"
f
"
coverage=
{
self
.
coverage
:
.
2
f
}
,
"
f
"
matched=
{
self
.
matched
}
)
"
)
def
__len__
(
self
):
...
...
This diff is collapsed.
Click to expand it.
src/plotting_on_genome/inserts_dict.py
+
14
−
11
View file @
ee445b70
...
...
@@ -287,11 +287,12 @@ class InsertsDict(object):
def
get
(
self
,
seq_id_or_idx
=
None
,
insert_type
s
=
"
both
"
,
insert_type
=
"
both
"
,
filter_threshold
=
None
,
):
assert
insert_types
in
(
"
matched
"
,
"
unmatched
"
,
"
both
"
)
seq_id_or_idx
=
seq_id_or_idx
or
self
.
seq_ids
assert
insert_type
in
(
"
matched
"
,
"
unmatched
"
,
"
both
"
)
if
seq_id_or_idx
is
None
:
seq_id_or_idx
=
self
.
seq_ids
inserts
=
self
.
__getitem__
(
seq_id_or_idx
)
# Apply the coverage filter
...
...
@@ -301,14 +302,14 @@ class InsertsDict(object):
inserts
=
[
x
for
x
in
inserts
if
x
.
coverage
>
filter_threshold
]
if
insert_type
s
==
"
matched
"
:
if
insert_type
==
"
matched
"
:
inserts
=
[
x
for
x
in
inserts
if
x
.
matched
]
elif
insert_type
s
==
"
unmatched
"
:
elif
insert_type
==
"
unmatched
"
:
inserts
=
[
x
for
x
in
inserts
if
not
x
.
matched
]
return
inserts
def
to_dataframe
(
self
,
insert_type
s
=
"
both
"
,
filter_threshold
=
None
):
def
to_dataframe
(
self
,
insert_type
=
"
both
"
,
filter_threshold
=
None
):
return
pd
.
DataFrame
(
[
(
...
...
@@ -322,7 +323,7 @@ class InsertsDict(object):
x
.
coverage
,
)
for
x
in
self
.
get
(
insert_type
s
=
insert_type
s
,
filter_threshold
=
filter_threshold
insert_type
=
insert_type
,
filter_threshold
=
filter_threshold
)
],
columns
=
(
...
...
@@ -340,11 +341,11 @@ class InsertsDict(object):
def
genes_to_dataframe
(
self
,
seq_id_or_idx
=
None
,
insert_type
s
=
"
both
"
,
insert_type
=
"
both
"
,
filter_threshold
=
None
,
buffer
=
4000
,
):
inserts
=
self
.
get
(
seq_id_or_idx
,
insert_type
s
,
filter_threshold
)
inserts
=
self
.
get
(
seq_id_or_idx
,
insert_type
,
filter_threshold
)
if
len
(
inserts
):
df_genes
=
pd
.
concat
(
...
...
@@ -415,7 +416,9 @@ class InsertsDict(object):
def
plot
(
self
,
inserts
=
None
,
seq_id_or_idxs
=
None
,
insert_type
=
"
both
"
,
filter_threshold
=
None
,
show_labels
=
True
,
col1
=
"
#8DDEF7
"
,
col2
=
"
#CFFCCC
"
,
...
...
@@ -426,7 +429,7 @@ class InsertsDict(object):
if
"
figsize
"
not
in
kwargs
:
kwargs
[
"
figsize
"
]
=
(
10
,
8
)
inserts
=
inserts
or
[]
inserts
=
self
.
get
(
seq_id_or_idxs
,
insert_type
,
filter_threshold
)
rec
=
self
.
_get_graphic_records_genome
(
inserts
,
show_labels
,
col1
,
col2
)
if
backend
==
"
matplotlib
"
:
...
...
This diff is collapsed.
Click to expand it.
streamlit_app.py
+
9
−
11
View file @
ee445b70
...
...
@@ -5,7 +5,6 @@ from pathlib import Path
from
tempfile
import
TemporaryDirectory
import
matplotlib.pyplot
as
plt
import
pandas
as
pd
import
streamlit
as
st
import
plotting_on_genome
as
pog
...
...
@@ -15,8 +14,8 @@ import plotting_on_genome as pog
if
"
stage
"
not
in
st
.
session_state
:
st
.
session_state
.
stage
=
0
if
"
insert_type
s
"
not
in
st
.
session_state
:
st
.
session_state
.
insert_type
s
=
"
both
"
if
"
insert_type
"
not
in
st
.
session_state
:
st
.
session_state
.
insert_type
=
"
both
"
if
"
workdir
"
not
in
st
.
session_state
:
st
.
session_state
.
workdir
=
None
...
...
@@ -113,7 +112,7 @@ def get_main_inputs():
fwd_suf
=
st
.
text_input
(
"
Forward suffix:
"
,
"
_F
"
,
key
=
"
fwd_suf
"
)
rev_suf
=
st
.
text_input
(
"
Reverse suffix:
"
,
"
_R
"
,
key
=
"
rev_suf
"
)
st
.
session_state
.
insert_type
s
=
st
.
selectbox
(
st
.
session_state
.
insert_type
=
st
.
selectbox
(
"
insert types:
"
,
[
"
both
"
,
"
matched
"
,
"
unmatched
"
]
)
...
...
@@ -143,7 +142,7 @@ def convert_df(df, **kwargs):
def
show_results
():
inserts_all
=
st
.
session_state
.
pipeline
insert_type
s
=
st
.
session_state
.
insert_type
s
insert_type
=
st
.
session_state
.
insert_type
filter_threshold
=
st
.
slider
(
"
Filter threshold:
"
,
0.0
,
1.0
,
0.7
)
...
...
@@ -154,7 +153,7 @@ def show_results():
value
=
4000
,
help
=
"
Number of bases either side of the insert
"
,
)
params
=
dict
(
insert_type
s
=
insert_type
s
,
filter_threshold
=
filter_threshold
)
params
=
dict
(
insert_type
=
insert_type
,
filter_threshold
=
filter_threshold
)
df_inserts
=
inserts_all
.
to_dataframe
(
**
params
)
df_genes
=
inserts_all
.
genes_to_dataframe
(
**
params
,
buffer
=
buffer
)
...
...
@@ -217,15 +216,14 @@ def show_results():
st
.
write
(
f
"
No inserts found for
{
seq_id
}
!
"
)
elif
option
==
"
plot genome
"
:
labels
=
st
.
toggle
(
"
Labels
"
)
inserts
=
[]
if
st
.
toggle
(
"
Plot inserts
"
,
True
):
inserts
=
inserts_all
.
get
(
**
params
)
st
.
write
(
df_inserts
)
labels
=
st
.
toggle
(
"
Labels
"
)
insert_idxs
=
None
if
st
.
toggle
(
"
Plot inserts
"
,
True
)
else
[]
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
10
,
10
*
(
1
+
2
*
labels
)))
ax
=
inserts_all
.
plot
(
inserts
,
show_labels
=
labels
,
ax
=
ax
)
ax
=
inserts_all
.
plot
(
insert
_idx
s
,
show_labels
=
labels
,
ax
=
ax
,
**
params
)
st
.
pyplot
(
fig
,
use_container_width
=
True
)
plt
.
close
()
...
...
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