From 2a8b92187e2d93e818119de56e82f241d3385ef9 Mon Sep 17 00:00:00 2001 From: Blaise Li <blaise.li__git@nsup.org> Date: Fri, 6 Oct 2023 17:09:27 +0200 Subject: [PATCH] Added global R4 computation. --- libcodonusage/__init__.py | 2 +- libcodonusage/libcodonusage.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libcodonusage/__init__.py b/libcodonusage/__init__.py index e82dd57..b1e7b77 100644 --- a/libcodonusage/__init__.py +++ b/libcodonusage/__init__.py @@ -1,6 +1,6 @@ __copyright__ = "Copyright (C) 2022-2023 Blaise Li" __licence__ = "GNU GPLv3" -__version__ = "0.28.0" +__version__ = "0.28.1" from .libcodonusage import ( aa2colour, aa_usage, diff --git a/libcodonusage/libcodonusage.py b/libcodonusage/libcodonusage.py index f63e15b..bf629e2 100644 --- a/libcodonusage/libcodonusage.py +++ b/libcodonusage/libcodonusage.py @@ -667,6 +667,12 @@ We compute the global usage, as the sum of the counts for a given codon, across genes. """) global_usage = counts_for_global.sum(axis=0) + if return_more: + # Same computation as for individual genes, + # but based on the total counts. + global_max_counts = global_usage.T.groupby("aa").max().T + global_r4 = global_usage.div( + global_max_counts) render_md("Then we sum over codons corresponding to the same amino-acid.") global_summed_by_aa = global_usage.groupby(level=0).sum() render_md(""" @@ -702,7 +708,8 @@ across genes) so that they are more comparable between codons. "rscu": rscu, "r4_table": r4_table, "global_proportions": global_proportions, - "global_rscu": global_proportions.mul(degeneracy)} + "global_rscu": global_proportions.mul(degeneracy), + "global_r4": global_r4} return standardized_codon_usage_biases -- GitLab