C++ Class: Pedigree Example
From Genome Analysis Wiki
Jump to navigationJump to searchExample
#include "Pedigree.h"
int main(int argc, char ** argv);
{
Pedigree ped;
// The data file contains a description of the contents of the
// pedigree file, including for example, a list of marker and
// trait names
ped.Prepare("pedigree.dat");
// The pedigree file contains a list of individuals, stored one
// per row, with specific information about each individual as
// detailed in the data file.
ped.Load("pedigree.ped");
printf("Loaded %d individuals\n", ped.count);
printf("Loaded %d markers\n", ped.markerCount);
// Print out names of the first 10 individuals
for (int i = 0; i < max(ped.count, 10); i++)
printf("Individual #1 is labeled %s\n", (const char *) ped[i].pid);
if (ped.markerCount == 0)
{
printf("No marker data available!\n");
return 0;
}
// Estimate allele frequencies for all markers
ped.EstimateAlleleFrequencies();
// Get some genotype statistics for the first marker
printf("Statistics for marker %s\n", (const char *) ped.markerNames[0]);
// Get information on the first marker
MarkerInfo * info = ped.GetMarkerInfo(0);
// Get information on marker rs12345
MarkerInfo * rs12345 = ped.GetMarkerInfo("rs12345");
// Number of alleles for the first marker
int alleleCount = info.GetAlleleCount();
// Frequency of the first allele
int freq1 = info.freq[1];
// Name of the first allele, typically "A", "C", "G" or "T" for SNPs
String label = info.GetAlleleLabel(1);
}