{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"jiggins = pd.read_csv(\"../Jiggins_Zenodo_Master.csv\", low_memory = False)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(49956, 25)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"jiggins.shape"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Unnamed: 0 | \n",
" CAMID | \n",
" X | \n",
" Image_name | \n",
" Side | \n",
" zenodo_name | \n",
" zenodo_link | \n",
" Sequence | \n",
" Taxonomic.Name | \n",
" Locality | \n",
" ... | \n",
" Dataset | \n",
" Store | \n",
" Eclosion.Date | \n",
" Brood | \n",
" Death.Date | \n",
" Cross.Type | \n",
" Stage | \n",
" Sex | \n",
" Unit.Type | \n",
" Verbatim.Coordinates | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 1 | \n",
" NaN | \n",
" 20776 | \n",
" NaN | \n",
" NaN | \n",
" 0.sheffield.ps.nn.ikiam.batch1.csv | \n",
" https://zenodo.org/record/4288311 | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" ... | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
"
\n",
" \n",
" 1 | \n",
" 2 | \n",
" NaN | \n",
" 20777 | \n",
" NaN | \n",
" NaN | \n",
" 0.sheffield.ps.nn.ikiam.batch1.csv | \n",
" https://zenodo.org/record/4288311 | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" ... | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
"
\n",
" \n",
" 2 | \n",
" 3 | \n",
" NaN | \n",
" 20778 | \n",
" NaN | \n",
" NaN | \n",
" 0.sheffield.ps.nn.ikiam.batch1.csv | \n",
" https://zenodo.org/record/4288311 | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" ... | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
"
\n",
" \n",
" 3 | \n",
" 4 | \n",
" NaN | \n",
" 20779 | \n",
" NaN | \n",
" NaN | \n",
" 0.sheffield.ps.nn.ikiam.batch1.csv | \n",
" https://zenodo.org/record/4288311 | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" ... | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
"
\n",
" \n",
" 4 | \n",
" 5 | \n",
" NaN | \n",
" 20780 | \n",
" NaN | \n",
" NaN | \n",
" 0.sheffield.ps.nn.ikiam.batch1.csv | \n",
" https://zenodo.org/record/4288311 | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" ... | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
"
\n",
" \n",
"
\n",
"
5 rows × 25 columns
\n",
"
"
],
"text/plain": [
" Unnamed: 0 CAMID X Image_name Side \\\n",
"0 1 NaN 20776 NaN NaN \n",
"1 2 NaN 20777 NaN NaN \n",
"2 3 NaN 20778 NaN NaN \n",
"3 4 NaN 20779 NaN NaN \n",
"4 5 NaN 20780 NaN NaN \n",
"\n",
" zenodo_name zenodo_link \\\n",
"0 0.sheffield.ps.nn.ikiam.batch1.csv https://zenodo.org/record/4288311 \n",
"1 0.sheffield.ps.nn.ikiam.batch1.csv https://zenodo.org/record/4288311 \n",
"2 0.sheffield.ps.nn.ikiam.batch1.csv https://zenodo.org/record/4288311 \n",
"3 0.sheffield.ps.nn.ikiam.batch1.csv https://zenodo.org/record/4288311 \n",
"4 0.sheffield.ps.nn.ikiam.batch1.csv https://zenodo.org/record/4288311 \n",
"\n",
" Sequence Taxonomic.Name Locality ... Dataset Store Eclosion.Date Brood \\\n",
"0 NaN NaN NaN ... NaN NaN NaN NaN \n",
"1 NaN NaN NaN ... NaN NaN NaN NaN \n",
"2 NaN NaN NaN ... NaN NaN NaN NaN \n",
"3 NaN NaN NaN ... NaN NaN NaN NaN \n",
"4 NaN NaN NaN ... NaN NaN NaN NaN \n",
"\n",
" Death.Date Cross.Type Stage Sex Unit.Type Verbatim.Coordinates \n",
"0 NaN NaN NaN NaN NaN NaN \n",
"1 NaN NaN NaN NaN NaN NaN \n",
"2 NaN NaN NaN NaN NaN NaN \n",
"3 NaN NaN NaN NaN NaN NaN \n",
"4 NaN NaN NaN NaN NaN NaN \n",
"\n",
"[5 rows x 25 columns]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"jiggins.head()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Index(['Unnamed: 0', 'CAMID', 'X', 'Image_name', 'Side', 'zenodo_name',\n",
" 'zenodo_link', 'Sequence', 'Taxonomic.Name', 'Locality',\n",
" 'Sample.accession', 'Collected.by', 'Other.Id', 'Collected.By', 'Date',\n",
" 'Dataset', 'Store', 'Eclosion.Date', 'Brood', 'Death.Date',\n",
" 'Cross.Type', 'Stage', 'Sex', 'Unit.Type', 'Verbatim.Coordinates'],\n",
" dtype='object')"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"jiggins.columns"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"411"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"jiggins.Image_name.isna().sum()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"28585 CAM036108_v.JPG\n",
"45469 CAM044420_v.CR2\n",
"16097 CAM011543_v.CR2\n",
"22992 CAM017525_v.JPG\n",
"6601 CAM000930_v.JPG\n",
"39261 CAM043354_v.CR2\n",
"2577 19N2059_d.CR2\n",
"21344 CAM017153_d.JPG\n",
"48669 CS004036_d.JPG\n",
"19706 CAM016699_v.JPG\n",
"12020 CAM009527_v.JPG\n",
"47898 CS000628_d.JPG\n",
"7592 CAM001394_d.JPG\n",
"43523 CAM044173_v.CR2\n",
"12596 CAM010226_v.JPG\n",
"33816 CAM041028_v.JPG\n",
"23148 CAM017547_v_whitestandard.JPG\n",
"44996 CAM044362_hwv.CR2\n",
"3460 19N2605_v.JPG\n",
"24164 CAM017738_d_whitestandard.CR2\n",
"Name: Image_name, dtype: object"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"jiggins.Image_name.sample(20)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" CAMID | \n",
" X | \n",
" Image_name | \n",
" zenodo_name | \n",
" zenodo_link | \n",
"
\n",
" \n",
" \n",
" \n",
" 22895 | \n",
" CAM017512 | \n",
" 5226 | \n",
" CAM017512_d.JPG | \n",
" CAM.coll.images.batch1_v2.csv | \n",
" https://zenodo.org/record/3082688 | \n",
"
\n",
" \n",
" 36246 | \n",
" CAM041681 | \n",
" 39690 | \n",
" CAM041681_d.CR2 | \n",
" 0.gmk.broods.all.csv | \n",
" https://zenodo.org/record/4291095 | \n",
"
\n",
" \n",
" 38630 | \n",
" CAM043178 | \n",
" 29793 | \n",
" CAM043178_fwv.CR2 | \n",
" batch1.Peru.image.names.Zenodo.csv | \n",
" https://zenodo.org/record/3569598 | \n",
"
\n",
" \n",
" 45984 | \n",
" CAM044484 | \n",
" 34635 | \n",
" CAM044484_hwd.CR2 | \n",
" batch2.Peru.image.names.Zenodo.csv | \n",
" https://zenodo.org/record/4287444 | \n",
"
\n",
" \n",
" 15393 | \n",
" CAM011382 | \n",
" 28038 | \n",
" CAM011382_d.JPG | \n",
" 2001_2.broods.batch.2.csv | \n",
" https://zenodo.org/record/2550097 | \n",
"
\n",
" \n",
" 44443 | \n",
" CAM044299 | \n",
" 33864 | \n",
" CAM044299_d.JPG | \n",
" batch2.Peru.image.names.Zenodo.csv | \n",
" https://zenodo.org/record/4287444 | \n",
"
\n",
" \n",
" 7117 | \n",
" CAM001175 | \n",
" 7908 | \n",
" CAM001175_d.JPG | \n",
" CAM.coll.images.batch4.csv | \n",
" https://zenodo.org/record/2682669 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" CAMID X Image_name \\\n",
"22895 CAM017512 5226 CAM017512_d.JPG \n",
"36246 CAM041681 39690 CAM041681_d.CR2 \n",
"38630 CAM043178 29793 CAM043178_fwv.CR2 \n",
"45984 CAM044484 34635 CAM044484_hwd.CR2 \n",
"15393 CAM011382 28038 CAM011382_d.JPG \n",
"44443 CAM044299 33864 CAM044299_d.JPG \n",
"7117 CAM001175 7908 CAM001175_d.JPG \n",
"\n",
" zenodo_name zenodo_link \n",
"22895 CAM.coll.images.batch1_v2.csv https://zenodo.org/record/3082688 \n",
"36246 0.gmk.broods.all.csv https://zenodo.org/record/4291095 \n",
"38630 batch1.Peru.image.names.Zenodo.csv https://zenodo.org/record/3569598 \n",
"45984 batch2.Peru.image.names.Zenodo.csv https://zenodo.org/record/4287444 \n",
"15393 2001_2.broods.batch.2.csv https://zenodo.org/record/2550097 \n",
"44443 batch2.Peru.image.names.Zenodo.csv https://zenodo.org/record/4287444 \n",
"7117 CAM.coll.images.batch4.csv https://zenodo.org/record/2682669 "
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"jiggins_imgs = jiggins[['CAMID', 'X', 'Image_name', 'zenodo_name', 'zenodo_link']].dropna()\n",
"jiggins_imgs.sample(7)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" CAMID | \n",
" X | \n",
" Image_name | \n",
" zenodo_name | \n",
" zenodo_link | \n",
"
\n",
" \n",
" \n",
" \n",
" 10528 | \n",
" CAM008821 | \n",
" 9887 | \n",
" CAM008821_d.JPG | \n",
" CAM.coll.images.batch6.csv | \n",
" https://zenodo.org/record/2686762 | \n",
"
\n",
" \n",
" 19587 | \n",
" CAM016660 | \n",
" 3856 | \n",
" CAM016660_v.JPG | \n",
" CAM.coll.images.batch1_v2.csv | \n",
" https://zenodo.org/record/3082688 | \n",
"
\n",
" \n",
" 25858 | \n",
" CAM017989 | \n",
" 17211 | \n",
" CAM017989_v_whitestandard.JPG | \n",
" CAM.coll.patricio.batch1.csv | \n",
" https://zenodo.org/record/1748277 | \n",
"
\n",
" \n",
" 10042 | \n",
" CAM008668 | \n",
" 46436 | \n",
" CAM008668_d.JPG | \n",
" occurences_and_multimedia.csv | \n",
" https://zenodo.org/record/3477891 | \n",
"
\n",
" \n",
" 30646 | \n",
" CAM040217 | \n",
" 47915 | \n",
" CAM040217_v.JPG | \n",
" occurences_and_multimedia.csv | \n",
" https://zenodo.org/record/3477891 | \n",
"
\n",
" \n",
" 42889 | \n",
" CAM044091 | \n",
" 33084 | \n",
" CAM044091_fwd.JPG | \n",
" batch2.Peru.image.names.Zenodo.csv | \n",
" https://zenodo.org/record/4287444 | \n",
"
\n",
" \n",
" 39215 | \n",
" CAM043344 | \n",
" 30372 | \n",
" CAM043344_fwd.JPG | \n",
" batch1.Peru.image.names.Zenodo.csv | \n",
" https://zenodo.org/record/3569598 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" CAMID X Image_name \\\n",
"10528 CAM008821 9887 CAM008821_d.JPG \n",
"19587 CAM016660 3856 CAM016660_v.JPG \n",
"25858 CAM017989 17211 CAM017989_v_whitestandard.JPG \n",
"10042 CAM008668 46436 CAM008668_d.JPG \n",
"30646 CAM040217 47915 CAM040217_v.JPG \n",
"42889 CAM044091 33084 CAM044091_fwd.JPG \n",
"39215 CAM043344 30372 CAM043344_fwd.JPG \n",
"\n",
" zenodo_name zenodo_link \n",
"10528 CAM.coll.images.batch6.csv https://zenodo.org/record/2686762 \n",
"19587 CAM.coll.images.batch1_v2.csv https://zenodo.org/record/3082688 \n",
"25858 CAM.coll.patricio.batch1.csv https://zenodo.org/record/1748277 \n",
"10042 occurences_and_multimedia.csv https://zenodo.org/record/3477891 \n",
"30646 occurences_and_multimedia.csv https://zenodo.org/record/3477891 \n",
"42889 batch2.Peru.image.names.Zenodo.csv https://zenodo.org/record/4287444 \n",
"39215 batch1.Peru.image.names.Zenodo.csv https://zenodo.org/record/3569598 "
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"jiggins_imgs[jiggins_imgs.Image_name.str.contains('JPG')].sample(7)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" CAMID | \n",
" X | \n",
" Image_name | \n",
" zenodo_name | \n",
" zenodo_link | \n",
"
\n",
" \n",
" \n",
" \n",
" 8296 | \n",
" CAM008147 | \n",
" 44302 | \n",
" 8147v.jpg | \n",
" occurences_and_multimedia.csv | \n",
" https://zenodo.org/record/3477891 | \n",
"
\n",
" \n",
" 15626 | \n",
" CAM011437 | \n",
" 44275 | \n",
" 11437v.jpg | \n",
" occurences_and_multimedia.csv | \n",
" https://zenodo.org/record/3477891 | \n",
"
\n",
" \n",
" 16975 | \n",
" CAM012169 | \n",
" 25057 | \n",
" 12169v.jpg | \n",
" Heliconius_wing_old_photos_2001_2019_part1.csv | \n",
" https://zenodo.org/record/2552371 | \n",
"
\n",
" \n",
" 14097 | \n",
" CAM010773 | \n",
" 23942 | \n",
" 10773v.jpg | \n",
" Heliconius_wing_old_photos_2001_2019_part1.csv | \n",
" https://zenodo.org/record/2552371 | \n",
"
\n",
" \n",
" 15970 | \n",
" CAM011513 | \n",
" 24565 | \n",
" 11513v.jpg | \n",
" Heliconius_wing_old_photos_2001_2019_part1.csv | \n",
" https://zenodo.org/record/2552371 | \n",
"
\n",
" \n",
" 13349 | \n",
" CAM010485 | \n",
" 23640 | \n",
" 10485d.jpg | \n",
" Heliconius_wing_old_photos_2001_2019_part1.csv | \n",
" https://zenodo.org/record/2552371 | \n",
"
\n",
" \n",
" 16919 | \n",
" CAM012124 | \n",
" 25001 | \n",
" 12124v.jpg | \n",
" Heliconius_wing_old_photos_2001_2019_part1.csv | \n",
" https://zenodo.org/record/2552371 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" CAMID X Image_name \\\n",
"8296 CAM008147 44302 8147v.jpg \n",
"15626 CAM011437 44275 11437v.jpg \n",
"16975 CAM012169 25057 12169v.jpg \n",
"14097 CAM010773 23942 10773v.jpg \n",
"15970 CAM011513 24565 11513v.jpg \n",
"13349 CAM010485 23640 10485d.jpg \n",
"16919 CAM012124 25001 12124v.jpg \n",
"\n",
" zenodo_name \\\n",
"8296 occurences_and_multimedia.csv \n",
"15626 occurences_and_multimedia.csv \n",
"16975 Heliconius_wing_old_photos_2001_2019_part1.csv \n",
"14097 Heliconius_wing_old_photos_2001_2019_part1.csv \n",
"15970 Heliconius_wing_old_photos_2001_2019_part1.csv \n",
"13349 Heliconius_wing_old_photos_2001_2019_part1.csv \n",
"16919 Heliconius_wing_old_photos_2001_2019_part1.csv \n",
"\n",
" zenodo_link \n",
"8296 https://zenodo.org/record/3477891 \n",
"15626 https://zenodo.org/record/3477891 \n",
"16975 https://zenodo.org/record/2552371 \n",
"14097 https://zenodo.org/record/2552371 \n",
"15970 https://zenodo.org/record/2552371 \n",
"13349 https://zenodo.org/record/2552371 \n",
"16919 https://zenodo.org/record/2552371 "
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"jiggins_imgs[jiggins_imgs.Image_name.str.contains('jpg')].sample(7)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" CAMID | \n",
" X | \n",
" Image_name | \n",
" zenodo_name | \n",
" zenodo_link | \n",
"
\n",
" \n",
" \n",
" \n",
" 47693 | \n",
" CAM050052 | \n",
" 26152 | \n",
" CAM050052_M1_10_Hmr_mut_D_cut.tif | \n",
" Heliconius_wing_old_photos_2001_2019_part3.csv | \n",
" https://zenodo.org/record/2553977 | \n",
"
\n",
" \n",
" 47694 | \n",
" CAM050063 | \n",
" 26155 | \n",
" CAM050063_M7_17_Hmr_mut_V_IMG_8293_wb_cut.tif | \n",
" Heliconius_wing_old_photos_2001_2019_part3.csv | \n",
" https://zenodo.org/record/2553977 | \n",
"
\n",
" \n",
" 47712 | \n",
" CAM050147 | \n",
" 26197 | \n",
" CAM050147_DS1_HW_IMG_8537_cut_3.tif | \n",
" Heliconius_wing_old_photos_2001_2019_part3.csv | \n",
" https://zenodo.org/record/2553977 | \n",
"
\n",
" \n",
" 47637 | \n",
" CAM050006 | \n",
" 26126 | \n",
" CAM050006_S1_17_Hsar_mut_V_8296_wb_cut.tif | \n",
" Heliconius_wing_old_photos_2001_2019_part3.csv | \n",
" https://zenodo.org/record/2553977 | \n",
"
\n",
" \n",
" 47626 | \n",
" CAM050001 | \n",
" 26118 | \n",
" CAM050001_S1_5_Hs_mut_D_wb_cut.tif | \n",
" Heliconius_wing_old_photos_2001_2019_part3.csv | \n",
" https://zenodo.org/record/2553977 | \n",
"
\n",
" \n",
" 47692 | \n",
" CAM050052 | \n",
" 26153 | \n",
" CAM050052_M1_10_Hmr_mut_V_cut.tif | \n",
" Heliconius_wing_old_photos_2001_2019_part3.csv | \n",
" https://zenodo.org/record/2553977 | \n",
"
\n",
" \n",
" 47673 | \n",
" CAM050026 | \n",
" 26147 | \n",
" CAM050026_S4_1_Hs_mut_V_IMG_8453_wb_cut.tif | \n",
" Heliconius_wing_old_photos_2001_2019_part3.csv | \n",
" https://zenodo.org/record/2553977 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" CAMID X Image_name \\\n",
"47693 CAM050052 26152 CAM050052_M1_10_Hmr_mut_D_cut.tif \n",
"47694 CAM050063 26155 CAM050063_M7_17_Hmr_mut_V_IMG_8293_wb_cut.tif \n",
"47712 CAM050147 26197 CAM050147_DS1_HW_IMG_8537_cut_3.tif \n",
"47637 CAM050006 26126 CAM050006_S1_17_Hsar_mut_V_8296_wb_cut.tif \n",
"47626 CAM050001 26118 CAM050001_S1_5_Hs_mut_D_wb_cut.tif \n",
"47692 CAM050052 26153 CAM050052_M1_10_Hmr_mut_V_cut.tif \n",
"47673 CAM050026 26147 CAM050026_S4_1_Hs_mut_V_IMG_8453_wb_cut.tif \n",
"\n",
" zenodo_name \\\n",
"47693 Heliconius_wing_old_photos_2001_2019_part3.csv \n",
"47694 Heliconius_wing_old_photos_2001_2019_part3.csv \n",
"47712 Heliconius_wing_old_photos_2001_2019_part3.csv \n",
"47637 Heliconius_wing_old_photos_2001_2019_part3.csv \n",
"47626 Heliconius_wing_old_photos_2001_2019_part3.csv \n",
"47692 Heliconius_wing_old_photos_2001_2019_part3.csv \n",
"47673 Heliconius_wing_old_photos_2001_2019_part3.csv \n",
"\n",
" zenodo_link \n",
"47693 https://zenodo.org/record/2553977 \n",
"47694 https://zenodo.org/record/2553977 \n",
"47712 https://zenodo.org/record/2553977 \n",
"47637 https://zenodo.org/record/2553977 \n",
"47626 https://zenodo.org/record/2553977 \n",
"47692 https://zenodo.org/record/2553977 \n",
"47673 https://zenodo.org/record/2553977 "
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"jiggins_imgs[jiggins_imgs.Image_name.str.contains('tif')].sample(7)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" CAMID | \n",
" X | \n",
" Image_name | \n",
" zenodo_name | \n",
" zenodo_link | \n",
"
\n",
" \n",
" \n",
" \n",
" 42543 | \n",
" CAM044049 | \n",
" 32915 | \n",
" CAM044049_d.CR2 | \n",
" batch2.Peru.image.names.Zenodo.csv | \n",
" https://zenodo.org/record/4287444 | \n",
"
\n",
" \n",
" 44160 | \n",
" CAM044261 | \n",
" 36392 | \n",
" CAM044261_d.JPG | \n",
" batch3.Peru.image.names.Zenodo.csv | \n",
" https://zenodo.org/record/4288250 | \n",
"
\n",
" \n",
" 14298 | \n",
" CAM010848 | \n",
" 27458 | \n",
" CAM010848_d.JPG | \n",
" 2001_2.broods.batch.1.csv | \n",
" https://zenodo.org/record/2549524 | \n",
"
\n",
" \n",
" 19141 | \n",
" CAM016524 | \n",
" 759 | \n",
" CAM016524_d.JPG | \n",
" CAM.coll.images.batch1.csv | \n",
" https://zenodo.org/record/1247307 | \n",
"
\n",
" \n",
" 3229 | \n",
" 19N2383 | \n",
" 22175 | \n",
" 19N2383_d.JPG | \n",
" 0.sheffield.ps.nn.ikiam.batch2.csv | \n",
" https://zenodo.org/record/4288311 | \n",
"
\n",
" \n",
" 34948 | \n",
" CAM041352 | \n",
" 14340 | \n",
" CAM041352_d.JPG | \n",
" CAM.coll.images.batch9.csv | \n",
" https://zenodo.org/record/2714333 | \n",
"
\n",
" \n",
" 28072 | \n",
" CAM021080 | \n",
" 11587 | \n",
" CAM021080_d.JPG | \n",
" CAM.coll.images.batch7.csv | \n",
" https://zenodo.org/record/2702457 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" CAMID X Image_name zenodo_name \\\n",
"42543 CAM044049 32915 CAM044049_d.CR2 batch2.Peru.image.names.Zenodo.csv \n",
"44160 CAM044261 36392 CAM044261_d.JPG batch3.Peru.image.names.Zenodo.csv \n",
"14298 CAM010848 27458 CAM010848_d.JPG 2001_2.broods.batch.1.csv \n",
"19141 CAM016524 759 CAM016524_d.JPG CAM.coll.images.batch1.csv \n",
"3229 19N2383 22175 19N2383_d.JPG 0.sheffield.ps.nn.ikiam.batch2.csv \n",
"34948 CAM041352 14340 CAM041352_d.JPG CAM.coll.images.batch9.csv \n",
"28072 CAM021080 11587 CAM021080_d.JPG CAM.coll.images.batch7.csv \n",
"\n",
" zenodo_link \n",
"42543 https://zenodo.org/record/4287444 \n",
"44160 https://zenodo.org/record/4288250 \n",
"14298 https://zenodo.org/record/2549524 \n",
"19141 https://zenodo.org/record/1247307 \n",
"3229 https://zenodo.org/record/4288311 \n",
"34948 https://zenodo.org/record/2714333 \n",
"28072 https://zenodo.org/record/2702457 "
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"jiggins_imgs[jiggins_imgs.Image_name.str.contains('d.')].sample(7)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'JPG', 'CR2', 'tif', 'jpeg', 'JPG(1)', 'jpg'}\n"
]
}
],
"source": [
"check_filetypes = []\n",
"for img_name in list(jiggins_imgs.Image_name.unique()):\n",
" check_filetypes.append(img_name.split(\".\")[1])\n",
"\n",
"print(set(check_filetypes))"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"# Note CR2 is raw, may be duplicates, would need conversion\n",
"file_types = [\"JPG\", \"jpg\", \"jpeg\", \"tif\", \"JPG(1)\", \"CR2\"]"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"37821"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"images = []\n",
"\n",
"for img_name in list(jiggins_imgs.Image_name.unique()):\n",
" if img_name.split(\".\")[1] in file_types:\n",
" images.append(img_name)\n",
"\n",
"len(images)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Index: 49359 entries, 433 to 49791\n",
"Data columns (total 5 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 CAMID 49359 non-null object\n",
" 1 X 49359 non-null int64 \n",
" 2 Image_name 49359 non-null object\n",
" 3 zenodo_name 49359 non-null object\n",
" 4 zenodo_link 49359 non-null object\n",
"dtypes: int64(1), object(4)\n",
"memory usage: 2.3+ MB\n"
]
}
],
"source": [
"img = jiggins_imgs[jiggins_imgs.Image_name.isin(images)]\n",
"img.info()"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"def get_file_type(filename):\n",
" jpgs = [\"JPG\", \"jpg\", \"jpeg\", \"JPG(1)\"]\n",
" file_type = filename.split(\".\")[1]\n",
" if file_type in jpgs:\n",
" return \"jpg\"\n",
" elif file_type == \"tif\":\n",
" return \"tif\"\n",
" elif file_type == \"CR2\":\n",
" return \"raw\"\n",
" else:\n",
" print(f\"{file_type} does not match known file types\")\n",
" return None"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Index: 49359 entries, 433 to 49791\n",
"Data columns (total 6 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 CAMID 49359 non-null object\n",
" 1 X 49359 non-null int64 \n",
" 2 Image_name 49359 non-null object\n",
" 3 zenodo_name 49359 non-null object\n",
" 4 zenodo_link 49359 non-null object\n",
" 5 file_type 49359 non-null object\n",
"dtypes: int64(1), object(5)\n",
"memory usage: 2.6+ MB\n"
]
}
],
"source": [
"img[\"file_type\"] = img[\"Image_name\"].apply(get_file_type)\n",
"img.info()"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"img.to_csv(\"../zendo_img_master.csv\", index = False)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Unnamed: 0 49956\n",
"CAMID 12586\n",
"X 49956\n",
"Image_name 37843\n",
"dtype: int64\n",
"\n",
"CAMID 12586\n",
"X 49359\n",
"Image_name 37821\n",
"zenodo_name 36\n",
"dtype: int64\n"
]
}
],
"source": [
"print(jiggins[list(jiggins.columns)[:4]].nunique())\n",
"print()\n",
"print(img[list(img.columns[:4])].nunique())"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"RangeIndex: 49956 entries, 0 to 49955\n",
"Data columns (total 4 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 Unnamed: 0 49956 non-null int64 \n",
" 1 CAMID 49359 non-null object\n",
" 2 X 49956 non-null int64 \n",
" 3 Image_name 49545 non-null object\n",
"dtypes: int64(2), object(2)\n",
"memory usage: 1.5+ MB\n",
"None\n",
"\n",
"\n",
"Index: 49359 entries, 433 to 49791\n",
"Data columns (total 4 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 CAMID 49359 non-null object\n",
" 1 X 49359 non-null int64 \n",
" 2 Image_name 49359 non-null object\n",
" 3 zenodo_name 49359 non-null object\n",
"dtypes: int64(1), object(3)\n",
"memory usage: 1.9+ MB\n",
"None\n"
]
}
],
"source": [
"print(jiggins[list(jiggins.columns)[:4]].info())\n",
"print()\n",
"print(img[list(img.columns[:4])].info())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We want to match these up on `X`, since all entries have a value and it is unique."
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Index: 49359 entries, 433 to 49791\n",
"Data columns (total 25 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 Unnamed: 0 49359 non-null int64 \n",
" 1 CAMID 49359 non-null object \n",
" 2 X 49359 non-null int64 \n",
" 3 Image_name 49359 non-null object \n",
" 4 Side 48288 non-null object \n",
" 5 zenodo_name 49359 non-null object \n",
" 6 zenodo_link 49359 non-null object \n",
" 7 Sequence 48424 non-null object \n",
" 8 Taxonomic.Name 45473 non-null object \n",
" 9 Locality 34015 non-null object \n",
" 10 Sample.accession 5884 non-null object \n",
" 11 Collected.by 5280 non-null object \n",
" 12 Other.Id 14382 non-null object \n",
" 13 Collected.By 0 non-null float64\n",
" 14 Date 33718 non-null object \n",
" 15 Dataset 40405 non-null object \n",
" 16 Store 39485 non-null object \n",
" 17 Eclosion.Date 97 non-null object \n",
" 18 Brood 14942 non-null object \n",
" 19 Death.Date 318 non-null object \n",
" 20 Cross.Type 5133 non-null object \n",
" 21 Stage 15 non-null object \n",
" 22 Sex 36243 non-null object \n",
" 23 Unit.Type 33890 non-null object \n",
" 24 Verbatim.Coordinates 0 non-null float64\n",
"dtypes: float64(2), int64(2), object(21)\n",
"memory usage: 9.8+ MB\n"
]
}
],
"source": [
"df_img = jiggins.loc[jiggins.X.isin(list(img.X))]\n",
"df_img.info()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Rename columns to have underscore"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_66533/3055364590.py:1: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame\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",
" df_img.rename(columns = {\"Side\": \"View\",\n"
]
}
],
"source": [
"df_img.rename(columns = {\"Side\": \"View\",\n",
" \"Taxonomic.Name\": \"Taxonomic_Name\",\n",
" \"Cross.Type\": \"Cross_Type\",\n",
" \"Sample.accession\": \"Sample_accession\",\n",
" \"Collected.by\": \"Collected_by\",\n",
" \"Other.Id\": \"Other_ID\",\n",
" \"Death.Date\": \"Death_Date\",\n",
" \"Unit.Type\": \"Unit_Type\"},\n",
" inplace = True)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"null_cols = [\"Unnamed: 0\", \"Collected.By\", \"Eclosion.Date\", \"Verbatim.Coordinates\"]\n",
"non_null_cols = [col for col in list(df_img.columns) if col not in null_cols]"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"df_img = df_img[non_null_cols]"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" CAMID | \n",
" X | \n",
" Image_name | \n",
" View | \n",
" zenodo_name | \n",
" zenodo_link | \n",
" Sequence | \n",
" Taxonomic_Name | \n",
" Locality | \n",
" Sample_accession | \n",
" ... | \n",
" Other_ID | \n",
" Date | \n",
" Dataset | \n",
" Store | \n",
" Brood | \n",
" Death_Date | \n",
" Cross_Type | \n",
" Stage | \n",
" Sex | \n",
" Unit_Type | \n",
"
\n",
" \n",
" \n",
" \n",
" 433 | \n",
" 14N004 | \n",
" 15131 | \n",
" 14N004_d.JPG | \n",
" dorsal | \n",
" 0.4.nn.requests2.csv | \n",
" https://zenodo.org/record/4289223 | \n",
" 4 | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" ... | \n",
" NaN | \n",
" NaN | \n",
" Nadeau Sheffield | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
"
\n",
" \n",
" 434 | \n",
" 14N004 | \n",
" 15132 | \n",
" 14N004_v.JPG | \n",
" ventral | \n",
" 0.4.nn.requests2.csv | \n",
" https://zenodo.org/record/4289223 | \n",
" 4 | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" ... | \n",
" NaN | \n",
" NaN | \n",
" Nadeau Sheffield | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
"
\n",
" \n",
" 435 | \n",
" 14N009 | \n",
" 15134 | \n",
" 14N009_v.JPG | \n",
" ventral | \n",
" 0.4.nn.requests2.csv | \n",
" https://zenodo.org/record/4289223 | \n",
" 9 | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" ... | \n",
" NaN | \n",
" NaN | \n",
" Nadeau Sheffield | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
"
\n",
" \n",
" 436 | \n",
" 14N009 | \n",
" 15133 | \n",
" 14N009_d.JPG | \n",
" dorsal | \n",
" 0.4.nn.requests2.csv | \n",
" https://zenodo.org/record/4289223 | \n",
" 9 | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" ... | \n",
" NaN | \n",
" NaN | \n",
" Nadeau Sheffield | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
"
\n",
" \n",
" 437 | \n",
" 14N014 | \n",
" 15136 | \n",
" 14N014_v.JPG | \n",
" ventral | \n",
" 0.4.nn.requests2.csv | \n",
" https://zenodo.org/record/4289223 | \n",
" 14 | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" ... | \n",
" NaN | \n",
" NaN | \n",
" Nadeau Sheffield | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
" NaN | \n",
"
\n",
" \n",
"
\n",
"
5 rows × 21 columns
\n",
"
"
],
"text/plain": [
" CAMID X Image_name View zenodo_name \\\n",
"433 14N004 15131 14N004_d.JPG dorsal 0.4.nn.requests2.csv \n",
"434 14N004 15132 14N004_v.JPG ventral 0.4.nn.requests2.csv \n",
"435 14N009 15134 14N009_v.JPG ventral 0.4.nn.requests2.csv \n",
"436 14N009 15133 14N009_d.JPG dorsal 0.4.nn.requests2.csv \n",
"437 14N014 15136 14N014_v.JPG ventral 0.4.nn.requests2.csv \n",
"\n",
" zenodo_link Sequence Taxonomic_Name Locality \\\n",
"433 https://zenodo.org/record/4289223 4 NaN NaN \n",
"434 https://zenodo.org/record/4289223 4 NaN NaN \n",
"435 https://zenodo.org/record/4289223 9 NaN NaN \n",
"436 https://zenodo.org/record/4289223 9 NaN NaN \n",
"437 https://zenodo.org/record/4289223 14 NaN NaN \n",
"\n",
" Sample_accession ... Other_ID Date Dataset Store Brood \\\n",
"433 NaN ... NaN NaN Nadeau Sheffield NaN NaN \n",
"434 NaN ... NaN NaN Nadeau Sheffield NaN NaN \n",
"435 NaN ... NaN NaN Nadeau Sheffield NaN NaN \n",
"436 NaN ... NaN NaN Nadeau Sheffield NaN NaN \n",
"437 NaN ... NaN NaN Nadeau Sheffield NaN NaN \n",
"\n",
" Death_Date Cross_Type Stage Sex Unit_Type \n",
"433 NaN NaN NaN NaN NaN \n",
"434 NaN NaN NaN NaN NaN \n",
"435 NaN NaN NaN NaN NaN \n",
"436 NaN NaN NaN NaN NaN \n",
"437 NaN NaN NaN NaN NaN \n",
"\n",
"[5 rows x 21 columns]"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_img.head()"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Index: 49359 entries, 433 to 49791\n",
"Data columns (total 22 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 CAMID 49359 non-null object\n",
" 1 X 49359 non-null int64 \n",
" 2 Image_name 49359 non-null object\n",
" 3 View 48288 non-null object\n",
" 4 zenodo_name 49359 non-null object\n",
" 5 zenodo_link 49359 non-null object\n",
" 6 Sequence 48424 non-null object\n",
" 7 Taxonomic_Name 45473 non-null object\n",
" 8 Locality 34015 non-null object\n",
" 9 Sample_accession 5884 non-null object\n",
" 10 Collected_by 5280 non-null object\n",
" 11 Other_ID 14382 non-null object\n",
" 12 Date 33718 non-null object\n",
" 13 Dataset 40405 non-null object\n",
" 14 Store 39485 non-null object\n",
" 15 Brood 14942 non-null object\n",
" 16 Death_Date 318 non-null object\n",
" 17 Cross_Type 5133 non-null object\n",
" 18 Stage 15 non-null object\n",
" 19 Sex 36243 non-null object\n",
" 20 Unit_Type 33890 non-null object\n",
" 21 file_type 49359 non-null object\n",
"dtypes: int64(1), object(21)\n",
"memory usage: 8.7+ MB\n"
]
}
],
"source": [
"df_img[\"file_type\"] = df_img[\"Image_name\"].apply(get_file_type)\n",
"df_img.info()"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
"df_img.to_csv(\"../Jiggins_Zenodo_Img_Master.csv\", index = False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Remaining Question is just if the raw images are duplicated as jpgs or are unique. The `CAMID`'s correspond to samples (as noted in the [zenodo records](https://zenodo.org/record/4289223)), so we can check a single view for this."
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"View\n",
"dorsal 15128\n",
"ventral 13424\n",
"Dorsal 8360\n",
"Ventral 8090\n",
"ventral 1644\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": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_img.View.value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['dorsal',\n",
" 'Dorsal',\n",
" 'Dorsal and Ventral',\n",
" 'forewing dorsal',\n",
" 'hindwing dorsal']"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dorsal_labels = [view for view in list(df_img.View.dropna().unique()) if \"dorsal\" in view.lower()]\n",
"dorsal_labels"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Index: 24318 entries, 433 to 49790\n",
"Data columns (total 22 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 CAMID 24318 non-null object\n",
" 1 X 24318 non-null int64 \n",
" 2 Image_name 24318 non-null object\n",
" 3 View 24318 non-null object\n",
" 4 zenodo_name 24318 non-null object\n",
" 5 zenodo_link 24318 non-null object\n",
" 6 Sequence 23851 non-null object\n",
" 7 Taxonomic_Name 22511 non-null object\n",
" 8 Locality 16773 non-null object\n",
" 9 Sample_accession 2953 non-null object\n",
" 10 Collected_by 2656 non-null object\n",
" 11 Other_ID 6931 non-null object\n",
" 12 Date 16847 non-null object\n",
" 13 Dataset 19935 non-null object\n",
" 14 Store 19894 non-null object\n",
" 15 Brood 7264 non-null object\n",
" 16 Death_Date 107 non-null object\n",
" 17 Cross_Type 2572 non-null object\n",
" 18 Stage 8 non-null object\n",
" 19 Sex 17875 non-null object\n",
" 20 Unit_Type 16693 non-null object\n",
" 21 file_type 24318 non-null object\n",
"dtypes: int64(1), object(21)\n",
"memory usage: 4.3+ MB\n"
]
}
],
"source": [
"df_img_dorsal = df_img.loc[df_img[\"View\"].isin(dorsal_labels)]\n",
"df_img_dorsal.info()"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CAMID 12296\n",
"X 24318\n",
"Image_name 18539\n",
"View 5\n",
"zenodo_name 36\n",
"zenodo_link 32\n",
"Sequence 11107\n",
"Taxonomic_Name 359\n",
"Locality 642\n",
"Sample_accession 1564\n",
"Collected_by 12\n",
"Other_ID 2897\n",
"Date 794\n",
"Dataset 8\n",
"Store 142\n",
"Brood 217\n",
"Death_Date 64\n",
"Cross_Type 30\n",
"Stage 1\n",
"Sex 3\n",
"Unit_Type 6\n",
"file_type 3\n",
"dtype: int64"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_img_dorsal.nunique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We still have repeated `CAMID`s."
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_66533/4002726096.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",
" df_img_dorsal[\"CAM_Dupe\"] = df_img_dorsal.duplicated(subset = \"CAMID\", keep = False)\n"
]
}
],
"source": [
"df_img_dorsal[\"CAM_Dupe\"] = df_img_dorsal.duplicated(subset = \"CAMID\", keep = False)"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CAM_Dupe\n",
"True 20765\n",
"False 3553\n",
"Name: count, dtype: int64"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_img_dorsal[\"CAM_Dupe\"].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Index: 20765 entries, 709 to 49692\n",
"Data columns (total 23 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 CAMID 20765 non-null object\n",
" 1 X 20765 non-null int64 \n",
" 2 Image_name 20765 non-null object\n",
" 3 View 20765 non-null object\n",
" 4 zenodo_name 20765 non-null object\n",
" 5 zenodo_link 20765 non-null object\n",
" 6 Sequence 20299 non-null object\n",
" 7 Taxonomic_Name 19368 non-null object\n",
" 8 Locality 15301 non-null object\n",
" 9 Sample_accession 2657 non-null object\n",
" 10 Collected_by 2653 non-null object\n",
" 11 Other_ID 6107 non-null object\n",
" 12 Date 15980 non-null object\n",
" 13 Dataset 16862 non-null object\n",
" 14 Store 17579 non-null object\n",
" 15 Brood 5414 non-null object\n",
" 16 Death_Date 26 non-null object\n",
" 17 Cross_Type 2572 non-null object\n",
" 18 Stage 0 non-null object\n",
" 19 Sex 14897 non-null object\n",
" 20 Unit_Type 13814 non-null object\n",
" 21 file_type 20765 non-null object\n",
" 22 CAM_Dupe 20765 non-null bool \n",
"dtypes: bool(1), int64(1), object(21)\n",
"memory usage: 3.7+ MB\n"
]
}
],
"source": [
"duplicate_samples = df_img_dorsal.loc[df_img_dorsal[\"CAM_Dupe\"]]\n",
"duplicate_samples.info()"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CAMID 8743\n",
"X 20765\n",
"Image_name 14986\n",
"View 5\n",
"zenodo_name 32\n",
"zenodo_link 31\n",
"Sequence 8407\n",
"Taxonomic_Name 328\n",
"Locality 516\n",
"Sample_accession 1268\n",
"Collected_by 12\n",
"Other_ID 2073\n",
"Date 578\n",
"Dataset 4\n",
"Store 130\n",
"Brood 144\n",
"Death_Date 12\n",
"Cross_Type 30\n",
"Stage 0\n",
"Sex 3\n",
"Unit_Type 3\n",
"file_type 3\n",
"CAM_Dupe 1\n",
"dtype: int64"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"duplicate_samples.nunique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"All sources are impacted."
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"file_type\n",
"jpg 14788\n",
"raw 5956\n",
"tif 21\n",
"Name: count, dtype: int64"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"duplicate_samples.file_type.value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will get some added duplication from `forewing dorsal` and `hindwing dorsal`, so we should filter those down to just one for a more accurate assessment."
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True 680\n",
"False 132\n",
"Name: count, dtype: int64"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"duplicate_samples.loc[duplicate_samples[\"View\"].isin([\"forewing dorsal\", \"hindwing dorsal\"])].duplicated(\"CAMID\", keep = \"first\").value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CAMID 132\n",
"X 812\n",
"Image_name 528\n",
"View 2\n",
"zenodo_name 3\n",
"zenodo_link 3\n",
"Sequence 132\n",
"Taxonomic_Name 7\n",
"Locality 59\n",
"Sample_accession 0\n",
"Collected_by 0\n",
"Other_ID 127\n",
"Date 16\n",
"Dataset 1\n",
"Store 17\n",
"Brood 0\n",
"Death_Date 0\n",
"Cross_Type 0\n",
"Stage 0\n",
"Sex 0\n",
"Unit_Type 0\n",
"file_type 2\n",
"CAM_Dupe 1\n",
"dtype: int64"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"duplicate_samples.loc[duplicate_samples[\"View\"].isin([\"forewing dorsal\", \"hindwing dorsal\"])].nunique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This is only a couple zenodo links, so it is not contributing to the duplication across sources. It also covers two file types."
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Index: 3553 entries, 433 to 49790\n",
"Data columns (total 23 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 CAMID 3553 non-null object\n",
" 1 X 3553 non-null int64 \n",
" 2 Image_name 3553 non-null object\n",
" 3 View 3553 non-null object\n",
" 4 zenodo_name 3553 non-null object\n",
" 5 zenodo_link 3553 non-null object\n",
" 6 Sequence 3552 non-null object\n",
" 7 Taxonomic_Name 3143 non-null object\n",
" 8 Locality 1472 non-null object\n",
" 9 Sample_accession 296 non-null object\n",
" 10 Collected_by 3 non-null object\n",
" 11 Other_ID 824 non-null object\n",
" 12 Date 867 non-null object\n",
" 13 Dataset 3073 non-null object\n",
" 14 Store 2315 non-null object\n",
" 15 Brood 1850 non-null object\n",
" 16 Death_Date 81 non-null object\n",
" 17 Cross_Type 0 non-null object\n",
" 18 Stage 8 non-null object\n",
" 19 Sex 2978 non-null object\n",
" 20 Unit_Type 2879 non-null object\n",
" 21 file_type 3553 non-null object\n",
" 22 CAM_Dupe 3553 non-null bool \n",
"dtypes: bool(1), int64(1), object(21)\n",
"memory usage: 641.9+ KB\n"
]
}
],
"source": [
"unique_samples = df_img_dorsal.loc[~df_img_dorsal[\"CAM_Dupe\"]]\n",
"unique_samples.info()"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CAMID 3553\n",
"X 3553\n",
"Image_name 3553\n",
"View 3\n",
"zenodo_name 21\n",
"zenodo_link 18\n",
"Sequence 3016\n",
"Taxonomic_Name 109\n",
"Locality 160\n",
"Sample_accession 296\n",
"Collected_by 3\n",
"Other_ID 824\n",
"Date 265\n",
"Dataset 8\n",
"Store 76\n",
"Brood 95\n",
"Death_Date 52\n",
"Cross_Type 0\n",
"Stage 1\n",
"Sex 3\n",
"Unit_Type 6\n",
"file_type 2\n",
"CAM_Dupe 1\n",
"dtype: int64"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"unique_samples.nunique()"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"file_type\n",
"jpg 3535\n",
"tif 18\n",
"Name: count, dtype: int64"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"unique_samples.file_type.value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ah, well all raw images are indeed duplicated. Let's check if they're duplicated among themselves or duplicated to other file types (eg., jpg)."
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(5753, 23)\n"
]
},
{
"data": {
"text/plain": [
"4944"
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print(duplicate_samples.loc[(duplicate_samples[\"View\"] != \"hindwing dorsal\") & (duplicate_samples[\"file_type\"] == \"raw\")].shape)\n",
"duplicate_samples.loc[(duplicate_samples[\"View\"] != \"hindwing dorsal\") & (duplicate_samples[\"file_type\"] == \"raw\"), \"CAMID\"].nunique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Okay, so there are multiple raw images of the same sample. "
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"View\n",
"dorsal 4219\n",
"Dorsal 1331\n",
"forewing dorsal 203\n",
"Name: count, dtype: int64"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"duplicate_raw = duplicate_samples.loc[(duplicate_samples[\"View\"] != \"hindwing dorsal\") & (duplicate_samples[\"file_type\"] == \"raw\")]\n",
"duplicate_raw.View.value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"raw_dupe\n",
"False 4240\n",
"True 1513\n",
"Name: count, dtype: int64\n",
"\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_66533/3049709573.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",
" duplicate_raw[\"raw_dupe\"] = duplicate_raw.duplicated(\"CAMID\", keep = False)\n"
]
},
{
"data": {
"text/plain": [
"View\n",
"dorsal 1159\n",
"Dorsal 212\n",
"forewing dorsal 142\n",
"Name: count, dtype: int64"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"duplicate_raw[\"raw_dupe\"] = duplicate_raw.duplicated(\"CAMID\", keep = False)\n",
"print(duplicate_raw[\"raw_dupe\"].value_counts())\n",
"print()\n",
"duplicate_raw.loc[duplicate_raw[\"raw_dupe\"], \"View\"].value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There does not seem to be an easy method of filtering these other than just keeping the first instance of a particular `CAMID`.\n",
"\n",
"It is interesting that non of the Cross Types are unique. Is that just because we have the forewing/hindwing duplication?"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(2572, 23)\n"
]
},
{
"data": {
"text/plain": [
"820"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print(duplicate_samples.loc[(duplicate_samples[\"View\"] != \"hindwing dorsal\") & (duplicate_samples[\"Cross_Type\"].notna())].shape)\n",
"duplicate_samples.loc[(duplicate_samples[\"View\"] != \"hindwing dorsal\") & (duplicate_samples[\"Cross_Type\"].notna()), \"CAMID\"].nunique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There still seem to be 3 images for each specimen."
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cross_dupe\n",
"True 2572\n",
"Name: count, dtype: int64\n",
"\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_66533/2419376272.py:2: 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",
" duplicate_cross[\"cross_dupe\"] = duplicate_cross.duplicated(\"CAMID\", keep = False)\n"
]
},
{
"data": {
"text/plain": [
"View\n",
"dorsal 2322\n",
"Dorsal 250\n",
"Name: count, dtype: int64"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"duplicate_cross = duplicate_samples.loc[(duplicate_samples[\"View\"] != \"hindwing dorsal\") & (duplicate_samples[\"Cross_Type\"].notna())]\n",
"duplicate_cross[\"cross_dupe\"] = duplicate_cross.duplicated(\"CAMID\", keep = False)\n",
"print(duplicate_cross[\"cross_dupe\"].value_counts())\n",
"print()\n",
"duplicate_cross.View.value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Yes, they are all duplicated."
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"file_type\n",
"jpg 1753\n",
"raw 819\n",
"Name: count, dtype: int64"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"duplicate_cross.file_type.value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It seems there's one raw image for each sample (other than one) and then everything else is jpg. I wonder if this includes the `JPG(1)` values."
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"count = 0\n",
"for img_name in list(duplicate_cross.Image_name.unique()):\n",
" if \"JPG(1)\" in img_name:\n",
" count = count + 1\n",
"count"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"No, that's not the issue."
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"count = 0\n",
"for img_name in list(duplicate_samples.Image_name.unique()):\n",
" if \"JPG(1)\" in img_name:\n",
" count = count + 1\n",
"count"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"count = 0\n",
"for img_name in list(df_img_dorsal.Image_name.unique()):\n",
" if \"JPG(1)\" in img_name:\n",
" count = count + 1\n",
"count"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"count = 0\n",
"for img_name in list(df_img.Image_name.unique()):\n",
" if \"JPG(1)\" in img_name:\n",
" count = count + 1\n",
"count"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There's only one instance of this, and it's not a dorsal image, so that's not part of the issue."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's save all the dorsal images as another CSV (with the duplicate `CAMID` indicator)."
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [],
"source": [
"df_img_dorsal.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
}