Add per-population copy number (PPCN) normalization to anvi-script-gen-function-matrix-across-genomes#2746
Merged
Conversation
…n-function-matrix-across-genomes Adds a --per-population-copy-number flag that reports an additional matrix in which each function's frequency in a metagenomic assembly is divided by the number of populations estimated to be present in that assembly. Population counts are estimated from single-copy core genes via anvi'o's NumGenomesEstimator (the mode of SCG hits per domain, summed across Bacteria, Archaea, and Eukarya), the same estimate anvi-display-contigs-stats reports. This normalization, introduced by Iva Veseli (Veseli et al. 2025), makes functional capacity comparable across metagenomic assemblies of very different community sizes. The flag works only with an external-genomes file (-e), since the normalization is meaningful for whole metagenomic assemblies (or long-read metagenomes) but not for individual genomes or a genomes storage database. Assemblies whose SCGs are too sparse to estimate a population count are reported as NA rather than dividing by zero. All matrix outputs also lead with their descriptive columns (key, function, accession) before the per-genome columns. Help page and CLI help included.
7b5b2cd to
133e413
Compare
the original flag doesn't matches the anvi'o conventions for parameters, and it does not signal 'extra output will come when you use it' immediately. Hence the change.
Member
|
I made a small change to better follow anvi'o conventions on flags. The parameter is now called I also added you to the list of authors of the program. I will merge it now as it appears to be working. But then I will rename this script from More later. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I would like to compare functional capacities across metagenomic assemblies using individual functional annotations such as KEGG kofams or NCBI's COGs. But similar to estimating metabolic capacity, the problem when comparing assemblies rather than individual genomes is that each function is most likely present everywhere at least once in complex communities and different samples can contain very different number of populations, either for ecological reasons or differences in sequencing depth. So Iva came up with the per-population-copy-number (PPCN) normalization to be able to compare the metabolic capacities acros metagenomic assemblies by normalizing the frequency of metabolic pathway annotations using the estimated number of populations based on SCGs. I want to do the same thing for functional annotations in an automated way and therefore added a --per-population-copy-number flag to the 'anvi-script-gen-function-matrix-across-genomes' script. When you add the flag, the script generates an additional output with PPCN normalized frequencies of functional annotations of whichever kind you chose.
Same as before, the population counts are estimated from single-copy core genes via anvi'o's NumGenomesEstimator (the mode of SCG hits per domain, summed across Bacteria, Archaea, and Eukarya). You need to provide an external-genomes file for this flag to work and the contig-dbs should contain metagenomic assemblies or long read metagenomes, in which case assembly probably wouldn't be strictly necessary.
One little thing I changed is the column order that 'anvi-script-gen-function-matrix-across-genomes' generates. Currently, the 'key' is the first column, then the contig-dbs with their numbers and then, at the very end, you can find a column with the functional annotation. I think it makes more sense to have that in front as well, especially if you have a large set of contig-dbs.
I created the code with the help of Claude AI