How wwylab/lfspro works
Project type and purpose
• This is an R package (“LFSPRO”) that computes Li-Fraumeni syndrome carrier probabilities and future cancer risks based on family history.
• It exposes R‐level functions (e.g., lfspro(), lfsClassic(), lfsChompret2015()) to end users, while heavy numerical routines are implemented in C++ under src/.
File structure
• Top‐level files: DESCRIPTION, NAMESPACE, README.md → standard R package metadata.
• R/: R‐level wrappers and data‐preparation functions (FormatChange.R, convert.data.R, lfspro.R, etc.).
• src/: Core computational modules in C++ (e.g., Mendel.cpp/.h, pedigree.cpp/.h, peelingC.cpp).
• data/: Preprocessed data sets (penetrances, cancer.type, fam.data, etc.) exposed as .rda/.RData.
• man/: Documentation for every R function.
• No separate tests/ or frontend/ directories — package is a library.
README for additional insights
• Describes main features: mutation‐carrier probabilities, future cancer risk, second primary cancer risk.
• Shows typical usage pattern: users call R functions with family and cancer data frames.
a. Components
• User R session / CLI
• R API layer (R/*.R)
• Data resources (data/*.rda, .RData)
• Computational core (C++ modules in src/)
• Documentation (man/*.Rd)
• Build/deploy toolchain (R CMD build/install, devtools, GitHub)
b. Relationships & data flow
1. User invokes R function (e.g., lfspro()) in their R console or script.
2. R API layer loads required data from data/*.rda.
3. R function marshals inputs and calls compiled C++ routines via R’s native interface.
4. C++ core performs numerical algorithms (Mendelian transmission, peeling, likelihood computations).
5. Results are returned to R, formatted into R objects (vectors, data frames).
6. User inspects output or downstream plots/tables.
c. Architectural patterns and principles
• “Wrapper” pattern: thin R interface → computational C++ backend.
• Modular C++ design: separate headers and source modules for Mendel, PCCP, pedigree, “peeling” algorithm.
• Data‐driven: static data in package loaded at runtime.
d. Key technologies & frameworks
• R (package framework: DESCRIPTION, NAMESPACE, man/)
• C++ (portable code compiled into a shared library via R CMD INSTALL)
• devtools/GitHub for distribution
Elements
• Clear labels:
• “User R Session”
• “R API Layer”
• “Data Resources”
• “C++ Computational Core”
• “Documentation”
• “Build & Deployment”
• User → R API Layer (function calls)
• R API → Data Resources (load)
• R API → C++ Core (native call)
• C++ Core → R API (return results)
• GitHub → Build & Deployment → Installed Package
• Blue rectangles for code components (R, C++)
• Green for data resources
• Orange for documentation
• Gray for external systems (GitHub, R CMD)