Debian Codegraph @

plink2_glm_logistic.h

raw
1 #ifndef __PLINK2_GLM_LOGISTIC_H__
2 #define __PLINK2_GLM_LOGISTIC_H__
3
4 // This file is part of PLINK 2.0, copyright (C) 2005-2025 Shaun Purcell,
5 // Christopher Chang.
6 //
7 // This program is free software: you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by the Free
9 // Software Foundation, either version 3 of the License, or (at your option)
10 // any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 // more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20
21 #include "plink2_glm_shared.h"
22
23 #ifdef __cplusplus
24 namespace plink2 {
25 #endif
26
27 // could split this into per-variant and per-tested-allele parts, but only 12
28 // bytes (sample_obs_ct, multiallelic mach_r2) can go into the former; probably
29 // unimportant
30 typedef struct {
31 // double beta;
32 // odds ratio = exp(beta)
33 // double se;
34 // zval = beta / se
35 // width of asymptotic CI (beta units) = ci_zt * se
36 // T-statistic = zval
37 // pval = ZscoreToP(zval)
38
39 uint32_t sample_obs_ct;
40
41 uint32_t allele_obs_ct;
42 double a1_dosage;
43
44 uint16_t firth_fallback;
45 uint16_t is_unfinished;
46 uint32_t case_allele_obs_ct;
47 double a1_case_dosage;
48
49 double mach_r2;
50
51 // case hom-ref, case ref-alt, case alt-alt, ctrl hom-ref, ...
52 STD_ARRAY_DECL(uint32_t, 6, geno_hardcall_cts);
53 } LogisticAuxResult;
54
55 typedef struct CcResidualizeCtxStruct {
56 float* logistic_nm_sample_offsets_f;
57 float* firth_nm_sample_offsets_f;
58 double* logistic_nm_sample_offsets_d;
59 double* firth_nm_sample_offsets_d;
60 uint32_t prefitted_pred_ct;
61 uint32_t domdev_present_p1;
62 uint32_t sample_ct;
63 } CcResidualizeCtx;
64
65 typedef struct GlmLogisticCtxStruct {
66 GlmCtx *common;
67
68 uintptr_t* pheno_cc;
69 uintptr_t* pheno_x_cc;
70 uintptr_t* pheno_y_cc;
71 uintptr_t* gcount_case_interleaved_vec;
72 uintptr_t* gcount_case_interleaved_vec_x;
73 uintptr_t* gcount_case_interleaved_vec_y;
74 const float* pheno_f;
75 const float* pheno_x_f;
76 const float* pheno_y_f;
77 const double* pheno_d;
78 const double* pheno_x_d;
79 const double* pheno_y_d;
80 const float* covars_cmaj_f;
81 const float* covars_cmaj_x_f;
82 const float* covars_cmaj_y_f;
83 const double* covars_cmaj_d;
84 double* covars_cmaj_x_d;
85 double* covars_cmaj_y_d;
86 CcResidualizeCtx* cc_residualize;
87 CcResidualizeCtx* cc_residualize_x;
88 CcResidualizeCtx* cc_residualize_y;
89 uint16_t separation_found;
90 uint16_t separation_found_x;
91 uint16_t separation_found_y;
92 float* local_covars_vcmaj_f[2];
93 double* local_covars_vcmaj_d[2];
94 LogisticAuxResult* block_aux;
95 } GlmLogisticCtx;
96
97 BoolErr GlmAllocFillAndTestPhenoCovarsCc(const uintptr_t* sample_include, const uintptr_t* pheno_cc, const uintptr_t* covar_include, const PhenoCol* covar_cols, const char* covar_names, uintptr_t sample_ct, uint32_t domdev_present_p1, uintptr_t covar_ct, uint32_t local_covar_ct, uint32_t covar_max_nonnull_cat_ct, uintptr_t extra_cat_ct, uintptr_t max_covar_name_blen, double max_corr, double vif_thresh, uintptr_t xtx_state, GlmFlags glm_flags, uintptr_t** pheno_cc_collapsed_ptr, uintptr_t** gcount_case_interleaved_vec_ptr, float** pheno_f_ptr, double** pheno_d_ptr, RegressionNmPrecomp** nm_precomp_ptr, float** covars_cmaj_f_ptr, double** covars_cmaj_d_ptr, CcResidualizeCtx** cc_residualize_ptr, const char*** cur_covar_names_ptr, GlmErr* glm_err_ptr);
98
99 PglErr GlmLogistic(const char* cur_pheno_name, const char* const* test_names, const char* const* test_names_x, const char* const* test_names_y, const uint32_t* variant_bps, const char* const* variant_ids, const char* const* allele_storage, const GlmInfo* glm_info_ptr, const uint32_t* local_sample_uidx_order, const uintptr_t* local_variant_include, const char* outname, uint32_t raw_variant_ct, uint32_t max_chr_blen, double ci_size, double ln_pfilter, double output_min_ln, uint32_t max_thread_ct, uintptr_t pgr_alloc_cacheline_ct, uintptr_t overflow_buf_size, uint32_t local_sample_ct, PgenFileInfo* pgfip, GlmLogisticCtx* ctx, TextStream* local_covar_txsp, LlStr** outfnames_ll_ptr, uintptr_t* valid_variants, uintptr_t* valid_alleles, double* orig_ln_pvals, double* orig_permstat, uintptr_t* valid_allele_ct_ptr);
100
101 // void LogisticTestInternal();
102
103 #ifdef __cplusplus
104 } // namespace plink2
105 #endif
106
107 #endif // __PLINK2_GLM_LOGISTIC_H__