Skip to content

Count the pseudogenes AMAP called in each sample in the report's chart - #67

Merged
Paururo merged 2 commits into
mainfrom
report-pseudogenes
Oct 19, 2026
Merged

Paururo merged 2 commits into
mainfrom
report-pseudogenes

Conversation

@Paururo

@Paururo Paururo commented Oct 18, 2026

Copy link
Copy Markdown
Member

What was wrong

The report's Pseudogene Detection section (bin/report/report_AMAP.Rmd, chunk pseudogenes) kept the master-table genes flagged in Mycobrowser's Is_Pseudogene or in AMAP's pseudogene column, counted them per lineage and titled the chart "Pseudogenes per Lineage (Mycobrowser annotation)". Its text described them as genes without a stop codon.

  • Is_Pseudogene says which genes are pseudogenes in H37Rv, not in the sample. CDC1551 alone came out at 129, where AMAP calls 123 and the QC table (after Count the pseudogenes AMAP called in the QC table聽#58) says 123; the other 6 are genes Mycobrowser marks that CDC1551 has intact: Rv0947c, Rv1150, Rv2023A, Rv2098c, Rv3021c, Rv3324A.
  • Without Mycobrowser (any other organism) Is_Pseudogene is empty, so the chart showed AMAP's calls under a Mycobrowser title.
  • count() over the flagged rows left out a lineage with none.
  • It added up a lineage's samples, so a lineage with more samples looked as if it had more pseudogenes.

Measured on real data: the benchmark's FIX_CDS outputs through the rendered scripts of GET_OUTPUTS, GET_COUNT and REPORT_INPUTS in paururo/amap:latest, then the chunk.

Run main draws this branch draws (each = the sample's pseudogene_count in the QC table)
CDC1551, CDC1551 in 40 contigs, H37Rv AL123456.3, H37Rv CP110619 (L4) and M. bovis (A4), Mycobrowser on L4 296, A4 178 L4: 123, 123, 7, 19; A4: 172
E. coli Sakai and K-12, --skip_mycobrowser Untyped 137, under the Mycobrowser title Untyped: 130, 7

L4's 296 is 129 + 129 + 13 + 25 added up over four genomes, though per genome M. bovis has the most.

What changed

  • REPORT_INPUTS (modules/local/freport.nf) puts the sample each master-table row is from, the name its file carries, in a first sample column of input_mastertables.txt, as it already does for the QC tables. The master tables GET_OUTPUTS publishes are unchanged.
  • The chart counts pseudogene == "yes", AMAP's own call and what the QC table counts, per sample within each lineage, a sample with none at 0: a box per lineage and each sample as a point (jittered sideways only) on an axis from 0, titled "Pseudogenes AMAP Called per Sample". A "Per Sample" tab lists the counts. When no sample has any, the section says so and the table shows every sample at 0.
  • The text says what AMAP calls a pseudogene (internal stops, a frameshift or lost stop that runs on past the reference protein, no stop within reach, a stop the reference itself lacks), that the master table's note column gives the reason, and that Mycobrowser's Is_Pseudogene is not counted. The em-dash is gone.
  • Master Table Explorer shows note next to pseudogene, so the reason is in the report.
  • bin/report/demo/make_demo.py writes the new sample column; its other tables and its random draws are unchanged.
  • docs/user-guide/report.md and its page, a CHANGELOG bullet under Correctness and one under Testing (694 tests), docs/about/changelog.html rebuilt.

Tests

tests/test_report_pseudogenes.py (12) chains the steps after the correction as tests/test_sample_ids.py does, with four samples (two in L2 with 2 pseudogenes each, one in L4 with none, one in NA with 3) and Mycobrowser marking Rv0001, intact in every sample, with Mycobrowser on and off. It checks that REPORT_INPUTS' rows carry their sample, then runs the section's own R code with the report_tables harness: each sample at the number AMAP called, equal to the QC table's, a sample with none at 0, a title that names AMAP and not Mycobrowser, and every sample at 0 when none has any.

  • On main all 12 fail: no sample column; the chunk's table is lineage, n (with Mycobrowser L2 6, NA 4, L4 1; without it L2 4, NA 3 and no L4); the title names Mycobrowser; with no pseudogene and no Mycobrowser it builds no table at all.
  • Container suite: 672 passed, 22 skipped (node and Nextflow only), 0 failed.
  • Python 3.9 (python:3.9-slim with requirements-test.txt): the chained tests pass and the R ones skip, as on CI.
  • tools/build_docs.py --check and tools/check_site.py on Python 3.11 pass.

Not changed

The report's Pseudogene Detection chart counted the genes flagged by Mycobrowser's Is_Pseudogene or AMAP's pseudogene column, summed by lineage under a Mycobrowser title, so CDC1551 showed 129 where AMAP calls 123, a lineage with none dropped out and a lineage with more samples looked as if it had more. REPORT_INPUTS now gives each master table row the sample it is from, and the chart draws every sample at the number AMAP called, the QC table's, a sample with none at 0, with a table of the counts beside it. The master table explorer shows the note that says why a gene is a pseudogene, and tests/test_report_pseudogenes.py runs the chained steps and the section's own R code.
@Paururo Paururo added bug Something isn't working documentation Improvements or additions to documentation labels Oct 18, 2026
@Paururo
Paururo merged commit 49981d0 into main Oct 19, 2026
3 checks passed
@Paururo
Paururo deleted the report-pseudogenes branch October 19, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant