-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKadiePySnpTools.htm
1562 lines (1340 loc) · 66.3 KB
/
KadiePySnpTools.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=Generator content="Microsoft Word 15 (filtered)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
{font-family:"MS Gothic";
panose-1:2 11 6 9 7 2 5 8 2 4;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Calibri Light";
panose-1:2 15 3 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@MS Gothic";
panose-1:2 11 6 9 7 2 5 8 2 4;}
@font-face
{font-family:"Adobe Gothic Std B";
panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Lucida Grande";}
@font-face
{font-family:"\@Adobe Gothic Std B";
panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"\@MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:9.0pt;
font-family:"Times New Roman",serif;}
h1
{mso-style-link:"Heading 1 Char";
margin-top:12.0pt;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
text-align:justify;
text-justify:inter-ideograph;
page-break-after:avoid;
font-size:9.0pt;
font-family:"Arial",sans-serif;
font-weight:bold;
text-decoration:underline;}
h2
{mso-style-link:"Heading 2 Char";
margin-top:12.0pt;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
text-align:justify;
text-justify:inter-ideograph;
page-break-after:avoid;
font-size:9.0pt;
font-family:"Times New Roman",serif;
font-weight:bold;
font-style:italic;}
h3
{mso-style-link:"Heading 3 Char";
margin-top:0in;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
text-align:justify;
text-justify:inter-ideograph;
page-break-after:avoid;
font-size:8.0pt;
font-family:"Arial",sans-serif;
font-weight:normal;
text-decoration:underline;}
h4
{mso-style-link:"Heading 4 Char";
margin-top:12.0pt;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
text-align:justify;
text-justify:inter-ideograph;
page-break-after:avoid;
font-size:14.0pt;
font-family:"Times New Roman",serif;
font-weight:bold;}
h5
{mso-style-link:"Heading 5 Char";
margin-top:12.0pt;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:13.0pt;
font-family:"Times New Roman",serif;
font-weight:bold;
font-style:italic;}
h6
{mso-style-link:"Heading 6 Char";
margin-top:12.0pt;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:11.0pt;
font-family:"Times New Roman",serif;
font-weight:bold;}
p.MsoHeading7, li.MsoHeading7, div.MsoHeading7
{mso-style-link:"Heading 7 Char";
margin-top:12.0pt;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:9.0pt;
font-family:"Times New Roman",serif;}
p.MsoHeading8, li.MsoHeading8, div.MsoHeading8
{mso-style-link:"Heading 8 Char";
margin-top:12.0pt;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:9.0pt;
font-family:"Times New Roman",serif;
font-style:italic;}
p.MsoHeading9, li.MsoHeading9, div.MsoHeading9
{mso-style-link:"Heading 9 Char";
margin-top:12.0pt;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:11.0pt;
font-family:"Calibri Light",sans-serif;}
p.MsoFootnoteText, li.MsoFootnoteText, div.MsoFootnoteText
{mso-style-link:"Footnote Text Char";
margin:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:10.0pt;
font-family:"Times New Roman",serif;}
p.MsoCommentText, li.MsoCommentText, div.MsoCommentText
{mso-style-link:"Comment Text Char";
margin:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:10.0pt;
font-family:"Times New Roman",serif;}
p.MsoHeader, li.MsoHeader, div.MsoHeader
{mso-style-link:"Header Char";
margin:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:9.0pt;
font-family:"Times New Roman",serif;}
p.MsoFooter, li.MsoFooter, div.MsoFooter
{mso-style-link:"Footer Char";
margin:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:9.0pt;
font-family:"Times New Roman",serif;}
span.MsoFootnoteReference
{vertical-align:super;}
p.MsoTitle, li.MsoTitle, div.MsoTitle
{mso-style-link:"Title Char";
margin-top:12.0pt;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
text-align:center;
font-size:16.0pt;
font-family:"Adobe Gothic Std B",sans-serif;
font-weight:bold;}
p.MsoSubtitle, li.MsoSubtitle, div.MsoSubtitle
{mso-style-link:"Subtitle Char";
margin-top:0in;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
text-align:center;
font-size:9.0pt;
font-family:"Calibri Light",sans-serif;}
a:link, span.MsoHyperlink
{color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:#954F72;
text-decoration:underline;}
em
{font-family:"Calibri",sans-serif;
font-weight:bold;}
p
{margin-right:0in;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
pre
{mso-style-link:"HTML Preformatted Char";
margin:0in;
font-size:10.0pt;
font-family:"Courier New";}
p.MsoCommentSubject, li.MsoCommentSubject, div.MsoCommentSubject
{mso-style-link:"Comment Subject Char";
margin:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:10.0pt;
font-family:"Times New Roman",serif;
font-weight:bold;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-link:"Balloon Text Char";
margin:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:9.0pt;
font-family:"Lucida Grande";}
span.MsoPlaceholderText
{color:gray;}
p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing
{margin:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:9.0pt;
font-family:"Times New Roman",serif;}
p.MsoRMPane, li.MsoRMPane, div.MsoRMPane
{margin:0in;
font-size:9.0pt;
font-family:"Times New Roman",serif;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
text-align:justify;
text-justify:inter-ideograph;
font-size:9.0pt;
font-family:"Times New Roman",serif;}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
{margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
text-align:justify;
text-justify:inter-ideograph;
font-size:9.0pt;
font-family:"Times New Roman",serif;}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
{margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
text-align:justify;
text-justify:inter-ideograph;
font-size:9.0pt;
font-family:"Times New Roman",serif;}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
{margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
text-align:justify;
text-justify:inter-ideograph;
font-size:9.0pt;
font-family:"Times New Roman",serif;}
p.MsoQuote, li.MsoQuote, div.MsoQuote
{mso-style-link:"Quote Char";
margin:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:9.0pt;
font-family:"Times New Roman",serif;
font-style:italic;}
p.MsoIntenseQuote, li.MsoIntenseQuote, div.MsoIntenseQuote
{mso-style-link:"Intense Quote Char";
margin-top:0in;
margin-right:.5in;
margin-bottom:0in;
margin-left:.5in;
text-align:justify;
text-justify:inter-ideograph;
font-size:9.0pt;
font-family:"Times New Roman",serif;
font-weight:bold;
font-style:italic;}
span.MsoSubtleEmphasis
{color:#5A5A5A;
font-style:italic;}
span.MsoIntenseEmphasis
{font-weight:bold;
font-style:italic;
text-decoration:underline;}
span.MsoSubtleReference
{text-decoration:underline;}
span.MsoIntenseReference
{font-weight:bold;
text-decoration:underline;}
span.MsoBookTitle
{font-family:"Calibri Light",sans-serif;
font-weight:bold;
font-style:italic;}
p.MsoBibliography, li.MsoBibliography, div.MsoBibliography
{margin:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:9.0pt;
font-family:"Times New Roman",serif;}
p.MsoTocHeading, li.MsoTocHeading, div.MsoTocHeading
{margin-top:12.0pt;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
text-align:justify;
text-justify:inter-ideograph;
page-break-after:avoid;
font-size:9.0pt;
font-family:"Arial",sans-serif;
font-weight:bold;
text-decoration:underline;}
span.TitleChar
{mso-style-name:"Title Char";
mso-style-link:Title;
font-family:"Adobe Gothic Std B",sans-serif;
font-weight:bold;}
span.Heading1Char
{mso-style-name:"Heading 1 Char";
mso-style-link:"Heading 1";
font-family:"Arial",sans-serif;
font-weight:bold;
text-decoration:underline;}
span.Heading2Char
{mso-style-name:"Heading 2 Char";
mso-style-link:"Heading 2";
font-family:"Times New Roman",serif;
font-weight:bold;
font-style:italic;}
span.Heading3Char
{mso-style-name:"Heading 3 Char";
mso-style-link:"Heading 3";
font-family:"Arial",sans-serif;
text-decoration:underline;}
span.Heading4Char
{mso-style-name:"Heading 4 Char";
mso-style-link:"Heading 4";
font-weight:bold;}
span.Heading5Char
{mso-style-name:"Heading 5 Char";
mso-style-link:"Heading 5";
font-weight:bold;
font-style:italic;}
span.Heading6Char
{mso-style-name:"Heading 6 Char";
mso-style-link:"Heading 6";
font-weight:bold;}
span.Heading7Char
{mso-style-name:"Heading 7 Char";
mso-style-link:"Heading 7";}
span.Heading8Char
{mso-style-name:"Heading 8 Char";
mso-style-link:"Heading 8";
font-style:italic;}
span.Heading9Char
{mso-style-name:"Heading 9 Char";
mso-style-link:"Heading 9";
font-family:"Calibri Light",sans-serif;}
span.SubtitleChar
{mso-style-name:"Subtitle Char";
mso-style-link:Subtitle;
font-family:"Calibri Light",sans-serif;}
span.QuoteChar
{mso-style-name:"Quote Char";
mso-style-link:Quote;
font-style:italic;}
span.IntenseQuoteChar
{mso-style-name:"Intense Quote Char";
mso-style-link:"Intense Quote";
font-weight:bold;
font-style:italic;}
span.HeaderChar
{mso-style-name:"Header Char";
mso-style-link:Header;
font-family:"Times New Roman",serif;}
span.FooterChar
{mso-style-name:"Footer Char";
mso-style-link:Footer;
font-family:"Times New Roman",serif;}
p.Keywords, li.Keywords, div.Keywords
{mso-style-name:Keywords;
mso-style-link:"Keywords Char";
margin-top:0in;
margin-right:0in;
margin-bottom:12.0pt;
margin-left:0in;
text-align:justify;
text-justify:inter-ideograph;
border:none;
padding:0in;
font-size:9.0pt;
font-family:"Times New Roman",serif;}
span.KeywordsChar
{mso-style-name:"Keywords Char";
mso-style-link:Keywords;
font-family:"Times New Roman",serif;}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-link:"Balloon Text";
font-family:"Lucida Grande";}
p.MaterialsandMethodsText, li.MaterialsandMethodsText, div.MaterialsandMethodsText
{mso-style-name:"Materials and Methods Text";
margin-top:0in;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
text-align:justify;
text-justify:inter-ideograph;
line-height:85%;
font-size:8.0pt;
font-family:"Arial",sans-serif;}
p.References, li.References, div.References
{mso-style-name:References;
margin-top:0in;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:8.0pt;
font-family:"Arial",sans-serif;}
p.Authors, li.Authors, div.Authors
{mso-style-name:Authors;
margin:0in;
text-align:center;
font-size:10.0pt;
font-family:"Times New Roman",serif;
font-weight:bold;}
p.FigureCaption, li.FigureCaption, div.FigureCaption
{mso-style-name:"Figure Caption";
margin:0in;
text-align:justify;
text-justify:inter-ideograph;
font-size:8.0pt;
font-family:"Arial",sans-serif;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
span.kn
{mso-style-name:kn;}
span.nn
{mso-style-name:nn;}
span.k
{mso-style-name:k;}
span.n
{mso-style-name:n;}
span.o
{mso-style-name:o;}
span.p
{mso-style-name:p;}
span.s2
{mso-style-name:s2;}
span.kc
{mso-style-name:kc;}
span.nb
{mso-style-name:nb;}
p.NotebookIn, li.NotebookIn, div.NotebookIn
{mso-style-name:NotebookIn;
mso-style-link:"NotebookIn Char";
margin:0in;
background:#F7F7F7;
word-break:break-all;
border:none;
padding:0in;
font-size:8.0pt;
font-family:"Courier New";}
p.NotebookOut, li.NotebookOut, div.NotebookOut
{mso-style-name:NotebookOut;
mso-style-link:"NotebookOut Char";
margin:0in;
background:white;
word-break:break-all;
font-size:8.0pt;
font-family:"Courier New";}
span.NotebookInChar
{mso-style-name:"NotebookIn Char";
mso-style-link:NotebookIn;
font-family:"Courier New";
background:#F7F7F7;}
span.mi
{mso-style-name:mi;}
span.NotebookOutChar
{mso-style-name:"NotebookOut Char";
mso-style-link:NotebookOut;
font-family:"Courier New";
background:white;}
p.NotebookIn2, li.NotebookIn2, div.NotebookIn2
{mso-style-name:NotebookIn2;
mso-style-link:"NotebookIn2 Char";
margin:0in;
background:#F7F7F7;
word-break:break-all;
border:none;
padding:0in;
font-size:8.0pt;
font-family:"Courier New";}
span.NotebookIn2Char
{mso-style-name:"NotebookIn2 Char";
mso-style-link:NotebookIn2;
font-family:"Courier New";
background:#F7F7F7;}
span.s1
{mso-style-name:s1;}
span.CommentTextChar
{mso-style-name:"Comment Text Char";
mso-style-link:"Comment Text";
font-family:"Times New Roman",serif;}
span.CommentSubjectChar
{mso-style-name:"Comment Subject Char";
mso-style-link:"Comment Subject";
font-family:"Times New Roman",serif;
font-weight:bold;}
span.pre
{mso-style-name:pre;}
span.FootnoteTextChar
{mso-style-name:"Footnote Text Char";
mso-style-link:"Footnote Text";
font-family:"Times New Roman",serif;}
.MsoChpDefault
{font-family:"Calibri",sans-serif;}
/* Page Definitions */
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
@page WordSection2
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection2
{page:WordSection2;}
@page WordSection3
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection3
{page:WordSection3;}
@page WordSection4
{size:8.5in 11.0in;
margin:1.0in .5in 1.0in .5in;}
div.WordSection4
{page:WordSection4;}
@page WordSection5
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection5
{page:WordSection5;}
/* List Definitions */
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
-->
</style>
</head>
<body lang=EN-US link="#0563C1" vlink="#954F72" style='word-wrap:break-word'>
<div class=WordSection1>
<p class=MsoTitle>PySnpTools: <br>
Reading and Manipulating Genomic Data in Python </p>
</div>
<b><span style='font-size:16.0pt;font-family:"Adobe Gothic Std B",sans-serif'><br
clear=all style='page-break-before:auto'>
</span></b>
<div class=WordSection2>
<p class=MsoNormal> </p>
<p class=Authors>Carl M Kadie</p>
<p class=Authors><span style='font-weight:normal'>Microsoft Research (Retired)</span></p>
<p class=Authors><span style='font-weight:normal'>Redmond, WA 98052</span></p>
<p class=Authors><span style='font-family:"Calibri",sans-serif;font-weight:
normal'>carlk@msn.com</span></p>
</div>
<span style='font-size:10.0pt;font-family:"Times New Roman",serif'><br
clear=all style='page-break-before:auto'>
</span>
<div class=WordSection3>
<p class=MsoNormal> </p>
<h1>Abstract</h1>
<p class=MsoNormal align=left style='text-align:left'>PySnpTools is a Python
library of reading and manipulating genomic data in Python 3 (and Python 2). It
allows users to efficiently select and reorder individuals (rows) and SNP
locations (columns). It then reads only the data selected. Originally developed
to support FaST-LMM a genome-wide-association-study (GWAS) tool PySnpTools
now supports large-memory and cluster-scale work.</p>
<p class=MsoNormal align=left style='text-align:left'><br>
More generally, PySnpTools was inspired by NumPy and Pandas. It can be thought
of as a way to add Pandas-like indexing to 2‑D NumPy arrays.</p>
<p class=MsoNormal> </p>
<div style='border:none;border-bottom:solid black 1.0pt;padding:0in 0in 4.0pt 0in'>
<p class=Keywords align=left style='text-align:left'>Keywords: Python, Open
Source, Genomics, Scalability</p>
</div>
</div>
<span style='font-size:9.0pt;font-family:"Times New Roman",serif'><br
clear=all style='page-break-before:auto'>
</span>
<div class=WordSection4>
<h1>Introduction</h1>
<p class=MsoNormal>As we developed the FaST-LMM package (1;
2; 3; 4; 5; 6), we tired of re-writing our code to support more and more file formats
(<i>e.g.</i>, PLINKs Bed, Dat, Pheno, etc.) (7; 8). Moreover, we noticed
ourselves repeatedly performing similar manipulations, for example,</p>
<p class=MsoListParagraphCxSpFirst style='text-indent:-.25in'><span
style='font-family:Symbol'>·<span style='font:7.0pt "Times New Roman"'>
</span></span>reading data for just a subset of SNPs (columns),</p>
<p class=MsoListParagraphCxSpMiddle style='text-indent:-.25in'><span
style='font-family:Symbol'>·<span style='font:7.0pt "Times New Roman"'>
</span></span>reordering the individuals (rows) in our phenotype data to match
their order in the SNP data, and </p>
<p class=MsoListParagraphCxSpLast style='text-indent:-.25in'><span
style='font-family:Symbol'>·<span style='font:7.0pt "Times New Roman"'>
</span></span>filling in missing data and normalizing data.</p>
<p class=MsoNormal>Inspired by NumPy and Pandas, we created PySnpTools, an
open-source library that makes these operations easy.</p>
<p class=MsoNormal> </p>
<p class=MsoNormal>We presented the first public version of PySnpTools at the
PyData 2015 conference in Seattle. At the conference, Travis Oliphant (primary
creator of NumPy) recommended PySnpTools approach to reading and manipulating
genomic data (9). Not long after the conference, Hilary Finucane (leader of the
Finucane Lab at the Broad Institute of MIT and Harvard) wrote us: I've been
loving PySnpTools and recommending it to other statistical geneticists who work
in Python (10)!</p>
<p class=MsoNormal> </p>
<p class=MsoNormal>Since the conference, as FaST-LMM grew to support datasets
of up to 1 million samples (6), we expanded PySnpTools to also simplify:</p>
<p class=MsoListParagraphCxSpFirst style='text-indent:-.25in'><span
style='font-family:Symbol'>·<span style='font:7.0pt "Times New Roman"'>
</span></span>larger-than-memory datasets</p>
<p class=MsoListParagraphCxSpMiddle style='text-indent:-.25in'><span
style='font-family:Symbol'>·<span style='font:7.0pt "Times New Roman"'>
</span></span>running loops on multiple processors or on any clusters, and</p>
<p class=MsoListParagraphCxSpLast style='text-indent:-.25in'><span
style='font-family:Symbol'>·<span style='font:7.0pt "Times New Roman"'>
</span></span>reading and writing files locally or from/to any remote storage.</p>
<p class=MsoNormal>Most recently, weve added support for Python 3, a much-requested
feature.</p>
<p class=MsoNormal> </p>
<p class=MsoNormal>This paper tells how to install PySnpTools and describes the
genomic data that PySnpTools focuses on. It then gives examples of core usage.
It closes by listing other PySnpTools features and providing a brief comparison
to other dataset approaches.</p>
<h1 style='margin-bottom:6.0pt'>Installing PySnpTools</h1>
<p class=MsoNormal>To use PySnpTools:</p>
<p class=MsoNormal> </p>
<p class=MsoNormal style='text-indent:.5in'><span style='font-size:8.0pt;
font-family:"Courier New";color:#333333'>pip install pysnptools<a href="#_ftn1"
name="_ftnref1" title=""><span class=MsoFootnoteReference><span
class=MsoFootnoteReference><span style='font-size:8.0pt;font-family:"Courier New";
color:#333333'>[1]</span></span></span></a></span></p>
<p class=MsoNormal> </p>
<p class=MsoNormal>Find Jupyter notebooks, full API documentation with examples,
and source code at <a href="https://github.com/fastlmm/PySnpTools">https://github.com/fastlmm/PySnpTools</a>.</p>
<h1 style='margin-bottom:6.0pt'>Genomic Data</h1>
<p class=MsoNormal>The genomic data of interest to us typically consists of
500,000 to 1.5 million columns -- one column for each SNP (that is a genome location
where humans are known to differ). The data includes of one row per individual.
One thousand to 1,000,000 rows are typical. Values within the initial data
might be 0,1,2 or missing (representing the number of minor alleles measured
for an individual at a genome location). After standardization, values are
64-bit or 32-bit floats, with missing values represented by NaN (not-a-number).</p>
<p class=MsoNormal> </p>
<p class=MsoNormal>Figure 1 shows PySnpTools in-memory representation of genomic
data. Two strings, called the <a
href="https://fastlmm.github.io/PySnpTools/#pysnptools.snpreader.SnpReader.iid"
title=pysnptools.snpreader.SnpReader.iid><span class=pre><b><span
style='font-size:8.0pt;font-family:"Courier New";color:windowtext;text-decoration:
none'>iid</span></b></span></a>, identify each individual. One string, called
the <span class=pre><b><span style='font-size:8.0pt;font-family:"Courier New"'>sid</span></b></span>,
identifies each SNP. A float, called <span class=pre><b><span style='font-size:
8.0pt;font-family:"Courier New"'>val</span></b></span>, tells an individuals allele
count at a SNP. Finally, a triple of floats, called <span class=pre><b><span
style='font-size:8.0pt;font-family:"Courier New"'>pos</span></b></span>, tells
the position of each SNP (chromosome number, genetic distance, and base-pair
position). For a given position in <span class=pre><b><span style='font-size:
8.0pt;font-family:"Courier New"'>val</span></b></span>, PySnpTools makes it
easy to find the corresponding <span class=pre><b><span style='font-size:8.0pt;
font-family:"Courier New"'>iid</span></b></span>, <span class=pre><b><span
style='font-size:8.0pt;font-family:"Courier New"'>sid</span></b></span>, and<span
class=pre><b><span style='font-size:8.0pt;font-family:"Courier New"'> pos.</span></b></span>
Moreover, for any <span class=pre><b><span style='font-size:8.0pt;font-family:
"Courier New"'>iids</span></b></span> or <span class=pre><b><span
style='font-size:8.0pt;font-family:"Courier New"'>sids</span></b></span> of
interest, PySnpTools makes it easy and efficient to find the corresponding
positions in <span class=pre><b><span style='font-size:8.0pt;font-family:"Courier New"'>val</span></b></span>.</p>
<p class=MsoNormal> </p>
<p class=MsoNormal>For phenotypic and covariate data (<i>e.g.</i>, age, sex, height,
weight, presence of a disease), PySnpTools uses the same representation. For such
data, <span class=pre><b><span style='font-size:8.0pt;font-family:"Courier New"'>sid</span></b></span>
tells the name of the feature (<i>e.g.</i>, height) while <span class=pre><b><span
style='font-size:8.0pt;font-family:"Courier New"'>pos</span></b></span> is
ignored. The <span class=pre><b><span style='font-size:8.0pt;font-family:"Courier New"'>val</span></b></span><b>
</b>array, as a float, can also represent binary data via 0.0 and 1.0. We
handle categorical data via hot-one encoding.</p>
<h1 style='margin-bottom:6.0pt'><span style='position:relative;z-index:251662848;
left:-2px;top:0px;width:345px;height:272px'><img width=345 height=272
src="KadiePySnpTools_files/image001.png"></span><br clear=ALL>
Reading Genomic Files: An Example</h1>
<p class=MsoNormal>A Python object that reads genomic data from a file is
called a SnpReader. Here is how to create a SnpReader for the popular Bed file
format: We tell it what file to read and how to read it. (This SnpReader, as
yet reads nothing from its file.)</p>
<p class=MsoNormal> </p>
<div style='border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
background:#F7F7F7'>
<p class=NotebookIn><i><span style='font-size:6.0pt;font-family:"Calibri Light",sans-serif;
color:black'>Input:</span></i></p>
<p class=NotebookIn><b><span style='color:green'>from</span><span
style='color:#333333'> </span><span style='color:black'>pysnptools.snpreader</span><span
style='color:#333333'> </span><span style='color:green'>import</span><span
style='color:#333333'> Bed</span></b></p>
<p class=NotebookIn><span style='color:#333333'>snpreader </span><span
style='color:#666666'>=</span><span style='color:#333333'> Bed(</span><span
style='color:#BA2121'>"all.bed"</span><span style='color:#333333'>,
count_A1</span><span style='color:#666666'>=</span><span style='color:green'>True</span><span
style='color:#333333'>)</span></p>
<p class=NotebookIn><span style='color:green'>print</span><span
style='color:#333333'>(snpreader)</span></p>
</div>
<p class=MsoNormal> </p>
<p class=NotebookOut><i><span style='font-size:6.0pt;font-family:"Calibri Light",sans-serif;
color:black'>Output:<br>
</span></i><span style='color:black'>Bed('all.bed',count_A1=True)</span></p>
<p class=MsoNormal> </p>
<p class=MsoNormal>We can ask a SnpReader for the number of individuals and the
number of SNPs. We can also, for example, ask it for the <span class=pre><b><span
style='font-size:8.0pt;font-family:"Courier New"'>iid</span></b></span> of the
first individual. We can additionally ask it for the <span class=pre><b><span
style='font-size:8.0pt;font-family:"Courier New"'>sid</span></b></span> of the
last SNP. (The Bed SnpReader reads only the small files needed to answer these
questions.)</p>
<p class=MsoNormal> </p>
<div style='border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
background:#F7F7F7'>
<p class=NotebookIn><i><span style='font-size:6.0pt;font-family:"Calibri Light",sans-serif;
color:black'>Input:</span></i></p>
<p class=NotebookIn2><span class=nb><span style='color:green'>print</span></span><span
class=p><span style='color:#333333'>(</span></span><span class=n><span
style='color:#333333'>snpreader</span></span><span class=o><span
style='color:#666666'>.</span></span><span class=n><span style='color:#333333'>iid_count</span></span><span
class=p><span style='color:#333333'>,</span></span><span class=n><span
style='color:#333333'>snpreader</span></span><span class=o><span
style='color:#666666'>.</span></span><span class=n><span style='color:#333333'>sid_count</span></span><span
class=p><span style='color:#333333'>)</span></span></p>
<p class=NotebookIn2><span class=nb><span style='color:green'>print</span></span><span
class=p><span style='color:#333333'>(</span></span><span class=n><span
style='color:#333333'>snpreader</span></span><span class=o><span
style='color:#666666'>.</span></span><span class=n><span style='color:#333333'>iid</span></span><span
class=p><span style='color:#333333'>[</span></span><span class=mi><span
style='color:#666666'>0</span></span><span class=p><span style='color:#333333'>])</span></span></p>
<p class=NotebookIn2><span class=nb><span style='color:green'>print</span></span><span
class=p><span style='color:#333333'>(</span></span><span class=n><span
style='color:#333333'>snpreader</span></span><span class=o><span
style='color:#666666'>.</span></span><span class=n><span style='color:#333333'>sid</span></span><span
class=p><span style='color:#333333'>[</span></span><span class=o><span
style='color:#666666'>-</span></span><span class=mi><span style='color:#666666'>1</span></span><span
class=p><span style='color:#333333'>])</span></span></p>
</div>
<p class=MsoNormal> </p>
<pre style='background:white;vertical-align:baseline;word-break:break-all'><i><span
style='font-size:6.0pt;font-family:"Calibri Light",sans-serif;color:black'>Output:<br>
</span></i><span style='font-size:8.0pt;color:black'>500 5000</span></pre><pre
style='background:white;vertical-align:baseline;word-break:break-all'><span
style='font-size:8.0pt;color:black'>['cid0P0' 'cid0P0']</span></pre><pre
style='background:white;vertical-align:baseline;word-break:break-all'><span
style='font-size:8.0pt;color:black'>snp124_m0_.23m1_.08</span></pre>
<p class=MsoNormal> </p>
<p class=MsoNormal>Next, we can read all the genomic data into memory, creating
a new SnpReader called a SnpData. Because a SnpData is a SnpReader, we can
again ask for the number of individuals and SNPs.</p>
<p class=MsoNormal> </p>
<div style='border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
background:#F7F7F7'>
<p class=NotebookIn><i><span style='font-size:6.0pt;font-family:"Calibri Light",sans-serif;
color:black'>Input:</span></i></p>
<pre style='background:#F7F7F7;word-break:break-all;border:none;padding:0in'><span
class=n><span style='font-size:8.0pt;color:#333333'>snpdata</span></span><span
style='font-size:8.0pt;color:#333333'> </span><span class=o><span
style='font-size:8.0pt;color:#666666'>=</span></span><span style='font-size:
8.0pt;color:#333333'> </span><span class=n><span style='font-size:8.0pt;
color:#333333'>snpreader</span></span><span class=o><span style='font-size:
8.0pt;color:#666666'>.</span></span><span class=n><span style='font-size:8.0pt;
color:#333333'>read</span></span><span class=p><span style='font-size:8.0pt;
color:#333333'>()</span></span></pre><pre style='background:#F7F7F7;word-break:
break-all;border:none;padding:0in'><span class=nb><span style='font-size:8.0pt;
color:green'>print</span></span><span class=p><span style='font-size:8.0pt;
color:#333333'>(</span></span><span class=n><span style='font-size:8.0pt;
color:#333333'>snpdata</span></span><span class=p><span style='font-size:8.0pt;
color:#333333'>)</span></span></pre><pre style='background:#F7F7F7;word-break:
break-all;border:none;padding:0in'><span class=nb><span style='font-size:8.0pt;
color:green'>print</span></span><span class=p><span style='font-size:8.0pt;
color:#333333'>(</span></span><span class=n><span style='font-size:8.0pt;
color:#333333'>snpdata</span></span><span class=o><span style='font-size:8.0pt;
color:#666666'>.</span></span><span class=n><span style='font-size:8.0pt;
color:#333333'>iid_count</span></span><span class=p><span style='font-size:
8.0pt;color:#333333'>,</span></span><span style='font-size:8.0pt;color:#333333'> </span><span
class=n><span style='font-size:8.0pt;color:#333333'>snpdata</span></span><span
class=o><span style='font-size:8.0pt;color:#666666'>.</span></span><span
class=n><span style='font-size:8.0pt;color:#333333'>sid_count</span></span><span
class=p><span style='font-size:8.0pt;color:#333333'>)</span></span></pre></div>
<pre style='background:white;vertical-align:baseline;word-break:break-all'><span
style='font-size:8.0pt;color:black'> </span></pre><pre style='background:
white;vertical-align:baseline;word-break:break-all'><i><span style='font-size:
6.0pt;font-family:"Calibri Light",sans-serif;color:black'>Output:<br>
</span></i><span style='font-size:8.0pt;color:black'>SnpData(Bed('all.bed',count_A1=True))</span></pre><pre
style='background:white;vertical-align:baseline;word-break:break-all'><span
style='font-size:8.0pt;color:black'>500 5000</span></pre>
<p class=MsoNormal> </p>
<p class=MsoNormal>A SnpData is a SnpReader that contains a <span class=pre><b><span
style='font-size:8.0pt;font-family:"Courier New"'>val</span></b></span> property
that other SnpReaders do not. The <span class=pre><b><span style='font-size:
8.0pt;font-family:"Courier New"'>val</span></b></span> property is an (in-memory)
NumPy array of the genomic data.</p>
<p class=MsoNormal> </p>
<p class=MsoNormal>We can, for example, show the genomic data for the first 7
individuals and first 7 SNPs. We can also find the mean of <b>all</b> the
genomic data.</p>
<p class=MsoNormal> </p>
<div style='border:solid windowtext 1.0pt;padding:1.0pt 1.0pt 1.0pt 1.0pt;
background:#F7F7F7'><pre style='background:#F7F7F7;word-break:break-all;
border:none;padding:0in'><i><span style='font-size:6.0pt;font-family:"Calibri Light",sans-serif;
color:black'>Input:</span></i></pre><pre style='background:#F7F7F7;word-break:
break-all;border:none;padding:0in'><span class=kn><b><span style='font-size:
8.0pt;color:green'>import</span></b></span><span style='font-size:8.0pt;
color:#333333'> </span><span class=nn><b><span style='font-size:8.0pt;
color:blue'>numpy</span></b></span><span style='font-size:8.0pt;color:#333333'> </span><span
class=k><b><span style='font-size:8.0pt;color:green'>as</span></b></span><span
style='font-size:8.0pt;color:#333333'> </span><span class=nn><b><span
style='font-size:8.0pt;color:blue'>np</span></b></span></pre><pre
style='background:#F7F7F7;word-break:break-all;border:none;padding:0in'><span
class=nb><span style='font-size:8.0pt;color:green'>print</span></span><span
class=p><span style='font-size:8.0pt;color:#333333'>(</span></span><span
class=n><span style='font-size:8.0pt;color:#333333'>snpdata</span></span><span
class=o><span style='font-size:8.0pt;color:#666666'>.</span></span><span
class=n><span style='font-size:8.0pt;color:#333333'>val</span></span><span
class=p><span style='font-size:8.0pt;color:#333333'>[:</span></span><span
class=mi><span style='font-size:8.0pt;color:#666666'>7</span></span><span
class=p><span style='font-size:8.0pt;color:#333333'>,:</span></span><span
class=mi><span style='font-size:8.0pt;color:#666666'>7</span></span><span
class=p><span style='font-size:8.0pt;color:#333333'>])</span></span></pre><pre
style='background:#F7F7F7;word-break:break-all;border:none;padding:0in'><span
class=nb><span style='font-size:8.0pt;color:green'>print</span></span><span
class=p><span style='font-size:8.0pt;color:#333333'>(</span></span><span
class=n><span style='font-size:8.0pt;color:#333333'>np</span></span><span
class=o><span style='font-size:8.0pt;color:#666666'>.</span></span><span
class=n><span style='font-size:8.0pt;color:#333333'>mean</span></span><span
class=p><span style='font-size:8.0pt;color:#333333'>(</span></span><span
class=n><span style='font-size:8.0pt;color:#333333'>snpdata</span></span><span
class=o><span style='font-size:8.0pt;color:#666666'>.</span></span><span
class=n><span style='font-size:8.0pt;color:#333333'>val</span></span><span
class=p><span style='font-size:8.0pt;color:#333333'>))</span></span></pre></div>
<pre style='background:white;vertical-align:baseline;word-break:break-all'><span
style='font-size:8.0pt;color:black'> </span></pre><pre style='background:
white;vertical-align:baseline;word-break:break-all'><i><span style='font-size:
6.0pt;font-family:"Calibri Light",sans-serif;color:black'>Output:<br>
</span></i><span style='font-size:8.0pt;color:black'> [[0. 0. 1. 2. 0. 1. 2.]</span></pre><pre
style='background:white;vertical-align:baseline;word-break:break-all'><span
style='font-size:8.0pt;color:black'> [0. 0. 1. 1. 0. 0. 2.]</span></pre><pre
style='background:white;vertical-align:baseline;word-break:break-all'><span
style='font-size:8.0pt;color:black'> [0. 0. 1. 2. 1. 0. 0.]</span></pre><pre
style='background:white;vertical-align:baseline;word-break:break-all'><span
style='font-size:8.0pt;color:black'> [0. 0. 0. 2. 0. 0. 0.]</span></pre><pre
style='background:white;vertical-align:baseline;word-break:break-all'><span
style='font-size:8.0pt;color:black'> [0. 0. 0. 0. 0. 0. 2.]</span></pre><pre
style='background:white;vertical-align:baseline;word-break:break-all'><span
style='font-size:8.0pt;color:black'> [0. 0. 1. 0. 0. 0. 2.]</span></pre><pre
style='background:white;vertical-align:baseline;word-break:break-all'><span
style='font-size:8.0pt;color:black'> [0. 0. 2. 1. 0. 1. 2.]]</span></pre><pre
style='background:white;vertical-align:baseline;word-break:break-all'><span
style='font-size:8.0pt;color:black'>0.521412</span></pre>
<p class=MsoNormal> </p>
<p class=MsoNormal>Alternatively, we can do everything in one line.</p>
<p class=MsoNormal> </p>
<div style='border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
background:#F7F7F7'>
<p class=NotebookIn><i><span style='font-size:6.0pt;font-family:"Calibri Light",sans-serif;
color:black'>Input:</span></i></p>
<p class=MsoNormal align=left style='text-align:left;background:#F7F7F7;
word-break:break-all;border:none;padding:0in'><span style='font-size:7.5pt;
font-family:"Courier New";color:green'>print</span><span style='font-size:7.5pt;
font-family:"Courier New";color:#333333'>(np</span><span style='font-size:7.5pt;