C++ Class: Pedigree Example

From Genome Analysis Wiki
Jump to: navigation, search


#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

  // The pedigree file contains a list of individuals, stored one
  // per row, with specific information about each individual as
  // detailed in the data file.

  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

  // 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); 

  // Genotype for a specific individual at a specific marker
  ped[0].markers[0].isKnown();      // Test if genotype is known
  ped[0].markers[0].isHomozygous(); // Test if genotype is homozygous
  ped[0].markers[0][0];             // Index of first allele
  ped[0].markers[0][1];             // Index of second allele