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
fa1283b6
Commit
fa1283b6
authored
3 years ago
by
Blaise Li
Browse files
Options
Downloads
Patches
Plain Diff
Handle new input and border cases.
parent
0390d53d
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
+18
-6
18 additions, 6 deletions
libcodonusage/libcodonusage.py
with
19 additions
and
7 deletions
libcodonusage/__init__.py
+
1
−
1
View file @
fa1283b6
__copyright__
=
"
Copyright (C) 2022 Blaise Li
"
__licence__
=
"
GNU GPLv3
"
__version__
=
0.
6
__version__
=
0.
7
from
.libcodonusage
import
(
aa2colour
,
codon2aa
,
...
...
This diff is collapsed.
Click to expand it.
libcodonusage/libcodonusage.py
+
18
−
6
View file @
fa1283b6
...
...
@@ -86,7 +86,8 @@ with Path(bgraphs.colorschemes._scheme_dir).joinpath(
aa2colour
=
{
**
colscheme
[
"
colors
"
],
"
*
"
:
'
#000000
'
}
def
load_counts_table
(
table_path
,
index_col
=
"
old_locus_tag
"
):
def
load_counts_table
(
table_path
,
index_col
=
"
old_locus_tag
"
,
index_unique
=
True
):
"""
Load a table or pre-computed codon counts at *table_path*.
...
...
@@ -94,9 +95,14 @@ def load_counts_table(table_path, index_col="old_locus_tag"):
Besides the columns containing the counts for each codon,
there are other columns containing various pieces of information
regarding those genes.
If *index_unique* is True, a ValueError error will be raised if
some elements in the the column *index_col* are not unique.
"""
render_md
(
f
"
Loading data from [
{
table_path
}
](
{
table_path
}
)...
\n
"
)
codon_counts
=
pd
.
read_table
(
table_path
,
index_col
=
index_col
)
if
index_unique
and
not
(
codon_counts
.
index
.
is_unique
):
raise
ValueError
(
f
"
Index
{
index_col
}
contains repeated values.
\n
"
)
nb_genes
=
len
(
codon_counts
)
render_md
(
f
"""
...
...
@@ -144,9 +150,12 @@ def compute_criteria(codon_counts):
display
(
criteria
.
agg
(
sum
))
render_md
(
"
Upset plot of the non-empty categories:
\n\n
"
)
fig
=
plt
.
figure
()
UpSet
(
from_indicators
(
*
[
criteria
.
columns
],
data
=
criteria
),
show_counts
=
True
).
plot
(
fig
=
fig
)
try
:
UpSet
(
from_indicators
(
*
[
criteria
.
columns
],
data
=
criteria
),
show_counts
=
True
).
plot
(
fig
=
fig
)
except
AttributeError
:
pass
display
(
fig
)
plt
.
close
(
fig
)
gene_sets
=
{
...
...
@@ -261,13 +270,16 @@ might be excluded.
return
criteria
def
make_counts_only
(
counts_table
):
def
make_counts_only
(
counts_table
,
seq_id_kw
=
"
locus_tag
"
,
alt_tag_kw
=
"
old_locus_tag
"
):
"""
Integrate
"
informative
"
columns of *counts_table* into the index.
"""
# To ensure a stable order:
ref_info_cols
=
[
"
old_locus_tag
"
,
"
locus_tag
"
,
"
length
"
,
alt_tag_kw
,
seq_id_kw
,
"
start
"
,
"
end
"
,
"
length
"
,
"
start_codon
"
,
"
expected_start_aa
"
,
"
first_stop
"
,
"
nb_stops
"
,
"
start_upstream
"
,
"
end_downstream
"
]
# To ensure no info columns are lost:
...
...
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