meta
Meta analysis of multi-ancestry gwas data.
meta(inputs, meta_method='meta_all')
¶
Perform meta-analysis using the specified method.
Parameters¶
inputs : LocusSet LocusSet containing input data from multiple studies. meta_method : str, optional Meta-analysis method to use, by default "meta_all". Options: - "meta_all": Meta-analyze all studies together - "meta_by_population": Meta-analyze within each population separately - "no_meta": No meta-analysis, just intersect individual studies
Returns¶
LocusSet LocusSet containing meta-analyzed results.
Raises¶
ValueError If an unsupported meta-analysis method is specified.
Notes¶
The different methods serve different purposes:
- "meta_all": Maximizes power by combining all studies, but may be inappropriate if LD patterns differ substantially between populations
- "meta_by_population": Preserves population-specific LD while allowing meta-analysis within populations
- "no_meta": Keeps studies separate, useful for comparison or when meta-analysis is not appropriate
Source code in credtools/meta.py
meta_all(inputs)
¶
Perform comprehensive meta-analysis of both summary statistics and LD matrices.
Parameters¶
inputs : LocusSet LocusSet containing input data from multiple studies.
Returns¶
Locus Meta-analyzed Locus object with combined population and cohort identifiers.
Notes¶
This function:
- Performs meta-analysis of summary statistics using inverse-variance weighting
- Performs meta-analysis of LD matrices using sample-size weighting
- Combines population and cohort names from all input studies
- Sums sample sizes across studies
- Intersects the meta-analyzed data to ensure consistency
Population and cohort names are combined with "+" as separator and sorted alphabetically.
Source code in credtools/meta.py
meta_by_population(inputs)
¶
Perform meta-analysis within each population separately.
Parameters¶
inputs : LocusSet LocusSet containing input data from multiple studies.
Returns¶
Dict[str, Locus] Dictionary mapping population codes to meta-analyzed Locus objects.
Notes¶
This function:
- Groups studies by population code
- Performs meta-analysis within each population group
- For single-study populations, applies intersection without meta-analysis
- Returns a dictionary with population codes as keys
This approach preserves population-specific LD patterns while still allowing meta-analysis of multiple cohorts within the same population.
Source code in credtools/meta.py
meta_lds(inputs)
¶
Perform meta-analysis of LD matrices using sample-size weighted averaging.
Parameters¶
inputs : LocusSet LocusSet containing input data from multiple studies.
Returns¶
LDMatrix Meta-analyzed LD matrix with merged variant map.
Notes¶
This function performs the following operations:
- Identifies unique variants across all studies
- Creates a master variant list sorted by chromosome and position
- Performs sample-size weighted averaging of LD correlations
- Handles missing variants by setting weights to zero
- Optionally meta-analyzes allele frequencies if available
The meta-analysis formula: LD_meta[i,j] = Σ(LD_k[i,j] * N_k) / Σ(N_k)
where k indexes studies, N_k is sample size, and the sum is over studies that have both variants i and j.
Source code in credtools/meta.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
meta_loci(inputs, outdir, threads=1, meta_method='meta_all', calculate_lambda_s=False)
¶
Perform meta-analysis on multiple loci in parallel.
Parameters¶
inputs : str Path to input file containing locus information. Must be a tab-separated file with columns including 'locus_id'. outdir : str Output directory path where results will be saved. threads : int, optional Number of parallel threads to use, by default 1. meta_method : str, optional Meta-analysis method to use, by default "meta_all". calculate_lambda_s : bool, optional Whether to calculate lambda_s parameter using estimate_s_rss function, by default False. See meta() function for available options.
Returns¶
None Results are saved to files in the output directory.
Notes¶
This function:
- Reads locus information from the input file
- Groups loci by locus_id for parallel processing
- Processes each locus group using the specified meta-analysis method
- Saves results with a progress bar for user feedback
- Creates a summary file (loci_info.txt) with all processed loci
The input file should contain columns: locus_id, prefix, popu, cohort, sample_size. Each locus_id can have multiple rows representing different cohorts/populations.
Output files are organized as: {outdir}/{locus_id}/{prefix}.{sumstats.gz,ld.npz,ldmap.gz}
Source code in credtools/meta.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
|
meta_locus(args)
¶
Process a single locus for meta-analysis.
Parameters¶
args : Tuple[str, pd.DataFrame, str, str] A tuple containing: - locus_id : str The ID of the locus - locus_info : pd.DataFrame DataFrame containing locus information - outdir : str Output directory path - meta_method : str Method for meta-analysis
Returns¶
List[List[Any]] A list of results containing processed locus information. Each inner list contains: [chrom, start, end, popu, sample_size, cohort, out_prefix, locus_id]
Notes¶
This function is designed for parallel processing and:
- Loads the locus set from the provided information
- Performs meta-analysis using the specified method
- Creates output directory for the locus
- Saves results to compressed files (sumstats.gz, ld.npz, ldmap.gz)
- Returns metadata for each processed locus
Source code in credtools/meta.py
meta_sumstats(inputs)
¶
Perform fixed effect meta-analysis of summary statistics.
Parameters¶
inputs : LocusSet LocusSet containing input data from multiple studies.
Returns¶
pd.DataFrame Meta-analysis summary statistics with columns: SNPID, BETA, SE, P, EAF, CHR, BP, EA, NEA.
Notes¶
This function performs inverse-variance weighted fixed-effects meta-analysis:
- Merges summary statistics from all studies on SNPID
- Calculates inverse-variance weights (1/SE²)
- Computes weighted average effect size
- Calculates meta-analysis standard error
- Computes Z-scores and p-values
- Performs sample-size weighted averaging of effect allele frequencies
The meta-analysis formulas used: - Beta_meta = Σ(Beta_i * Weight_i) / Σ(Weight_i) - SE_meta = 1 / sqrt(Σ(Weight_i)) - Weight_i = 1 / SE_i²