$ show PoisonAlien/maftools
maftools is an R/Bioconductor package for the analysis and visualization of somatic mutations in cancer genomics, primarily using Mutation Annotation Format (MAF) files. It provides a comprehensive suite of functions for reading, summarizing, and plotting mutation landscapes (oncoplots, lollipop plots, rainfall plots), detecting driver genes, analyzing mutational signatures via NMF, assessing tumor heterogeneity (MATH score), comparing cohorts, and integrating copy number alterations from GISTIC or ASCAT. The package also includes tools for converting other formats (ANNOVAR, ICGC) to MAF, querying cancer hotspots directly from BAM files via a C backend, and detecting sample swaps. It is widely used by cancer researchers and relies on Bioconductor infrastructure, with extensive bundled reference data (COSMIC signatures, cancer hotspots, TCGA burden). While primarily a software library, its heavy use of precompiled research data and domain-specific pipelines gives it a hybrid character. The codebase is well-structured with S4 classes and data.table for performance, though some functions have long parameter lists and a few deprecated modules.
The LLM identified 2 files worth highlighting for reuse:
Self-contained C code for rapid nucleotide counting at specific genomic positions in BAM files. Efficiently computes read depths, reference/alternate allele counts, and variant allele frequencies. Can be compiled as a standalone command-line tool (somaticfreq) or called from R via Rhtslib. Demonstrates non-obvious skill in integrating htslib with R and is reusable for any project requiring targeted BAM analysis, such as hotspot validation or contamination checks.
Implements an algorithm to repel overlapping labels in scatter-like plots (e.g., lollipop and rainfall plots). Uses iterative displacement to reduce overlap while preserving approximate original positioning. The logic is self-contained and can be extracted for any R graphics or Shiny application requiring intelligent label placement, demonstrating a non-obvious spatial problem-solving approach.