| 1 |
#ifndef __PLINK2_MISC_H__ |
| 2 |
#define __PLINK2_MISC_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_common.h" |
| 22 |
|
| 23 |
#ifdef __cplusplus |
| 24 |
namespace plink2 { |
| 25 |
#endif |
| 26 |
|
| 27 |
FLAGSET_DEF_START() |
| 28 |
kfRecoverVarIds0, |
| 29 |
kfRecoverVarIdsStrictBimOrder = (1 << 0), |
| 30 |
kfRecoverVarIdsRigid = (1 << 1), |
| 31 |
kfRecoverVarIdsForce = (1 << 2), |
| 32 |
kfRecoverVarIdsPartial = (1 << 3) |
| 33 |
FLAGSET_DEF_END(RecoverVarIdsFlags); |
| 34 |
|
| 35 |
FLAGSET_DEF_START() |
| 36 |
kfUpdateAlleles0, |
| 37 |
kfUpdateAllelesAllowMismatch = (1 << 0), |
| 38 |
kfUpdateAllelesStrictMissing = (1 << 1) |
| 39 |
FLAGSET_DEF_END(UpdateAllelesFlags); |
| 40 |
|
| 41 |
FLAGSET_DEF_START() |
| 42 |
kfUpdateSex0, |
| 43 |
kfUpdateSexMale0 = (1 << 0) |
| 44 |
FLAGSET_DEF_END(UpdateSexFlags); |
| 45 |
|
| 46 |
FLAGSET_DEF_START() |
| 47 |
kfPhenoTransform0, |
| 48 |
kfPhenoTransformSplitCat = (1 << 0), |
| 49 |
kfPhenoTransformSplitCatOmitMost = (1 << 1), |
| 50 |
kfPhenoTransformSplitCatOmitLast = (1 << 2), |
| 51 |
kfPhenoTransformSplitCatCovar01 = (1 << 3), |
| 52 |
kfPhenoTransformVstdCovar = (1 << 4), |
| 53 |
kfPhenoTransformVstdAll = (1 << 5), |
| 54 |
kfPhenoTransformQuantnormPheno = (1 << 6), |
| 55 |
kfPhenoTransformQuantnormCovar = (1 << 7), |
| 56 |
kfPhenoTransformQuantnormAll = (1 << 8) |
| 57 |
FLAGSET_DEF_END(PhenoTransformFlags); |
| 58 |
|
| 59 |
FLAGSET_DEF_START() |
| 60 |
kfWriteCovar0, |
| 61 |
kfWriteCovarColMaybefid = (1 << 0), |
| 62 |
kfWriteCovarColFid = (1 << 1), |
| 63 |
kfWriteCovarColMaybesid = (1 << 2), |
| 64 |
kfWriteCovarColSid = (1 << 3), |
| 65 |
kfWriteCovarColMaybeparents = (1 << 4), |
| 66 |
kfWriteCovarColParents = (1 << 5), |
| 67 |
kfWriteCovarColSex = (1 << 6), |
| 68 |
kfWriteCovarColPheno1 = (1 << 7), |
| 69 |
kfWriteCovarColPhenos = (1 << 8), |
| 70 |
kfWriteCovarColDefault = (kfWriteCovarColMaybefid | kfWriteCovarColMaybesid), |
| 71 |
kfWriteCovarColAll = ((kfWriteCovarColPhenos * 2) - kfWriteCovarColMaybefid) |
| 72 |
FLAGSET_DEF_END(WriteCovarFlags); |
| 73 |
|
| 74 |
FLAGSET_DEF_START() |
| 75 |
kfAlleleFreq0, |
| 76 |
kfAlleleFreqZs = (1 << 0), |
| 77 |
kfAlleleFreqCounts = (1 << 1), |
| 78 |
kfAlleleFreqBinsRefFname = (1 << 2), |
| 79 |
kfAlleleFreqBinsAlt1Fname = (1 << 3), |
| 80 |
kfAlleleFreqBinsOnly = (1 << 4), |
| 81 |
|
| 82 |
kfAlleleFreqColChrom = (1 << 5), |
| 83 |
kfAlleleFreqColPos = (1 << 6), |
| 84 |
kfAlleleFreqColRef = (1 << 7), |
| 85 |
kfAlleleFreqColAlt1 = (1 << 8), |
| 86 |
kfAlleleFreqColAlt = (1 << 9), |
| 87 |
kfAlleleFreqColMaybeprovref = (1 << 10), |
| 88 |
kfAlleleFreqColProvref = (1 << 11), |
| 89 |
kfAlleleFreqColReffreq = (1 << 12), |
| 90 |
kfAlleleFreqColAlt1freq = (1 << 13), |
| 91 |
kfAlleleFreqColAltfreq = (1 << 14), |
| 92 |
kfAlleleFreqColFreq = (1 << 15), |
| 93 |
kfAlleleFreqColEq = (1 << 16), |
| 94 |
kfAlleleFreqColEqz = (1 << 17), |
| 95 |
kfAlleleFreqColAlteq = (1 << 18), |
| 96 |
kfAlleleFreqColAlteqz = (1 << 19), |
| 97 |
kfAlleleFreqColNumeq = (1 << 20), |
| 98 |
kfAlleleFreqColAltnumeq = (1 << 21), |
| 99 |
kfAlleleFreqColMachR2 = (1 << 22), |
| 100 |
kfAlleleFreqColMinimac3R2 = (1 << 23), |
| 101 |
kfAlleleFreqColNobs = (1 << 24), |
| 102 |
kfAlleleFreqColDefault = (kfAlleleFreqColChrom | kfAlleleFreqColRef | kfAlleleFreqColAlt | kfAlleleFreqColMaybeprovref | kfAlleleFreqColAltfreq | kfAlleleFreqColNobs), |
| 103 |
kfAlleleFreqColAll = ((kfAlleleFreqColNobs * 2) - kfAlleleFreqColChrom), |
| 104 |
// only mutual exclusion is altfreq/freq/eq/eqz/alteq/alteqz/numeq/numeqz |
| 105 |
// don't force alt1freq/altfreq mutual exclusion since the former plays a bit |
| 106 |
// better with shell scripts |
| 107 |
// alt+alteqz is a bit silly, but I won't bother prohibiting it |
| 108 |
kfAlleleFreqColMutex = ((kfAlleleFreqColAltnumeq * 2) - kfAlleleFreqColAltfreq) |
| 109 |
FLAGSET_DEF_END(FreqRptFlags); |
| 110 |
|
| 111 |
// Will need to split this into multiple flagsets if we add any more options... |
| 112 |
FLAGSET_DEF_START() |
| 113 |
kfMissingRpt0, |
| 114 |
kfMissingRptZs = (1 << 0), |
| 115 |
kfMissingRptSampleOnly = (1 << 1), |
| 116 |
kfMissingRptVariantOnly = (1 << 2), |
| 117 |
|
| 118 |
kfMissingRptScolMaybefid = (1 << 3), |
| 119 |
kfMissingRptScolFid = (1 << 4), |
| 120 |
kfMissingRptScolMaybesid = (1 << 5), |
| 121 |
kfMissingRptScolSid = (1 << 6), |
| 122 |
kfMissingRptScolMisspheno1 = (1 << 7), |
| 123 |
kfMissingRptScolMissphenos = (1 << 8), |
| 124 |
kfMissingRptScolNmissDosage = (1 << 9), |
| 125 |
kfMissingRptScolNmiss = (1 << 10), |
| 126 |
kfMissingRptScolNmissHh = (1 << 11), |
| 127 |
kfMissingRptScolHethap = (1 << 12), |
| 128 |
kfMissingRptScolNobs = (1 << 13), |
| 129 |
kfMissingRptScolFmissDosage = (1 << 14), |
| 130 |
kfMissingRptScolFmiss = (1 << 15), |
| 131 |
kfMissingRptScolFmissHh = (1 << 16), |
| 132 |
kfMissingRptScolDefault = (kfMissingRptScolMaybefid | kfMissingRptScolMaybesid | kfMissingRptScolMissphenos | kfMissingRptScolNmiss | kfMissingRptScolNobs | kfMissingRptScolFmiss), |
| 133 |
kfMissingRptScolAll = ((kfMissingRptScolFmissHh * 2) - kfMissingRptScolMaybesid), |
| 134 |
|
| 135 |
kfMissingRptVcolChrom = (1 << 17), |
| 136 |
kfMissingRptVcolPos = (1 << 18), |
| 137 |
kfMissingRptVcolRef = (1 << 19), |
| 138 |
kfMissingRptVcolAlt = (1 << 20), |
| 139 |
kfMissingRptVcolMaybeprovref = (1 << 21), |
| 140 |
kfMissingRptVcolProvref = (1 << 22), |
| 141 |
kfMissingRptVcolNmissDosage = (1 << 23), |
| 142 |
kfMissingRptVcolNmiss = (1 << 24), |
| 143 |
kfMissingRptVcolNmissHh = (1 << 25), |
| 144 |
kfMissingRptVcolHethap = (1 << 26), |
| 145 |
kfMissingRptVcolNobs = (1 << 27), |
| 146 |
kfMissingRptVcolFmissDosage = (1 << 28), |
| 147 |
kfMissingRptVcolFmiss = (1 << 29), |
| 148 |
kfMissingRptVcolFmissHh = (1 << 30), |
| 149 |
kfMissingRptVcolFhethap = (1U << 31), |
| 150 |
kfMissingRptVcolDefault = (kfMissingRptVcolChrom | kfMissingRptVcolMaybeprovref | kfMissingRptVcolNmiss | kfMissingRptVcolNobs | kfMissingRptVcolFmiss), |
| 151 |
kfMissingRptVcolAll = ((kfMissingRptVcolFhethap * 2U) - kfMissingRptVcolChrom) |
| 152 |
FLAGSET_DEF_END(MissingRptFlags); |
| 153 |
|
| 154 |
FLAGSET_DEF_START() |
| 155 |
kfGenoCounts0, |
| 156 |
kfGenoCountsZs = (1 << 0), |
| 157 |
|
| 158 |
kfGenoCountsColChrom = (1 << 1), |
| 159 |
kfGenoCountsColPos = (1 << 2), |
| 160 |
kfGenoCountsColRef = (1 << 3), |
| 161 |
kfGenoCountsColAlt1 = (1 << 4), |
| 162 |
kfGenoCountsColAlt = (1 << 5), |
| 163 |
kfGenoCountsColMaybeprovref = (1 << 6), |
| 164 |
kfGenoCountsColProvref = (1 << 7), |
| 165 |
kfGenoCountsColHomref = (1 << 8), |
| 166 |
kfGenoCountsColRefalt1 = (1 << 9), |
| 167 |
kfGenoCountsColRefalt = (1 << 10), |
| 168 |
kfGenoCountsColHomalt1 = (1 << 11), |
| 169 |
kfGenoCountsColAltxy = (1 << 12), |
| 170 |
kfGenoCountsColXy = (1 << 13), |
| 171 |
kfGenoCountsColHapref = (1 << 14), |
| 172 |
kfGenoCountsColHapalt1 = (1 << 15), |
| 173 |
kfGenoCountsColHapalt = (1 << 16), |
| 174 |
kfGenoCountsColHap = (1 << 17), |
| 175 |
kfGenoCountsColNumeq = (1 << 18), |
| 176 |
kfGenoCountsColMissing = (1 << 19), |
| 177 |
kfGenoCountsColNobs = (1 << 20), |
| 178 |
kfGenoCountsColDefault = (kfGenoCountsColChrom | kfGenoCountsColRef | kfGenoCountsColAlt | kfGenoCountsColMaybeprovref | kfGenoCountsColHomref | kfGenoCountsColRefalt | kfGenoCountsColAltxy | kfGenoCountsColHapref | kfGenoCountsColHapalt | kfGenoCountsColMissing), |
| 179 |
kfGenoCountsColAll = ((kfGenoCountsColNobs * 2) - kfGenoCountsColChrom), |
| 180 |
|
| 181 |
kfGenoCountsColPairex = (kfGenoCountsColHapalt | kfGenoCountsColHap), |
| 182 |
kfGenoCountsColMutex = (kfGenoCountsColAltxy | kfGenoCountsColXy | kfGenoCountsColNumeq) |
| 183 |
FLAGSET_DEF_END(GenoCountsFlags); |
| 184 |
|
| 185 |
FLAGSET_DEF_START() |
| 186 |
kfHardy0, |
| 187 |
kfHardyZs = (1 << 0), |
| 188 |
kfHardyMidp = (1 << 1), |
| 189 |
kfHardyLog10 = (1 << 2), |
| 190 |
kfHardyRedundant = (1 << 3), |
| 191 |
|
| 192 |
kfHardyColChrom = (1 << 4), |
| 193 |
kfHardyColPos = (1 << 5), |
| 194 |
kfHardyColRef = (1 << 6), |
| 195 |
kfHardyColAlt1 = (1 << 7), |
| 196 |
kfHardyColAlt = (1 << 8), |
| 197 |
kfHardyColMaybeprovref = (1 << 9), |
| 198 |
kfHardyColProvref = (1 << 10), |
| 199 |
kfHardyColAx = (1 << 11), |
| 200 |
kfHardyColGcounts = (1 << 12), |
| 201 |
kfHardyColGcount1col = (1 << 13), |
| 202 |
kfHardyColHetfreq = (1 << 14), |
| 203 |
kfHardyColSexaf = (1 << 15), |
| 204 |
kfHardyColFemalep = (1 << 16), |
| 205 |
kfHardyColP = (1 << 17), |
| 206 |
kfHardyColDefault = (kfHardyColChrom | kfHardyColMaybeprovref | kfHardyColAx | kfHardyColGcounts | kfHardyColHetfreq | kfHardyColSexaf | kfHardyColP), |
| 207 |
kfHardyColAll = ((kfHardyColP * 2) - kfHardyColChrom) |
| 208 |
FLAGSET_DEF_END(HardyFlags); |
| 209 |
|
| 210 |
FLAGSET_DEF_START() |
| 211 |
kfHet0, |
| 212 |
kfHetZs = (1 << 0), |
| 213 |
kfHetSmallSample = (1 << 1), |
| 214 |
|
| 215 |
kfHetColMaybefid = (1 << 3), |
| 216 |
kfHetColFid = (1 << 4), |
| 217 |
kfHetColMaybesid = (1 << 5), |
| 218 |
kfHetColSid = (1 << 6), |
| 219 |
kfHetColHom = (1 << 7), |
| 220 |
kfHetColHet = (1 << 8), |
| 221 |
kfHetColNobs = (1 << 9), |
| 222 |
kfHetColF = (1 << 10), |
| 223 |
kfHetColDefault = (kfHetColMaybefid | kfHetColMaybesid | kfHetColHom | kfHetColNobs | kfHetColF), |
| 224 |
kfHetColAll = ((kfHetColF * 2) - kfHetColMaybefid) |
| 225 |
FLAGSET_DEF_END(HetFlags); |
| 226 |
|
| 227 |
typedef struct UpdateAllelesStruct { |
| 228 |
NONCOPYABLE(UpdateAllelesStruct); |
| 229 |
UpdateAllelesFlags flags; |
| 230 |
char* fname; |
| 231 |
} UpdateAllelesInfo; |
| 232 |
|
| 233 |
typedef struct UpdateSexStruct { |
| 234 |
NONCOPYABLE(UpdateSexStruct); |
| 235 |
UpdateSexFlags flags; |
| 236 |
uint32_t col_num; |
| 237 |
char* fname; |
| 238 |
} UpdateSexInfo; |
| 239 |
|
| 240 |
FLAGSET_DEF_START() |
| 241 |
kfSampleCounts0, |
| 242 |
kfSampleCountsZs = (1 << 0), |
| 243 |
|
| 244 |
kfSampleCountsColMaybefid = (1 << 1), |
| 245 |
kfSampleCountsColFid = (1 << 2), |
| 246 |
kfSampleCountsColMaybesid = (1 << 3), |
| 247 |
kfSampleCountsColSid = (1 << 4), |
| 248 |
kfSampleCountsColSex = (1 << 5), |
| 249 |
kfSampleCountsColHom = (1 << 6), |
| 250 |
kfSampleCountsColHomref = (1 << 7), |
| 251 |
kfSampleCountsColHomalt = (1 << 8), |
| 252 |
kfSampleCountsColHomaltSnp = (1 << 9), |
| 253 |
kfSampleCountsColHet = (1 << 10), |
| 254 |
kfSampleCountsColRefalt = (1 << 11), |
| 255 |
kfSampleCountsColHet2alt = (1 << 12), |
| 256 |
|
| 257 |
kfSampleCountsColHetSnp = (1 << 13), |
| 258 |
kfSampleCountsColDiploidTs = (1 << 14), |
| 259 |
kfSampleCountsColTs = (1 << 15), |
| 260 |
kfSampleCountsColDiploidTv = (1 << 16), |
| 261 |
kfSampleCountsColTv = (1 << 17), |
| 262 |
kfSampleCountsColDiploidNonsnpsymb = (1 << 18), |
| 263 |
kfSampleCountsColNonsnpsymb = (1 << 19), |
| 264 |
kfSampleCountsColSymbolic = (1 << 20), |
| 265 |
kfSampleCountsColNonsnp = (1 << 21), |
| 266 |
|
| 267 |
kfSampleCountsColDiploidSingle = (1 << 22), |
| 268 |
kfSampleCountsColSingle = (1 << 23), |
| 269 |
kfSampleCountsColHaprefWithFemaleY = (1 << 24), |
| 270 |
kfSampleCountsColHapref = (1 << 25), |
| 271 |
kfSampleCountsColHapaltWithFemaleY = (1 << 26), |
| 272 |
kfSampleCountsColHapalt = (1 << 27), |
| 273 |
kfSampleCountsColMissingWithFemaleY = (1 << 28), |
| 274 |
kfSampleCountsColMissing = (1 << 29), |
| 275 |
kfSampleCountsColDefault = (kfSampleCountsColMaybefid | kfSampleCountsColMaybesid | kfSampleCountsColHomref | kfSampleCountsColHomaltSnp | kfSampleCountsColHetSnp | kfSampleCountsColDiploidTs | kfSampleCountsColDiploidTv | kfSampleCountsColDiploidNonsnpsymb | kfSampleCountsColDiploidSingle | kfSampleCountsColHaprefWithFemaleY | kfSampleCountsColHapaltWithFemaleY | kfSampleCountsColMissingWithFemaleY), |
| 276 |
kfSampleCountsColAll = ((kfSampleCountsColMissing * 2) - kfSampleCountsColMaybefid) |
| 277 |
FLAGSET_DEF_END(SampleCountsFlags); |
| 278 |
|
| 279 |
FLAGSET_DEF_START() |
| 280 |
kfSdiff0, |
| 281 |
kfSdiffIncludeMissing = (1 << 0), |
| 282 |
kfSdiffPairwise = (1 << 1), |
| 283 |
kfSdiffCountsOnly = (1 << 2), |
| 284 |
kfSdiffOneBase = (1 << 3), |
| 285 |
// no need for kfSdiffFile since that's synonymous with other_id_ct == 0 |
| 286 |
kfSdiffZs = (1 << 4), |
| 287 |
|
| 288 |
kfSdiffColChrom = (1 << 5), |
| 289 |
kfSdiffColPos = (1 << 6), |
| 290 |
kfSdiffColRef = (1 << 7), |
| 291 |
kfSdiffColAlt = (1 << 8), |
| 292 |
kfSdiffColMaybeprovref = (1 << 9), |
| 293 |
kfSdiffColProvref = (1 << 10), |
| 294 |
kfSdiffColMaybefid = (1 << 11), |
| 295 |
kfSdiffColFid = (1 << 12), |
| 296 |
kfSdiffColId = (1 << 13), |
| 297 |
kfSdiffColMaybesid = (1 << 14), |
| 298 |
kfSdiffColSid = (1 << 15), |
| 299 |
kfSdiffColGeno = (1 << 16), |
| 300 |
kfSdiffColPairwiseDefault = (kfSdiffColChrom | kfSdiffColPos | kfSdiffColRef | kfSdiffColAlt | kfSdiffColMaybeprovref | kfSdiffColGeno), |
| 301 |
kfSdiffColDefault = (kfSdiffColPairwiseDefault | kfSdiffColMaybefid | kfSdiffColId | kfSdiffColMaybesid), |
| 302 |
kfSdiffColAll = ((kfSdiffColGeno * 2) - kfSdiffColChrom), |
| 303 |
|
| 304 |
kfSdiffCountsColMaybefid = (1 << 17), |
| 305 |
kfSdiffCountsColFid = (1 << 18), |
| 306 |
kfSdiffCountsColMaybesid = (1 << 19), |
| 307 |
kfSdiffCountsColSid = (1 << 20), |
| 308 |
kfSdiffCountsColNobs = (1 << 21), |
| 309 |
kfSdiffCountsColNobsIbs = (1 << 22), |
| 310 |
kfSdiffCountsColIbs0 = (1 << 23), |
| 311 |
kfSdiffCountsColIbs1 = (1 << 24), |
| 312 |
kfSdiffCountsColIbs2 = (1 << 25), |
| 313 |
kfSdiffCountsIbsNeeded = (kfSdiffCountsColNobsIbs | kfSdiffCountsColIbs0 | kfSdiffCountsColIbs1 | kfSdiffCountsColIbs2), |
| 314 |
kfSdiffCountsColHalfmiss = (1 << 26), |
| 315 |
kfSdiffCountsColDiff = (1 << 27), |
| 316 |
kfSdiffCountsColDefault = (kfSdiffCountsColMaybefid | kfSdiffCountsColMaybesid | kfSdiffCountsColNobs | kfSdiffCountsColHalfmiss | kfSdiffCountsColDiff), |
| 317 |
kfSdiffCountsColAll = ((kfSdiffCountsColDiff * 2) - kfSdiffCountsColMaybefid) |
| 318 |
FLAGSET_DEF_END(SdiffFlags); |
| 319 |
|
| 320 |
typedef struct SdiffStruct { |
| 321 |
NONCOPYABLE(SdiffStruct); |
| 322 |
SdiffFlags flags; |
| 323 |
Dosage dosage_hap_tol; // missing value when 'dosage' not specified |
| 324 |
char fname_id_delim; |
| 325 |
uint32_t other_id_ct; |
| 326 |
char* first_id_or_fname; |
| 327 |
char* other_ids_flattened; |
| 328 |
} SdiffInfo; |
| 329 |
|
| 330 |
FLAGSET_DEF_START() |
| 331 |
kfFst0, |
| 332 |
kfFstMethodWc = (1 << 0), |
| 333 |
kfFstReportVariants = (1 << 1), |
| 334 |
kfFstZs = (1 << 2), |
| 335 |
kfFstOneBasePop = (1 << 3), |
| 336 |
kfFstExplicitPopIds = (1 << 4), |
| 337 |
kfFstPopPairFile = (1 << 5), |
| 338 |
|
| 339 |
kfFstColNobs = (1 << 6), |
| 340 |
kfFstColDefault = 0, |
| 341 |
kfFstColAll = ((kfFstColNobs * 2) - kfFstColNobs), |
| 342 |
|
| 343 |
kfFstVcolChrom = (1 << 7), |
| 344 |
kfFstVcolPos = (1 << 8), |
| 345 |
kfFstVcolRef = (1 << 9), |
| 346 |
kfFstVcolAlt = (1 << 10), |
| 347 |
kfFstVcolMaybeprovref = (1 << 11), |
| 348 |
kfFstVcolProvref = (1 << 12), |
| 349 |
kfFstVcolNobs = (1 << 13), |
| 350 |
kfFstVcolNallele = (1 << 14), |
| 351 |
kfFstVcolFstfrac = (1 << 15), |
| 352 |
kfFstVcolFst = (1 << 16), |
| 353 |
kfFstVcolDefault = (kfFstVcolChrom | kfFstVcolPos | kfFstVcolMaybeprovref | kfFstVcolNobs | kfFstVcolFst), |
| 354 |
kfFstVcolAll = ((kfFstVcolFst * 2) - kfFstVcolChrom) |
| 355 |
FLAGSET_DEF_END(FstFlags); |
| 356 |
|
| 357 |
typedef struct FstInfoStruct { |
| 358 |
NONCOPYABLE(FstInfoStruct); |
| 359 |
FstFlags flags; |
| 360 |
uint32_t blocksize; |
| 361 |
char* pheno_name; |
| 362 |
char* first_id_or_fname; |
| 363 |
char* other_ids_flattened; |
| 364 |
} FstInfo; |
| 365 |
|
| 366 |
FLAGSET_DEF_START() |
| 367 |
kfCheckSex0, |
| 368 |
kfCheckSexImpute = (1 << 0), |
| 369 |
kfCheckSexUseX = (1 << 1), |
| 370 |
kfCheckSexUseY = (1 << 2), |
| 371 |
|
| 372 |
kfCheckSexColMaybefid = (1 << 3), |
| 373 |
kfCheckSexColFid = (1 << 4), |
| 374 |
kfCheckSexColMaybesid = (1 << 5), |
| 375 |
kfCheckSexColSid = (1 << 6), |
| 376 |
kfCheckSexColPedsex = (1 << 7), |
| 377 |
kfCheckSexColStatus = (1 << 8), |
| 378 |
kfCheckSexColXF = (1 << 9), |
| 379 |
kfCheckSexColYcount = (1 << 10), |
| 380 |
kfCheckSexColYrate = (1 << 11), |
| 381 |
kfCheckSexColYobs = (1 << 12), |
| 382 |
kfCheckSexColDefault = (kfCheckSexColMaybefid | kfCheckSexColMaybesid | kfCheckSexColPedsex | kfCheckSexColStatus | kfCheckSexColXF | kfCheckSexColYrate), |
| 383 |
kfCheckSexColAll = ((kfCheckSexColYobs * 2) - kfCheckSexColMaybefid) |
| 384 |
FLAGSET_DEF_END(CheckSexFlags); |
| 385 |
|
| 386 |
typedef struct CheckSexInfoStruct { |
| 387 |
NONCOPYABLE(CheckSexInfoStruct); |
| 388 |
CheckSexFlags flags; |
| 389 |
double max_female_xf; |
| 390 |
double min_male_xf; |
| 391 |
uint32_t max_female_ycount; |
| 392 |
uint32_t min_male_ycount; |
| 393 |
double max_female_yrate; |
| 394 |
double min_male_yrate; |
| 395 |
} CheckSexInfo; |
| 396 |
|
| 397 |
void InitUpdateAlleles(UpdateAllelesInfo* update_alleles_info_ptr); |
| 398 |
|
| 399 |
void CleanupUpdateAlleles(UpdateAllelesInfo* update_alleles_info_ptr); |
| 400 |
|
| 401 |
void InitUpdateSex(UpdateSexInfo* update_sex_info_ptr); |
| 402 |
|
| 403 |
void CleanupUpdateSex(UpdateSexInfo* update_sex_info_ptr); |
| 404 |
|
| 405 |
void InitSdiff(SdiffInfo* sdiff_info_ptr); |
| 406 |
|
| 407 |
void CleanupSdiff(SdiffInfo* sdiff_info_ptr); |
| 408 |
|
| 409 |
void InitFst(FstInfo* fst_info_ptr); |
| 410 |
|
| 411 |
void CleanupFst(FstInfo* fst_info_ptr); |
| 412 |
|
| 413 |
void InitCheckSex(CheckSexInfo* check_sex_info_ptr); |
| 414 |
|
| 415 |
PglErr UpdateVarBps(const ChrInfo* cip, const char* const* variant_ids, const uint32_t* variant_id_htable, const uint32_t* htable_dup_base, const TwoColParams* params, uint32_t sort_vars_in_cmd, uint32_t raw_variant_ct, uint32_t max_variant_id_slen, uint32_t htable_size, uint32_t max_thread_ct, uintptr_t* variant_include, uint32_t* __restrict variant_bps, uint32_t* __restrict variant_ct_ptr, UnsortedVar* vpos_sortstatusp); |
| 416 |
|
| 417 |
PglErr UpdateVarNames(const uintptr_t* variant_include, const uint32_t* variant_id_htable, const uint32_t* htable_dup_base, const TwoColParams* params, uint32_t raw_variant_ct, uint32_t htable_size, uint32_t max_thread_ct, char** variant_ids, uint32_t* max_variant_id_slen_ptr); |
| 418 |
|
| 419 |
PglErr UpdateVarAlleles(const uintptr_t* variant_include, const char* const* variant_ids, const uint32_t* variant_id_htable, const uint32_t* htable_dup_base, const uintptr_t* allele_idx_offsets, const UpdateAllelesInfo* update_alleles_info_ptr, uint32_t raw_variant_ct, uint32_t max_variant_id_slen, uint32_t htable_size, uint32_t max_allele_ct, char input_missing_geno_char, uint32_t max_thread_ct, char** allele_storage_mutable, uint32_t* max_allele_slen_ptr, char* outname, char* outname_end); |
| 420 |
|
| 421 |
PglErr RecoverVarIds(const char* fname, const uintptr_t* variant_include, const ChrInfo* cip, const uint32_t* variant_bps, const uintptr_t* allele_idx_offsets, const char* const* allele_storage, const char* missing_varid, uint32_t raw_variant_ct, uint32_t variant_ct, RecoverVarIdsFlags flags, uint32_t max_thread_ct, char** variant_ids, uint32_t* max_variant_id_slen_ptr, char* outname, char* outname_end); |
| 422 |
|
| 423 |
PglErr Plink1ClusterImport(const char* within_fname, const char* catpheno_name, const char* family_missing_catname, const uintptr_t* sample_include, const char* sample_ids, const char* missing_catname, uint32_t raw_sample_ct, uint32_t sample_ct, uintptr_t max_sample_id_blen, uint32_t mwithin_val, uint32_t max_thread_ct, PhenoCol** pheno_cols_ptr, char** pheno_names_ptr, uint32_t* pheno_ct_ptr, uintptr_t* max_pheno_name_blen_ptr); |
| 424 |
|
| 425 |
// These functions return kPglRetEof on empty files. |
| 426 |
PglErr PrescanSampleIds(const char* fname, SampleIdInfo* siip); |
| 427 |
|
| 428 |
PglErr PrescanParentalIds(const char* fname, uint32_t max_thread_ct, ParentalIdInfo* parental_id_infop); |
| 429 |
|
| 430 |
|
| 431 |
PglErr UpdateSampleIds(const char* fname, const uintptr_t* sample_include, uint32_t raw_sample_ct, uintptr_t sample_ct, SampleIdInfo* siip); |
| 432 |
|
| 433 |
PglErr UpdateSampleParents(const char* fname, const SampleIdInfo* siip, const uintptr_t* sample_include, uint32_t raw_sample_ct, uintptr_t sample_ct, uint32_t max_thread_ct, ParentalIdInfo* parental_id_infop, uintptr_t* founder_info); |
| 434 |
|
| 435 |
PglErr UpdateSampleSexes(const uintptr_t* sample_include, const SampleIdInfo* siip, const UpdateSexInfo* update_sex_info_ptr, uint32_t raw_sample_ct, uintptr_t sample_ct, uint32_t max_thread_ct, uintptr_t* sex_nm, uintptr_t* sex_male); |
| 436 |
|
| 437 |
PglErr SplitCatPheno(const char* split_cat_phenonames_flattened, const uintptr_t* sample_include, uint32_t raw_sample_ct, PhenoTransformFlags pheno_transform_flags, PhenoCol** pheno_cols_ptr, char** pheno_names_ptr, uint32_t* pheno_ct_ptr, uintptr_t* max_pheno_name_blen_ptr, PhenoCol** covar_cols_ptr, char** covar_names_ptr, uint32_t* covar_ct_ptr, uintptr_t* max_covar_name_blen_ptr); |
| 438 |
|
| 439 |
PglErr PhenoVarianceStandardize(const char* vstd_flattened, const uintptr_t* sample_include, const char* pheno_names, uint32_t raw_sample_ct, uint32_t pheno_ct, uintptr_t max_pheno_name_blen, uint32_t is_covar, uint32_t is_covar_flag, PhenoCol* pheno_cols); |
| 440 |
|
| 441 |
PglErr PhenoQuantileNormalize(const char* quantnorm_flattened, const uintptr_t* sample_include, const char* pheno_names, uint32_t raw_sample_ct, uint32_t sample_ct, uint32_t pheno_ct, uintptr_t max_pheno_name_blen, uint32_t is_covar, uint32_t is_subset_flag, PhenoCol* pheno_cols); |
| 442 |
|
| 443 |
PglErr WriteAlleleFreqs(const uintptr_t* variant_include, const ChrInfo* cip, const uint32_t* variant_bps, const char* const* variant_ids, const uintptr_t* allele_idx_offsets, const char* const* allele_storage, const uintptr_t* nonref_flags, const uint64_t* founder_allele_ddosages, const double* imp_r2_vals, const char* ref_binstr, const char* alt1_binstr, uint32_t raw_variant_ct, uint32_t variant_ct, uint32_t max_allele_ct, uint32_t max_allele_slen, PgenGlobalFlags gflags, FreqRptFlags freq_rpt_flags, uint32_t max_thread_ct, uint32_t nonfounders, char* outname, char* outname_end); |
| 444 |
|
| 445 |
PglErr WriteGenoCounts(const uintptr_t* sample_include, const uintptr_t* sex_nm, const uintptr_t* sex_male, const uintptr_t* variant_include, const ChrInfo* cip, const uint32_t* variant_bps, const char* const* variant_ids, const uintptr_t* allele_idx_offsets, const char* const* allele_storage, const uintptr_t* nonref_flags, const STD_ARRAY_PTR_DECL(uint32_t, 3, raw_geno_cts), const STD_ARRAY_PTR_DECL(uint32_t, 3, x_male_geno_cts), uint32_t raw_sample_ct, uint32_t sample_ct, uint32_t male_ct, uint32_t nosex_ct, uint32_t raw_variant_ct, uint32_t variant_ct, uint32_t x_start, uint32_t max_allele_slen, PgenGlobalFlags gflags, GenoCountsFlags geno_counts_flags, uint32_t max_thread_ct, PgenReader* simple_pgrp, char* outname, char* outname_end); |
| 446 |
|
| 447 |
PglErr WriteMissingnessReports(const uintptr_t* sample_include, const SampleIdInfo* siip, const uintptr_t* sex_nm, const uintptr_t* sex_male, const PhenoCol* pheno_cols, const char* pheno_names, const uint32_t* sample_missing_hc_cts, const uint32_t* sample_missing_dosage_cts, const uint32_t* sample_hethap_cts, const uintptr_t* variant_include, const ChrInfo* cip, const uint32_t* variant_bps, const char* const* variant_ids, const uintptr_t* allele_idx_offsets, const char* const* allele_storage, const uintptr_t* nonref_flags, const uint32_t* variant_missing_hc_cts, const uint32_t* variant_missing_dosage_cts, const uint32_t* variant_hethap_cts, uint32_t raw_sample_ct, uint32_t sample_ct, uint32_t pheno_ct, uintptr_t max_pheno_name_blen, uint32_t raw_variant_ct, uint32_t variant_ct, uintptr_t max_allele_slen, uint32_t y_nosex_missing_stats, PgenGlobalFlags gflags, uint32_t first_hap_uidx, MissingRptFlags missing_rpt_flags, uint32_t max_thread_ct, char* outname, char* outname_end); |
| 448 |
|
| 449 |
PglErr GetMultiallelicMarginalCounts(const uintptr_t* founder_info, const uintptr_t* sex_nm, const uintptr_t* sex_male, const uintptr_t* variant_include, const ChrInfo* cip, const uintptr_t* allele_idx_offsets, const STD_ARRAY_PTR_DECL(uint32_t, 3, hwe_geno_cts), uint32_t raw_sample_ct, uint32_t autosomal_variant_ct, uint32_t autosomal_xallele_ct, uint32_t hwe_x_ct, uint32_t x_xallele_ct, PgenReader* simple_pgrp, STD_ARRAY_PTR_DECL(uint32_t, 2, x_male_xgeno_cts), STD_ARRAY_PTR_DECL(uint32_t, 2, autosomal_xgeno_cts), STD_ARRAY_PTR_DECL(uint32_t, 2, x_knownsex_xgeno_cts)); |
| 450 |
|
| 451 |
PglErr ComputeHweXLnPvals(const uintptr_t* variant_include, const uintptr_t* allele_idx_offsets, const STD_ARRAY_PTR_DECL(uint32_t, 3, founder_raw_geno_cts), const STD_ARRAY_PTR_DECL(uint32_t, 3, founder_x_male_geno_cts), const STD_ARRAY_PTR_DECL(uint32_t, 3, founder_x_nosex_geno_cts), const STD_ARRAY_PTR_DECL(uint32_t, 2, x_knownsex_xgeno_cts), const STD_ARRAY_PTR_DECL(uint32_t, 2, x_male_xgeno_cts), uint32_t x_start, uint32_t hwe_x_ct, uintptr_t x_xallele_ct, uint32_t hwe_midp, uint32_t calc_thread_ct, double** hwe_x_ln_pvals_ptr); |
| 452 |
|
| 453 |
PglErr HardyReport(const uintptr_t* variant_include, const ChrInfo* cip, const uint32_t* variant_bps, const char* const* variant_ids, const uintptr_t* allele_idx_offsets, const char* const* allele_storage, const uintptr_t* nonref_flags, const STD_ARRAY_PTR_DECL(uint32_t, 3, hwe_geno_cts), const STD_ARRAY_PTR_DECL(uint32_t, 2, autosomal_xgeno_cts), const STD_ARRAY_PTR_DECL(uint32_t, 3, hwe_x_male_geno_cts), const STD_ARRAY_PTR_DECL(uint32_t, 3, hwe_x_nosex_geno_cts), const STD_ARRAY_PTR_DECL(uint32_t, 2, x_knownsex_xgeno_cts), const STD_ARRAY_PTR_DECL(uint32_t, 2, x_male_xgeno_cts), const double* hwe_x_pvals, uint32_t variant_ct, uint32_t hwe_x_ct, uint32_t max_allele_slen, PgenGlobalFlags gflags, double output_min_ln, HardyFlags hardy_flags, uint32_t max_thread_ct, uint32_t nonfounders, char* outname, char* outname_end); |
| 454 |
|
| 455 |
PglErr SampleCounts(const uintptr_t* sample_include, const SampleIdInfo* siip, const uintptr_t* sex_nm, const uintptr_t* sex_male, const uintptr_t* variant_include, const ChrInfo* cip, const uintptr_t* allele_idx_offsets, const char* const* allele_storage, uint32_t raw_sample_ct, uint32_t sample_ct, uint32_t male_ct, uint32_t raw_variant_ct, uint32_t variant_ct, uint32_t max_allele_ct, SampleCountsFlags flags, uint32_t max_thread_ct, uintptr_t pgr_alloc_cacheline_ct, PgenFileInfo* pgfip, char* outname, char* outname_end); |
| 456 |
|
| 457 |
PglErr Sdiff(const uintptr_t* orig_sample_include, const SampleIdInfo* siip, const uintptr_t* sex_nm, const uintptr_t* sex_male, const uintptr_t* variant_include, const ChrInfo* cip, const uint32_t* variant_bps, const char* const* variant_ids, const uintptr_t* allele_idx_offsets, const char* const* allele_storage, const SdiffInfo* sdip, uint32_t raw_sample_ct, uint32_t orig_sample_ct, uint32_t raw_variant_ct, uint32_t variant_ct, uint32_t iid_sid, uint32_t max_thread_ct, PgenReader* simple_pgrp, char* outname, char* outname_end); |
| 458 |
|
| 459 |
PglErr WriteSnplist(const uintptr_t* variant_include, const char* const* variant_ids, uint32_t variant_ct, uint32_t output_zst, uint32_t allow_dups, uint32_t max_thread_ct, char* outname, char* outname_end); |
| 460 |
|
| 461 |
PglErr WriteCovar(const uintptr_t* sample_include, const PedigreeIdInfo* piip, const uintptr_t* sex_nm, const uintptr_t* sex_male, const PhenoCol* pheno_cols, const char* pheno_names, const PhenoCol* covar_cols, const char* covar_names, const uint32_t* new_sample_idx_to_old, const char* output_missing_pheno, uint32_t sample_ct, uint32_t pheno_ct, uintptr_t max_pheno_name_blen, uint32_t covar_ct, uintptr_t max_covar_name_blen, WriteCovarFlags write_covar_flags, char* outname, char* outname_end); |
| 462 |
|
| 463 |
PglErr HetReport(const uintptr_t* sample_include, const SampleIdInfo* siip, const uintptr_t* orig_variant_include, const ChrInfo* cip, const uintptr_t* allele_idx_offsets, const double* allele_freqs, const uintptr_t* founder_info, uint32_t raw_sample_ct, uint32_t sample_ct, uint32_t founder_ct, uint32_t raw_variant_ct, uint32_t orig_variant_ct, uint32_t max_allele_ct, HetFlags flags, uint32_t max_thread_ct, uintptr_t pgr_alloc_cacheline_ct, PgenFileInfo* pgfip, char* outname, char* outname_end); |
| 464 |
|
| 465 |
PglErr CheckOrImputeSex(const uintptr_t* sample_include, const SampleIdInfo* siip, const uintptr_t* orig_variant_include, const ChrInfo* cip, const uintptr_t* allele_idx_offsets, const double* allele_freqs, const CheckSexInfo* csip, uint32_t raw_sample_ct, uint32_t sample_ct, uint32_t raw_variant_ct, uint32_t max_allele_ct, uint32_t max_thread_ct, uintptr_t pgr_alloc_cacheline_ct, uintptr_t* sex_nm, uintptr_t* sex_male, PgenFileInfo* pgfip, char* outname, char* outname_end); |
| 466 |
|
| 467 |
PglErr FstReport(const uintptr_t* orig_sample_include, const uintptr_t* sex_male, const PhenoCol* pheno_cols, const char* pheno_names, const uintptr_t* orig_variant_include, const ChrInfo* cip, const uint32_t* variant_bps, const char* const* variant_ids, const uintptr_t* allele_idx_offsets, const char* const* allele_storage, const FstInfo* fst_infop, uint32_t raw_sample_ct, uint32_t pheno_ct, uintptr_t max_pheno_name_blen, uint32_t raw_variant_ct, uint32_t orig_variant_ct, uint32_t max_allele_ct, uint32_t max_thread_ct, uintptr_t pgr_alloc_cacheline_ct, PgenFileInfo* pgfip, char* outname, char* outname_end); |
| 468 |
|
| 469 |
PglErr CheckAlleleUniqueness(const uintptr_t* variant_include, const ChrInfo* cip, const ChrIdx* chr_idxs, const uint32_t* variant_bps, const char* const* variant_ids, const uintptr_t* allele_idx_offsets, const char* const* allele_storage, uint32_t variant_ct, uint32_t max_allele_ct, uint32_t max_thread_ct); |
| 470 |
|
| 471 |
#ifdef __cplusplus |
| 472 |
} // namespace plink2 |
| 473 |
#endif |
| 474 |
|
| 475 |
#endif // __PLINK2_MISC_H__ |