7354383ad1e6cb20625d5203a9593ce5022aa2ea angie Mon Aug 29 16:00:58 2011 -0700 Feature #2823 (VCF track handler): on details page, display allele andgenotype frequencies as percents. When genotypes are given, display Hardy-Weinberg equilibrium genotype probabilities for comparison. diff --git src/hg/hgc/vcfClick.c src/hg/hgc/vcfClick.c index e39854b..62a7fab 100644 --- src/hg/hgc/vcfClick.c +++ src/hg/hgc/vcfClick.c @@ -149,42 +149,49 @@ refs++; else alts++; if (gt->hapIxA == 0 && gt->hapIxB == 0) refRefs++; else if (gt->hapIxA == 1 && gt->hapIxB == 1) altAlts++; else if ((gt->hapIxA == 1 && gt->hapIxB == 0) || (gt->hapIxA == 0 && gt->hapIxB == 1)) refAlts++; else gtOther++; } } printf("<B>Genotype count:</B> %d (%d phased)<BR>\n", vcff->genotypeCount, phasedGts); -printf("<B>Alleles:</B> %s: %d (%.2f); %s: %d (%.2f)<BR>\n", - rec->alleles[0], refs, (double)refs/(2*vcff->genotypeCount), - rec->alleles[1], alts, (double)alts/(2*vcff->genotypeCount)); +double refAf = (double)refs/(2*vcff->genotypeCount); +double altAf = (double)alts/(2*vcff->genotypeCount); +printf("<B>Alleles:</B> %s: %d (%.3f%%); %s: %d (%.3f%%)<BR>\n", + rec->alleles[0], refs, 100*refAf, rec->alleles[1], alts, 100*altAf); if (vcff->genotypeCount > 1) { - printf("<B>Genotypes:</B> %s/%s: %d (%.2f); %s/%s: %d (%.2f); %s/%s: %d (%.2f)", - rec->alleles[0], rec->alleles[0], refRefs, (double)refRefs/vcff->genotypeCount, - rec->alleles[0], rec->alleles[1], refAlts, (double)refAlts/vcff->genotypeCount, - rec->alleles[1], rec->alleles[1], altAlts, (double)altAlts/vcff->genotypeCount); + printf("<B>Genotypes:</B> %s/%s: %d (%.3f%%); %s/%s: %d (%.3f%%); %s/%s: %d (%.3f%%)", + rec->alleles[0], rec->alleles[0], refRefs, 100*(double)refRefs/vcff->genotypeCount, + rec->alleles[0], rec->alleles[1], refAlts, 100*(double)refAlts/vcff->genotypeCount, + rec->alleles[1], rec->alleles[1], altAlts, 100*(double)altAlts/vcff->genotypeCount); if (gtOther > 0) - printf("; other: %d (%.2f)", gtOther, (double)gtOther/vcff->genotypeCount); + printf("; other: %d (%.3f)", gtOther, (double)gtOther/vcff->genotypeCount); printf("<BR>\n"); + if (rec->alleleCount == 2) + printf("<B>Hardy-Weinberg equilibrium:</B> " + "P(%s/%s) = %.3f%%; P(%s/%s) = %.3f%%; P(%s/%s) = %.3f%%<BR>", + rec->alleles[0], rec->alleles[0], 100*refAf*refAf, + rec->alleles[0], rec->alleles[1], 100*2*refAf*altAf, + rec->alleles[1], rec->alleles[1], 100*altAf*altAf); } jsBeginCollapsibleSection(cart, track, "genotypes", "Detailed genotypes", FALSE); dyStringClear(tmp1); dyStringAppend(tmp1, rec->format); enum vcfInfoType formatTypes[256]; char *formatKeys[256]; int formatCount = chopString(tmp1->string, ":", formatKeys, ArraySize(formatKeys)); puts("<B>Genotype info key:</B><BR>"); for (i = 0; i < formatCount; i++) { if (sameString(formatKeys[i], vcfGtGenotype)) continue; const struct vcfInfoDef *def = vcfInfoDefForGtKey(vcff, formatKeys[i]); char *desc = def ? def->description : "<em>not described in VCF header</em>"; printf(" <B>%s:</B> %s<BR>\n", formatKeys[i], desc);