Run the NIPTmer regression model on count data
niptmer_score_samples.RdThis ports the legacy SEX Inference model into stateless R utilities.
Usage
niptmer_score_samples(
count_table,
control = NULL,
normalize = FALSE,
extra_columns = character(),
boy_threshold = 0.02,
girl_threshold = 0.01,
reference_mode = c("fixed", "match_subset", "filtered_controls"),
reference_top_n = 100,
reference_exclude_chromosomes = c("13", "18", "21", "X", "Y", "GC"),
reference_diagnose_chromosomes = as.character(seq_len(22L)),
reference_z_threshold = 3,
reference_max_outlier_chromosomes = 1
)Arguments
- count_table
A NIPT count table data.frame or file path.
- control
Either
NULL, a control file path, a character vector of control sample names, or a 1-2 column data.frame (sample, optionalsex).- normalize
Whether to use normalized differences
(actual - predicted) / predicted.- extra_columns
Optional additional predictor columns.
- boy_threshold
Y-coverage threshold above which sample is called boy.
- girl_threshold
Y-coverage threshold below which sample is called girl.
- reference_mode
Control-group strategy:
"fixed"uses one shared control group;"match_subset"picks best-matching controls per sample via Match QC;"filtered_controls"removes outlier controls before scoring.- reference_top_n
Number of controls for sample-specific matching when
reference_mode = "match_subset".- reference_exclude_chromosomes
Chromosomes excluded from Match QC.
- reference_diagnose_chromosomes
Chromosomes used for control diagnostics.
- reference_z_threshold
Absolute z-score threshold for control diagnostics.
- reference_max_outlier_chromosomes
Maximum allowed outlier chromosomes in control diagnostics.
Value
A data.frame with autosomal/GC z-scores, sex-model z-scores, Mahalanobis distance, and model gender.
Examples
counts <- system.file("extdata", "niptmer_counts_example.tsv", package = "RGenomeTester4")
controls <- system.file("extdata", "niptmer_controls_example.tsv", package = "RGenomeTester4")
scores <- niptmer_score_samples(counts, control = controls, normalize = TRUE)
niptmer_interpret(scores)
#> SampleName AA SA Distance Gender
#> 1 2NV9 XY Good boy