code: def heritability(args):
      
      p = OptionParser(heritability.__doc__)
      opts, args, iopts = p.set_image_options(args, figsize="12x18")
  
      if len(args) != 3:
          sys.exit(not p.print_help())
  
      combined, mz, dz = args
  
      # Prepare twins data
      def get_pairs(filename):
          with open(filename) as fp:
              for row in fp:
                  yield row.strip().split(",")
  
      MZ = list(get_pairs(mz))
      DZ = list(get_pairs(dz))
  
      print(len(MZ), "monozygotic twins")
      print(len(DZ), "dizygotic twins")
  
      df = pd.read_csv(combined, sep="\t", index_col=0)
      df["Sample name"] = np.array(df["Sample name"], dtype=np.str)
      gender = extract_trait(df, "Sample name", "hli_calc_gender")
      sameGenderMZ = list(filter_same_gender(MZ, gender))
      sameGenderDZ = list(filter_same_gender(DZ, gender))
  
      composite(df, sameGenderMZ, sameGenderDZ, size=(iopts.w, iopts.h))
      logging.getLogger().setLevel(logging.CRITICAL)
      savefig("heritability.pdf")
docs: %prog pg.tsv MZ-twins.csv DZ-twins.csv
  
      Plot composite figures ABCD on absolute difference of 4 traits,
      EFGH on heritability of 4 traits. The 4 traits are:
      telomere length, ccn.chrX, ccn.chrY, TRA.PPM