Skip to content

Instantly share code, notes, and snippets.

@Pragyagarg
Last active December 4, 2018 01:34
Show Gist options
  • Save Pragyagarg/8a8fb27883f0cda45dd60f2f1950d6ec to your computer and use it in GitHub Desktop.
Save Pragyagarg/8a8fb27883f0cda45dd60f2f1950d6ec to your computer and use it in GitHub Desktop.
final
license: mit
Generation numberOfChildren childrenList mouseId gender litter fatherId motherId dobMonth dobDay dobYear dodMonth dodDay dodYear tod notes OSM NA NA
2 0 [] 19 F C3 1 4 4 11 2011 5 6 2011 NA C3F0 OSM?/? NA NA NA
2 0 [] 17 F C2 1 2 3 30 2011 -1 -1 -1 NA C2F3 OSM?/? NA NA NA
2 0 [] 18 M C3 1 4 4 11 2011 5 6 2011 NA C3M0 +/+ NA NA
3 0 [] 33 F C5 13 6 8 30 2011 10 5 2011 NA C5F5 OSM?/? NA NA NA
2 0 [] 15 F C2 1 2 3 30 2011 -1 -1 -1 NA C2F1 OSM?/? NA NA NA
2 0 [] 16 F C2 1 2 3 30 2011 -1 -1 -1 NA C2F2 OSM?/? NA NA NA
2 13 ['33', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '32', '31'] 13 M C2 1 2 3 30 2011 -1 -1 -1 NA M1 +/- NA NA
2 0 [] 14 F C2 1 2 3 30 2011 -1 -1 -1 NA C2F0 OSM?/? NA NA NA
2 0 [] 11 F C1 1 3 3 28 2011 4 28 2011 NA F1 OSM?/? NA NA NA
2 0 [] 12 M C2 1 2 3 30 2011 -1 -1 -1 NA M0 +/- NA NA
3 0 [] 21 M C4 13 5 8 26 2011 -1 -1 -1 NA C4M1 +/+ NA NA
2 0 [] 20 F C3 1 4 4 11 2011 5 6 2011 NA C3F1 OSM?/? NA NA NA
3 0 [] 22 M C4 13 5 8 26 2011 -1 -1 -1 NA C4M2 +/- NA NA
3 0 [] 23 M C4 13 5 8 26 2011 -1 -1 -1 NA C4M3 SAC? re-genotype +/+ NA NA
3 0 [] 24 M C4 13 5 8 26 2011 -1 -1 -1 NA C4M4 sac? re-genotype +/+ NA NA
3 0 [] 25 F C4 13 5 8 26 2011 10 5 2011 NA C4F0 OSM?/? NA NA NA
3 0 [] 26 M C5 13 6 8 30 2011 -1 -1 -1 NA C5M0 OSM?/? NA NA NA
3 0 [] 27 M C5 13 6 8 30 2011 -1 -1 -1 NA C5M1 OSM?/? NA NA NA
3 0 [] 28 F C5 13 6 8 30 2011 10 5 2011 NA C5F0 OSM?/? NA NA NA
3 0 [] 29 F C5 13 6 8 30 2011 10 5 2011 NA C5F1 OSM?/? NA NA NA
1 4 ['11', '10', '9', '8'] 3 F Z1 NA NA 3 16 2012 -1 -1 -1 NA Z1F7 +/- NA NA
1 6 ['17', '15', '16', '13', '14', '12'] 2 F Z1 NA NA 3 16 2012 -1 -1 -1 NA Z1F5 +/- NA NA
2 0 [] 10 F C1 1 3 3 28 2011 4 28 2011 NA F0 OSM?/? NA NA NA
1 13 ['19', '17', '18', '15', '16', '13', '14', '11', '12', '20', '10', '9', '8'] 1 M 35G6 NA NA 12 30 2010 -1 -1 -1 SAC 35G6M2 ready to breed 2/3/11 +/- NA NA
3 0 [] 30 F C5 13 6 8 30 2011 10 5 2011 NA C5F2 OSM?/? NA NA NA
1 0 [] 7 F Y NA NA 3 16 2012 -1 -1 -1 NA YF0 or YF1 +/- NA NA
1 8 ['33', '26', '27', '28', '29', '30', '32', '31'] 6 F Z2 NA NA 3 16 2012 -1 -1 -1 NA Z2F1 +/- NA NA
3 0 [] 32 F C5 13 6 8 30 2011 10 5 2011 NA C5F4 OSM?/? NA NA NA
1 5 ['21', '22', '23', '24', '25'] 5 F Z2 NA NA 3 16 2012 -1 -1 -1 NA Z2F0 +/- NA NA
3 0 [] 31 F C5 13 6 8 30 2011 10 5 2011 NA C5F3 OSM?/? NA NA NA
1 3 ['19', '18', '20'] 4 F Z1 NA NA 3 16 2012 -1 -1 -1 NA Z1F8 +/- NA NA
2 0 [] 9 M C1 1 3 3 28 2011 4 28 2011 NA M1 generation 7 +/+ NA NA
2 0 [] 8 M C1 1 3 3 28 2011 4 28 2011 NA M0 generation 7 +/+ NA NA
Generation numberOfChildren childrenList mouseId gender litter fatherId motherId dobMonth dobDay dobYear dodMonth dodDay dodYear tod notes OSM NA NA
1 0 [] 35 F 9G6F NA NA 6 2 2010 4 25 2011 NA F2 OSM=?? Bred on 9/1/10 9G6M3 Pups: 9/23/10 NA NA NA
1 0 [] 36 F 9G6F NA NA 6 2 2010 4 25 2011 NA F1 OSM=?? NA NA NA
1 0 [] 33 M 9G6M NA NA 6 2 2010 2 15 2011 NA M1 OSM=?? Bred on 9/1/10__COMMA__ 9G6F2 & 4 NA NA NA
1 0 [] 34 F 9G6F NA NA 6 2 2010 4 25 2011 NA F1 OSM=?? NA NA NA
1 0 [] 39 F 10G7F NA NA 9 23 2010 4 25 2011 NA F1 -/- NA NA
1 0 [] 37 F 9G6F NA NA 3 16 2012 -1 -1 -1 NA F1 OSM=?? NA NA NA
1 2 ['51', '50'] 38 M 10G7M NA NA 9 23 2010 10 20 2011 NA M1 bred on 11/29/10 10G7F 4 & 6 -/- NA NA
1 1 ['50'] 43 F 10G7F NA NA 9 23 2010 10 20 2011 NA F4 bred on 11/29/10 10G7M1 Pups: 3 pups__COMMA__ ate others__COMMA__ DOB 12/26/10 -/- NA NA
1 0 [] 42 F 10G7F NA NA 9 23 2010 4 25 2011 NA F3 -/- NA NA
1 0 [] 41 F 10G7F NA NA 9 23 2010 4 25 2011 NA F3 -/- NA NA
1 0 [] 40 F 10G7F NA NA 9 23 2010 4 25 2011 NA F2 -/- NA NA
4 0 [] 66 F A4 52 56 10 16 2011 -1 -1 -1 NA F2 NA NA NA
1 0 [] 22 F 7G5F NA NA 7 17 2009 3 22 2010 NA F3 -/- NA NA
1 0 [] 23 M 8G5M NA NA 12 17 2009 11 16 2010 Sacrificed M1 Genotype=?? NA NA NA
1 0 [] 24 M 8G5M NA NA 12 17 2009 11 16 2010 Sacrificed M2 Genotype=?? I see him in the cage! sacrificed with sibling NA NA NA
1 0 [] 25 F 8G5F NA NA 12 17 2009 9 1 2010 NA F1 Bred on 5/11/10__COMMA__ 7G5M1 NA NA NA
1 0 [] 26 F 8G5F NA NA 12 17 2009 9 1 2010 NA F2 Bred on 5/11/10__COMMA__ 7G5M5__COMMA__ Pups: destroyed all 4 NA NA NA
1 0 [] 27 F 8G5F NA NA 3 16 2012 -1 -1 -1 NA F3 NA NA NA
1 0 [] 28 F 8G5F NA NA 12 17 2009 11 16 2010 NA F4 Bred on 5/11/10__COMMA__ 7G5M5__COMMA__ Pups: 9G6M(3) F(4) NA NA NA
1 0 [] 29 F 8G5F NA NA 12 17 2009 9 1 2010 NA F5 Bred on 5/11/10__COMMA__ 7G5M1__COMMA__ Pups: destroyed all 3 NA NA NA
1 0 [] 3 F 1G4F NA NA 5 03 2009 1 27 2010 NA Breeding: 2G4M1 (-/-) Pups: 7G5M(7)__COMMA__ 7G5F(3) +/- NA NA
1 0 [] 2 M 1 NA NA 02 01 2009 09 17 2009 NA -/- NA NA
1 0 [] 1 F 1 NA NA 2 01 2009 09 17 2009 NA This colony is from the first tab of Dollie's excel sheet -/- NA NA
1 0 [] 30 F 8G5F NA NA 12 17 2009 2 3 2010 NA F6 NA NA NA
1 0 [] 7 F 1G4F NA NA 5 03 2009 9 17 2009 NA +/- NA NA
1 0 [] 6 F 1G4F NA NA 5 03 2009 9 17 2009 NA +/- NA NA
1 0 [] 5 F 1G4F NA NA 5 03 2009 9 17 2009 NA +/- NA NA
1 0 [] 32 M 9G6M NA NA 6 2 2010 2 15 2011 NA M1 OSM=?? NA NA NA
1 0 [] 4 F 1G4F NA NA 5 03 2009 -1 -1 -1 NA Breeding: 6G4M1(-/-) No Pups -/- NA NA
1 0 [] 31 M 9G6M NA NA 6 2 2010 4 25 2011 NA M1 OSM=?? NA NA NA
1 0 [] 9 M 2G4M NA NA 5 08 2009 2 03 2010 NA -/- NA NA
1 0 [] 8 F 1G4F NA NA 5 03 2009 9 17 2009 NA +/- NA NA
4 0 [] 59 M A4 52 56 10 16 2011 -1 -1 -1 NA M0 Parents: A2M0+A2F0 NA NA NA
3 0 [] 58 F A3 50 51 7 9 2011 -1 -1 -1 NA F0 Bred w A3M0 on 9/20/11 separated on 10/11/11 Parents: A2M0+A2F0 NA NA NA
3 0 [] 57 F A3 50 51 7 9 2011 -1 -1 -1 NA F0 Bred w A3M0 on 9/20/11 separated on 10/11/11 Parents: A2M0+A2F0 NA NA NA
3 8 ['66', '59', '64', '65', '62', '63', '60', '61'] 56 F A3 50 51 7 9 2011 -1 -1 -1 NA F0 Bred w A3M0 on 9/20/11 separated on 10/11/11 Parents: A2M0+A2F0 NA NA NA
1 0 [] 19 M 7G5M NA NA 7 17 2009 9 17 2009 NA M6 +/- NA NA
3 0 [] 55 M A3 50 51 7 9 2011 -1 -1 -1 NA M3 Parents: A2M0+A2F0 NA NA NA
1 0 [] 17 M 7G5M NA NA 7 17 2009 9 17 2009 NA M4 -/- NA NA
1 0 [] 18 M 7G5M NA NA 7 17 2009 9 01 2010 NA M5 -/- NA NA
1 0 [] 15 M 7G5M NA NA 7 17 2009 1 27 2010 NA M2 -/- NA NA
1 0 [] 16 M 7G5M NA NA 7 17 2009 9 01 2010 NA M3 -/- NA NA
1 0 [] 13 M 7G5M NA NA 7 17 2009 1 27 2010 NA M0 +/- NA NA
1 0 [] 14 M 7G5M NA NA 7 17 2009 9 01 2010 NA M1 -/- NA NA
1 0 [] 11 M 6G4M NA NA 5 8 2009 6 29 2009 NA +/+ NA NA
1 0 [] 12 M 6G4M NA NA 5 8 2009 9 17 2009 NA +/- NA NA
1 0 [] 21 F 7G5F NA NA 7 17 2009 3 22 2010 NA F2 +/- NA NA
1 0 [] 20 F 7G5F NA NA 7 17 2009 3 22 2010 NA F1 +/- NA NA
4 0 [] 64 F A4 52 56 10 16 2011 -1 -1 -1 NA F0 NA NA NA
4 0 [] 65 F A4 52 56 10 16 2011 -1 -1 -1 NA F1 NA NA NA
4 0 [] 62 M A4 52 56 10 16 2011 -1 -1 -1 NA M3 Parents: A2M0+A2F0 NA NA NA
4 0 [] 63 M A4 52 56 10 16 2011 -1 -1 -1 NA M4 Parents: A2M0+A2F0 NA NA NA
4 0 [] 60 M A4 52 56 10 16 2011 -1 -1 -1 NA M1 Parents: A2M0+A2F0 NA NA NA
4 0 [] 61 M A4 52 56 10 16 2011 -1 -1 -1 NA M2 Parents: A2M0+A2F0 NA NA NA
1 0 [] 49 F A1 NA NA 12 26 2010 10 20 2011 NA F0 OSM=?? NA NA NA
1 0 [] 48 M A1 NA NA 12 26 2010 10 20 2011 NA M0 OSM=?? NA NA NA
1 1 ['51'] 45 F 10G7F NA NA 9 23 2010 10 20 2011 NA F6 Bred on 11/29/10 10G7M1 Pups: 2 pups__COMMA__ ate others__COMMA__ DOB 12/28/11 -/- NA NA
1 0 [] 44 F 10G7F NA NA 9 23 2010 4 25 2011 NA F5 -/- NA NA
1 0 [] 47 M A1 NA NA 12 26 2010 10 20 2011 NA M0 OSM=?? NA NA NA
1 0 [] 46 F 10G7F NA NA 9 23 2010 4 25 2011 NA F7 -/- NA NA
1 0 [] 10 M 6G4M NA NA 5 8 2009 9 17 2009 NA +/- NA NA
2 7 ['58', '57', '56', '55', '52', '53', '54'] 51 F A2 38 45 12 28 2010 12 09 2011 NA F0 Bred w A2__COMMA__ M0 6/17/11 Pups: 7pups born 7/9/11 Parents: 10G7M1/10G7F6 NA NA NA
3 8 ['66', '59', '64', '65', '62', '63', '60', '61'] 52 M A3 50 51 7 9 2011 -1 -1 -1 NA M0 Bred w A3F0__COMMA__A3F1 on 9/20/11 Parents: A2M0+A2F0 NA NA NA
3 0 [] 53 M A3 50 51 7 9 2011 -1 -1 -1 NA M1 Parents: A2M0+A2F0 NA NA NA
3 0 [] 54 M A3 50 51 7 9 2011 -1 -1 -1 NA M2 Parents: A2M0+A2F0 NA NA NA
2 7 ['58', '57', '56', '55', '52', '53', '54'] 50 M A2 38 43 12 28 2010 12 09 2011 NA M0 OSM=?? bred w A2__COMMA__ F0 6/17/11__COMMA__ A2F0 Parents: 10G7M1/10G7F4 NA NA NA
Generation numberOfChildren childrenList mouseId gender litter fatherId motherId dobMonth dobDay dobYear dodMonth dodDay dodYear tod notes gene1 gene2 gene3 gene4 gene5
3 0 [] 100 NA 1 10 11 11 10 2012 11 10 2012 NA +/- +/- +/- +/- +/-
3 0 [] 101 NA 1 10 11 11 10 2012 -1 -1 -1 NA +/- +/- +/- +/- +/-
3 28 ['200', '201', '202', '203', '204', '205', '206', '207', '208', '209', '210', '211', '212', '213', '214', '215', '216', '217', '218', '219', '220', '221', '222', '223', '224', '225', '226', '227'] 102 M 2 10 11 11 10 2012 -1 -1 -1 NA +/- +/- +/- +/- +/-
3 0 [] 103 M 2 10 11 11 10 2012 -1 -1 -1 NA +/- +/- +/- +/- +/-
3 28 ['200', '201', '202', '203', '204', '205', '206', '207', '208', '209', '210', '211', '212', '213', '214', '215', '216', '217', '218', '219', '220', '221', '222', '223', '224', '225', '226', '227'] 104 F 2 10 11 11 10 2012 -1 -1 -1 NA +/- +/- +/- +/- +/-
3 0 [] 105 F 2 10 11 11 10 2012 -1 -1 -1 NA +/- +/- +/- +/- +/-
3 8 ['228', '229', '230', '231', '232', '233', '234', '235'] 106 M 4 10 11 11 10 2012 -1 -1 -1 NA +/+ +/- +/- +/- +/-
3 0 [] 107 M 4 10 11 11 10 2012 -1 -1 -1 NA +/+ +/- +/- +/- +/-
3 8 ['228', '229', '230', '231', '232', '233', '234', '235'] 108 F 4 10 11 11 10 2012 -1 -1 -1 NA +/+ +/- +/- +/- +/-
3 0 [] 109 F 4 10 11 11 10 2012 -1 -1 -1 NA +/+ +/- +/- +/- +/-
2 30 ['100', '101', '102', '103', '104', '105', '106', '107', '108', '109', '110', '111', '112', '113', '114', '115', '116', '117', '118', '119', '120', '121', '122', '123', '124', '125', '126', '127', '128', '129'] 11 F 1 1 2 11 10 2012 -1 -1 -1 NA NA NA NA +/- +/-
3 0 [] 110 M 5 10 11 11 10 2012 -1 -1 -1 NA +/+ -/- +/- +/- +/-
3 0 [] 111 M 5 10 11 11 10 2012 -1 -1 -1 NA +/+ -/- +/- +/- +/-
3 0 [] 112 F 5 10 11 11 10 2012 -1 -1 -1 NA +/+ -/- +/- +/- +/-
3 0 [] 113 F 5 10 11 11 10 2012 -1 -1 -1 NA +/+ -/- +/- +/- +/-
3 0 [] 114 M 6 10 11 11 10 2012 -1 -1 -1 NA +/+ +/+ +/- +/- +/-
3 0 [] 115 M 6 10 11 11 10 2012 -1 -1 -1 NA +/+ +/+ +/- +/- +/-
3 0 [] 116 F 6 10 11 11 10 2012 -1 -1 -1 NA +/+ +/+ +/- +/- +/-
3 0 [] 117 F 6 10 11 11 10 2012 -1 -1 -1 NA +/+ +/+ +/- +/- +/-
3 0 [] 118 F 7 10 11 11 10 2012 -1 -1 -1 NA +/+ +/+ -/- +/- +/-
3 10 ['236', '237', '238', '239', '240', '241', '242', '243', '244', '245'] 119 F 7 10 11 11 10 2012 -1 -1 -1 NA +/+ +/+ -/- +/- +/-
3 10 ['236', '237', '238', '239', '240', '241', '242', '243', '244', '245'] 120 M 7 10 11 11 10 2012 -1 -1 -1 NA +/+ +/+ -/- +/- +/-
3 0 [] 121 M 7 10 11 11 10 2012 -1 -1 -1 NA +/+ +/+ -/- +/- +/-
3 0 [] 122 M 8 10 11 11 10 2012 -1 -1 -1 NA +/+ +/+ +/+ +/- +/-
3 0 [] 123 M 8 10 11 11 10 2012 -1 -1 -1 NA +/+ +/+ +/+ +/- +/-
3 0 [] 124 F 8 10 11 11 10 2012 -1 -1 -1 NA +/+ +/+ +/+ +/- +/-
3 0 [] 125 F 8 10 11 11 10 2012 -1 -1 -1 NA +/+ +/+ +/+ +/- +/-
3 0 [] 126 M 9 10 11 11 10 2012 -1 -1 -1 NA NA NA NA +/- +/-
3 0 [] 127 M 9 10 11 11 10 2012 -1 -1 -1 NA NA NA NA +/- +/-
3 0 [] 128 F 9 10 11 11 10 2012 -1 -1 -1 NA NA NA NA +/- +/-
3 0 [] 129 F 9 10 11 11 10 2012 -1 -1 -1 NA NA NA NA +/- +/-
4 0 [] 200 M 1 102 104 11 10 2012 -1 -1 -1 NA +/- +/- +/- +/- +/-
4 0 [] 201 M 1 102 104 11 10 2012 -1 -1 -1 NA +/- +/- +/- +/- +/-
4 0 [] 202 F 1 102 104 11 10 2012 -1 -1 -1 NA +/- +/- +/- +/- +/-
4 0 [] 203 F 1 102 104 11 10 2012 -1 -1 -1 NA +/- +/- +/- +/- +/-
4 0 [] 204 M 2 102 104 11 10 2012 -1 -1 -1 NA -/- +/- +/- +/- +/-
4 0 [] 205 M 2 102 104 11 10 2012 -1 -1 -1 NA -/- +/- +/- +/- +/-
4 0 [] 206 F 2 102 104 11 10 2012 -1 -1 -1 NA -/- +/- +/- +/- +/-
4 0 [] 207 F 2 102 104 11 10 2012 -1 -1 -1 NA -/- +/- +/- +/- +/-
4 0 [] 208 M 3 102 104 11 10 2012 -1 -1 -1 NA -/- -/- +/- +/- +/-
4 0 [] 209 M 3 102 104 11 10 2012 -1 -1 -1 NA -/- -/- +/- +/- +/-
4 0 [] 210 F 3 102 104 11 10 2012 -1 -1 -1 NA -/- -/- +/- +/- +/-
4 0 [] 211 F 3 102 104 11 10 2012 -1 -1 -1 NA -/- -/- +/- +/- +/-
4 0 [] 212 M 3 102 104 11 10 2012 -1 -1 -1 NA +/+ -/- +/- +/- +/-
4 0 [] 213 M 3 102 104 11 10 2012 -1 -1 -1 NA +/+ -/- +/- +/- +/-
4 0 [] 214 F 3 102 104 11 10 2012 -1 -1 -1 NA +/+ -/- +/- +/- +/-
4 0 [] 215 F 3 102 104 11 10 2012 -1 -1 -1 NA +/+ -/- +/- +/- +/-
4 0 [] 216 M 4 102 104 11 10 2012 -1 -1 -1 NA +/+ +/+ +/- +/- +/-
4 0 [] 217 M 4 102 104 11 10 2012 -1 -1 -1 NA +/+ +/+ +/- +/- +/-
4 0 [] 218 F 4 102 104 11 10 2012 -1 -1 -1 NA +/+ +/+ +/- +/- +/-
4 0 [] 219 F 4 102 104 11 10 2012 -1 -1 -1 NA +/+ +/+ +/- +/- +/-
4 0 [] 220 M 5 102 104 11 10 2012 -1 -1 -1 NA +/+ +/+ -/- +/- +/-
4 0 [] 221 M 5 102 104 11 10 2012 -1 -1 -1 NA +/+ +/+ -/- +/- +/-
4 0 [] 222 F 5 102 104 11 10 2012 -1 -1 -1 NA +/+ +/+ -/- +/- +/-
4 0 [] 223 F 5 102 104 11 10 2012 -1 -1 -1 NA +/+ +/+ -/- +/- +/-
4 0 [] 224 M 6 102 104 11 10 2012 -1 -1 -1 NA +/+ +/+ +/+ +/- +/-
4 0 [] 225 M 6 102 104 11 10 2012 -1 -1 -1 NA +/+ +/+ +/+ +/- +/-
4 0 [] 226 F 6 102 104 11 10 2012 -1 -1 -1 NA +/+ +/+ +/+ +/- +/-
4 0 [] 227 F 6 102 104 11 10 2012 -1 -1 -1 NA +/+ +/+ +/+ +/- +/-
4 0 [] 228 M 6 106 108 11 10 2012 -1 -1 -1 NA +/+ +/- +/- +/- +/-
4 0 [] 229 M 6 106 108 11 10 2012 -1 -1 -1 NA +/+ +/- +/- +/- +/-
4 0 [] 230 F 6 106 108 11 10 2012 -1 -1 -1 NA +/+ +/- +/- +/- +/-
4 0 [] 231 F 6 106 108 11 10 2012 -1 -1 -1 NA +/+ +/- +/- +/- +/-
4 0 [] 232 M 6 106 108 11 10 2012 -1 -1 -1 NA NA +/- +/- +/- +/-
4 0 [] 233 M 6 106 108 11 10 2012 -1 -1 -1 NA NA +/- +/- +/- +/-
4 0 [] 234 F 6 106 108 11 10 2012 -1 -1 -1 NA NA +/- +/- +/- +/-
4 0 [] 235 F 6 106 108 11 10 2012 -1 -1 -1 NA NA +/- +/- +/- +/-
4 0 [] 236 M 1 120 119 11 10 2012 -1 -1 -1 NA +/+ +/+ -/- +/- +/-
4 0 [] 237 M 1 120 119 11 10 2012 -1 -1 -1 NA +/+ +/+ -/- +/- +/-
4 0 [] 238 F 1 120 119 11 10 2012 -1 -1 -1 NA +/+ +/+ -/- +/- +/-
4 0 [] 239 F 1 120 119 11 10 2012 -1 -1 -1 NA +/+ +/+ -/- +/- +/-
4 0 [] 240 M 2 120 119 11 10 2012 -1 -1 -1 NA +/+ +/+ NA +/- +/-
4 0 [] 241 M 2 120 119 11 10 2012 -1 -1 -1 NA +/+ +/+ NA +/- +/-
4 0 [] 242 F 2 120 119 11 10 2012 -1 -1 -1 NA +/+ +/+ NA +/- +/-
4 0 [] 243 F 2 120 119 11 10 2012 -1 -1 -1 NA +/+ +/+ NA +/- +/-
4 0 [] 244 M 3 120 119 11 10 2012 -1 -1 -1 NA NA NA NA +/- +/-
4 0 [] 245 M 3 120 119 11 10 2012 -1 -1 -1 NA NA NA NA +/- +/-
1 0 [] orph0 M 1 NA NA 11 10 2012 -1 -1 -1 NA NA NA NA +/- +/-
1 0 [] orph1 M 1 NA NA 11 10 2012 -1 -1 -1 NA NA NA NA +/- +/-
1 30 ['100', '101', '102', '103', '104', '105', '106', '107', '108', '109', '110', '111', '112', '113', '114', '115', '116', '117', '118', '119', '120', '121', '122', '123', '124', '125', '126', '127', '128', '129'] 10 M 1 NA NA NA NA 2012 -1 -1 -1 NA NA NA NA +/- +/-
1 1 ['11'] 2 F 1 NA NA NA NA 2012 -1 -1 -1 NA NA NA NA +/- +/-
1 1 ['11'] 1 M 1 NA NA NA NA 2012 -1 -1 -1 NA NA NA NA +/- +/-
{"name": "Generation 1", "children": [{"name": 3, "size": 4, "gender": "F"}, {"name": 2, "size": 6, "gender": "F"}, {"name": 1, "size": 13, "gender": "M"}, {"name": 7, "size": 1, "gender": "F"}, {"name": 6, "size": 8, "gender": "F"}, {"name": 5, "size": 5, "gender": "F"}, {"name": 4, "size": 3, "gender": "F"}, {"name": "Generation 2", "children": [{"name": 19, "size": 1, "gender": "F"}, {"name": 17, "size": 1, "gender": "F"}, {"name": 18, "size": 1, "gender": "M"}, {"name": 15, "size": 1, "gender": "F"}, {"name": 16, "size": 1, "gender": "F"}, {"name": 13, "size": 13, "gender": "M"}, {"name": 14, "size": 1, "gender": "F"}, {"name": 11, "size": 1, "gender": "F"}, {"name": 12, "size": 1, "gender": "M"}, {"name": 20, "size": 1, "gender": "F"}, {"name": 10, "size": 1, "gender": "F"}, {"name": 9, "size": 1, "gender": "M"}, {"name": 8, "size": 1, "gender": "M"}, {"name": "Generation 3", "children": [{"name": 33, "size": 1, "gender": "F"}, {"name": 21, "size": 1, "gender": "M"}, {"name": 22, "size": 1, "gender": "M"}, {"name": 23, "size": 1, "gender": "M"}, {"name": 24, "size": 1, "gender": "M"}, {"name": 25, "size": 1, "gender": "F"}, {"name": 26, "size": 1, "gender": "M"}, {"name": 27, "size": 1, "gender": "M"}, {"name": 28, "size": 1, "gender": "F"}, {"name": 29, "size": 1, "gender": "F"}, {"name": 30, "size": 1, "gender": "F"}, {"name": 32, "size": 1, "gender": "F"}, {"name": 31, "size": 1, "gender": "F"}]}]}]}
{"name": "Generation 1", "children": [{"gender": "F", "name": 1, "size": 1}, {"gender": "M", "name": 2, "size": 1}, {"gender": "F", "name": 3, "size": 1}, {"gender": "F", "name": 4, "size": 1}, {"gender": "F", "name": 5, "size": 1}, {"gender": "F", "name": 6, "size": 1}, {"gender": "F", "name": 7, "size": 1}, {"gender": "F", "name": 8, "size": 1}, {"gender": "M", "name": 9, "size": 1}, {"gender": "M", "name": 10, "size": 1}, {"gender": "M", "name": 11, "size": 1}, {"gender": "M", "name": 12, "size": 1}, {"gender": "M", "name": 13, "size": 1}, {"gender": "M", "name": 14, "size": 1}, {"gender": "M", "name": 15, "size": 1}, {"gender": "M", "name": 16, "size": 1}, {"gender": "M", "name": 17, "size": 1}, {"gender": "M", "name": 18, "size": 1}, {"gender": "M", "name": 19, "size": 1}, {"gender": "F", "name": 20, "size": 1}, {"gender": "F", "name": 21, "size": 1}, {"gender": "F", "name": 22, "size": 1}, {"gender": "M", "name": 23, "size": 1}, {"gender": "M", "name": 24, "size": 1}, {"gender": "F", "name": 25, "size": 1}, {"gender": "F", "name": 26, "size": 1}, {"gender": "F", "name": 27, "size": 1}, {"gender": "F", "name": 28, "size": 1}, {"gender": "F", "name": 29, "size": 1}, {"gender": "F", "name": 30, "size": 1}, {"gender": "M", "name": 31, "size": 1}, {"gender": "M", "name": 32, "size": 1}, {"gender": "M", "name": 33, "size": 1}, {"gender": "F", "name": 34, "size": 1}, {"gender": "F", "name": 35, "size": 1}, {"gender": "F", "name": 36, "size": 1}, {"gender": "F", "name": 37, "size": 1}, {"gender": "M", "name": 38, "size": 2}, {"gender": "F", "name": 39, "size": 1}, {"gender": "F", "name": 40, "size": 1}, {"gender": "F", "name": 41, "size": 1}, {"gender": "F", "name": 42, "size": 1}, {"gender": "F", "name": 43, "size": 1}, {"gender": "F", "name": 44, "size": 1}, {"gender": "F", "name": 45, "size": 1}, {"gender": "F", "name": 46, "size": 1}, {"gender": "M", "name": 47, "size": 1}, {"gender": "M", "name": 48, "size": 1}, {"gender": "F", "name": 49, "size": 1}, {"name": "Generation 2", "children": [{"gender": "M", "name": 50, "size": 7}, {"gender": "F", "name": 51, "size": 7}, {"name": "Generation 3", "children": [{"gender": "M", "name": 52, "size": 8}, {"gender": "M", "name": 53, "size": 1}, {"gender": "M", "name": 54, "size": 1}, {"gender": "M", "name": 55, "size": 1}, {"gender": "F", "name": 56, "size": 8}, {"gender": "F", "name": 57, "size": 1}, {"gender": "F", "name": 58, "size": 1}, {"name": "Generation 4", "children": [{"gender": "M", "name": 59, "size": 1}, {"gender": "M", "name": 60, "size": 1}, {"gender": "M", "name": 61, "size": 1}, {"gender": "M", "name": 62, "size": 1}, {"gender": "M", "name": 63, "size": 1}, {"gender": "F", "name": 64, "size": 1}, {"gender": "F", "name": 65, "size": 1}, {"gender": "F", "name": 66, "size": 1}]}]}]}]}
{"name": "Generation 1", "children": [{"gender": "F", "name": 2, "size": 1}, {"gender": "M", "name": 1, "size": 1}, {"gender": "M", "name": 10, "size": 30}, {"gender": "M", "name": 0, "size": 1}, {"name": "Generation 2", "children": [{"gender": "F", "name": 11, "size": 30}, {"name": "Generation 3", "children": [{"gender": "F", "name": 128, "size": 1}, {"gender": "F", "name": 129, "size": 1}, {"gender": "NA", "name": 100, "size": 1}, {"gender": "NA", "name": 101, "size": 1}, {"gender": "M", "name": 102, "size": 28}, {"gender": "M", "name": 103, "size": 1}, {"gender": "F", "name": 104, "size": 28}, {"gender": "F", "name": 105, "size": 1}, {"gender": "M", "name": 106, "size": 8}, {"gender": "M", "name": 107, "size": 1}, {"gender": "F", "name": 108, "size": 8}, {"gender": "F", "name": 109, "size": 1}, {"gender": "M", "name": 110, "size": 1}, {"gender": "M", "name": 111, "size": 1}, {"gender": "F", "name": 112, "size": 1}, {"gender": "F", "name": 113, "size": 1}, {"gender": "M", "name": 114, "size": 1}, {"gender": "M", "name": 115, "size": 1}, {"gender": "F", "name": 116, "size": 1}, {"gender": "F", "name": 117, "size": 1}, {"gender": "F", "name": 118, "size": 1}, {"gender": "F", "name": 119, "size": 10}, {"gender": "M", "name": 120, "size": 10}, {"gender": "M", "name": 121, "size": 1}, {"gender": "M", "name": 122, "size": 1}, {"gender": "M", "name": 123, "size": 1}, {"gender": "F", "name": 124, "size": 1}, {"gender": "F", "name": 125, "size": 1}, {"gender": "M", "name": 126, "size": 1}, {"gender": "M", "name": 127, "size": 1}, {"name": "Generation 4", "children": [{"gender": "F", "name": 235, "size": 1}, {"gender": "F", "name": 230, "size": 1}, {"gender": "M", "name": 236, "size": 1}, {"gender": "M", "name": 233, "size": 1}, {"gender": "M", "name": 237, "size": 1}, {"gender": "F", "name": 238, "size": 1}, {"gender": "F", "name": 239, "size": 1}, {"gender": "F", "name": 231, "size": 1}, {"gender": "M", "name": 240, "size": 1}, {"gender": "M", "name": 241, "size": 1}, {"gender": "F", "name": 242, "size": 1}, {"gender": "M", "name": 229, "size": 1}, {"gender": "F", "name": 243, "size": 1}, {"gender": "F", "name": 234, "size": 1}, {"gender": "M", "name": 244, "size": 1}, {"gender": "M", "name": 232, "size": 1}, {"gender": "M", "name": 245, "size": 1}, {"gender": "M", "name": 228, "size": 1}, {"gender": "M", "name": 200, "size": 1}, {"gender": "M", "name": 201, "size": 1}, {"gender": "F", "name": 202, "size": 1}, {"gender": "F", "name": 203, "size": 1}, {"gender": "M", "name": 204, "size": 1}, {"gender": "M", "name": 205, "size": 1}, {"gender": "F", "name": 206, "size": 1}, {"gender": "F", "name": 207, "size": 1}, {"gender": "M", "name": 208, "size": 1}, {"gender": "M", "name": 209, "size": 1}, {"gender": "F", "name": 210, "size": 1}, {"gender": "F", "name": 211, "size": 1}, {"gender": "M", "name": 212, "size": 1}, {"gender": "M", "name": 213, "size": 1}, {"gender": "F", "name": 214, "size": 1}, {"gender": "F", "name": 215, "size": 1}, {"gender": "M", "name": 216, "size": 1}, {"gender": "M", "name": 217, "size": 1}, {"gender": "F", "name": 218, "size": 1}, {"gender": "F", "name": 219, "size": 1}, {"gender": "M", "name": 220, "size": 1}, {"gender": "M", "name": 221, "size": 1}, {"gender": "F", "name": 222, "size": 1}, {"gender": "F", "name": 223, "size": 1}, {"gender": "M", "name": 224, "size": 1}, {"gender": "M", "name": 225, "size": 1}, {"gender": "F", "name": 226, "size": 1}, {"gender": "F", "name": 227, "size": 1}]}]}]}]}
<!DOCTYPE html>
<meta charset="utf-8">
<style>
svg {
border: solid 1px black;
}
div {
width: 1305px;
}
.node {
cursor: pointer;
}
.node:hover {
stroke: #3f3f3f;
stroke-width: 4.5px;
}
.node--leaf {
fill: #ffffff;
}
.label {
font: 15px "Helvetica Neue", Helvetica, Arial, sans-serif;
text-anchor: middle;
text-shadow: 0 1px 0 #fff, 1px 0 0 #fff, -1px 0 0 #fff, 0 -1px 0 #fff;
}
.label,
.node--root,
{
pointer-events: none;
}
#graphic {
background-color: #424242;
}
.node text { font: 12px sans-serif; }
.node--internal text {
text-shadow: 0 1px 0 #fff, 0 -1px 0 #fff, 1px 0 0 #fff, -1px 0 0 #fff;
}
.link1 {
fill: none;
stroke: #ccc;
stroke-width: 2px;
}
.link {
fill: none;
stroke: #000;
stroke-opacity: .2;
}
.link:hover {
stroke-opacity: .5;
}
</style>
<input type="text" id="myId" placeholder="Add mouseId&hellip;">
<input name="button" type="submit" value="View Hierarchy" onclick="search()">
<div></div>
<div id = "genNo"></div>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="sankey.js"></script>
<script>
var svg1 = d3.select("div").append("svg")
.attr("width", 450)
.attr("height", 750);
var svg2 = d3.select("div").append("svg")
.attr('width',750)
.attr('height',750),
margin = 300,
diameter = svg2.attr("width"),
g2 = svg2.append("g").attr("transform", "translate(" + (diameter / 2)+ "," + ((diameter / 2) - 50) + ")");
var svg3 = d3.select("div").append("svg")
.attr("width", 1200)
.attr("height", 300);
var color = d3.scaleLinear()
.domain([-1, 5])
.range(["hsl(204,81%,96%)", "hsl(228,30%,40%)"])
.interpolate(d3.interpolateHcl);
var color1 = d3.scaleLinear()
.domain([1, 2])
.range(["hsl(213,92%,63%)", "hsl(2,80%,74%)"])
.interpolate(d3.interpolateHcl);
var tooltip = d3.select("body")
.append("div")
.style("position", "absolute")
.style("visibility", "hidden")
.style("color", "black")
var focus,nodes,node,circle;
svg1.selectAll("*").remove();
svg2.selectAll("*").remove();
svg3.selectAll("*").remove();
var margin = 300,
diameter = svg2.attr("width"),
g2 = svg2.append("g").attr("transform", "translate(" + (diameter / 2)+ "," + ((diameter / 2) - 50) + ")");
d3.json("colony_result2.json", function(error, root) {
if(error) {
console.log("in error");
// svg1.selectAll("*").remove();
// svg2.selectAll("*").remove();
// svg3.selectAll("*").remove();
throw error;
}
root = d3.hierarchy(root)
.sum(function(d) { return d.size; })
.sort(function(a, b) { return b.value - a.value; });
var pack = d3.pack()
.size([diameter, diameter])
.padding(10)
focus = root,
nodes = pack(root).descendants();
circle = g2.selectAll(".circle")
.data(nodes)
.enter().append("circle")
.attr("class", function(d) { return d.parent ? d.children ? "node" : "node node--leaf" : "node node--root"; })
.attr("id", function(d) {
return "node-" + d.data.name})
.style("fill", function(d) { return d.children ? color(d.depth) : d.data.gender == 'M' ? color1(1) : color1(2); })
.on("click", function(d) {
console.log("heya! d: " + d.data.name);
var str = d.data.name.toString();
if(str.startsWith("Gen") == false) {
searchId2(d.data.name);}
if (focus !== d) zoom(d), d3.event.stopPropagation(); })
.on("mouseover", function(d){
if(!d.children) {
return tooltip.text(d.data.name).style("visibility", "visible");}})
.on("mousemove", function(d){return !d.children ? tooltip.style("top", (event.pageY-10)+"px").style("left",(event.pageX+10)+"px") : printGen(d.data.name);})
.on("mouseout", function(){
removeGen();
return tooltip.style("visibility", "hidden");});
node = g2.selectAll("circle");
svg2
.style("background", color(-1))
.on("click", function() { zoom(root); });
zoomTo([root.x, root.y, root.r * 2 + margin]);
});
// }
function printGen(val) {
document.getElementById("genNo").innerHTML = val;
}
function removeGen(val) {
document.getElementById("genNo").innerHTML = "";
}
function zoom(d) {
var focus0 = focus; focus = d;
var transition = d3.transition()
.duration(d3.event.altKey ? 7500 : 750)
.tween("zoom", function(d) {
var i = d3.interpolateZoom(view, [focus.x, focus.y, focus.r * 2 + margin]);
return function(t) { zoomTo(i(t)); };
});
}
function zoomTo(v) {
var k = (diameter / v[2] ); view = v;
node.attr("transform", function(d) { return "translate(" + (d.x - v[0]) * k + "," + (d.y - v[1]) * k + ")"; });
circle.attr("r", function(d) { return d.r * k; });
}
function search() {
id = document.getElementById("myId").value;
searchId2(id)
}
function searchId2(id) {
svg3.selectAll("*").remove();
var sankey = d3.sankey()
.nodeWidth(36)
.nodePadding(40)
.size([500, 200]);
var path = sankey.link();
console.log(path);
d3.queue()
.defer(d3.csv, "colony2_updated.csv")
.defer(d3.json, "result2_parent_child.json")
.await(function(error,data10,data){
var graph = f2(data, id);
console.log("result: " + graph);
console.log("num of nodes: " + graph.nodes1.length);
console.log("num of links: " + graph.links1.length);
var graph1 = {
"nodes1":[
{"name":"1"},
{"name":"2"},
{"name":"10"},
{"name":"11"},
{"name":"101"},
{"name":"102"},
{"name":"204"}
],
"links1":[
{"source":"1","target":"10","value":1},
{"source":"1","target":"11","value":1},
{"source":"2","target":"10","value":1},
{"source":"2","target":"11","value":1},
{"source":"10","target":"101","value":1},
{"source":"10","target":"102","value":1},
{"source":"11","target":"101","value":1},
{"source":"11","target":"102","value":1},
{"source":"101","target":"204","value":1},
{"source":"102","target":"204","value":1}
]};
color = d3.scaleOrdinal(d3.schemeCategory20);
console.log("here1")
var nodeMap = {};
graph.nodes1.forEach(function(x) { nodeMap[x.name] = x; });
graph.links1 = graph.links1.map(function(x) {
return {
source: nodeMap[x.source],
target: nodeMap[x.target],
value: x.value
};
});
console.log("here2")
sankey
.nodes(graph.nodes1)
.links(graph.links1)
.layout(32);
console.log(sankey.nodes)
console.log("here3")
// add in the links
var link = svg3.append("g").selectAll(".link")
.data(graph.links1)
.enter().append("path")
.attr("class", "link")
.attr("d", path)
.style("stroke-width", function(d) {
console.log("dy: " + d.dy)
return Math.max(1, d.dy); })
.sort(function(a, b) { return b.dy - a.dy; });
console.log("here4")
// add the link titles
link.append("title")
.text(function(d) {
return d.source.name + " → " +
d.target.name; });
console.log("link: " + link)
console.log("here6")
// add in the nodes
var node3 = svg3.append("g").selectAll(".node3")
.data(graph.nodes1)
.enter().append("g")
.attr("class", "node3")
.attr("transform", function(d) {
console.log("name: " + d.name)
if(graph.links1.length == 0) {
return "translate(0,0)";
}
return "translate(" + d.x + "," + d.y + ")"; })
.call(d3.drag()
.subject(function(d) {
return d;
})
.on("start", function() {
this.parentNode.appendChild(this);
})
.on("drag", dragmove))
.on("click", function(d) {
console.log("onclick on: ")
});;
console.log("node3: " + node3)
console.log("here7")
// add the rectangles for the nodes
node3.append("rect")
.attr("height", function(d) {
if(graph.links1.length == 0) {
return 130;
}
return d.dy; })
.attr("width", sankey.nodeWidth())
.style("fill", function(d) { return findGender(data10, d.name) == 'M' ? color1(1) : color1(2); })
.style("stroke", function(d) {
return d3.rgb(d.color).darker(1); })
.on("click", function(d) {
console.log("onclick on: ")
searchId2(d.name);});
console.log("here8")
// add in the title for the nodes
node3.append("text")
.attr("x", -6)
.attr("y", function(d) {
if(graph.links1.length == 0) {
return 65;
}
return d.dy / 2; })
.attr("dy", ".35em")
.attr("text-anchor", "end")
.attr("transform", null)
.text(function(d) {
console.log("name: " + d.name)
return d.name; })
.filter(function(d) { return d.x < 700 / 2; })
.attr("x", 6 + sankey.nodeWidth())
.attr("text-anchor", "start");
console.log("here9")
// the function for moving the nodes
function dragmove(d) {
d3.select(this)
.attr("transform",
"translate("
+ d.x + ","
+ (d.y = Math.max(
0, Math.min(300 - d.dy, d3.event.y))
) + ")");
sankey.relayout();
link.attr("d", path);
}
console.log("here10")
findFamily2(id,data10);
});
}
function gen(id,data) {
console.log("in gen " + id);
var val;
d3.csv("colony2_updated.csv", function(data) {
console.log("here");
val = data.filter(function(d) {
return d.mouseId == id })[0].gender;
console.log("val: " + val);
})
console.log("data in gen: " + val);
return val;
}
function findFamily2(id, data) {
// d3.csv("colony2_updated.csv", function(data) {
var gender = findGender(data, id);
console.log("gender of node: " + gender)
var matesId = findFamily(data, id);
console.log("mates are: " + matesId);
var mates = svg3.selectAll("mates")
.data(matesId)
.enter().append("g")
.attr("class", "mates");
mates.append("circle")
.attr("r", 10)
.attr("stroke-width", 2)
.style("stroke", function(d) { return findGender(data,d) == 'M' ? color1(1) : color1(2); })
.attr("fill", "white")
.attr("cx", 750)
.attr("cy", function(d, i) {return(150 - (i*50));})
.on("click", function(d) {
searchId2(d);});
mates.append("text")
.attr("dx", 715)
.attr("dy", function(d, i) {return(150 - (i*50))+5;})
.text(function(d) {
return d });
var i = 0,j = 0, k = 0;
matesId.forEach(function(mate){
var childrenId = findChildren(data,gender,id,mate);
console.log("female childre are: " + childrenId.childrenFemale)
console.log("male childre are: " + childrenId.childrenMale)
var children = svg3.selectAll("children")
.data(childrenId.childrenFemale)
.enter().append("g")
.attr("class", "children");
children.append("circle")
.attr("r", 7)
.style("fill", function(d) { return findGender(data, d) == 'M' ? color1(1) : color1(2); })
.attr("cx", function(d, i) {return 780 + (i*20);})
.attr("cy",150 - (j*50))
.on("click", function(d) {
searchId2(d);})
.on("mouseover", function(d){return tooltip.text(d).style("visibility", "visible");})
.on("mousemove", function(d){return tooltip.style("top", (event.pageY-20)+"px").style("left",(event.pageX)+"px");;})
.on("mouseout", function(){return tooltip.style("visibility", "hidden");});
var children = svg3.selectAll("children")
.data(childrenId.childrenMale)
.enter().append("g")
.attr("class", "children");
children.append("circle")
.attr("r", 7)
.style("fill", function(d) { return findGender(data, d) == 'M' ? color1(1) : color1(2); })
.attr("cx", function(d, i) {return 780 + (i*20);})
.attr("cy",150 - (j*50) + 20)
.on("click", function(d) {
searchId2(d);})
.on("mouseover", function(d){return tooltip.text(d).style("visibility", "visible");})
.on("mousemove", function(d){return tooltip.style("top", (event.pageY-20)+"px").style("left",(event.pageX)+"px");;})
.on("mouseout", function(){return tooltip.style("visibility", "hidden");});
j = j+1;
});
// });
}
function findFamily(data, id) {
var mates = [];
var gender = findGender(data, id);
var matesId = [];
if(gender == "M") {
mates = data.filter(function(d, i) { return d.fatherId == id });
console.log("mates are: " + mates);
if(mates.length > 0) {
Object.keys(mates).forEach(function(key){
console.log("mates are: " + mates);
if(matesId.indexOf(mates[key].motherId) < 0) {
matesId.push(mates[key].motherId);
}
});
}
}
else {
mates = data.filter(function(d, i) { return d.motherId == id });
console.log("mates are: " + mates);
if(mates.length > 0) {
Object.keys(mates).forEach(function(key){
console.log("mates are: " + mates);
if(matesId.indexOf(mates[key].fatherId) < 0) {
matesId.push(mates[key].fatherId);
}
});
}
}
return matesId;
}
function findGender(data, id) {
return data.filter(function(d) { return d.mouseId == id })[0].gender;
}
function findChildren(data, gender, id, mate) {
var childrenId = [];
var childrenMale = [];
var childrenFemale = [];
var children = [];
if(gender == "M") {
// console.log("male")
children = data.filter(function(d, i) { return d.fatherId == id && d.motherId == mate});
}
else {
children = data.filter(function(d, i) { return d.motherId == id && d.fatherId == mate})
}
Object.keys(children).forEach(function(key){
if(children[key].gender == 'M') {
childrenMale.push(children[key].mouseId);
}
else if(children[key].gender == 'F') {
childrenFemale.push(children[key].mouseId);
}
});
console.log("Inside children function, male children: " + childrenMale);
console.log("Inside children function, female children: " + childrenFemale);
return {
childrenMale: childrenMale,
childrenFemale: childrenFemale,
};
}
function f1(data, id) {
var data1 = [];
var list = [];
list.push(id);
while(list.length > 0) {
Object.keys(data).forEach(function(key){
if(data[key]["parent"] == list[0]) {
list.push(data[key]["name"])
data1.push(data[key])
console.log("adding data: " + data[key]["name"] + "and parent" + data[key]["parent"])
}
});
list.shift();
}
data1.push( {"name": id, "parent": null})
return data1;
}
function f2(data, id) {
console.log("1, id: " + id);
var data1 = {};
var list = [];
var uniqueIds = [];
var uniqueLinks = [];
var nodeList = [];
var linkList = [];
list.push(id);
uniqueIds.push(id);
while(list.length > 0) {
Object.keys(data).forEach(function(key){
if(data[key]["parent"] == list[0]) {
list.push(data[key]["name"])
var dataNode = {};
var dataLink = {};
if(!uniqueIds.includes(data[key]["name"])) {
uniqueIds.push(data[key]["name"])
dataNode["name"] = data[key]["name"];
nodeList.push(dataNode);
}
var s = data[key]["name"] <= data[key]["parent"] ? data[key]["name"].concat(data[key]["parent"]) : data[key]["parent"].concat(data[key]["name"]);
if(!uniqueLinks.includes(s)) {
dataLink["source"] = data[key]["name"];
dataLink["target"] = data[key]["parent"];
dataLink["value"] = "1";
uniqueLinks.push(s);
linkList.push(dataLink);
// map.set(data[key]["name"],data[key]["parent"])
}
console.log("datanode: " + dataNode["name"]);
console.log("datalink: " + dataLink["source"] + ", " + dataLink["target"] + ", " + dataLink["value"]);
}
});
list.shift();
}
nodeList.push( {"name": id})
data1 = Object.assign(
{ nodes1: nodeList },
{ links1: linkList }
);
console.log("nodeList: " + JSON.stringify(nodeList));
console.log("linkList: " + JSON.stringify(linkList));
console.log("data1: " + JSON.stringify(data1));
return data1;
}
</script>
[{"name": "1", "parent": "19"}, {"name": "4", "parent": "19"}, {"name": "1", "parent": "17"}, {"name": "2", "parent": "17"}, {"name": "1", "parent": "18"}, {"name": "4", "parent": "18"}, {"name": "13", "parent": "33"}, {"name": "6", "parent": "33"}, {"name": "1", "parent": "15"}, {"name": "2", "parent": "15"}, {"name": "1", "parent": "16"}, {"name": "2", "parent": "16"}, {"name": "1", "parent": "13"}, {"name": "2", "parent": "13"}, {"name": "1", "parent": "14"}, {"name": "2", "parent": "14"}, {"name": "1", "parent": "11"}, {"name": "3", "parent": "11"}, {"name": "1", "parent": "12"}, {"name": "2", "parent": "12"}, {"name": "13", "parent": "21"}, {"name": "5", "parent": "21"}, {"name": "1", "parent": "20"}, {"name": "4", "parent": "20"}, {"name": "13", "parent": "22"}, {"name": "5", "parent": "22"}, {"name": "13", "parent": "23"}, {"name": "5", "parent": "23"}, {"name": "13", "parent": "24"}, {"name": "5", "parent": "24"}, {"name": "13", "parent": "25"}, {"name": "5", "parent": "25"}, {"name": "13", "parent": "26"}, {"name": "6", "parent": "26"}, {"name": "13", "parent": "27"}, {"name": "6", "parent": "27"}, {"name": "13", "parent": "28"}, {"name": "6", "parent": "28"}, {"name": "13", "parent": "29"}, {"name": "6", "parent": "29"}, {"name": "1", "parent": "10"}, {"name": "3", "parent": "10"}, {"name": "13", "parent": "30"}, {"name": "6", "parent": "30"}, {"name": "13", "parent": "32"}, {"name": "6", "parent": "32"}, {"name": "13", "parent": "31"}, {"name": "6", "parent": "31"}, {"name": "1", "parent": "9"}, {"name": "3", "parent": "9"}, {"name": "1", "parent": "8"}, {"name": "3", "parent": "8"}]
[{"name": "52", "parent": "66"}, {"name": "56", "parent": "66"}, {"name": "52", "parent": "59"}, {"name": "56", "parent": "59"}, {"name": "50", "parent": "58"}, {"name": "51", "parent": "58"}, {"name": "50", "parent": "57"}, {"name": "51", "parent": "57"}, {"name": "50", "parent": "56"}, {"name": "51", "parent": "56"}, {"name": "50", "parent": "55"}, {"name": "51", "parent": "55"}, {"name": "52", "parent": "64"}, {"name": "56", "parent": "64"}, {"name": "52", "parent": "65"}, {"name": "56", "parent": "65"}, {"name": "52", "parent": "62"}, {"name": "56", "parent": "62"}, {"name": "52", "parent": "63"}, {"name": "56", "parent": "63"}, {"name": "52", "parent": "60"}, {"name": "56", "parent": "60"}, {"name": "52", "parent": "61"}, {"name": "56", "parent": "61"}, {"name": "38", "parent": "51"}, {"name": "45", "parent": "51"}, {"name": "50", "parent": "52"}, {"name": "51", "parent": "52"}, {"name": "50", "parent": "53"}, {"name": "51", "parent": "53"}, {"name": "50", "parent": "54"}, {"name": "51", "parent": "54"}, {"name": "38", "parent": "50"}, {"name": "43", "parent": "50"}]
[{"name": "10", "parent": "100"}, {"name": "11", "parent": "100"}, {"name": "10", "parent": "101"}, {"name": "11", "parent": "101"}, {"name": "10", "parent": "102"}, {"name": "11", "parent": "102"}, {"name": "10", "parent": "103"}, {"name": "11", "parent": "103"}, {"name": "10", "parent": "104"}, {"name": "11", "parent": "104"}, {"name": "10", "parent": "105"}, {"name": "11", "parent": "105"}, {"name": "10", "parent": "106"}, {"name": "11", "parent": "106"}, {"name": "10", "parent": "107"}, {"name": "11", "parent": "107"}, {"name": "10", "parent": "108"}, {"name": "11", "parent": "108"}, {"name": "10", "parent": "109"}, {"name": "11", "parent": "109"}, {"name": "1", "parent": "11"}, {"name": "2", "parent": "11"}, {"name": "10", "parent": "110"}, {"name": "11", "parent": "110"}, {"name": "10", "parent": "111"}, {"name": "11", "parent": "111"}, {"name": "10", "parent": "112"}, {"name": "11", "parent": "112"}, {"name": "10", "parent": "113"}, {"name": "11", "parent": "113"}, {"name": "10", "parent": "114"}, {"name": "11", "parent": "114"}, {"name": "10", "parent": "115"}, {"name": "11", "parent": "115"}, {"name": "10", "parent": "116"}, {"name": "11", "parent": "116"}, {"name": "10", "parent": "117"}, {"name": "11", "parent": "117"}, {"name": "10", "parent": "118"}, {"name": "11", "parent": "118"}, {"name": "10", "parent": "119"}, {"name": "11", "parent": "119"}, {"name": "10", "parent": "120"}, {"name": "11", "parent": "120"}, {"name": "10", "parent": "121"}, {"name": "11", "parent": "121"}, {"name": "10", "parent": "122"}, {"name": "11", "parent": "122"}, {"name": "10", "parent": "123"}, {"name": "11", "parent": "123"}, {"name": "10", "parent": "124"}, {"name": "11", "parent": "124"}, {"name": "10", "parent": "125"}, {"name": "11", "parent": "125"}, {"name": "10", "parent": "126"}, {"name": "11", "parent": "126"}, {"name": "10", "parent": "127"}, {"name": "11", "parent": "127"}, {"name": "10", "parent": "128"}, {"name": "11", "parent": "128"}, {"name": "10", "parent": "129"}, {"name": "11", "parent": "129"}, {"name": "102", "parent": "200"}, {"name": "104", "parent": "200"}, {"name": "102", "parent": "201"}, {"name": "104", "parent": "201"}, {"name": "102", "parent": "202"}, {"name": "104", "parent": "202"}, {"name": "102", "parent": "203"}, {"name": "104", "parent": "203"}, {"name": "102", "parent": "204"}, {"name": "104", "parent": "204"}, {"name": "102", "parent": "205"}, {"name": "104", "parent": "205"}, {"name": "102", "parent": "206"}, {"name": "104", "parent": "206"}, {"name": "102", "parent": "207"}, {"name": "104", "parent": "207"}, {"name": "102", "parent": "208"}, {"name": "104", "parent": "208"}, {"name": "102", "parent": "209"}, {"name": "104", "parent": "209"}, {"name": "102", "parent": "210"}, {"name": "104", "parent": "210"}, {"name": "102", "parent": "211"}, {"name": "104", "parent": "211"}, {"name": "102", "parent": "212"}, {"name": "104", "parent": "212"}, {"name": "102", "parent": "213"}, {"name": "104", "parent": "213"}, {"name": "102", "parent": "214"}, {"name": "104", "parent": "214"}, {"name": "102", "parent": "215"}, {"name": "104", "parent": "215"}, {"name": "102", "parent": "216"}, {"name": "104", "parent": "216"}, {"name": "102", "parent": "217"}, {"name": "104", "parent": "217"}, {"name": "102", "parent": "218"}, {"name": "104", "parent": "218"}, {"name": "102", "parent": "219"}, {"name": "104", "parent": "219"}, {"name": "102", "parent": "220"}, {"name": "104", "parent": "220"}, {"name": "102", "parent": "221"}, {"name": "104", "parent": "221"}, {"name": "102", "parent": "222"}, {"name": "104", "parent": "222"}, {"name": "102", "parent": "223"}, {"name": "104", "parent": "223"}, {"name": "102", "parent": "224"}, {"name": "104", "parent": "224"}, {"name": "102", "parent": "225"}, {"name": "104", "parent": "225"}, {"name": "102", "parent": "226"}, {"name": "104", "parent": "226"}, {"name": "102", "parent": "227"}, {"name": "104", "parent": "227"}, {"name": "106", "parent": "228"}, {"name": "108", "parent": "228"}, {"name": "106", "parent": "229"}, {"name": "108", "parent": "229"}, {"name": "106", "parent": "230"}, {"name": "108", "parent": "230"}, {"name": "106", "parent": "231"}, {"name": "108", "parent": "231"}, {"name": "106", "parent": "232"}, {"name": "108", "parent": "232"}, {"name": "106", "parent": "233"}, {"name": "108", "parent": "233"}, {"name": "106", "parent": "234"}, {"name": "108", "parent": "234"}, {"name": "106", "parent": "235"}, {"name": "108", "parent": "235"}, {"name": "120", "parent": "236"}, {"name": "119", "parent": "236"}, {"name": "120", "parent": "237"}, {"name": "119", "parent": "237"}, {"name": "120", "parent": "238"}, {"name": "119", "parent": "238"}, {"name": "120", "parent": "239"}, {"name": "119", "parent": "239"}, {"name": "120", "parent": "240"}, {"name": "119", "parent": "240"}, {"name": "120", "parent": "241"}, {"name": "119", "parent": "241"}, {"name": "120", "parent": "242"}, {"name": "119", "parent": "242"}, {"name": "120", "parent": "243"}, {"name": "119", "parent": "243"}, {"name": "120", "parent": "244"}, {"name": "119", "parent": "244"}, {"name": "120", "parent": "245"}, {"name": "119", "parent": "245"}]
d3.sankey = function() {
var sankey = {},
nodeWidth = 24,
nodePadding = 8,
size = [1, 1],
nodes = [],
links = [];
sankey.nodeWidth = function(_) {
if (!arguments.length) return nodeWidth;
nodeWidth = +_;
return sankey;
};
sankey.nodePadding = function(_) {
if (!arguments.length) return nodePadding;
nodePadding = +_;
return sankey;
};
sankey.nodes = function(_) {
if (!arguments.length) return nodes;
nodes = _;
return sankey;
};
sankey.links = function(_) {
if (!arguments.length) return links;
links = _;
return sankey;
};
sankey.size = function(_) {
if (!arguments.length) return size;
size = _;
return sankey;
};
sankey.layout = function(iterations) {
computeNodeLinks();
computeNodeValues();
computeNodeBreadths();
computeNodeDepths(iterations);
computeLinkDepths();
return sankey;
};
sankey.relayout = function() {
computeLinkDepths();
return sankey;
};
sankey.link = function() {
var curvature = .5;
function link(d) {
var x0 = d.source.x + d.source.dx,
x1 = d.target.x,
xi = d3.interpolateNumber(x0, x1),
x2 = xi(curvature),
x3 = xi(1 - curvature),
y0 = d.source.y + d.sy + d.dy / 2,
y1 = d.target.y + d.ty + d.dy / 2;
return "M" + x0 + "," + y0
+ "C" + x2 + "," + y0
+ " " + x3 + "," + y1
+ " " + x1 + "," + y1;
}
link.curvature = function(_) {
if (!arguments.length) return curvature;
curvature = +_;
return link;
};
return link;
};
// Populate the sourceLinks and targetLinks for each node.
// Also, if the source and target are not objects, assume they are indices.
function computeNodeLinks() {
nodes.forEach(function(node) {
node.sourceLinks = [];
node.targetLinks = [];
});
links.forEach(function(link) {
var source = link.source,
target = link.target;
if (typeof source === "number") source = link.source = nodes[link.source];
if (typeof target === "number") target = link.target = nodes[link.target];
source.sourceLinks.push(link);
target.targetLinks.push(link);
});
}
// Compute the value (size) of each node by summing the associated links.
function computeNodeValues() {
nodes.forEach(function(node) {
node.value = Math.max(
d3.sum(node.sourceLinks, value),
d3.sum(node.targetLinks, value)
);
});
}
// Iteratively assign the breadth (x-position) for each node.
// Nodes are assigned the maximum breadth of incoming neighbors plus one;
// nodes with no incoming links are assigned breadth zero, while
// nodes with no outgoing links are assigned the maximum breadth.
function computeNodeBreadths() {
var remainingNodes = nodes,
nextNodes,
x = 0;
while (remainingNodes.length) {
nextNodes = [];
remainingNodes.forEach(function(node) {
node.x = x;
node.dx = nodeWidth;
node.sourceLinks.forEach(function(link) {
if (nextNodes.indexOf(link.target) < 0) {
nextNodes.push(link.target);
}
});
});
remainingNodes = nextNodes;
++x;
}
//
moveSinksRight(x);
scaleNodeBreadths((size[0] - nodeWidth) / (x - 1));
}
function moveSourcesRight() {
nodes.forEach(function(node) {
if (!node.targetLinks.length) {
node.x = d3.min(node.sourceLinks, function(d) { return d.target.x; }) - 1;
}
});
}
function moveSinksRight(x) {
nodes.forEach(function(node) {
if (!node.sourceLinks.length) {
node.x = x - 1;
}
});
}
function scaleNodeBreadths(kx) {
nodes.forEach(function(node) {
node.x *= kx;
});
}
function computeNodeDepths(iterations) {
var nodesByBreadth = d3.nest()
.key(function(d) { return d.x; })
.sortKeys(d3.ascending)
.entries(nodes)
.map(function(d) { return d.values; });
//
initializeNodeDepth();
resolveCollisions();
for (var alpha = 1; iterations > 0; --iterations) {
relaxRightToLeft(alpha *= .99);
resolveCollisions();
relaxLeftToRight(alpha);
resolveCollisions();
}
function initializeNodeDepth() {
var ky = d3.min(nodesByBreadth, function(nodes) {
return (size[1] - (nodes.length - 1) * nodePadding) / d3.sum(nodes, value);
});
nodesByBreadth.forEach(function(nodes) {
nodes.forEach(function(node, i) {
node.y = i;
node.dy = node.value * ky;
});
});
links.forEach(function(link) {
link.dy = link.value * ky;
});
}
function relaxLeftToRight(alpha) {
nodesByBreadth.forEach(function(nodes, breadth) {
nodes.forEach(function(node) {
if (node.targetLinks.length) {
var y = d3.sum(node.targetLinks, weightedSource) / d3.sum(node.targetLinks, value);
node.y += (y - center(node)) * alpha;
}
});
});
function weightedSource(link) {
return center(link.source) * link.value;
}
}
function relaxRightToLeft(alpha) {
nodesByBreadth.slice().reverse().forEach(function(nodes) {
nodes.forEach(function(node) {
if (node.sourceLinks.length) {
var y = d3.sum(node.sourceLinks, weightedTarget) / d3.sum(node.sourceLinks, value);
node.y += (y - center(node)) * alpha;
}
});
});
function weightedTarget(link) {
return center(link.target) * link.value;
}
}
function resolveCollisions() {
nodesByBreadth.forEach(function(nodes) {
var node,
dy,
y0 = 0,
n = nodes.length,
i;
// Push any overlapping nodes down.
nodes.sort(ascendingDepth);
for (i = 0; i < n; ++i) {
node = nodes[i];
dy = y0 - node.y;
if (dy > 0) node.y += dy;
y0 = node.y + node.dy + nodePadding;
}
// If the bottommost node goes outside the bounds, push it back up.
dy = y0 - nodePadding - size[1];
if (dy > 0) {
y0 = node.y -= dy;
// Push any overlapping nodes back up.
for (i = n - 2; i >= 0; --i) {
node = nodes[i];
dy = node.y + node.dy + nodePadding - y0;
if (dy > 0) node.y -= dy;
y0 = node.y;
}
}
});
}
function ascendingDepth(a, b) {
return a.y - b.y;
}
}
function computeLinkDepths() {
nodes.forEach(function(node) {
node.sourceLinks.sort(ascendingTargetDepth);
node.targetLinks.sort(ascendingSourceDepth);
});
nodes.forEach(function(node) {
var sy = 0, ty = 0;
node.sourceLinks.forEach(function(link) {
link.sy = sy;
sy += link.dy;
});
node.targetLinks.forEach(function(link) {
link.ty = ty;
ty += link.dy;
});
});
function ascendingSourceDepth(a, b) {
return a.source.y - b.source.y;
}
function ascendingTargetDepth(a, b) {
return a.target.y - b.target.y;
}
}
function center(node) {
return node.y + node.dy / 2;
}
function value(link) {
return link.value;
}
return sankey;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment