MGHome page

GWAS course

Course map

0 of 64 steps done

Start with step 0.1Install R

Saved in this browser only.

Step 7.8

Module 7 · Plots and reporting · step 8 of 8

7.8Final summary and reporting

Commands tested on Windows

In short

We save a final report and a table of the lead variant in each of the three groups. We calculate intervals that describe uncertainty in the estimated effects and check the saved report, tables and main figures so others can review the analysis.

Do this

You should see: A final summary, three rows for the lead variants with alleles, odds ratios and intervals, and all main figures.

Command

Module setup, needed before this step

R: module setup

source("R/guided.R")cfg <- guided_init()

R command

Type or paste into the RStudio console.

1psam <- guided_table(paste0(guided_path(cfg, "5.7"), ".psam"))comparison <- read.delim(guided_path(cfg, "7.7", "comparison.tsv"))clumps <- guided_table(paste0(guided_path(cfg, "7.5", "clump"), ".clumps"))stats <- guided_summary_stats(cfg)2lead <- stats[match(clumps$ID, stats$variant_id), c("chromosome", "base_pair_location", "variant_id", "effect_allele", "odds_ratio", "beta", "standard_error", "p_value", "n")]lead$ci_low <- exp(lead$beta - 1.96 * lead$standard_error)lead$ci_high <- exp(lead$beta + 1.96 * lead$standard_error)3guided_write(lead, guided_path(cfg, "7.8", "leads.tsv"))4summary <- c("# Simulated GWAS: main-path summary", "", "Genome assembly: GRCh38. Simulated data, seed 20261111.",  paste("Software:", paste(cfg$version, collapse = "; ")),  "Initial: 2,016 measured wells, 2,000 people, 299,523 variant entries.",  paste("Final cohort:", nrow(psam), "samples; cases:", sum(psam$Disease == "2"), "; controls:", sum(psam$Disease == "1")),  "After QC: 238,513 variants; 236,815 finite additive association tests.",  "Model: additive logistic regression, adjusted for age, recorded sex and ten within-cohort PCs; Firth fallback enabled.",  "Eight variants pass p < 5e-8 in three LD clumps. Autosomal lambda is approximately 1.016.",  "Report the effect allele, odds ratio, 95% interval, p-value and per-variant sample count n from s7-8_leads.tsv.",  "Interpretation: the three simulated regions with very small p-values are recovered; the moderate region is subthreshold. No causal gene is established.",  "Sensitivity: omitting PCs increases lambda to approximately 1.546; omitting sample/variant QC as well gives approximately 1.655.",  "Limitations: simulated design, selected array sites, finite power, provisional imported REF labels, study-specific QC and ancestry rules.",  "Three named ancestry markers left at HWE step 4.4; comparisons must not pretend they survived to module 5.",  "Figures: s7-1_qq.png, s7-3_manhattan.png, s7-6_regional.png and s7-7_qq_comparison.png.",  "No biological discovery or clinical recommendation follows from this simulation.")5writeLines(summary, guided_path(cfg, "7.8", "summary.md"), useBytes = TRUE)# Course bookkeeping: records the counts for the next step. Do not change.files <- c(guided_path(cfg, "7.8", "summary.md"), guided_path(cfg, "7.8", "leads.tsv"),  guided_path(cfg, "7.1", "qq.png"), guided_path(cfg, "7.3", "manhattan.png"),  guided_path(cfg, "7.6", "regional.png"), guided_path(cfg, "7.7", "qq_comparison.png"),  guided_path(cfg, "7.7", "comparison.tsv"), paste0(guided_path(cfg, "7.5", "clump"), ".clumps"),  file.path(cfg$out, "step_counts.tsv"), file.path(cfg$out, "software_versions.txt"))guided_artifact_checkpoint(cfg, "7.8", files, parent = "6.8")check_step("7.8", data_dir = cfg$out, work_dir = cfg$out)6cat(paste(summary, collapse = "\n"), "\n")
  1. Note 1: Read the final sample counts, comparison table, variant groups and association results.
  2. Note 2: Select the lead variant in each group and calculate its uncertainty interval.
  3. Note 3: Save the table of the three lead variants.
  4. Note 4: Prepare the report describing the analysis, results and limitations.
  5. Note 5: Save the report as a text file.
  6. Note 6: Print the final report.

You need

Modules 0 to 6, checked. Also the summary statistics file from step 6.8 and the figures and comparisons from steps 7.1 to 7.7.

What we do

Write a clear summary of the whole simulated main path. Save the final results and figures so that others can check them.

Why

A report must link the study design, the QC decisions, the model, the effect sizes, the uncertainty and the figures. Include the genome build, the software versions, the numbers of samples, the exclusions, the PCs, the tested allele and the threshold. Report the odds ratio (opens in a new tab) and its 95% confidence interval (opens in a new tab) for each lead variant. The interval shows how uncertain the estimate is.

Keep two differences clear. An association that we observed is not a proof of a cause. A signal that we simulated for teaching is not a biological discovery. A result that is not significant can come from low statistical power (opens in a new tab), which is the chance to detect an effect of a given size in this study. Keep a record that others can repeat, but do not publish data about single people.

Illustration in preparation

Alt text: Teaching schematic: Final summary and reporting.
PLINK terminal equivalent. Optional: you do not need it for the course.

Not applicable: this step needs no PLINK command. The R chunk is the complete command.

R reads or calculates the displayed values without changing the genotype files.

Expected result

Show the expected result

A final summary, three rows for the lead variants with alleles, odds ratios and intervals, and all main figures. The 7.8 checkpoint manifest protects these files. The main path ends here. Imputation, mixed models and the analysis after a GWAS are not part of it.

The tested PLINK version is set in config.R and recorded in software_versions.txt. Validation: the executable chunks, the comparisons with the expected results and the final plot checks passed on Windows.

If something goes wrong

If something goes wrong

Stop at the first error. Check the input file that R names and the previous step. Keep the command and the messages from the console. Do not use files from a different version of the dataset. See troubleshooting (opens in a new tab).

Quick check

What more evidence would we need before we call a simulated association a biological discovery?

Show the answer

We would need real data that are handled under proper rules, replication (opens in a new tab) in independent data and suitable biological evidence. This simulation gives none of these.

Files created

s7-8_summary.md, s7-8_leads.tsv, and the complete checkpoints/7.8/ artifact checkpoint.