Datasets:
File size: 90,950 Bytes
38a17b3 |
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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It turns out [record 3082688](https://zenodo.org/records/3082688) is version 2 of [record 1247307](https://zenodo.org/records/1247307), where some mislabeling was fixed. Images from record 1247307 should not be used, so we will remove them here.\n",
"\n",
"Will also add `hybrid_stat` and `file_url` columns so these can be explored with all functionality of the [data dashboard](https://huggingface.co/spaces/imageomics/dashboard-prototype)."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv(\"../Jiggins_Zenodo_Img_Master.csv\", low_memory=False)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CAMID 12586\n",
"X 49359\n",
"Image_name 37821\n",
"View 7\n",
"zenodo_name 36\n",
"zenodo_link 32\n",
"Sequence 11301\n",
"Taxonomic_Name 363\n",
"Locality 645\n",
"Sample_accession 1571\n",
"Collected_by 12\n",
"Other_ID 3088\n",
"Date 810\n",
"Dataset 8\n",
"Store 142\n",
"Brood 226\n",
"Death_Date 82\n",
"Cross_Type 30\n",
"Stage 1\n",
"Sex 3\n",
"Unit_Type 6\n",
"file_type 3\n",
"record_number 32\n",
"species 246\n",
"subspecies 155\n",
"genus 94\n",
"dtype: int64"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.nunique()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.series.Series'>\n",
"RangeIndex: 49359 entries, 0 to 49358\n",
"Series name: record_number\n",
"Non-Null Count Dtype\n",
"-------------- -----\n",
"49359 non-null int64\n",
"dtypes: int64(1)\n",
"memory usage: 385.7 KB\n"
]
}
],
"source": [
"df.record_number.info()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CAMID 12586\n",
"X 46439\n",
"Image_name 37821\n",
"View 7\n",
"zenodo_name 35\n",
"zenodo_link 31\n",
"Sequence 11301\n",
"Taxonomic_Name 363\n",
"Locality 645\n",
"Sample_accession 1571\n",
"Collected_by 12\n",
"Other_ID 3088\n",
"Date 810\n",
"Dataset 8\n",
"Store 142\n",
"Brood 226\n",
"Death_Date 82\n",
"Cross_Type 30\n",
"Stage 1\n",
"Sex 3\n",
"Unit_Type 6\n",
"file_type 3\n",
"record_number 31\n",
"species 246\n",
"subspecies 155\n",
"genus 94\n",
"dtype: int64"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = df.loc[df.record_number != 1247307]\n",
"df.nunique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Checking all records on Zenodo for the [Butterfly Genetics Group](https://zenodo.org/communities/butterfly/records) (the overall source of the Jiggins data), [record 3477891](https://zenodo.org/records/3477891) and [record 2548678](https://zenodo.org/records/2548678) are marked as version 2 of records 3477412 & 1880783, respectively. Let's check that the first versions are not included.\n",
"\n",
"It is also noted in [record 2548678](https://zenodo.org/records/2548678):\n",
">Some images overlap with 'Cambridge butterfly wing collection batch 1', taken by Eva Whiltshire. Images here differ in having a white reflectance standard for calibration. Information on duplicates can be found in 'CAM.coll.patricio.batch2.csv'.\n",
"\n",
"Note that this is a reference to [record 1247307](https://zenodo.org/records/1247307), so the overlap is in fact with Cambridge butterfly wing collection batch 1- version 2 ([record 3082688](https://zenodo.org/records/3082688)); it is unclear as yet if the duplication information will be acurate considering the mislabelings fixed between the versions."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(0, 26)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"v1s = [3477412, 1880783]\n",
"df.loc[df[\"record_number\"].isin(v1s)].shape"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The good news is that neither of these earlier versions seem to have been picked up, so we can move on to assessing this and adding the `hybrid_stat` and `file_url` columns."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"file_type\n",
"jpg 34152\n",
"raw 12226\n",
"tif 61\n",
"Name: count, dtype: int64"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.file_type.value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"View\n",
"dorsal 22022\n",
"ventral 21704\n",
"forewing dorsal 406\n",
"hindwing dorsal 406\n",
"forewing ventral 406\n",
"hindwing ventral 406\n",
"dorsal and ventral 18\n",
"Name: count, dtype: int64"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.View.value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We have 31 unique records represented in the full dataset. When we reduce down to just the Heliconius images, this will probably be less."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Add File URL Column"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>CAMID</th>\n",
" <th>X</th>\n",
" <th>Image_name</th>\n",
" <th>View</th>\n",
" <th>zenodo_name</th>\n",
" <th>zenodo_link</th>\n",
" <th>Sequence</th>\n",
" <th>Taxonomic_Name</th>\n",
" <th>Locality</th>\n",
" <th>Sample_accession</th>\n",
" <th>...</th>\n",
" <th>Cross_Type</th>\n",
" <th>Stage</th>\n",
" <th>Sex</th>\n",
" <th>Unit_Type</th>\n",
" <th>file_type</th>\n",
" <th>record_number</th>\n",
" <th>species</th>\n",
" <th>subspecies</th>\n",
" <th>genus</th>\n",
" <th>file_url</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>34925</th>\n",
" <td>CAM041457</td>\n",
" <td>38799</td>\n",
" <td>CAM041457_d.CR2</td>\n",
" <td>dorsal</td>\n",
" <td>0.gmk.broods.all.csv</td>\n",
" <td>https://zenodo.org/record/4291095</td>\n",
" <td>41,457</td>\n",
" <td>Heliconius timareta</td>\n",
" <td>Reventador road 2</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Male</td>\n",
" <td>NaN</td>\n",
" <td>raw</td>\n",
" <td>4291095</td>\n",
" <td>Heliconius timareta</td>\n",
" <td>NaN</td>\n",
" <td>Heliconius</td>\n",
" <td>https://zenodo.org/record/4291095/files/CAM041...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28286</th>\n",
" <td>CAM036145</td>\n",
" <td>41369</td>\n",
" <td>CAM036145_v.JPG</td>\n",
" <td>ventral</td>\n",
" <td>Filelist.csv</td>\n",
" <td>https://zenodo.org/record/5561246</td>\n",
" <td>36,145</td>\n",
" <td>Methona singularis</td>\n",
" <td>Guaribas - RG16</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Male</td>\n",
" <td>NaN</td>\n",
" <td>jpg</td>\n",
" <td>5561246</td>\n",
" <td>Methona singularis</td>\n",
" <td>NaN</td>\n",
" <td>Methona</td>\n",
" <td>https://zenodo.org/record/5561246/files/CAM036...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21858</th>\n",
" <td>CAM017409</td>\n",
" <td>19047</td>\n",
" <td>CAM017409_d.CR2</td>\n",
" <td>dorsal</td>\n",
" <td>CAM.coll.PS.list.individuals.haplotagging.new....</td>\n",
" <td>https://zenodo.org/record/4153502</td>\n",
" <td>17,409</td>\n",
" <td>Heliconius erato ssp. lativitta</td>\n",
" <td>San Pedro de Arajuno, Río Arajuno</td>\n",
" <td>ERS353373</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Female</td>\n",
" <td>wild</td>\n",
" <td>raw</td>\n",
" <td>4153502</td>\n",
" <td>Heliconius erato</td>\n",
" <td>lativitta</td>\n",
" <td>Heliconius</td>\n",
" <td>https://zenodo.org/record/4153502/files/CAM017...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12708</th>\n",
" <td>CAM010412</td>\n",
" <td>26792</td>\n",
" <td>CAM010412_v.CR2</td>\n",
" <td>ventral</td>\n",
" <td>2001_2.broods.batch.1.csv</td>\n",
" <td>https://zenodo.org/record/2549524</td>\n",
" <td>10,412</td>\n",
" <td>Heliconius sp.</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Unknown</td>\n",
" <td>reared</td>\n",
" <td>raw</td>\n",
" <td>2549524</td>\n",
" <td>Heliconius sp.</td>\n",
" <td>NaN</td>\n",
" <td>Heliconius</td>\n",
" <td>https://zenodo.org/record/2549524/files/CAM010...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>4 rows × 27 columns</p>\n",
"</div>"
],
"text/plain": [
" CAMID X Image_name View \\\n",
"34925 CAM041457 38799 CAM041457_d.CR2 dorsal \n",
"28286 CAM036145 41369 CAM036145_v.JPG ventral \n",
"21858 CAM017409 19047 CAM017409_d.CR2 dorsal \n",
"12708 CAM010412 26792 CAM010412_v.CR2 ventral \n",
"\n",
" zenodo_name \\\n",
"34925 0.gmk.broods.all.csv \n",
"28286 Filelist.csv \n",
"21858 CAM.coll.PS.list.individuals.haplotagging.new.... \n",
"12708 2001_2.broods.batch.1.csv \n",
"\n",
" zenodo_link Sequence \\\n",
"34925 https://zenodo.org/record/4291095 41,457 \n",
"28286 https://zenodo.org/record/5561246 36,145 \n",
"21858 https://zenodo.org/record/4153502 17,409 \n",
"12708 https://zenodo.org/record/2549524 10,412 \n",
"\n",
" Taxonomic_Name Locality \\\n",
"34925 Heliconius timareta Reventador road 2 \n",
"28286 Methona singularis Guaribas - RG16 \n",
"21858 Heliconius erato ssp. lativitta San Pedro de Arajuno, Río Arajuno \n",
"12708 Heliconius sp. NaN \n",
"\n",
" Sample_accession ... Cross_Type Stage Sex Unit_Type file_type \\\n",
"34925 NaN ... NaN NaN Male NaN raw \n",
"28286 NaN ... NaN NaN Male NaN jpg \n",
"21858 ERS353373 ... NaN NaN Female wild raw \n",
"12708 NaN ... NaN NaN Unknown reared raw \n",
"\n",
" record_number species subspecies genus \\\n",
"34925 4291095 Heliconius timareta NaN Heliconius \n",
"28286 5561246 Methona singularis NaN Methona \n",
"21858 4153502 Heliconius erato lativitta Heliconius \n",
"12708 2549524 Heliconius sp. NaN Heliconius \n",
"\n",
" file_url \n",
"34925 https://zenodo.org/record/4291095/files/CAM041... \n",
"28286 https://zenodo.org/record/5561246/files/CAM036... \n",
"21858 https://zenodo.org/record/4153502/files/CAM017... \n",
"12708 https://zenodo.org/record/2549524/files/CAM010... \n",
"\n",
"[4 rows x 27 columns]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[\"file_url\"] = df[\"zenodo_link\"] + \"/files/\" + df[\"Image_name\"]\n",
"df.sample(4)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Add Proper Taxonomic Name for Crosstypes\n",
"\n",
"We want the cross types to also have full taxonomic names (`Heliconius <species> <subspecies>`) so this can be used in downloading to appropriate branches and also for easier diversity counts. Cross Types will still be easily filtered using the `Cross_Type` column."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"subspecies\n",
"(malleti x plesseni) x malleti 1007\n",
"plesseni x (malleti x plesseni) 462\n",
"(plesseni x malleti) x (malleti x plesseni) 348\n",
"(plesseni x malleti) x plesseni 345\n",
"malleti x (plesseni x malleti) 324\n",
"(plesseni x malleti) x (plesseni x malleti) 228\n",
"(malleti x plesseni) x plesseni 216\n",
"plesseni x malleti 212\n",
"malleti x plesseni 156\n",
"lativitta x notabilis 111\n",
"plesseni x (plesseni x malleti) 106\n",
"(lativitta x notabilis) x notabilis 90\n",
"(lativitta x notabilis) x lativitta 90\n",
"(malleti x plesseni) x (malleti x plesseni) 81\n",
"(plesseni x malleti) x malleti 80\n",
"(malleti x plesseni) x (plesseni x malleti) 42\n",
"malleti 28\n",
"plesseni 28\n",
"(latRo x notabilis) x notabilis 12\n",
"latRo x notabilis 4\n",
"lativitta 4\n",
"Name: count, dtype: int64"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.loc[df[\"Cross_Type\"].notna(), \"subspecies\"].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Cross_Type\n",
"Test cross (4 spots x 4 spots) 150\n",
"Test cross (N heterozygocity - NBNN x malleti - thin) 114\n",
"Test cross (N heterozygozity) 78\n",
"Test cross (short HW bar) 54\n",
"Test cross (4 spots x 2 banded) 48\n",
"2 banded 16\n",
"hybrid 10\n",
"Ac heterozygote 4\n",
"Test cross (2 banded F2 x 2 banded F2) 4\n",
"Name: count, dtype: int64"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.loc[(df[\"Cross_Type\"].notna()) & (df[\"subspecies\"].isna()), \"Cross_Type\"].value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Notice that we have hybrids here which should be indicated as such though they don't all have an ` x ` in their name. We'll remember this for the `hybrid_stat` column and generate using the Cross Type indicator. Our only non-hybrid Cross Types are `malleti`, `plesseni`, and `lativitta`."
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(['hybrid', 'Ac heterozygote', '2 banded',\n",
" 'Test cross (2 banded F2 x 2 banded F2)',\n",
" 'Test cross (4 spots x 2 banded)', 'Test cross (N heterozygozity)',\n",
" 'Test cross (short HW bar)', 'Test cross (4 spots x 4 spots)',\n",
" 'Test cross (N heterozygocity - NBNN x malleti - thin)'],\n",
" dtype=object)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"non_specific_cross_hybrids = df.loc[(df[\"Cross_Type\"].notna()) & (df[\"subspecies\"].isna()), \"Cross_Type\"].unique()\n",
"non_specific_cross_hybrids"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(['cythera', 'cyrbia', 'venus', 'venus x chestertonii', 'vulcanus',\n",
" 'chestertonii', 'vulcanus x melpomene', 'lativitta', 'malleti',\n",
" 'erato', 'ssp.nov.P', 'melpomene', 'willmotti',\n",
" 'chestertonii x venus', 'eleuchia', 'cydnides', 'weymeri',\n",
" 'chioneus', 'demophoon', 'hydara', 'sapho', 'numata', 'iulia',\n",
" 'melpomene x thelxiope', 'wallacei', 'rosina', 'formosus',\n",
" 'melpomene x rosina', 'menapis', 'hydara x petiverana', 'decumana',\n",
" 'relata', 'agna', 'isthmia', 'bicoloratus', 'euphrasius',\n",
" 'salapia', 'matronalis', 'ethica', 'agnosia', 'andromica',\n",
" 'hippocrenis', 'saturata', 'evanides', 'lyra', 'pagasa',\n",
" 'staudingeri', 'valora', 'cassotis', 'chiriquensis', 'alithea',\n",
" 'timareta', 'plesseni', 'notabilis', 'amaryllis', 'thelxinoe',\n",
" 'doris', 'amaryllis x aglaope', 'aglaope', 'carbo', 'lycaste',\n",
" 'idae', 'macrinus', 'abida', 'notilla', 'neustetteri', 'giulia',\n",
" 'panamensis', 'eleusinus', 'agalla', 'xanthina', 'ecuadorensis',\n",
" 'congener', 'etylus', 'derasa', 'lenaeus', 'petiverana',\n",
" 'melicerta', 'thelxiopeia', 'meriana', 'plesseni x malleti',\n",
" 'notabilis x lativitta', 'sara', 'silvana', 'amalfreda',\n",
" 'hydara x amalfreda', 'flavescens', 'hydara x erato',\n",
" 'meriana x melpomene', 'nanna', 'daetina', 'nesaea', 'phyllis',\n",
" 'laphria', 'paraiya', 'lysimnia', 'daeta', 'yanetta', 'pyrrha',\n",
" 'casabranca', 'tristero', 'dignus', 'bellula',\n",
" 'dignus x lativitta', 'malleti x bellula', 'napoensis',\n",
" 'clysonymus', 'sotericus', 'primularis', 'sprucei', 'bassleri',\n",
" 'eximius', 'manabiana', 'nigrippus', 'hygiana', 'neildi',\n",
" 'clysonomus', 'hierax', 'magdalena', 'calathus', 'corena',\n",
" 'zelinde', 'florencia', 'weymeri f. gustavi', 'weymeri f. weymeri',\n",
" 'wanningeri', 'cydno', 'cordula', 'linaresi', 'lisethae',\n",
" 'hermogenes', 'martinae', 'vicina', 'malleti x vicina',\n",
" 'reductimacula', 'sergestus', 'felix', 'aerotome'], dtype=object)"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.loc[df[\"Cross_Type\"].isna(), \"subspecies\"].dropna().unique()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"def get_cross_taxa_name(species, cross_type):\n",
" # label unspecified hybrids as such\n",
" if cross_type in non_specific_cross_hybrids:\n",
" return species + \" \" + \"cross hybrid\"\n",
" \n",
" # separate out hybrids from non-hybrids\n",
" subsp_cross_list = cross_type.split(\"(\")\n",
" if len(subsp_cross_list) > 1:\n",
" subsp_cross = subsp_cross_list[1].split(\")\")[0]\n",
" else:\n",
" subsp_cross = cross_type\n",
" \n",
" # Ensure order of hybrid names is consistent so they get placed in same folders (using scripts/download_jiggins.py)\n",
" # And so counts by taxonomic name aren't needlessly skewed\n",
" if subsp_cross == \"malleti x plesseni\":\n",
" subsp_cross = \"plesseni x malleti\"\n",
" elif subsp_cross == \"lativitta x notabilis\":\n",
" subsp_cross = \"notabilis x lativitta\"\n",
" \n",
" # Set taxa_name as with non cross types labeled to subspecies\n",
" taxa_name = species + \" ssp. \" + subsp_cross\n",
" return taxa_name"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"H.sp. ssp. malleti\n",
"H.sp. ssp. plesseni x malleti\n",
"H.sp. ssp. plesseni\n",
"H.sp. ssp. plesseni x malleti\n",
"H.sp. ssp. latRo x notabilis\n",
"H.sp. ssp. latRo x notabilis\n",
"H.sp. ssp. plesseni x malleti\n",
"H.sp. ssp. plesseni x malleti\n",
"H.sp. ssp. plesseni x malleti\n",
"H.sp. ssp. plesseni x malleti\n",
"H.sp. ssp. notabilis x lativitta\n",
"H.sp. ssp. plesseni x malleti\n",
"H.sp. ssp. plesseni x malleti\n",
"H.sp. ssp. plesseni x malleti\n",
"H.sp. ssp. plesseni x malleti\n",
"H.sp. ssp. plesseni x malleti\n",
"H.sp. cross hybrid\n",
"H.sp. ssp. plesseni x malleti\n",
"H.sp. ssp. notabilis x lativitta\n",
"H.sp. ssp. notabilis x lativitta\n",
"H.sp. cross hybrid\n",
"H.sp. ssp. plesseni x malleti\n",
"H.sp. cross hybrid\n",
"H.sp. ssp. lativitta\n",
"H.sp. cross hybrid\n",
"H.sp. cross hybrid\n",
"H.sp. cross hybrid\n",
"H.sp. cross hybrid\n",
"H.sp. cross hybrid\n",
"H.sp. cross hybrid\n"
]
}
],
"source": [
"for cross_type in list(df[\"Cross_Type\"].dropna().unique()):\n",
" print(get_cross_taxa_name(\"H.sp.\", cross_type))"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(['Heliconius melpomene', 'Heliconius erato'], dtype=object)"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.loc[df[\"Cross_Type\"].notna(), \"species\"].unique()"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array(['Heliconius melpomene ssp. malleti',\n",
" 'Heliconius melpomene ssp. plesseni x malleti',\n",
" 'Heliconius melpomene ssp. plesseni',\n",
" 'Heliconius erato ssp. latRo x notabilis',\n",
" 'Heliconius erato ssp. notabilis x lativitta',\n",
" 'Heliconius erato cross hybrid',\n",
" 'Heliconius melpomene cross hybrid',\n",
" 'Heliconius erato ssp. lativitta'], dtype=object)"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# https://stackoverflow.com/a/52854800\n",
"df.loc[df[\"Cross_Type\"].notna(), \"Taxonomic_Name\"] = df.loc[df[\"Cross_Type\"].notna()].apply(lambda x: get_cross_taxa_name(x[\"species\"], x[\"Cross_Type\"]), axis = 1)\n",
"df.loc[df[\"Cross_Type\"].notna(), \"Taxonomic_Name\"].unique()"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"366"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.Taxonomic_Name.nunique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So we've added 3 more unique values of `Taxonomic_Name`, that checks out: `Heliconius erato ssp. latRo x notabilis`, `Heliconius erato cross hybrid`, and `Heliconius melpomene cross hybrid`."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Add Hybrid Status Column"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"20"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"hybrids = [taxa_name for taxa_name in list(df[\"Taxonomic_Name\"].dropna().unique()) if (\" x \" in taxa_name) or (\"hybrid\" in taxa_name)]\n",
"len(hybrids)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['Heliconius erato ssp. venus x chestertonii',\n",
" 'Heliconius melpomene ssp. vulcanus x melpomene',\n",
" 'Heliconius erato ssp. chestertonii x venus',\n",
" 'Heliconius melpomene ssp. melpomene x thelxiope',\n",
" 'Heliconius melpomene ssp. melpomene x rosina',\n",
" 'Heliconius hybrid',\n",
" 'Heliconius erato ssp. hydara x petiverana',\n",
" 'Heliconius melpomene ssp. amaryllis x aglaope',\n",
" 'Anartia fatima x amathea',\n",
" 'Heliconius melpomene ssp. plesseni x malleti',\n",
" 'Heliconius erato ssp. notabilis x lativitta',\n",
" 'Heliconius erato ssp. latRo x notabilis',\n",
" 'Heliconius erato cross hybrid',\n",
" 'Heliconius melpomene cross hybrid',\n",
" 'Heliconius erato ssp. hydara x amalfreda',\n",
" 'Heliconius erato ssp. hydara x erato',\n",
" 'Heliconius melpomene ssp. meriana x melpomene',\n",
" 'Heliconius melpomene ssp. dignus x lativitta',\n",
" 'Heliconius melpomene ssp. malleti x bellula',\n",
" 'Heliconius melpomene ssp. malleti x vicina']"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"hybrids"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Observe that we have one species-level hybrid: `Anartia fatima x amathea`."
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"sp_hybrid_parents = [\"Anartia fatima\", \"Anartia amathea\"]"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"df[\"hybrid_stat\"] = None\n",
"df.loc[df[\"subspecies\"].notna(), \"hybrid_stat\"] = \"non-hybrid\"\n",
"df.loc[df[\"species\"].isin(sp_hybrid_parents), \"hybrid_stat\"] = \"non-hybrid\"\n",
"\n",
"df.loc[df[\"Taxonomic_Name\"].isin(hybrids), \"hybrid_stat\"] = \"hybrid\""
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>CAMID</th>\n",
" <th>X</th>\n",
" <th>Image_name</th>\n",
" <th>View</th>\n",
" <th>zenodo_name</th>\n",
" <th>zenodo_link</th>\n",
" <th>Sequence</th>\n",
" <th>Taxonomic_Name</th>\n",
" <th>Locality</th>\n",
" <th>Sample_accession</th>\n",
" <th>...</th>\n",
" <th>Stage</th>\n",
" <th>Sex</th>\n",
" <th>Unit_Type</th>\n",
" <th>file_type</th>\n",
" <th>record_number</th>\n",
" <th>species</th>\n",
" <th>subspecies</th>\n",
" <th>genus</th>\n",
" <th>file_url</th>\n",
" <th>hybrid_stat</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>7326</th>\n",
" <td>CAM002890</td>\n",
" <td>8482</td>\n",
" <td>CAM002890_v.JPG</td>\n",
" <td>ventral</td>\n",
" <td>CAM.coll.images.batch5.csv</td>\n",
" <td>https://zenodo.org/record/2684906</td>\n",
" <td>2,890</td>\n",
" <td>Anartia fatima</td>\n",
" <td>El Tirao,</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>Female</td>\n",
" <td>wild</td>\n",
" <td>jpg</td>\n",
" <td>2684906</td>\n",
" <td>Anartia fatima</td>\n",
" <td>NaN</td>\n",
" <td>Anartia</td>\n",
" <td>https://zenodo.org/record/2684906/files/CAM002...</td>\n",
" <td>non-hybrid</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7327</th>\n",
" <td>CAM002890</td>\n",
" <td>45376</td>\n",
" <td>CAM002890_v.JPG</td>\n",
" <td>ventral</td>\n",
" <td>occurences_and_multimedia.csv</td>\n",
" <td>https://zenodo.org/record/3477891</td>\n",
" <td>2,890</td>\n",
" <td>Anartia fatima</td>\n",
" <td>El Tirao,</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>Female</td>\n",
" <td>wild</td>\n",
" <td>jpg</td>\n",
" <td>3477891</td>\n",
" <td>Anartia fatima</td>\n",
" <td>NaN</td>\n",
" <td>Anartia</td>\n",
" <td>https://zenodo.org/record/3477891/files/CAM002...</td>\n",
" <td>non-hybrid</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7328</th>\n",
" <td>CAM002890</td>\n",
" <td>45375</td>\n",
" <td>CAM002890_d.JPG</td>\n",
" <td>dorsal</td>\n",
" <td>occurences_and_multimedia.csv</td>\n",
" <td>https://zenodo.org/record/3477891</td>\n",
" <td>2,890</td>\n",
" <td>Anartia fatima</td>\n",
" <td>El Tirao,</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>Female</td>\n",
" <td>wild</td>\n",
" <td>jpg</td>\n",
" <td>3477891</td>\n",
" <td>Anartia fatima</td>\n",
" <td>NaN</td>\n",
" <td>Anartia</td>\n",
" <td>https://zenodo.org/record/3477891/files/CAM002...</td>\n",
" <td>non-hybrid</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7329</th>\n",
" <td>CAM002890</td>\n",
" <td>8481</td>\n",
" <td>CAM002890_d.JPG</td>\n",
" <td>dorsal</td>\n",
" <td>CAM.coll.images.batch5.csv</td>\n",
" <td>https://zenodo.org/record/2684906</td>\n",
" <td>2,890</td>\n",
" <td>Anartia fatima</td>\n",
" <td>El Tirao,</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>Female</td>\n",
" <td>wild</td>\n",
" <td>jpg</td>\n",
" <td>2684906</td>\n",
" <td>Anartia fatima</td>\n",
" <td>NaN</td>\n",
" <td>Anartia</td>\n",
" <td>https://zenodo.org/record/2684906/files/CAM002...</td>\n",
" <td>non-hybrid</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>4 rows × 28 columns</p>\n",
"</div>"
],
"text/plain": [
" CAMID X Image_name View \\\n",
"7326 CAM002890 8482 CAM002890_v.JPG ventral \n",
"7327 CAM002890 45376 CAM002890_v.JPG ventral \n",
"7328 CAM002890 45375 CAM002890_d.JPG dorsal \n",
"7329 CAM002890 8481 CAM002890_d.JPG dorsal \n",
"\n",
" zenodo_name zenodo_link \\\n",
"7326 CAM.coll.images.batch5.csv https://zenodo.org/record/2684906 \n",
"7327 occurences_and_multimedia.csv https://zenodo.org/record/3477891 \n",
"7328 occurences_and_multimedia.csv https://zenodo.org/record/3477891 \n",
"7329 CAM.coll.images.batch5.csv https://zenodo.org/record/2684906 \n",
"\n",
" Sequence Taxonomic_Name Locality Sample_accession ... Stage Sex \\\n",
"7326 2,890 Anartia fatima El Tirao, NaN ... NaN Female \n",
"7327 2,890 Anartia fatima El Tirao, NaN ... NaN Female \n",
"7328 2,890 Anartia fatima El Tirao, NaN ... NaN Female \n",
"7329 2,890 Anartia fatima El Tirao, NaN ... NaN Female \n",
"\n",
" Unit_Type file_type record_number species subspecies genus \\\n",
"7326 wild jpg 2684906 Anartia fatima NaN Anartia \n",
"7327 wild jpg 3477891 Anartia fatima NaN Anartia \n",
"7328 wild jpg 3477891 Anartia fatima NaN Anartia \n",
"7329 wild jpg 2684906 Anartia fatima NaN Anartia \n",
"\n",
" file_url hybrid_stat \n",
"7326 https://zenodo.org/record/2684906/files/CAM002... non-hybrid \n",
"7327 https://zenodo.org/record/3477891/files/CAM002... non-hybrid \n",
"7328 https://zenodo.org/record/3477891/files/CAM002... non-hybrid \n",
"7329 https://zenodo.org/record/2684906/files/CAM002... non-hybrid \n",
"\n",
"[4 rows x 28 columns]"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.loc[df[\"species\"].isin(sp_hybrid_parents)]"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>CAMID</th>\n",
" <th>X</th>\n",
" <th>Image_name</th>\n",
" <th>View</th>\n",
" <th>zenodo_name</th>\n",
" <th>zenodo_link</th>\n",
" <th>Sequence</th>\n",
" <th>Taxonomic_Name</th>\n",
" <th>Locality</th>\n",
" <th>Sample_accession</th>\n",
" <th>...</th>\n",
" <th>Stage</th>\n",
" <th>Sex</th>\n",
" <th>Unit_Type</th>\n",
" <th>file_type</th>\n",
" <th>record_number</th>\n",
" <th>species</th>\n",
" <th>subspecies</th>\n",
" <th>genus</th>\n",
" <th>file_url</th>\n",
" <th>hybrid_stat</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" </tbody>\n",
"</table>\n",
"<p>0 rows × 28 columns</p>\n",
"</div>"
],
"text/plain": [
"Empty DataFrame\n",
"Columns: [CAMID, X, Image_name, View, zenodo_name, zenodo_link, Sequence, Taxonomic_Name, Locality, Sample_accession, Collected_by, Other_ID, Date, Dataset, Store, Brood, Death_Date, Cross_Type, Stage, Sex, Unit_Type, file_type, record_number, species, subspecies, genus, file_url, hybrid_stat]\n",
"Index: []\n",
"\n",
"[0 rows x 28 columns]"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.loc[df[\"species\"].str.lower() == \"amathea\"] #not represented in the dataset"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Taxonomic_Name\n",
"Anartia fatima x amathea 60\n",
"Anartia fatima 4\n",
"Name: count, dtype: int64"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.loc[df[\"genus\"] == \"Anartia\", \"Taxonomic_Name\"].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>CAMID</th>\n",
" <th>X</th>\n",
" <th>Image_name</th>\n",
" <th>View</th>\n",
" <th>zenodo_name</th>\n",
" <th>zenodo_link</th>\n",
" <th>Sequence</th>\n",
" <th>Taxonomic_Name</th>\n",
" <th>Locality</th>\n",
" <th>Sample_accession</th>\n",
" <th>...</th>\n",
" <th>Stage</th>\n",
" <th>Sex</th>\n",
" <th>Unit_Type</th>\n",
" <th>file_type</th>\n",
" <th>record_number</th>\n",
" <th>species</th>\n",
" <th>subspecies</th>\n",
" <th>genus</th>\n",
" <th>file_url</th>\n",
" <th>hybrid_stat</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>40498</th>\n",
" <td>CAM043842</td>\n",
" <td>32098</td>\n",
" <td>CAM043842_hwv.JPG</td>\n",
" <td>hindwing ventral</td>\n",
" <td>batch2.Peru.image.names.Zenodo.csv</td>\n",
" <td>https://zenodo.org/record/4287444</td>\n",
" <td>43,842</td>\n",
" <td>Catoblepia berecynthia</td>\n",
" <td>B1prim3</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>jpg</td>\n",
" <td>4287444</td>\n",
" <td>Catoblepia berecynthia</td>\n",
" <td>NaN</td>\n",
" <td>Catoblepia</td>\n",
" <td>https://zenodo.org/record/4287444/files/CAM043...</td>\n",
" <td>None</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9192</th>\n",
" <td>CAM008567</td>\n",
" <td>46249</td>\n",
" <td>CAM008567_v.JPG</td>\n",
" <td>ventral</td>\n",
" <td>occurences_and_multimedia.csv</td>\n",
" <td>https://zenodo.org/record/3477891</td>\n",
" <td>8,567</td>\n",
" <td>Heliconius demeter</td>\n",
" <td>Tarapoto-Yurimaguas (Km15), Tunel Cumbre, Fond...</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>Male</td>\n",
" <td>wild</td>\n",
" <td>jpg</td>\n",
" <td>3477891</td>\n",
" <td>Heliconius demeter</td>\n",
" <td>NaN</td>\n",
" <td>Heliconius</td>\n",
" <td>https://zenodo.org/record/3477891/files/CAM008...</td>\n",
" <td>None</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14127</th>\n",
" <td>CAM010971</td>\n",
" <td>27577</td>\n",
" <td>CAM010971_d.CR2</td>\n",
" <td>dorsal</td>\n",
" <td>2001_2.broods.batch.1.csv</td>\n",
" <td>https://zenodo.org/record/2549524</td>\n",
" <td>10,971</td>\n",
" <td>Heliconius sp.</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>Male</td>\n",
" <td>reared</td>\n",
" <td>raw</td>\n",
" <td>2549524</td>\n",
" <td>Heliconius sp.</td>\n",
" <td>NaN</td>\n",
" <td>Heliconius</td>\n",
" <td>https://zenodo.org/record/2549524/files/CAM010...</td>\n",
" <td>None</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5315</th>\n",
" <td>CAM000537</td>\n",
" <td>6676</td>\n",
" <td>CAM000537_d.JPG</td>\n",
" <td>dorsal</td>\n",
" <td>CAM.coll.images.batch3.csv</td>\n",
" <td>https://zenodo.org/record/2682458</td>\n",
" <td>537</td>\n",
" <td>Heliconius melpomene ssp. rosina</td>\n",
" <td>Pipeline road 4km,</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>Male</td>\n",
" <td>wild</td>\n",
" <td>jpg</td>\n",
" <td>2682458</td>\n",
" <td>Heliconius melpomene</td>\n",
" <td>rosina</td>\n",
" <td>Heliconius</td>\n",
" <td>https://zenodo.org/record/2682458/files/CAM000...</td>\n",
" <td>non-hybrid</td>\n",
" </tr>\n",
" <tr>\n",
" <th>585</th>\n",
" <td>19N0204</td>\n",
" <td>19553</td>\n",
" <td>19N0204_d.JPG</td>\n",
" <td>dorsal</td>\n",
" <td>0.sheffield.ps.nn.ikiam.batch1.csv</td>\n",
" <td>https://zenodo.org/record/4288311</td>\n",
" <td>204</td>\n",
" <td>Heliconius erato ssp. lativitta</td>\n",
" <td>Ikiam Mariposario</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>Male</td>\n",
" <td>reared</td>\n",
" <td>jpg</td>\n",
" <td>4288311</td>\n",
" <td>Heliconius erato</td>\n",
" <td>lativitta</td>\n",
" <td>Heliconius</td>\n",
" <td>https://zenodo.org/record/4288311/files/19N020...</td>\n",
" <td>non-hybrid</td>\n",
" </tr>\n",
" <tr>\n",
" <th>38875</th>\n",
" <td>CAM043366</td>\n",
" <td>30469</td>\n",
" <td>CAM043366_v.CR2</td>\n",
" <td>ventral</td>\n",
" <td>batch1.Peru.image.names.Zenodo.csv</td>\n",
" <td>https://zenodo.org/record/3569598</td>\n",
" <td>43,366</td>\n",
" <td>Eunica pusilla</td>\n",
" <td>B6rec3</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>raw</td>\n",
" <td>3569598</td>\n",
" <td>Eunica pusilla</td>\n",
" <td>NaN</td>\n",
" <td>Eunica</td>\n",
" <td>https://zenodo.org/record/3569598/files/CAM043...</td>\n",
" <td>None</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19226</th>\n",
" <td>CAM016687</td>\n",
" <td>18917</td>\n",
" <td>CAM016687_d.CR2</td>\n",
" <td>dorsal</td>\n",
" <td>CAM.coll.PS.list.individuals.haplotagging.new....</td>\n",
" <td>https://zenodo.org/record/4153502</td>\n",
" <td>16,687</td>\n",
" <td>Heliconius melpomene ssp. plesseni</td>\n",
" <td>El Topo, Baños - Puyo road,</td>\n",
" <td>SRS7540355</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>Male</td>\n",
" <td>wild</td>\n",
" <td>raw</td>\n",
" <td>4153502</td>\n",
" <td>Heliconius melpomene</td>\n",
" <td>plesseni</td>\n",
" <td>Heliconius</td>\n",
" <td>https://zenodo.org/record/4153502/files/CAM016...</td>\n",
" <td>non-hybrid</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>7 rows × 28 columns</p>\n",
"</div>"
],
"text/plain": [
" CAMID X Image_name View \\\n",
"40498 CAM043842 32098 CAM043842_hwv.JPG hindwing ventral \n",
"9192 CAM008567 46249 CAM008567_v.JPG ventral \n",
"14127 CAM010971 27577 CAM010971_d.CR2 dorsal \n",
"5315 CAM000537 6676 CAM000537_d.JPG dorsal \n",
"585 19N0204 19553 19N0204_d.JPG dorsal \n",
"38875 CAM043366 30469 CAM043366_v.CR2 ventral \n",
"19226 CAM016687 18917 CAM016687_d.CR2 dorsal \n",
"\n",
" zenodo_name \\\n",
"40498 batch2.Peru.image.names.Zenodo.csv \n",
"9192 occurences_and_multimedia.csv \n",
"14127 2001_2.broods.batch.1.csv \n",
"5315 CAM.coll.images.batch3.csv \n",
"585 0.sheffield.ps.nn.ikiam.batch1.csv \n",
"38875 batch1.Peru.image.names.Zenodo.csv \n",
"19226 CAM.coll.PS.list.individuals.haplotagging.new.... \n",
"\n",
" zenodo_link Sequence \\\n",
"40498 https://zenodo.org/record/4287444 43,842 \n",
"9192 https://zenodo.org/record/3477891 8,567 \n",
"14127 https://zenodo.org/record/2549524 10,971 \n",
"5315 https://zenodo.org/record/2682458 537 \n",
"585 https://zenodo.org/record/4288311 204 \n",
"38875 https://zenodo.org/record/3569598 43,366 \n",
"19226 https://zenodo.org/record/4153502 16,687 \n",
"\n",
" Taxonomic_Name \\\n",
"40498 Catoblepia berecynthia \n",
"9192 Heliconius demeter \n",
"14127 Heliconius sp. \n",
"5315 Heliconius melpomene ssp. rosina \n",
"585 Heliconius erato ssp. lativitta \n",
"38875 Eunica pusilla \n",
"19226 Heliconius melpomene ssp. plesseni \n",
"\n",
" Locality Sample_accession \\\n",
"40498 B1prim3 NaN \n",
"9192 Tarapoto-Yurimaguas (Km15), Tunel Cumbre, Fond... NaN \n",
"14127 NaN NaN \n",
"5315 Pipeline road 4km, NaN \n",
"585 Ikiam Mariposario NaN \n",
"38875 B6rec3 NaN \n",
"19226 El Topo, Baños - Puyo road, SRS7540355 \n",
"\n",
" ... Stage Sex Unit_Type file_type record_number \\\n",
"40498 ... NaN NaN NaN jpg 4287444 \n",
"9192 ... NaN Male wild jpg 3477891 \n",
"14127 ... NaN Male reared raw 2549524 \n",
"5315 ... NaN Male wild jpg 2682458 \n",
"585 ... NaN Male reared jpg 4288311 \n",
"38875 ... NaN NaN NaN raw 3569598 \n",
"19226 ... NaN Male wild raw 4153502 \n",
"\n",
" species subspecies genus \\\n",
"40498 Catoblepia berecynthia NaN Catoblepia \n",
"9192 Heliconius demeter NaN Heliconius \n",
"14127 Heliconius sp. NaN Heliconius \n",
"5315 Heliconius melpomene rosina Heliconius \n",
"585 Heliconius erato lativitta Heliconius \n",
"38875 Eunica pusilla NaN Eunica \n",
"19226 Heliconius melpomene plesseni Heliconius \n",
"\n",
" file_url hybrid_stat \n",
"40498 https://zenodo.org/record/4287444/files/CAM043... None \n",
"9192 https://zenodo.org/record/3477891/files/CAM008... None \n",
"14127 https://zenodo.org/record/2549524/files/CAM010... None \n",
"5315 https://zenodo.org/record/2682458/files/CAM000... non-hybrid \n",
"585 https://zenodo.org/record/4288311/files/19N020... non-hybrid \n",
"38875 https://zenodo.org/record/3569598/files/CAM043... None \n",
"19226 https://zenodo.org/record/4153502/files/CAM016... non-hybrid \n",
"\n",
"[7 rows x 28 columns]"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.sample(7)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Investigate entries with no Taxonomic Information"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Index: 3886 entries, 0 to 49350\n",
"Data columns (total 28 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 CAMID 3886 non-null object\n",
" 1 X 3886 non-null int64 \n",
" 2 Image_name 3886 non-null object\n",
" 3 View 3594 non-null object\n",
" 4 zenodo_name 3886 non-null object\n",
" 5 zenodo_link 3886 non-null object\n",
" 6 Sequence 2951 non-null object\n",
" 7 Taxonomic_Name 0 non-null object\n",
" 8 Locality 70 non-null object\n",
" 9 Sample_accession 24 non-null object\n",
" 10 Collected_by 0 non-null object\n",
" 11 Other_ID 30 non-null object\n",
" 12 Date 70 non-null object\n",
" 13 Dataset 461 non-null object\n",
" 14 Store 345 non-null object\n",
" 15 Brood 5 non-null object\n",
" 16 Death_Date 2 non-null object\n",
" 17 Cross_Type 0 non-null object\n",
" 18 Stage 9 non-null object\n",
" 19 Sex 35 non-null object\n",
" 20 Unit_Type 47 non-null object\n",
" 21 file_type 3886 non-null object\n",
" 22 record_number 3886 non-null int64 \n",
" 23 species 0 non-null object\n",
" 24 subspecies 0 non-null object\n",
" 25 genus 0 non-null object\n",
" 26 file_url 3886 non-null object\n",
" 27 hybrid_stat 0 non-null object\n",
"dtypes: int64(2), object(26)\n",
"memory usage: 880.4+ KB\n"
]
}
],
"source": [
"df.loc[df.Taxonomic_Name.isna()].info()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Wow, there are a surprising number of images with no taxonomic information."
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"no_taxa_cams = list(df.loc[df[\"Taxonomic_Name\"].isna(), \"CAMID\"].unique())\n",
"no_taxa_entries = list(df.loc[df[\"Taxonomic_Name\"].isna(), \"X\"])\n",
"\n",
"no_taxa_cam_match = [camid for camid in list(df.loc[~df[\"X\"].isin(no_taxa_entries), \"CAMID\"]) if camid in no_taxa_cams]\n",
"len(no_taxa_cam_match)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are no CAMIDs that these can match to for taxonomic info recovery. Last option is to check the records they come from, then we'll remove them."
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"21\n"
]
},
{
"data": {
"text/plain": [
"zenodo_link\n",
"https://zenodo.org/record/5526257 1324\n",
"https://zenodo.org/record/2554218 492\n",
"https://zenodo.org/record/4288311 486\n",
"https://zenodo.org/record/2555086 440\n",
"https://zenodo.org/record/5731587 388\n",
"Name: count, dtype: int64"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print(df.loc[df[\"X\"].isin(no_taxa_entries), \"record_number\"].nunique())\n",
"df.loc[df[\"X\"].isin(no_taxa_entries), \"zenodo_link\"].value_counts()[:5]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"These are across most of the records. We can check the one with the most, but otherwise they should likely be dropped (can save them in a separate CSV in case they are to be assessed at a later point).\n",
"\n",
"The first appear to be all _Heliconius erato ssp. cyrbia_, so those could be realigned.\n",
"\n",
"The second indicates all _Heliconius erato_.\n",
"\n",
"The third is a mix, so not resolvable without an expert.\n",
"\n",
"It seems record 2555086 is all bred specimens of _Heliconius erato demophoon_.\n",
"\n",
"The fifth record is a mix, and not all are labeled in the excel file (in fact, there's a lot of red which is probably why they were excluded)."
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.series.Series'>\n",
"Index: 1324 entries, 45868 to 47191\n",
"Series name: Taxonomic_Name\n",
"Non-Null Count Dtype \n",
"-------------- ----- \n",
"0 non-null object\n",
"dtypes: object(1)\n",
"memory usage: 20.7+ KB\n"
]
}
],
"source": [
"df.loc[df[\"record_number\"] == 5526257, \"Taxonomic_Name\"].info()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ah, so these are all null, but all are of the same subspecies, so they can be labeled."
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pot_single_taxa_records = []\n",
"for record_num in (df.loc[df[\"X\"].isin(no_taxa_entries), \"record_number\"].unique()):\n",
" temp = df.loc[df[\"record_number\"] == record_num]\n",
" if temp.loc[temp[\"Taxonomic_Name\"].notna()].shape[0] == 0:\n",
" pot_single_taxa_records.append(record_num)\n",
"\n",
"len(pot_single_taxa_records)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[5731587, 5526257, 2554218, 2555086]"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pot_single_taxa_records"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>CAMID</th>\n",
" <th>X</th>\n",
" <th>Image_name</th>\n",
" <th>View</th>\n",
" <th>zenodo_name</th>\n",
" <th>zenodo_link</th>\n",
" <th>Sequence</th>\n",
" <th>Taxonomic_Name</th>\n",
" <th>Locality</th>\n",
" <th>Sample_accession</th>\n",
" <th>...</th>\n",
" <th>Stage</th>\n",
" <th>Sex</th>\n",
" <th>Unit_Type</th>\n",
" <th>file_type</th>\n",
" <th>record_number</th>\n",
" <th>species</th>\n",
" <th>subspecies</th>\n",
" <th>genus</th>\n",
" <th>file_url</th>\n",
" <th>hybrid_stat</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>46747</th>\n",
" <td>CAM045219</td>\n",
" <td>43439</td>\n",
" <td>CAM045219_d.JPG</td>\n",
" <td>dorsal</td>\n",
" <td>image.names.cook.island.erato.csv</td>\n",
" <td>https://zenodo.org/record/5526257</td>\n",
" <td>45,219</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>jpg</td>\n",
" <td>5526257</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/5526257/files/CAM045...</td>\n",
" <td>None</td>\n",
" </tr>\n",
" <tr>\n",
" <th>47062</th>\n",
" <td>CAM045298</td>\n",
" <td>43756</td>\n",
" <td>CAM045298_v.CR2</td>\n",
" <td>ventral</td>\n",
" <td>image.names.cook.island.erato.csv</td>\n",
" <td>https://zenodo.org/record/5526257</td>\n",
" <td>45,298</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>raw</td>\n",
" <td>5526257</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/5526257/files/CAM045...</td>\n",
" <td>None</td>\n",
" </tr>\n",
" <tr>\n",
" <th>37255</th>\n",
" <td>CAM042050</td>\n",
" <td>43982</td>\n",
" <td>CAM042050_d.JPG</td>\n",
" <td>dorsal</td>\n",
" <td>Collection_August2019.csv</td>\n",
" <td>https://zenodo.org/record/5731587</td>\n",
" <td>42,050</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>jpg</td>\n",
" <td>5731587</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/5731587/files/CAM042...</td>\n",
" <td>None</td>\n",
" </tr>\n",
" <tr>\n",
" <th>46992</th>\n",
" <td>CAM045281</td>\n",
" <td>43687</td>\n",
" <td>CAM045281_d.JPG</td>\n",
" <td>dorsal</td>\n",
" <td>image.names.cook.island.erato.csv</td>\n",
" <td>https://zenodo.org/record/5526257</td>\n",
" <td>45,281</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>jpg</td>\n",
" <td>5526257</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/5526257/files/CAM045...</td>\n",
" <td>None</td>\n",
" </tr>\n",
" <tr>\n",
" <th>49106</th>\n",
" <td>F901</td>\n",
" <td>38167</td>\n",
" <td>F901_d.CR2</td>\n",
" <td>dorsal</td>\n",
" <td>Anniina.Mattila.Bred.F.csv</td>\n",
" <td>https://zenodo.org/record/2555086</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>raw</td>\n",
" <td>2555086</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2555086/files/F901_d...</td>\n",
" <td>None</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 28 columns</p>\n",
"</div>"
],
"text/plain": [
" CAMID X Image_name View \\\n",
"46747 CAM045219 43439 CAM045219_d.JPG dorsal \n",
"47062 CAM045298 43756 CAM045298_v.CR2 ventral \n",
"37255 CAM042050 43982 CAM042050_d.JPG dorsal \n",
"46992 CAM045281 43687 CAM045281_d.JPG dorsal \n",
"49106 F901 38167 F901_d.CR2 dorsal \n",
"\n",
" zenodo_name zenodo_link \\\n",
"46747 image.names.cook.island.erato.csv https://zenodo.org/record/5526257 \n",
"47062 image.names.cook.island.erato.csv https://zenodo.org/record/5526257 \n",
"37255 Collection_August2019.csv https://zenodo.org/record/5731587 \n",
"46992 image.names.cook.island.erato.csv https://zenodo.org/record/5526257 \n",
"49106 Anniina.Mattila.Bred.F.csv https://zenodo.org/record/2555086 \n",
"\n",
" Sequence Taxonomic_Name Locality Sample_accession ... Stage Sex \\\n",
"46747 45,219 NaN NaN NaN ... NaN NaN \n",
"47062 45,298 NaN NaN NaN ... NaN NaN \n",
"37255 42,050 NaN NaN NaN ... NaN NaN \n",
"46992 45,281 NaN NaN NaN ... NaN NaN \n",
"49106 NaN NaN NaN NaN ... NaN NaN \n",
"\n",
" Unit_Type file_type record_number species subspecies genus \\\n",
"46747 NaN jpg 5526257 NaN NaN NaN \n",
"47062 NaN raw 5526257 NaN NaN NaN \n",
"37255 NaN jpg 5731587 NaN NaN NaN \n",
"46992 NaN jpg 5526257 NaN NaN NaN \n",
"49106 NaN raw 2555086 NaN NaN NaN \n",
"\n",
" file_url hybrid_stat \n",
"46747 https://zenodo.org/record/5526257/files/CAM045... None \n",
"47062 https://zenodo.org/record/5526257/files/CAM045... None \n",
"37255 https://zenodo.org/record/5731587/files/CAM042... None \n",
"46992 https://zenodo.org/record/5526257/files/CAM045... None \n",
"49106 https://zenodo.org/record/2555086/files/F901_d... None \n",
"\n",
"[5 rows x 28 columns]"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.loc[df.record_number.isin(pot_single_taxa_records)].sample(5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Christopher agrees that the following is sufficient to label images from the following three records:\n",
">3 records seem to have all of just one indicated species/subspecies: https://zenodo.org/record/5526257, https://zenodo.org/record/2554218, and https://zenodo.org/record/2555086. According to their Zenodo pages, the first appear to be all _Heliconius erato ssp. cyrbia_, the second indicates all _Heliconius erato_, and the third it seems is all bred specimens of _Heliconius erato demophoon_. \n",
"\n",
"`Unit_Type` and some other details could potentially be realigned at a later date, but we'll stick with taxonomic information for now."
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"df.loc[df[\"record_number\"] == 5526257, \"Taxonomic_Name\"] = \"Heliconius erato ssp. cyrbia\"\n",
"df.loc[df[\"record_number\"] == 5526257, \"genus\"] = \"Heliconius\"\n",
"df.loc[df[\"record_number\"] == 5526257, \"species\"] = \"Heliconius erato\"\n",
"df.loc[df[\"record_number\"] == 5526257, \"subspecies\"] = \"cyrbia\"\n",
"df.loc[df[\"record_number\"] == 5526257, \"hybrid_stat\"] = \"non-hybrid\""
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
"df.loc[df[\"record_number\"] == 2554218, \"Taxonomic_Name\"] = \"Heliconius erato\"\n",
"df.loc[df[\"record_number\"] == 2554218, \"genus\"] = \"Heliconius\"\n",
"df.loc[df[\"record_number\"] == 2554218, \"species\"] = \"Heliconius erato\""
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [],
"source": [
"df.loc[df[\"record_number\"] == 2555086, \"Taxonomic_Name\"] = \"Heliconius erato ssp. demophoon\"\n",
"df.loc[df[\"record_number\"] == 2555086, \"genus\"] = \"Heliconius\"\n",
"df.loc[df[\"record_number\"] == 2555086, \"species\"] = \"Heliconius erato\"\n",
"df.loc[df[\"record_number\"] == 2555086, \"subspecies\"] = \"demophoon\"\n",
"df.loc[df[\"record_number\"] == 2555086, \"hybrid_stat\"] = \"non-hybrid\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Save record of entries with no Taxonomic Info"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(1630, 28)"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"missing_taxa_df = df.loc[df.Taxonomic_Name.isna()]\n",
"missing_taxa_df.shape"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
"missing_taxa_df.to_csv(\"../metadata/Missing_taxa_Jiggins_Zenodo_Master.csv\", index = False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Drop Entries with no Taxonomic Information"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
"master_df = df.loc[df.Taxonomic_Name.notna()]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Final stats for all data in master file summarized here."
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CAMID 11991\n",
"X 44809\n",
"Image_name 36281\n",
"View 7\n",
"zenodo_name 33\n",
"zenodo_link 30\n",
"Sequence 10905\n",
"Taxonomic_Name 366\n",
"Locality 645\n",
"Sample_accession 1559\n",
"Collected_by 12\n",
"Other_ID 3081\n",
"Date 807\n",
"Dataset 8\n",
"Store 137\n",
"Brood 224\n",
"Death_Date 81\n",
"Cross_Type 30\n",
"Stage 1\n",
"Sex 3\n",
"Unit_Type 4\n",
"file_type 3\n",
"record_number 30\n",
"species 246\n",
"subspecies 155\n",
"genus 94\n",
"file_url 44794\n",
"hybrid_stat 2\n",
"dtype: int64"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"master_df.nunique()"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Index: 44809 entries, 6 to 49358\n",
"Data columns (total 28 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 CAMID 44809 non-null object\n",
" 1 X 44809 non-null int64 \n",
" 2 Image_name 44809 non-null object\n",
" 3 View 44030 non-null object\n",
" 4 zenodo_name 44809 non-null object\n",
" 5 zenodo_link 44809 non-null object\n",
" 6 Sequence 43877 non-null object\n",
" 7 Taxonomic_Name 44809 non-null object\n",
" 8 Locality 31708 non-null object\n",
" 9 Sample_accession 4572 non-null object\n",
" 10 Collected_by 3043 non-null object\n",
" 11 Other_ID 14352 non-null object\n",
" 12 Date 30730 non-null object\n",
" 13 Dataset 37024 non-null object\n",
" 14 Store 36220 non-null object\n",
" 15 Brood 14258 non-null object\n",
" 16 Death_Date 316 non-null object\n",
" 17 Cross_Type 4452 non-null object\n",
" 18 Stage 6 non-null object\n",
" 19 Sex 33312 non-null object\n",
" 20 Unit_Type 30923 non-null object\n",
" 21 file_type 44809 non-null object\n",
" 22 record_number 44809 non-null int64 \n",
" 23 species 44809 non-null object\n",
" 24 subspecies 24559 non-null object\n",
" 25 genus 44809 non-null object\n",
" 26 file_url 44809 non-null object\n",
" 27 hybrid_stat 25139 non-null object\n",
"dtypes: int64(2), object(26)\n",
"memory usage: 9.9+ MB\n"
]
}
],
"source": [
"master_df.info()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Update Master File with Hybrid Status and URL Columns (& unique records)"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [],
"source": [
"master_df.to_csv(\"../Jiggins_Zenodo_Img_Master.csv\", index = False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Make Heliconius Subset"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Index: 34265 entries, 6 to 49358\n",
"Data columns (total 28 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 CAMID 34265 non-null object\n",
" 1 X 34265 non-null int64 \n",
" 2 Image_name 34265 non-null object\n",
" 3 View 33486 non-null object\n",
" 4 zenodo_name 34265 non-null object\n",
" 5 zenodo_link 34265 non-null object\n",
" 6 Sequence 33333 non-null object\n",
" 7 Taxonomic_Name 34265 non-null object\n",
" 8 Locality 21180 non-null object\n",
" 9 Sample_accession 4572 non-null object\n",
" 10 Collected_by 3043 non-null object\n",
" 11 Other_ID 6404 non-null object\n",
" 12 Date 20244 non-null object\n",
" 13 Dataset 29926 non-null object\n",
" 14 Store 26526 non-null object\n",
" 15 Brood 14242 non-null object\n",
" 16 Death_Date 316 non-null object\n",
" 17 Cross_Type 4452 non-null object\n",
" 18 Stage 6 non-null object\n",
" 19 Sex 30984 non-null object\n",
" 20 Unit_Type 29055 non-null object\n",
" 21 file_type 34265 non-null object\n",
" 22 record_number 34265 non-null int64 \n",
" 23 species 34265 non-null object\n",
" 24 subspecies 23801 non-null object\n",
" 25 genus 34265 non-null object\n",
" 26 file_url 34265 non-null object\n",
" 27 hybrid_stat 24317 non-null object\n",
"dtypes: int64(2), object(26)\n",
"memory usage: 7.6+ MB\n"
]
}
],
"source": [
"heliconius_subset = master_df.loc[master_df.genus.str.lower() == \"heliconius\"]\n",
"\n",
"heliconius_subset.info()"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CAMID 10109\n",
"X 34265\n",
"Image_name 29192\n",
"View 3\n",
"zenodo_name 33\n",
"zenodo_link 30\n",
"Sequence 9031\n",
"Taxonomic_Name 132\n",
"Locality 472\n",
"Sample_accession 1559\n",
"Collected_by 12\n",
"Other_ID 1865\n",
"Date 776\n",
"Dataset 8\n",
"Store 121\n",
"Brood 224\n",
"Death_Date 81\n",
"Cross_Type 30\n",
"Stage 1\n",
"Sex 3\n",
"Unit_Type 4\n",
"file_type 3\n",
"record_number 30\n",
"species 37\n",
"subspecies 110\n",
"genus 1\n",
"file_url 34250\n",
"hybrid_stat 2\n",
"dtype: int64"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"heliconius_subset.nunique()"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"View\n",
"dorsal 16882\n",
"ventral 16586\n",
"dorsal and ventral 18\n",
"Name: count, dtype: int64"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"heliconius_subset.View.value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that this subset is distributed across 30 Zenodo records from the [Butterfly Genetics Group](https://zenodo.org/communities/butterfly?q=&l=list&p=1&s=10&sort=newest)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Save the Heliconius Subset to CSV\n"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [],
"source": [
"heliconius_subset.to_csv(\"../Jiggins_Heliconius_Master.csv\", index = False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Make Dorsal Subset"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Index: 22175 entries, 7 to 49357\n",
"Data columns (total 28 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 CAMID 22175 non-null object\n",
" 1 X 22175 non-null int64 \n",
" 2 Image_name 22175 non-null object\n",
" 3 View 22175 non-null object\n",
" 4 zenodo_name 22175 non-null object\n",
" 5 zenodo_link 22175 non-null object\n",
" 6 Sequence 21709 non-null object\n",
" 7 Taxonomic_Name 22175 non-null object\n",
" 8 Locality 15615 non-null object\n",
" 9 Sample_accession 2294 non-null object\n",
" 10 Collected_by 1533 non-null object\n",
" 11 Other_ID 6916 non-null object\n",
" 12 Date 15347 non-null object\n",
" 13 Dataset 18250 non-null object\n",
" 14 Store 18254 non-null object\n",
" 15 Brood 6920 non-null object\n",
" 16 Death_Date 106 non-null object\n",
" 17 Cross_Type 2230 non-null object\n",
" 18 Stage 3 non-null object\n",
" 19 Sex 16403 non-null object\n",
" 20 Unit_Type 15203 non-null object\n",
" 21 file_type 22175 non-null object\n",
" 22 record_number 22175 non-null int64 \n",
" 23 species 22175 non-null object\n",
" 24 subspecies 12040 non-null object\n",
" 25 genus 22175 non-null object\n",
" 26 file_url 22175 non-null object\n",
" 27 hybrid_stat 12330 non-null object\n",
"dtypes: int64(2), object(26)\n",
"memory usage: 4.9+ MB\n"
]
}
],
"source": [
"dorsal_views = [view for view in list(master_df.View.dropna().unique()) if \"dorsal\" in view]\n",
"\n",
"dorsal_subset = master_df.loc[master_df[\"View\"].isin(dorsal_views)]\n",
"dorsal_subset.info()"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CAMID 11776\n",
"X 22175\n",
"Image_name 17907\n",
"View 4\n",
"zenodo_name 33\n",
"zenodo_link 30\n",
"Sequence 10713\n",
"Taxonomic_Name 362\n",
"Locality 642\n",
"Sample_accession 1552\n",
"Collected_by 12\n",
"Other_ID 2890\n",
"Date 791\n",
"Dataset 8\n",
"Store 137\n",
"Brood 215\n",
"Death_Date 63\n",
"Cross_Type 30\n",
"Stage 1\n",
"Sex 3\n",
"Unit_Type 4\n",
"file_type 3\n",
"record_number 30\n",
"species 245\n",
"subspecies 152\n",
"genus 94\n",
"file_url 22168\n",
"hybrid_stat 2\n",
"dtype: int64"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dorsal_subset.nunique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Observe that we still have duplicate samples (duplicated `CAMID`), so we'll add a column indicating this (`CAM_Dupe`). We will not leave the first instance as a non-duplicate to have a clear assessment of all duplication (eg., is it just across a couple records).\n",
"\n",
"Note that they will be duplicated for the images that are of a dorsal forewing or hindwing, so we will label those as `single_wing`."
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_21745/2272441064.py:1: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
"Try using .loc[row_indexer,col_indexer] = value instead\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" dorsal_subset[\"CAM_Dupe\"] = dorsal_subset.duplicated(subset = \"CAMID\", keep = False)\n"
]
},
{
"data": {
"text/plain": [
"CAM_Dupe\n",
"True 17213\n",
"False 4170\n",
"single-wing 792\n",
"Name: count, dtype: int64"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dorsal_subset[\"CAM_Dupe\"] = dorsal_subset.duplicated(subset = \"CAMID\", keep = False)\n",
"dorsal_subset.loc[dorsal_subset[\"View\"].isin([\"forewing dorsal\", \"hindwing dorsal\"]), \"CAM_Dupe\"] = \"single-wing\"\n",
"dorsal_subset[\"CAM_Dupe\"].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"29"
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dorsal_subset.loc[dorsal_subset[\"CAM_Dupe\"] == True, \"record_number\"].nunique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Okay, nearly all records have duplication even in the dorsal subset. That does make sense when we have just over half as many unique `CAMID`s as number of images."
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"record_number\n",
"4287444 396\n",
"4288250 284\n",
"3569598 112\n",
"Name: count, dtype: int64"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dorsal_subset.loc[dorsal_subset[\"CAM_Dupe\"] == \"single-wing\", \"record_number\"].value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Single-wing images are constrained to 3 records."
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"file_type\n",
"jpg 11752\n",
"raw 5440\n",
"tif 21\n",
"Name: count, dtype: int64"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dorsal_subset.loc[dorsal_subset[\"CAM_Dupe\"] == True, \"file_type\"].value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Some of this duplication is by file type."
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True 8415\n",
"False 3337\n",
"Name: count, dtype: int64"
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dorsal_subset.loc[(dorsal_subset[\"CAM_Dupe\"] == True) & (dorsal_subset[\"file_type\"] == \"jpg\")].duplicated(subset = \"CAMID\", keep = False).value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False 4106\n",
"True 1334\n",
"Name: count, dtype: int64"
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dorsal_subset.loc[(dorsal_subset[\"CAM_Dupe\"] == True) & (dorsal_subset[\"file_type\"] == \"raw\")].duplicated(subset = \"CAMID\", keep = False).value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We have multiple jpg images & multiple raw images of the same specimen. Note that this does not necessarily mean these are duplicates of the same images. There are also jpg copies provided alongside raw images."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Save Dorsal Subset to CSV"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {},
"outputs": [],
"source": [
"dorsal_subset.to_csv(\"../Jiggins_Zenodo_dorsal_Img_Master.csv\", index = False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "std",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
|