Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcodonusage
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Blaise LI
libcodonusage
Commits
189af8b9
Commit
189af8b9
authored
3 years ago
by
Blaise Li
Browse files
Options
Downloads
Patches
Plain Diff
Fix violin order. Legend issues.
parent
437a43ec
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
libcodonusage/__init__.py
+1
-1
1 addition, 1 deletion
libcodonusage/__init__.py
libcodonusage/libcodonusage.py
+21
-6
21 additions, 6 deletions
libcodonusage/libcodonusage.py
with
22 additions
and
7 deletions
libcodonusage/__init__.py
+
1
−
1
View file @
189af8b9
__copyright__
=
"
Copyright (C) 2022 Blaise Li
"
__licence__
=
"
GNU GPLv3
"
__version__
=
"
0.
19
"
__version__
=
"
0.
20
"
from
.libcodonusage
import
(
aa2colour
,
aa_usage
,
...
...
This diff is collapsed.
Click to expand it.
libcodonusage/libcodonusage.py
+
21
−
6
View file @
189af8b9
...
...
@@ -19,7 +19,7 @@ import json
from
operator
import
itemgetter
from
pathlib
import
Path
# python3 -m pip install cytoolz
from
cytoolz
import
groupby
,
unique
from
cytoolz
import
concat
,
groupby
,
unique
# To render mardown in a Jupyter notebook on gitlab
from
IPython.core.display
import
display
,
HTML
# python3 -m pip install markdown
...
...
@@ -575,7 +575,7 @@ methionine (M) and tryptophan (W).
render_md
(
"
The following columns contain only NaNs:
"
)
display
(
all_nan_cols
)
render_md
(
"
This likely resulted from a division by zero.
"
)
render_md
(
"
These columns will be excluded
"
)
render_md
(
"
These columns will be excluded
.
"
)
return
(
standardized_usage_biases
.
drop
(
columns
=
all_nan_cols
).
fillna
(
0
),
all_nan_cols
)
...
...
@@ -1118,15 +1118,24 @@ def violin_usage(usage_table, variable, ylabel, hue="aa", axis=None):
long_form
=
to_long_form
(
usage_table
,
ylabel
)
if
axis
is
None
:
_
,
axis
=
plt
.
subplots
(
figsize
=
(
18
,
6
))
do_legend
=
True
else
:
do_legend
=
False
if
hue
==
"
aa
"
:
palette
=
aa2colour
else
:
palette
=
None
sns
.
violinplot
(
x
=
variable
,
y
=
ylabel
,
if
variable
==
"
aa
"
:
order
=
[
aa
for
aa
in
columns_by_aa
.
keys
()]
elif
variable
==
"
codon
"
:
order
=
[
codon
for
(
_
,
codon
)
in
concat
(
columns_by_aa
.
values
())]
else
:
raise
ValueError
(
f
"
variable can only be
'
aa
'
or
'
codon
'
.
\n
"
)
sns
.
violinplot
(
x
=
variable
,
y
=
ylabel
,
order
=
order
,
hue
=
hue
,
palette
=
palette
,
dodge
=
False
,
data
=
long_form
,
ax
=
axis
,
orient
=
"
v
"
,
scale
=
"
count
"
)
plt
.
legend
(
bbox_to_anchor
=
(
1.01
,
1
),
borderaxespad
=
0
)
if
do_legend
:
plt
.
legend
(
bbox_to_anchor
=
(
1.01
,
1
),
borderaxespad
=
0
)
axis
.
set_xticklabels
(
axis
.
get_xticklabels
(),
rotation
=
90
)
return
axis
...
...
@@ -1144,8 +1153,14 @@ def violin_usage_vertical(usage_table, variable, ylabel, hue="aa", axis=None):
palette
=
aa2colour
else
:
palette
=
None
if
variable
==
"
aa
"
:
order
=
[
aa
for
aa
in
columns_by_aa
.
keys
()]
elif
variable
==
"
codon
"
:
order
=
[
codon
for
(
_
,
codon
)
in
concat
(
columns_by_aa
.
values
())]
else
:
raise
ValueError
(
f
"
variable can only be
'
aa
'
or
'
codon
'
.
\n
"
)
sns
.
violinplot
(
y
=
variable
,
x
=
ylabel
,
y
=
variable
,
x
=
ylabel
,
order
=
order
,
hue
=
hue
,
palette
=
palette
,
dodge
=
False
,
data
=
long_form
,
ax
=
axis
,
orient
=
"
h
"
,
scale
=
"
count
"
)
return
axis
...
...
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