mecfs_bio.build_system.task.fixed_effect_meta_analysis_task
Task to combine GWAS with fixed-effects meta analysis
Classes:
-
CaseControlSampleInfo–Specifies the number of cases and controls in a case control study
-
FixedEffectsMetaAnalysisTask–Task to perform a fixed effects meta analysis on non-overlapping GWAS of the same trait
-
GwasSource–Describes a source from which to draw GWAS data in order to perform a meta analysis
Functions:
-
check_source–Fail fast on input that a fixed effects meta analysis cannot combine.
-
combine_prepared_sources–Combine prepared studies into the meta analysis by inverse variance weighting.
-
common_harmonized_build–The genome build that every source is harmonized to.
-
prepare_source–Reduce a study to its variant key and the quantities the meta analysis sums.
-
read_source– -
report_output_size– -
report_study_count_distribution–How many variants each number of contributing studies accounts for. Variants
-
rsid_column–The rsID of a study, or a column of nulls for a study that does not report one, so
Attributes:
-
META_ANALYSIS_NUM_STUDIES_COL– -
SampleInfo– -
logger–
CaseControlSampleInfo
Specifies the number of cases and controls in a case control study
Methods:
Attributes:
FixedEffectsMetaAnalysisTask
Bases: Task
Task to perform a fixed effects meta analysis on non-overlapping GWAS of the same trait
Every source must be harmonized to the same reference genome build, so that its non-effect allele is the reference allele (as produced by GenomeReferenceHarmonizationTask). This is checked from the sources' metadata at construction. A variant is then identified exactly by chromosome, position, reference allele and effect allele, and no allele flipping is performed. Identifying variants by their unordered allele pair instead would be unsafe: an insertion and the mirrored deletion at the same position (for example T/TCA and TCA/T) share an allele pair but are distinct variants.
The variants present in the output dataframe are the union of the variants in the studies, so a variant genotyped by only some of the studies is kept and is combined from those studies alone.
Each output variant carries a sample size column, GWASLAB_SAMPLE_SIZE_COLUMN, holding the sum of the effective sample sizes of just the studies that contributed to it, and a count of those studies in META_ANALYSIS_NUM_STUDIES_COL. Because that sample size varies per variant, downstream analyses should consume it with a PerVariantSampleSize rather than a scalar.
Output rows are ordered by chromosome and position.
For more information on fixed effects meta analysis, see: Chapter 22 of Balding, David J., Ida Moltke, and John Marioni, eds. Handbook of statistical genomics. John Wiley & Sons, 2019.
Methods:
Attributes:
create
classmethod
Source code in mecfs_bio/build_system/task/fixed_effect_meta_analysis_task.py
execute
Source code in mecfs_bio/build_system/task/fixed_effect_meta_analysis_task.py
GwasSource
Describes a source from which to draw GWAS data in order to perform a meta analysis
The pipe is applied after reading and must not change allele orientation, since the meta analysis relies on the task's harmonization to the reference genome.
Attributes:
-
pipe(DataProcessingPipe) – -
sample_info(SampleInfo) – -
task(Task) –
check_source
Fail fast on input that a fixed effects meta analysis cannot combine.
Every check is gathered in one streaming pass, so validating a study costs one scan of it however many things are being checked.
Source code in mecfs_bio/build_system/task/fixed_effect_meta_analysis_task.py
combine_prepared_sources
Combine prepared studies into the meta analysis by inverse variance weighting.
Stacking the studies and grouping by variant, rather than joining them pairwise, keeps this to a single streaming pass whose memory is set by the number of distinct output variants rather than by the combined size of the studies.
Source code in mecfs_bio/build_system/task/fixed_effect_meta_analysis_task.py
common_harmonized_build
The genome build that every source is harmonized to.
Asserts that each source's metadata records harmonization with the non-effect allele as the reference allele, and that all sources share one build.
Source code in mecfs_bio/build_system/task/fixed_effect_meta_analysis_task.py
prepare_source
Reduce a study to its variant key and the quantities the meta analysis sums.
Source code in mecfs_bio/build_system/task/fixed_effect_meta_analysis_task.py
read_source
report_output_size
report_study_count_distribution
How many variants each number of contributing studies accounts for. Variants backed by a single study are the lowest powered part of a union meta analysis, so their share is worth seeing.
Source code in mecfs_bio/build_system/task/fixed_effect_meta_analysis_task.py
rsid_column
The rsID of a study, or a column of nulls for a study that does not report one, so that studies remain vertically concatenable.