Genotype preprocessing#
Convert raw genotype VCFs into quality-controlled, sample-matched PLINK datasets and genetic principal components for downstream xQTL analysis.
Miniprotocol Timing#
This is the total duration for all phases; module-specific timings appear on their respective pages.
Timing: ~3-5 min (on the toy dataset)
Overview#
This mini-protocol walks through how raw genotype VCFs are normalized, converted to PLINK, quality-controlled, matched to molecular-phenotype samples, and prepared for population-structure adjustment. Each step calls a workflow from VCF_QC.ipynb, genotype_formatting.ipynb, GWAS_QC.ipynb, or PCA.ipynb.
The commands are organized as selectable routes rather than one mandatory 12-step chain. The standard route estimates principal components in unrelated individuals. Use the conditional extension only when related individuals will remain in the analysis and must be projected into the same PCA space before the datasets are recombined.
Steps#
Choose a route before running commands; the 12 commands are not one mandatory chain.
Analysis goal |
Commands to run, in order |
Inputs |
|---|---|---|
Produce a QC-passed, chromosome-partitioned PLINK dataset |
1 → 2 → 3 → 4 |
|
Match samples and estimate PCA in unrelated individuals |
1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 |
Basic-route inputs plus |
Retain related individuals by PCA projection |
1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 → 9 → 10 → 11 → 12 |
Standard-PCA inputs plus |
Run only the row matching the intended analysis goal, following its commands in numerical order.
1. Quality-control the input VCF#
What it does: Normalize and filter the toy VCF against dbSNP and GRCh38.
sos run pipeline/VCF_QC.ipynb qc \
--genoFile input/genotype/protocol_example.genotype.chr22.vcf.gz \
--dbsnp-variants input/reference_data/00-All.add_chr.variants.gz \
--reference-genome input/reference_data/GRCh38_full_analysis_set_plus_decoy_hla.noALT_noHLA_noDecoy_ERCC.fasta \
--cwd output/vcf_qc \
--skip-vcf-header-filtering True
2. Convert the QC-passed VCF to PLINK and merge chromosomes#
What it does: Convert the output of step 1 to PLINK. The merge command generalizes to multiple chromosome-level files.
sos run pipeline/genotype_formatting.ipynb vcf_to_plink \
--genoFile output/vcf_qc/protocol_example.genotype.chr22.leftnorm.vcf.gz \
--cwd output/genotype_formatting/plink \
--name protocol_example \
-j 4
sos run pipeline/genotype_formatting.ipynb merge_plink \
--genoFile `ls output/genotype_formatting/plink/protocol_example.genotype.chr*.bed` \
--name protocol_example.genotype.merged \
--cwd output/genotype_formatting/plink \
-j 2
3. Apply PLINK-level quality control#
What it does: Apply genotype-, sample- and Hardy-Weinberg-equilibrium filters to the merged PLINK dataset.
sos run pipeline/GWAS_QC.ipynb qc_no_prune \
--cwd output/gwas_qc/plink \
--genoFile output/genotype_formatting/plink/protocol_example.genotype.merged.bed \
--geno-filter 0.1 \
--mind-filter 0.1 \
--hwe-filter 1e-08 \
--mac-filter 0
4. Partition the QC-passed genotype data by chromosome#
What it does: Create chromosome-specific PLINK files required by chromosome-oriented downstream workflows.
sos run pipeline/genotype_formatting.ipynb genotype_by_chrom \
--genoFile output/gwas_qc/plink/protocol_example.genotype.merged.plink_qc.bed \
--cwd output/genotype_by_chrom \
--chrom `cut -f 1 output/gwas_qc/plink/protocol_example.genotype.merged.plink_qc.bim | uniq | sed "s/chr//g"` \
-j 4
5. Match genotype and molecular-phenotype samples#
What it does: Retain the sample intersection between the QC-passed genotype data and molecular phenotype.
sos run pipeline/GWAS_QC.ipynb genotype_phenotype_sample_overlap \
--cwd output/gwas_qc/genotype \
--genoFile output/gwas_qc/plink/protocol_example.genotype.merged.plink_qc.fam \
--phenoFile input/rnaseq/protocol_example.rnaseq.bed.gz
11. Remove projected PCA outliers#
What it does: Remove projected outliers before recombining samples.
sos run pipeline/GWAS_QC.ipynb qc_no_prune \
--cwd output/pca_related \
--genoFile output/pca_related/protocol_example.genotype.merged.plink_qc.protocol_example.king.related.for_pca.plink_qc.extracted.bed \
--remove-samples output/pca_uf/protocol_example.pca_pheno.pca.projected.outliers \
--name no_outlier
Output Files#
Route or step |
Products |
|---|---|
Step 1: VCF quality control |
|
Step 2: PLINK conversion and merge |
|
Step 3: PLINK quality control |
|
Step 4: Chromosome partitioning |
|
Step 5: Sample matching |
|
Step 6: Kinship |
KING results and related/unrelated PLINK subsets under |
Steps 7–8: Unrelated-sample PCA |
LD-pruned PLINK data under |
Steps 9–11: Related-sample projection |
Variant-matched related PLINK data under |
Step 12: Recombined analysis dataset |
|
Anticipated Results#
The QC route produces normalized genotype data in PLINK format, including chromosome-partitioned files for downstream xQTL workflows. The standard PCA route additionally produces sample-matched related and unrelated subsets, an LD-pruned unrelated dataset, and principal-component scores estimated without close relatives.
When related individuals are retained, steps 9–12 project them using the unrelated-sample PCA loadings, remove designated projection outliers, and recombine the retained samples into the final analysis dataset.
Proceed to phenotype and covariate preprocessing before association testing.
Command interface#
List the workflows and parameters available in each module used by this mini-protocol.
sos run pipeline/VCF_QC.ipynb -h
sos run pipeline/genotype_formatting.ipynb -h
sos run pipeline/GWAS_QC.ipynb -h
sos run pipeline/PCA.ipynb -h