|
382 | 382 | "ag3 = Ag3(pre=True)\n", |
383 | 383 | "\n", |
384 | 384 | "print(\"MalariaGEN Ag3 API client initialized.\")\n", |
385 | | - "print(ag3)\n" |
| 385 | + "print(ag3)" |
386 | 386 | ] |
387 | 387 | }, |
388 | 388 | { |
|
416 | 416 | "\n", |
417 | 417 | "# We'll pick one sample set for demonstration, preferably one known to have data\n", |
418 | 418 | "# For this example, we'll use '1237-VO-BJ-DJOGBENOU-VMF00050'\n", |
419 | | - "demo_sample_set = '1237-VO-BJ-DJOGBENOU-VMF00050'\n", |
| 419 | + "demo_sample_set = \"1237-VO-BJ-DJOGBENOU-VMF00050\"\n", |
420 | 420 | "if demo_sample_set not in phenotype_sample_sets:\n", |
421 | | - " print(f\"Warning: '{demo_sample_set}' not found. Using the first available: {phenotype_sample_sets}\")\n", |
| 421 | + " print(\n", |
| 422 | + " f\"Warning: '{demo_sample_set}' not found. Using the first available: {phenotype_sample_sets}\"\n", |
| 423 | + " )\n", |
422 | 424 | " demo_sample_set = phenotype_sample_sets\n", |
423 | 425 | "\n", |
424 | | - "print(f\"\\nUsing sample set for demonstration: {demo_sample_set}\")\n" |
| 426 | + "print(f\"\\nUsing sample set for demonstration: {demo_sample_set}\")" |
425 | 427 | ] |
426 | 428 | }, |
427 | 429 | { |
|
531 | 533 | } |
532 | 534 | ], |
533 | 535 | "source": [ |
534 | | - "print(f\"\\n--- Loading phenotype data for '{demo_sample_set}' filtered by Deltamethrin ---\")\n", |
| 536 | + "print(\n", |
| 537 | + " f\"\\n--- Loading phenotype data for '{demo_sample_set}' filtered by Deltamethrin ---\"\n", |
| 538 | + ")\n", |
535 | 539 | "df_deltamethrin = ag3.phenotype_data(\n", |
536 | | - " sample_sets=[demo_sample_set],\n", |
537 | | - " sample_query=\"insecticide == 'Deltamethrin'\"\n", |
| 540 | + " sample_sets=[demo_sample_set], sample_query=\"insecticide == 'Deltamethrin'\"\n", |
538 | 541 | ")\n", |
539 | 542 | "\n", |
540 | 543 | "print(f\"Shape of DataFrame: {df_deltamethrin.shape}\")\n", |
541 | 544 | "print(\"\\nFirst 5 rows of the filtered DataFrame:\")\n", |
542 | 545 | "df_deltamethrin.head()\n", |
543 | | - "print(f\"\\nUnique insecticides in filtered data: {df_deltamethrin['insecticide'].unique()}\")\n", |
| 546 | + "print(\n", |
| 547 | + " f\"\\nUnique insecticides in filtered data: {df_deltamethrin['insecticide'].unique()}\"\n", |
| 548 | + ")\n", |
544 | 549 | "print(\"\\nDataFrame Info:\")\n", |
545 | | - "df_deltamethrin.info() " |
| 550 | + "df_deltamethrin.info()" |
546 | 551 | ] |
547 | 552 | }, |
548 | 553 | { |
|
647 | 652 | "print(f\"\\n--- Loading phenotype data filtered by Deltamethrin and dose >= 1.0 ---\")\n", |
648 | 653 | "df_filtered_multi = ag3.phenotype_data(\n", |
649 | 654 | " sample_sets=[demo_sample_set],\n", |
650 | | - " sample_query=\"insecticide == 'Deltamethrin' and dose >= 1.0\"\n", |
| 655 | + " sample_query=\"insecticide == 'Deltamethrin' and dose >= 1.0\",\n", |
651 | 656 | ")\n", |
652 | 657 | "\n", |
653 | 658 | "print(f\"Shape of DataFrame: {df_filtered_multi.shape}\")\n", |
|
657 | 662 | "print(f\"\\nUnique insecticides: {df_filtered_multi['insecticide'].unique()}\")\n", |
658 | 663 | "print(f\"Unique doses: {df_filtered_multi['dose'].unique()}\")\n", |
659 | 664 | "print(\"\\nDataFrame Info:\")\n", |
660 | | - "df_filtered_multi.info()\n" |
| 665 | + "df_filtered_multi.info()" |
661 | 666 | ] |
662 | 667 | }, |
663 | 668 | { |
|
761 | 766 | "df_cohort_filtered = ag3.phenotype_data(\n", |
762 | 767 | " sample_sets=[demo_sample_set],\n", |
763 | 768 | " sample_query=\"insecticide == 'Deltamethrin'\",\n", |
764 | | - " min_cohort_size=10\n", |
| 769 | + " min_cohort_size=10,\n", |
765 | 770 | ")\n", |
766 | 771 | "\n", |
767 | 772 | "print(f\"Shape of DataFrame: {df_cohort_filtered.shape}\")\n", |
768 | 773 | "print(\"\\nFirst 5 rows of the cohort-filtered DataFrame:\")\n", |
769 | | - "df_cohort_filtered.head() \n", |
| 774 | + "df_cohort_filtered.head()\n", |
770 | 775 | "print(\"\\nDataFrame Info:\")\n", |
771 | | - "df_cohort_filtered.info() \n", |
| 776 | + "df_cohort_filtered.info()\n", |
772 | 777 | "# Verify cohort sizes (optional, for internal testing)\n", |
773 | 778 | "# if not df_cohort_filtered.empty:\n", |
774 | 779 | "# cohort_keys = [\"insecticide\", \"dose\", \"location\", \"country\", \"sample_set\"]\n", |
|
777 | 782 | "# cohort_sizes = df_cohort_filtered.groupby(available_keys).size()\n", |
778 | 783 | "# print(\"\\nCohort sizes after filtering:\")\n", |
779 | 784 | "# print(cohort_sizes)\n", |
780 | | - "# print(f\"All cohorts meet min_cohort_size (>=10): {all(cohort_sizes >= 10)}\")\n" |
| 785 | + "# print(f\"All cohorts meet min_cohort_size (>=10): {all(cohort_sizes >= 10)}\")" |
781 | 786 | ] |
782 | 787 | }, |
783 | 788 | { |
|
832 | 837 | "\n", |
833 | 838 | "# Example 1: Binary outcomes for all Deltamethrin samples\n", |
834 | 839 | "binary_deltamethrin = ag3.phenotype_binary(\n", |
835 | | - " sample_sets=[demo_sample_set],\n", |
836 | | - " sample_query=\"insecticide == 'Deltamethrin'\"\n", |
| 840 | + " sample_sets=[demo_sample_set], sample_query=\"insecticide == 'Deltamethrin'\"\n", |
837 | 841 | ")\n", |
838 | 842 | "\n", |
839 | 843 | "print(f\"Shape of binary series: {binary_deltamethrin.shape}\")\n", |
|
845 | 849 | "# Example 2: Binary outcomes for samples that were 'alive' with Deltamethrin\n", |
846 | 850 | "binary_alive_deltamethrin = ag3.phenotype_binary(\n", |
847 | 851 | " sample_sets=[demo_sample_set],\n", |
848 | | - " sample_query=\"insecticide == 'Deltamethrin' and phenotype == 'alive'\"\n", |
| 852 | + " sample_query=\"insecticide == 'Deltamethrin' and phenotype == 'alive'\",\n", |
849 | 853 | ")\n", |
850 | 854 | "\n", |
851 | | - "print(f\"\\nShape of binary series (alive Deltamethrin): {binary_alive_deltamethrin.shape}\")\n", |
| 855 | + "print(\n", |
| 856 | + " f\"\\nShape of binary series (alive Deltamethrin): {binary_alive_deltamethrin.shape}\"\n", |
| 857 | + ")\n", |
852 | 858 | "print(\"First 5 entries:\")\n", |
853 | 859 | "print(binary_alive_deltamethrin.head())\n", |
854 | 860 | "print(f\"Unique values in series: {binary_alive_deltamethrin.unique()}\")\n", |
855 | 861 | "\n", |
856 | 862 | "# Example 3: Binary outcomes for samples with dose 0.5\n", |
857 | 863 | "binary_dose_0_5 = ag3.phenotype_binary(\n", |
858 | | - " sample_sets=[demo_sample_set],\n", |
859 | | - " sample_query=\"dose == 0.5\"\n", |
| 864 | + " sample_sets=[demo_sample_set], sample_query=\"dose == 0.5\"\n", |
860 | 865 | ")\n", |
861 | 866 | "\n", |
862 | 867 | "print(f\"\\nShape of binary series (dose 0.5): {binary_dose_0_5.shape}\")\n", |
|
927 | 932 | "\n", |
928 | 933 | "# Example 1: Binary outcomes for all Deltamethrin samples\n", |
929 | 934 | "binary_deltamethrin = ag3.phenotype_binary(\n", |
930 | | - " sample_sets=[demo_sample_set],\n", |
931 | | - " sample_query=\"insecticide == 'Deltamethrin'\"\n", |
| 935 | + " sample_sets=[demo_sample_set], sample_query=\"insecticide == 'Deltamethrin'\"\n", |
932 | 936 | ")\n", |
933 | 937 | "\n", |
934 | 938 | "print(f\"Shape of binary series: {binary_deltamethrin.shape}\")\n", |
|
940 | 944 | "# Example 2: Binary outcomes for samples that were 'alive' with Deltamethrin\n", |
941 | 945 | "binary_alive_deltamethrin = ag3.phenotype_binary(\n", |
942 | 946 | " sample_sets=[demo_sample_set],\n", |
943 | | - " sample_query=\"insecticide == 'Deltamethrin' and phenotype == 'alive'\"\n", |
| 947 | + " sample_query=\"insecticide == 'Deltamethrin' and phenotype == 'alive'\",\n", |
944 | 948 | ")\n", |
945 | 949 | "\n", |
946 | | - "print(f\"\\nShape of binary series (alive Deltamethrin): {binary_alive_deltamethrin.shape}\")\n", |
| 950 | + "print(\n", |
| 951 | + " f\"\\nShape of binary series (alive Deltamethrin): {binary_alive_deltamethrin.shape}\"\n", |
| 952 | + ")\n", |
947 | 953 | "print(\"First 5 entries:\")\n", |
948 | 954 | "print(binary_alive_deltamethrin.head())\n", |
949 | 955 | "print(f\"Unique values in series: {binary_alive_deltamethrin.unique()}\")\n", |
950 | 956 | "\n", |
951 | 957 | "# Example 3: Binary outcomes for samples with dose 0.5\n", |
952 | 958 | "binary_dose_0_5 = ag3.phenotype_binary(\n", |
953 | | - " sample_sets=[demo_sample_set],\n", |
954 | | - " sample_query=\"dose == 0.5\"\n", |
| 959 | + " sample_sets=[demo_sample_set], sample_query=\"dose == 0.5\"\n", |
955 | 960 | ")\n", |
956 | 961 | "\n", |
957 | 962 | "print(f\"\\nShape of binary series (dose 0.5): {binary_dose_0_5.shape}\")\n", |
|
1038 | 1043 | "ds_snps = ag3.phenotypes_with_snps(\n", |
1039 | 1044 | " sample_sets=[demo_sample_set],\n", |
1040 | 1045 | " sample_query=\"insecticide == 'Deltamethrin' and phenotype == 'alive'\",\n", |
1041 | | - " region=demo_region_snps\n", |
| 1046 | + " region=demo_region_snps,\n", |
1042 | 1047 | ")\n", |
1043 | 1048 | "\n", |
1044 | 1049 | "print(f\"Dataset dimensions: {ds_snps.dims}\")\n", |
|
1052 | 1057 | "print(\"\\nFirst 5 variant positions:\")\n", |
1053 | 1058 | "print(ds_snps[\"variant_position\"].head(5).values)\n", |
1054 | 1059 | "print(\"\\nDataset Info:\")\n", |
1055 | | - "ds_snps.info()\n" |
| 1060 | + "ds_snps.info()" |
1056 | 1061 | ] |
1057 | 1062 | }, |
1058 | 1063 | { |
|
1126 | 1131 | "ds_haps = ag3.phenotypes_with_haplotypes(\n", |
1127 | 1132 | " sample_sets=[demo_sample_set],\n", |
1128 | 1133 | " sample_query=\"insecticide == 'Deltamethrin' and phenotype == 'dead'\",\n", |
1129 | | - " region=demo_region_haps\n", |
| 1134 | + " region=demo_region_haps,\n", |
1130 | 1135 | ")\n", |
1131 | 1136 | "\n", |
1132 | 1137 | "print(f\"Dataset dimensions: {ds_haps.dims}\")\n", |
|
1140 | 1145 | "print(\"\\nFirst 5 variant positions:\")\n", |
1141 | 1146 | "print(ds_haps[\"variant_position\"].head(5).values)\n", |
1142 | 1147 | "print(\"\\nDataset Info:\")\n", |
1143 | | - "ds_haps.info()\n" |
| 1148 | + "ds_haps.info()" |
1144 | 1149 | ] |
1145 | 1150 | }, |
1146 | 1151 | { |
|
0 commit comments