You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add per-population copy number (PPCN) normalization to anvi-script-gen-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.
Copy file name to clipboardExpand all lines: anvio/docs/artifacts/functions-across-genomes-txt.md
+47-41Lines changed: 47 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,58 +2,64 @@ A TAB-delimited output file that describes the distribution of functions across
2
2
3
3
## General format
4
4
5
-
With this file type anvi'o may describe the presence-absence of individual functions across genomes, or the frequency of functions. The header of the last column in a %(functions-across-genomes-txt)s file will be the name of the function annotation source from which the gene functions were recovered.
5
+
With this file type anvi'o may describe the presence-absence of individual functions across genomes, or the frequency of functions. The first column contains a unique `key` for each function, and the second column the annotation generated from the annotation source the user chose. The third column is optional and includes the accession ids. The remaining columns hold one value per (meta)genome.
6
6
7
7
### Frequency of function hits across genomes
8
8
9
9
Here is an example output file that shows the frequency of functions across 9 _Bifidobacterium_ genomes:
### Per-population copy number of functions across metagenomes
62
+
63
+
When the program that generates this file is run with the `--per-population-copy-number` flag, anvi'o additionally reports the per-population copy number (PPCN) of each function. In this file, the frequency of a function in a given metagenome is divided by the number of populations estimated to be present in that metagenome (which anvi'o estimates from single-copy core genes). This normalization makes the values comparable across metagenomes that describe communities of different sizes.
64
+
65
+
The layout is identical to the frequency file, except that the values are per-population copy numbers rather than raw counts. If anvi'o was unable to estimate the number of populations for a given metagenome, its values in this file will be reported as `NA`.
Copy file name to clipboardExpand all lines: anvio/docs/programs/anvi-script-gen-function-matrix-across-genomes.md
+24-1Lines changed: 24 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,10 +20,33 @@ The command above will result in two files in your work directory, both of which
20
20
* MY-GENOMES-FREQUENCY.txt
21
21
* MY-GENOMES-PRESENCE-ABSENCE.txt
22
22
23
+
In each of these files, the first columns describe each function (a unique `key`, the function name, and optionally the function accession ids), and the remaining columns hold one value per genome.
24
+
23
25
{:.notice}
24
26
You can always learn about which functions are in a given %(contigs-db)s using the program %(anvi-db-info)s.
25
27
26
-
Alternatively you can run it with a %(groups-txt)s that associates sets of genomes with distinct groups,
28
+
## Per-population copy number normalization for metagenomic assemblies
29
+
30
+
If we want to get an idea of differences in functional capacity across different metagenomic assemblies (or long-read sequence metagenomes) but, for some good reasons, we do not have MAGs from these assemblies, or we want to make sure that we make use of all the sequence data we have and not only those reads that are used to reconstruct genomes, we can't just look at the distribution of functions across genomes, because all functions and metabolic pathways will most likely occur nearly everywhere, at least in one population, and population numbers may differ dramatically across samples, and just counting the occurrence of a given function would not provide ecologically meaningful insights. To overcome this, Iva Veseli introduced the [per-population copy number](https://elifesciences.org/reviewed-preprints/89862) normalization. Based on the same principle, adding the flag `--per-population-copy-number` allows you to normalize individual functional annotations within a metagenomic assembly using the SCG-based estimate of population numbers within the sample.
Adding the flag generates an additional output file of type %(functions-across-genomes-txt)s:
40
+
41
+
* MY-METAGENOMES-PER-POPULATION-COPY-NUMBER.txt
42
+
43
+
By dividing the frequency of each function in a given metagenomic assembly by the number of populations estimated to be present in that same assembly based on counts of single-copy core genes (SCGs) in each %(contigs-db)s: for each domain-specific SCG set, anvi'o takes the mode of the number of hits across all SCGs, and sums these per-domain estimates across Bacteria, Archaea, and Eukarya.
44
+
45
+
The script relies on SCG annotations generated by %(anvi-run-hmms)s, and you need an %(external-genomes)s file to let it know which assemblies to compare.
46
+
47
+
A per-population copy number is an *average number of copies of a function per population*: a value near 1 means the function tends to occur once in every population, a value below 1 means it is present in only a fraction of the populations, and a value above 1 means it tends to occur in multiple copies per population (as is common for, e.g., transposases). If a given metagenome has single-copy core genes that are too sparse to yield a reliable estimate, anvi'o cannot compute its number of populations, and the per-population copy number values for that assembly will be reported as `NA`.
48
+
49
+
Alternatively, you can run it with a %(groups-txt)s that associates sets of genomes with distinct groups,
0 commit comments