Skip to content
Snippets Groups Projects
Commit d83084c7 authored by Blaise Li's avatar Blaise Li
Browse files

Added computing of R4 (sensu Suzuki et al 2005).

This consists in dividing counts by the maximum across synonymous codons
for a given amino-acid, and is supposed to avoid certain biases in PCA.
parent ebff9137
No related branches found
No related tags found
No related merge requests found
__copyright__ = "Copyright (C) 2022-2023 Blaise Li" __copyright__ = "Copyright (C) 2022-2023 Blaise Li"
__licence__ = "GNU GPLv3" __licence__ = "GNU GPLv3"
__version__ = "0.27.3" __version__ = "0.27.4"
from .libcodonusage import ( from .libcodonusage import (
aa2colour, aa2colour,
aa_usage, aa_usage,
......
...@@ -541,7 +541,7 @@ def check_aa_codon_columns(table): ...@@ -541,7 +541,7 @@ def check_aa_codon_columns(table):
def compute_rscu(codon_proportions_by_aa): def compute_rscu(codon_proportions_by_aa):
""" """
Compute Relative Syninymous Codon Usage from proportions in genes. Compute Relative Synonymous Codon Usage from proportions in genes.
*codon_proportions_by_aa* should be a pandas DataFrame where *codon_proportions_by_aa* should be a pandas DataFrame where
rows correspond to genes, and columns to codons. It contains rows correspond to genes, and columns to codons. It contains
...@@ -641,6 +641,12 @@ for that amino-acid. ...@@ -641,6 +641,12 @@ for that amino-acid.
(This corresponds to R3 in {SUZUKI_LINK}) (This corresponds to R3 in {SUZUKI_LINK})
""") """)
rscu = compute_rscu(codon_proportions) rscu = compute_rscu(codon_proportions)
render_md(f"""
We will also compute R4 ({SUZUKI_LINK}) by computing codon counts relative
to the maxium across synonymous codons of the counts for that amino-acid.
""")
r4_table = codon_counts.div(
codon_counts.T.groupby("aa").max().T)
if ref_filter_dict is None: if ref_filter_dict is None:
counts_for_global = codon_counts counts_for_global = codon_counts
else: else:
...@@ -688,6 +694,7 @@ across genes) so that they are more comparable between codons. ...@@ -688,6 +694,7 @@ across genes) so that they are more comparable between codons.
"biases": standardized_codon_usage_biases, "biases": standardized_codon_usage_biases,
"proportions": codon_proportions, "proportions": codon_proportions,
"rscu": rscu, "rscu": rscu,
"r4_table": r4_table,
"global_proportions": global_proportions} "global_proportions": global_proportions}
return standardized_codon_usage_biases return standardized_codon_usage_biases
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment