R/marginal_scan.R
annotate_gds_marginal.RdStores marginal analysis results as an annotation node in a GDS file for downstream reuse. Follows the same pattern as FunctionalAnnotation storage.
annotate_gds_marginal(
gds_path,
results,
node_name = "MarginalAnalysis",
overwrite = FALSE,
verbose = 1
)Character path to GDS file to annotate.
A data.frame (class "glow_marginal_scan" or plain
data.frame) from marginal_scan().
Character name for the annotation node. Default: "MarginalAnalysis".
Logical. If TRUE, replace existing node. Default: FALSE.
Integer verbosity level (0=silent, 1=progress).
Invisible gds_path.
Opens the GDS file for writing and navigates to (or creates)
annotation/info/<node_name>. The results data.frame is aligned to the
GDS variant order via match(gds_variant_ids, results$variant_id);
any GDS variant not present in results will have NA values in the stored
matrix. A verbose message is emitted when unmatched variants are detected.
Columns stored: MAF, MAC, score, var_score, Z, pvalue. When SPA results
are present in results, Z_SPA and pvalue_SPA are also stored.
The matrix is compressed with LZMA_RA. Metadata attributes
"column_names" and "analysis_date" are attached to the node.
Complexity: O(V) in the total number of GDS variants. The file is modified in-place; no temporary copy is created.
if (FALSE) { # \dontrun{
pheno <- extract_pheno_covar_gds("chr22.gds", covar_names = "sex")
nm <- fit_null_model(pheno$X, pheno$Y, trait = "binary",
sample_id = pheno$sample_id)
results <- marginal_scan("chr22.gds", nm, use_SPA = FALSE)
annotate_gds_marginal("chr22.gds", results, node_name = "MarginalAnalysis")
} # }