{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Add Mimicry Group Information for Heliconius Species\n", "\n", "This notebook will add mimicry group information for the Heliconius species (at the subspecies level) included in this dataset." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load in master CSVs and Heliconius mimicry group csvs." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Master CSVs\n", "full_df = pd.read_csv(\"../Jiggins_Zenodo_Img_Master.csv\", low_memory = False)\n", "dorsal_df = pd.read_csv(\"../Jiggins_Zenodo_dorsal_Img_Master.csv\", low_memory = False)\n", "heli_df = pd.read_csv(\"../Jiggins_Heliconius_Master.csv\", low_memory = False)\n", "\n", "# Heliconius Mimicry Group CSV\n", "mimic_gp_df = pd.read_csv(\"../metadata/heliconius_mimic_groups.csv\", low_memory = False)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['CAMID', 'X', 'Image_name', 'View', 'zenodo_name', 'zenodo_link',\n", " 'Sequence', 'Taxonomic_Name', 'Locality', 'Sample_accession',\n", " 'Collected_by', 'Other_ID', 'Date', 'Dataset', 'Store', 'Brood',\n", " 'Death_Date', 'Cross_Type', 'Stage', 'Sex', 'Unit_Type', 'file_type',\n", " 'record_number', 'species', 'subspecies', 'genus', 'file_url',\n", " 'hybrid_stat', 'filename', 'filepath', 'md5'],\n", " dtype='object')" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "full_df.columns" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First, we need to fix a typo found in the subspecies (\"clysonomus\" should be \"clysonymus\")." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "136" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "full_df.loc[full_df[\"subspecies\"] == \"clysonymus\"].shape[0]" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
CAMIDXImage_nameViewzenodo_namezenodo_linkSequenceTaxonomic_NameLocalitySample_accession...file_typerecord_numberspeciessubspeciesgenusfile_urlhybrid_statfilenamefilepathmd5
24962CAM04123314103CAM041233_d.JPGdorsalCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,233Heliconius clysonomus ssp. clysonomusWild Sumaco Hummingbird TrailNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14103_CAM041233_d.JPGimages/Heliconius clysonomus ssp. clysonomus/1...2236af310ed7d7027cbec678a636b5ee
24963CAM04123314104CAM041233_v.JPGventralCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,233Heliconius clysonomus ssp. clysonomusWild Sumaco Hummingbird TrailNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14104_CAM041233_v.JPGimages/Heliconius clysonomus ssp. clysonomus/1...d45a9ef82f9cd4646c4ea51e266b2814
24964CAM04123414105CAM041234_d.JPGdorsalCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,234Heliconius clysonomus ssp. clysonomusWild Sumaco Hummingbird TrailNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14105_CAM041234_d.JPGimages/Heliconius clysonomus ssp. clysonomus/1...2c19b958ad77e448d7ad2ad41273bb65
24965CAM04123414106CAM041234_v.JPGventralCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,234Heliconius clysonomus ssp. clysonomusWild Sumaco Hummingbird TrailNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14106_CAM041234_v.JPGimages/Heliconius clysonomus ssp. clysonomus/1...8249c142e90bda050accab7e59e9821d
24966CAM04123514107CAM041235_d.JPGdorsalCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,235Heliconius clysonomus ssp. clysonomusWild Sumaco Hummingbird TrailNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14107_CAM041235_d.JPGimages/Heliconius clysonomus ssp. clysonomus/1...a988e503bbe0404e07c89405c05e0f9d
24967CAM04123514108CAM041235_v.JPGventralCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,235Heliconius clysonomus ssp. clysonomusWild Sumaco Hummingbird TrailNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14108_CAM041235_v.JPGimages/Heliconius clysonomus ssp. clysonomus/1...495869bf772c8d4d95b07620d3e3c6dd
24968CAM04123614109CAM041236_d.JPGdorsalCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,236Heliconius clysonomus ssp. clysonomusWild Sumaco Hummingbird TrailNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14109_CAM041236_d.JPGimages/Heliconius clysonomus ssp. clysonomus/1...15f796491b44543453b6f7ce0311c9dc
24969CAM04123614110CAM041236_v.JPGventralCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,236Heliconius clysonomus ssp. clysonomusWild Sumaco Hummingbird TrailNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14110_CAM041236_v.JPGimages/Heliconius clysonomus ssp. clysonomus/1...20684478a650287e49f64675deb80ed6
25055CAM04128014196CAM041280_d.JPGdorsalCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,280Heliconius clysonomus ssp. clysonomusReventador roadNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14196_CAM041280_d.JPGimages/Heliconius clysonomus ssp. clysonomus/1...9363c286d5fb4790b99fd2bc2fe8aaad
25056CAM04128014197CAM041280_v.JPGventralCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,280Heliconius clysonomus ssp. clysonomusReventador roadNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14197_CAM041280_v.JPGimages/Heliconius clysonomus ssp. clysonomus/1...9085c0f1bb0230d7ccc9089f1a299aed
25057CAM04128114198CAM041281_d.JPGdorsalCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,281Heliconius clysonomus ssp. clysonomusReventador roadNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14198_CAM041281_d.JPGimages/Heliconius clysonomus ssp. clysonomus/1...d371321547ec020347275e7b89cf6af2
25058CAM04128114199CAM041281_v.JPGventralCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,281Heliconius clysonomus ssp. clysonomusReventador roadNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14199_CAM041281_v.JPGimages/Heliconius clysonomus ssp. clysonomus/1...13e5a78afa77e0b1fb238377600fc9b8
25059CAM04128214201CAM041282_v.JPGventralCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,282Heliconius clysonomus ssp. clysonomusReventador roadNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14201_CAM041282_v.JPGimages/Heliconius clysonomus ssp. clysonomus/1...922f2db6299e004bcb09906f99c038ba
25060CAM04128214200CAM041282_d.JPGdorsalCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,282Heliconius clysonomus ssp. clysonomusReventador roadNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14200_CAM041282_d.JPGimages/Heliconius clysonomus ssp. clysonomus/1...8b40ba830d38f9f4061a63a854c86404
25061CAM04128314203CAM041283_v.JPGventralCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,283Heliconius clysonomus ssp. clysonomusReventador roadNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14203_CAM041283_v.JPGimages/Heliconius clysonomus ssp. clysonomus/1...349520a30aee4bb098789b0b24d0a288
25062CAM04128314202CAM041283_d.JPGdorsalCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,283Heliconius clysonomus ssp. clysonomusReventador roadNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14202_CAM041283_d.JPGimages/Heliconius clysonomus ssp. clysonomus/1...810791d8777381676724cbee09f4c9b6
25063CAM04128414204CAM041284_d.JPGdorsalCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,284Heliconius clysonomus ssp. clysonomusReventador roadNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14204_CAM041284_d.JPGimages/Heliconius clysonomus ssp. clysonomus/1...040da0a338a3318baef1de8f275912dd
25064CAM04128414205CAM041284_v.JPGventralCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,284Heliconius clysonomus ssp. clysonomusReventador roadNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14205_CAM041284_v.JPGimages/Heliconius clysonomus ssp. clysonomus/1...955d38ec86c457378e8b9e1a8a3776f8
25065CAM04128514206CAM041285_d.JPGdorsalCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,285Heliconius clysonomus ssp. clysonomusReventador roadNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14206_CAM041285_d.JPGimages/Heliconius clysonomus ssp. clysonomus/1...2af97a0ad748065aecc88dfa1649c51c
25066CAM04128514207CAM041285_v.JPGventralCAM.coll.images.batch9.csvhttps://zenodo.org/record/271433341,285Heliconius clysonomus ssp. clysonomusReventador roadNaN...jpg2714333Heliconius clysonomusclysonomusHeliconiushttps://zenodo.org/record/2714333/files/CAM041...non-hybrid14207_CAM041285_v.JPGimages/Heliconius clysonomus ssp. clysonomus/1...24acf462d66c712f3be5aab7f1c85b6e
\n", "

20 rows × 31 columns

\n", "
" ], "text/plain": [ " CAMID X Image_name View zenodo_name \\\n", "24962 CAM041233 14103 CAM041233_d.JPG dorsal CAM.coll.images.batch9.csv \n", "24963 CAM041233 14104 CAM041233_v.JPG ventral CAM.coll.images.batch9.csv \n", "24964 CAM041234 14105 CAM041234_d.JPG dorsal CAM.coll.images.batch9.csv \n", "24965 CAM041234 14106 CAM041234_v.JPG ventral CAM.coll.images.batch9.csv \n", "24966 CAM041235 14107 CAM041235_d.JPG dorsal CAM.coll.images.batch9.csv \n", "24967 CAM041235 14108 CAM041235_v.JPG ventral CAM.coll.images.batch9.csv \n", "24968 CAM041236 14109 CAM041236_d.JPG dorsal CAM.coll.images.batch9.csv \n", "24969 CAM041236 14110 CAM041236_v.JPG ventral CAM.coll.images.batch9.csv \n", "25055 CAM041280 14196 CAM041280_d.JPG dorsal CAM.coll.images.batch9.csv \n", "25056 CAM041280 14197 CAM041280_v.JPG ventral CAM.coll.images.batch9.csv \n", "25057 CAM041281 14198 CAM041281_d.JPG dorsal CAM.coll.images.batch9.csv \n", "25058 CAM041281 14199 CAM041281_v.JPG ventral CAM.coll.images.batch9.csv \n", "25059 CAM041282 14201 CAM041282_v.JPG ventral CAM.coll.images.batch9.csv \n", "25060 CAM041282 14200 CAM041282_d.JPG dorsal CAM.coll.images.batch9.csv \n", "25061 CAM041283 14203 CAM041283_v.JPG ventral CAM.coll.images.batch9.csv \n", "25062 CAM041283 14202 CAM041283_d.JPG dorsal CAM.coll.images.batch9.csv \n", "25063 CAM041284 14204 CAM041284_d.JPG dorsal CAM.coll.images.batch9.csv \n", "25064 CAM041284 14205 CAM041284_v.JPG ventral CAM.coll.images.batch9.csv \n", "25065 CAM041285 14206 CAM041285_d.JPG dorsal CAM.coll.images.batch9.csv \n", "25066 CAM041285 14207 CAM041285_v.JPG ventral CAM.coll.images.batch9.csv \n", "\n", " zenodo_link Sequence \\\n", "24962 https://zenodo.org/record/2714333 41,233 \n", "24963 https://zenodo.org/record/2714333 41,233 \n", "24964 https://zenodo.org/record/2714333 41,234 \n", "24965 https://zenodo.org/record/2714333 41,234 \n", "24966 https://zenodo.org/record/2714333 41,235 \n", "24967 https://zenodo.org/record/2714333 41,235 \n", "24968 https://zenodo.org/record/2714333 41,236 \n", "24969 https://zenodo.org/record/2714333 41,236 \n", "25055 https://zenodo.org/record/2714333 41,280 \n", "25056 https://zenodo.org/record/2714333 41,280 \n", "25057 https://zenodo.org/record/2714333 41,281 \n", "25058 https://zenodo.org/record/2714333 41,281 \n", "25059 https://zenodo.org/record/2714333 41,282 \n", "25060 https://zenodo.org/record/2714333 41,282 \n", "25061 https://zenodo.org/record/2714333 41,283 \n", "25062 https://zenodo.org/record/2714333 41,283 \n", "25063 https://zenodo.org/record/2714333 41,284 \n", "25064 https://zenodo.org/record/2714333 41,284 \n", "25065 https://zenodo.org/record/2714333 41,285 \n", "25066 https://zenodo.org/record/2714333 41,285 \n", "\n", " Taxonomic_Name Locality \\\n", "24962 Heliconius clysonomus ssp. clysonomus Wild Sumaco Hummingbird Trail \n", "24963 Heliconius clysonomus ssp. clysonomus Wild Sumaco Hummingbird Trail \n", "24964 Heliconius clysonomus ssp. clysonomus Wild Sumaco Hummingbird Trail \n", "24965 Heliconius clysonomus ssp. clysonomus Wild Sumaco Hummingbird Trail \n", "24966 Heliconius clysonomus ssp. clysonomus Wild Sumaco Hummingbird Trail \n", "24967 Heliconius clysonomus ssp. clysonomus Wild Sumaco Hummingbird Trail \n", "24968 Heliconius clysonomus ssp. clysonomus Wild Sumaco Hummingbird Trail \n", "24969 Heliconius clysonomus ssp. clysonomus Wild Sumaco Hummingbird Trail \n", "25055 Heliconius clysonomus ssp. clysonomus Reventador road \n", "25056 Heliconius clysonomus ssp. clysonomus Reventador road \n", "25057 Heliconius clysonomus ssp. clysonomus Reventador road \n", "25058 Heliconius clysonomus ssp. clysonomus Reventador road \n", "25059 Heliconius clysonomus ssp. clysonomus Reventador road \n", "25060 Heliconius clysonomus ssp. clysonomus Reventador road \n", "25061 Heliconius clysonomus ssp. clysonomus Reventador road \n", "25062 Heliconius clysonomus ssp. clysonomus Reventador road \n", "25063 Heliconius clysonomus ssp. clysonomus Reventador road \n", "25064 Heliconius clysonomus ssp. clysonomus Reventador road \n", "25065 Heliconius clysonomus ssp. clysonomus Reventador road \n", "25066 Heliconius clysonomus ssp. clysonomus Reventador road \n", "\n", " Sample_accession ... file_type record_number species \\\n", "24962 NaN ... jpg 2714333 Heliconius clysonomus \n", "24963 NaN ... jpg 2714333 Heliconius clysonomus \n", "24964 NaN ... jpg 2714333 Heliconius clysonomus \n", "24965 NaN ... jpg 2714333 Heliconius clysonomus \n", "24966 NaN ... jpg 2714333 Heliconius clysonomus \n", "24967 NaN ... jpg 2714333 Heliconius clysonomus \n", "24968 NaN ... jpg 2714333 Heliconius clysonomus \n", "24969 NaN ... jpg 2714333 Heliconius clysonomus \n", "25055 NaN ... jpg 2714333 Heliconius clysonomus \n", "25056 NaN ... jpg 2714333 Heliconius clysonomus \n", "25057 NaN ... jpg 2714333 Heliconius clysonomus \n", "25058 NaN ... jpg 2714333 Heliconius clysonomus \n", "25059 NaN ... jpg 2714333 Heliconius clysonomus \n", "25060 NaN ... jpg 2714333 Heliconius clysonomus \n", "25061 NaN ... jpg 2714333 Heliconius clysonomus \n", "25062 NaN ... jpg 2714333 Heliconius clysonomus \n", "25063 NaN ... jpg 2714333 Heliconius clysonomus \n", "25064 NaN ... jpg 2714333 Heliconius clysonomus \n", "25065 NaN ... jpg 2714333 Heliconius clysonomus \n", "25066 NaN ... jpg 2714333 Heliconius clysonomus \n", "\n", " subspecies genus \\\n", "24962 clysonomus Heliconius \n", "24963 clysonomus Heliconius \n", "24964 clysonomus Heliconius \n", "24965 clysonomus Heliconius \n", "24966 clysonomus Heliconius \n", "24967 clysonomus Heliconius \n", "24968 clysonomus Heliconius \n", "24969 clysonomus Heliconius \n", "25055 clysonomus Heliconius \n", "25056 clysonomus Heliconius \n", "25057 clysonomus Heliconius \n", "25058 clysonomus Heliconius \n", "25059 clysonomus Heliconius \n", "25060 clysonomus Heliconius \n", "25061 clysonomus Heliconius \n", "25062 clysonomus Heliconius \n", "25063 clysonomus Heliconius \n", "25064 clysonomus Heliconius \n", "25065 clysonomus Heliconius \n", "25066 clysonomus Heliconius \n", "\n", " file_url hybrid_stat \\\n", "24962 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "24963 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "24964 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "24965 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "24966 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "24967 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "24968 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "24969 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "25055 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "25056 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "25057 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "25058 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "25059 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "25060 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "25061 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "25062 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "25063 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "25064 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "25065 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "25066 https://zenodo.org/record/2714333/files/CAM041... non-hybrid \n", "\n", " filename \\\n", "24962 14103_CAM041233_d.JPG \n", "24963 14104_CAM041233_v.JPG \n", "24964 14105_CAM041234_d.JPG \n", "24965 14106_CAM041234_v.JPG \n", "24966 14107_CAM041235_d.JPG \n", "24967 14108_CAM041235_v.JPG \n", "24968 14109_CAM041236_d.JPG \n", "24969 14110_CAM041236_v.JPG \n", "25055 14196_CAM041280_d.JPG \n", "25056 14197_CAM041280_v.JPG \n", "25057 14198_CAM041281_d.JPG \n", "25058 14199_CAM041281_v.JPG \n", "25059 14201_CAM041282_v.JPG \n", "25060 14200_CAM041282_d.JPG \n", "25061 14203_CAM041283_v.JPG \n", "25062 14202_CAM041283_d.JPG \n", "25063 14204_CAM041284_d.JPG \n", "25064 14205_CAM041284_v.JPG \n", "25065 14206_CAM041285_d.JPG \n", "25066 14207_CAM041285_v.JPG \n", "\n", " filepath \\\n", "24962 images/Heliconius clysonomus ssp. clysonomus/1... \n", "24963 images/Heliconius clysonomus ssp. clysonomus/1... \n", "24964 images/Heliconius clysonomus ssp. clysonomus/1... \n", "24965 images/Heliconius clysonomus ssp. clysonomus/1... \n", "24966 images/Heliconius clysonomus ssp. clysonomus/1... \n", "24967 images/Heliconius clysonomus ssp. clysonomus/1... \n", "24968 images/Heliconius clysonomus ssp. clysonomus/1... \n", "24969 images/Heliconius clysonomus ssp. clysonomus/1... \n", "25055 images/Heliconius clysonomus ssp. clysonomus/1... \n", "25056 images/Heliconius clysonomus ssp. clysonomus/1... \n", "25057 images/Heliconius clysonomus ssp. clysonomus/1... \n", "25058 images/Heliconius clysonomus ssp. clysonomus/1... \n", "25059 images/Heliconius clysonomus ssp. clysonomus/1... \n", "25060 images/Heliconius clysonomus ssp. clysonomus/1... \n", "25061 images/Heliconius clysonomus ssp. clysonomus/1... \n", "25062 images/Heliconius clysonomus ssp. clysonomus/1... \n", "25063 images/Heliconius clysonomus ssp. clysonomus/1... \n", "25064 images/Heliconius clysonomus ssp. clysonomus/1... \n", "25065 images/Heliconius clysonomus ssp. clysonomus/1... \n", "25066 images/Heliconius clysonomus ssp. clysonomus/1... \n", "\n", " md5 \n", "24962 2236af310ed7d7027cbec678a636b5ee \n", "24963 d45a9ef82f9cd4646c4ea51e266b2814 \n", "24964 2c19b958ad77e448d7ad2ad41273bb65 \n", "24965 8249c142e90bda050accab7e59e9821d \n", "24966 a988e503bbe0404e07c89405c05e0f9d \n", "24967 495869bf772c8d4d95b07620d3e3c6dd \n", "24968 15f796491b44543453b6f7ce0311c9dc \n", "24969 20684478a650287e49f64675deb80ed6 \n", "25055 9363c286d5fb4790b99fd2bc2fe8aaad \n", "25056 9085c0f1bb0230d7ccc9089f1a299aed \n", "25057 d371321547ec020347275e7b89cf6af2 \n", "25058 13e5a78afa77e0b1fb238377600fc9b8 \n", "25059 922f2db6299e004bcb09906f99c038ba \n", "25060 8b40ba830d38f9f4061a63a854c86404 \n", "25061 349520a30aee4bb098789b0b24d0a288 \n", "25062 810791d8777381676724cbee09f4c9b6 \n", "25063 040da0a338a3318baef1de8f275912dd \n", "25064 955d38ec86c457378e8b9e1a8a3776f8 \n", "25065 2af97a0ad748065aecc88dfa1649c51c \n", "25066 24acf462d66c712f3be5aab7f1c85b6e \n", "\n", "[20 rows x 31 columns]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "full_df.loc[full_df[\"subspecies\"] == \"clysonomus\"]" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "for x in list(full_df.loc[full_df[\"subspecies\"] == \"clysonomus\", \"X\"]):\n", " filepath = full_df.loc[full_df[\"X\"] == x, \"filepath\"].values[0]\n", " full_df.loc[full_df[\"X\"] == x, \"filepath\"] = filepath.replace(\"clysonomus\", \"clysonymus\")" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "filepath\n", "images/Heliconius clysonymus ssp. clysonymus/14103_CAM041233_d.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14104_CAM041233_v.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14206_CAM041285_d.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14205_CAM041284_v.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14204_CAM041284_d.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14202_CAM041283_d.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14203_CAM041283_v.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14200_CAM041282_d.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14201_CAM041282_v.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14199_CAM041281_v.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14198_CAM041281_d.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14197_CAM041280_v.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14196_CAM041280_d.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14110_CAM041236_v.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14109_CAM041236_d.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14108_CAM041235_v.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14107_CAM041235_d.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14106_CAM041234_v.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14105_CAM041234_d.JPG 1\n", "images/Heliconius clysonymus ssp. clysonymus/14207_CAM041285_v.JPG 1\n", "Name: count, dtype: int64" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "full_df.loc[full_df[\"subspecies\"] == \"clysonomus\", \"filepath\"].value_counts()" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "full_df.loc[full_df[\"subspecies\"] == \"clysonomus\", \"Taxonomic_Name\"] = \"Heliconius clysonymus ssp. clysonymus\"\n", "full_df.loc[full_df[\"subspecies\"] == \"clysonomus\", \"species\"] = \"Heliconius clysonymus\"\n", "full_df.loc[full_df[\"subspecies\"] == \"clysonomus\", \"subspecies\"] = \"clysonymus\"" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
CAMIDXImage_nameViewzenodo_namezenodo_linkSequenceTaxonomic_NameLocalitySample_accession...file_typerecord_numberspeciessubspeciesgenusfile_urlhybrid_statfilenamefilepathmd5
\n", "

0 rows × 31 columns

\n", "
" ], "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, filename, filepath, md5]\n", "Index: []\n", "\n", "[0 rows x 31 columns]" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "full_df.loc[full_df[\"subspecies\"] == \"clysonomus\"]" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "species\n", "Heliconius clysonymus 156\n", "Name: count, dtype: int64\n" ] }, { "data": { "text/plain": [ "Taxonomic_Name\n", "Heliconius clysonymus ssp. clysonymus 156\n", "Name: count, dtype: int64" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "print(full_df.loc[full_df[\"subspecies\"] == \"clysonymus\", \"species\"].value_counts())\n", "full_df.loc[full_df[\"subspecies\"] == \"clysonymus\", \"Taxonomic_Name\"].value_counts()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Great, all fixed! Need to do the same for the other two CSVs." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "df_list = [full_df, heli_df, dorsal_df]\n", "col_list = [\"filepath\", \"Taxonomic_Name\", \"species\", \"subspecies\"]" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "typos: 0\n", "actual: 156\n", "typos: 20\n", "actual: 136\n", "typos: 10\n", "actual: 68\n" ] } ], "source": [ "for df in df_list:\n", " print(\"typos: \", df.loc[df[\"subspecies\"] == \"clysonomus\"].shape[0])\n", " print(\"actual: \", df.loc[df[\"subspecies\"] == \"clysonymus\"].shape[0])" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "def fix_clysonymus(df):\n", " df = df.copy()\n", " for x in list(df.loc[df[\"subspecies\"] == \"clysonomus\", \"X\"]):\n", " for col in col_list:\n", " col_val = df.loc[df[\"X\"] == x, col].values[0]\n", " df.loc[df[\"X\"] == x, col] = col_val.replace(\"clysonomus\", \"clysonymus\")\n", " return df" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "full_df_fixed = fix_clysonymus(full_df)\n", "heli_df_fixed = fix_clysonymus(heli_df)\n", "dorsal_df_fixed = fix_clysonymus(dorsal_df)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "actual: ['Heliconius clysonymus ssp. clysonymus']\n", "actual: ['Heliconius clysonymus']\n", "actual: ['clysonymus']\n", "actual: ['Heliconius clysonymus ssp. clysonymus']\n", "actual: ['Heliconius clysonymus']\n", "actual: ['clysonymus']\n", "actual: ['Heliconius clysonymus ssp. clysonymus']\n", "actual: ['Heliconius clysonymus']\n", "actual: ['clysonymus']\n" ] } ], "source": [ "for df in df_list:\n", " for col in col_list[1:]:\n", " print(\"actual: \", df.loc[df[\"subspecies\"] == \"clysonymus\", col].unique())" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "for df in df_list:\n", " for filepath in list(df.loc[df[\"subspecies\"] == \"clysonymus\", \"filepath\"].unique()):\n", " if \"clysonomus\" in filepath:\n", " print(\"missed a typo\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Save Fixed CSVs" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "full_df_fixed.to_csv(\"../Jiggins_Zenodo_Img_Master.csv\",index = False)\n", "dorsal_df_fixed.to_csv(\"../Jiggins_Zenodo_dorsal_Img_Master.csv\", index = False)\n", "heli_df_fixed.to_csv(\"../Jiggins_Heliconius_Master.csv\", index = False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get Mimic Groups" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
subspeciesgroup1group2_if_polymorphicgroup3_if_polymorphicUnnamed: 4
0cytheracyrbiaNaNNaNNaN
1cyrbiacyrbiaNaNNaNNaN
2venuspostmanNaNNaNNaN
3vulcanusdennis_rayedNaNNaNNaN
4chestertoniichestertoniiNaNNaNNaN
\n", "
" ], "text/plain": [ " subspecies group1 group2_if_polymorphic group3_if_polymorphic \\\n", "0 cythera cyrbia NaN NaN \n", "1 cyrbia cyrbia NaN NaN \n", "2 venus postman NaN NaN \n", "3 vulcanus dennis_rayed NaN NaN \n", "4 chestertonii chestertonii NaN NaN \n", "\n", " Unnamed: 4 \n", "0 NaN \n", "1 NaN \n", "2 NaN \n", "3 NaN \n", "4 NaN " ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mimic_gp_df.head()" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "def add_mimic_group(df):\n", " df = df.copy()\n", " for subspecies in list(df.subspecies.dropna().unique()):\n", " if subspecies in list(mimic_gp_df.subspecies.unique()):\n", " temp_mimic = mimic_gp_df.loc[mimic_gp_df[\"subspecies\"] == subspecies]\n", " df.loc[df[\"subspecies\"] == subspecies, \"mimic_group\"] = temp_mimic[\"group1\"].values[0]\n", " if temp_mimic[\"group2_if_polymorphic\"] is not None:\n", " df.loc[df[\"subspecies\"] == subspecies, \"mimic_group_2\"] = temp_mimic[\"group2_if_polymorphic\"].values[0]\n", " if temp_mimic[\"group3_if_polymorphic\"] is not None:\n", " df.loc[df[\"subspecies\"] == subspecies, \"mimic_group_3\"] = temp_mimic[\"group3_if_polymorphic\"].values[0]\n", " return df" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "full_df_mimic_gp = add_mimic_group(full_df_fixed)\n", "heli_df_mimic_gp = add_mimic_group(heli_df_fixed)\n", "dorsal_df_mimic_gp = add_mimic_group(dorsal_df_fixed)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "mimic_group : 22\n", "mimic_group\n", "dennis_rayed 7031\n", "cyrbia 2164\n", "postman_yellowbar 1368\n", "postman 1236\n", "notabilis 617\n", "plesseni 500\n", "blue_yellow 473\n", "cydnides 304\n", "chioneus 239\n", "chestertonii 185\n", "inverse_postman 176\n", "telesiphe 72\n", "leuce 70\n", "bicoloratus 34\n", "Elzunia 18\n", "charithonia 12\n", "superioris 10\n", "silvana 9\n", "messene 6\n", "tarapotensis 4\n", "longarena 4\n", "zuleika 2\n", "Name: count, dtype: int64\n", "mimic_group_2 : 2\n", "mimic_group_2\n", "dennis_rayed 72\n", "postman_yellowbar 2\n", "Name: count, dtype: int64\n", "mimic_group_3 : 1\n", "mimic_group_3\n", "green 72\n", "Name: count, dtype: int64\n", "\n", "mimic_group : 22\n", "mimic_group\n", "dennis_rayed 7031\n", "cyrbia 2164\n", "postman_yellowbar 1368\n", "postman 1236\n", "notabilis 617\n", "plesseni 500\n", "blue_yellow 473\n", "cydnides 304\n", "chioneus 239\n", "chestertonii 185\n", "inverse_postman 176\n", "telesiphe 72\n", "leuce 70\n", "bicoloratus 34\n", "Elzunia 18\n", "charithonia 12\n", "superioris 10\n", "silvana 9\n", "messene 6\n", "tarapotensis 4\n", "longarena 4\n", "zuleika 2\n", "Name: count, dtype: int64\n", "mimic_group_2 : 2\n", "mimic_group_2\n", "dennis_rayed 72\n", "postman_yellowbar 2\n", "Name: count, dtype: int64\n", "mimic_group_3 : 1\n", "mimic_group_3\n", "green 72\n", "Name: count, dtype: int64\n", "\n", "mimic_group : 22\n", "mimic_group\n", "dennis_rayed 3150\n", "cyrbia 1085\n", "postman_yellowbar 681\n", "postman 619\n", "notabilis 310\n", "plesseni 251\n", "blue_yellow 240\n", "cydnides 153\n", "chioneus 120\n", "chestertonii 92\n", "inverse_postman 88\n", "telesiphe 36\n", "leuce 35\n", "bicoloratus 17\n", "Elzunia 9\n", "charithonia 6\n", "superioris 5\n", "silvana 4\n", "messene 3\n", "tarapotensis 2\n", "longarena 2\n", "zuleika 1\n", "Name: count, dtype: int64\n", "mimic_group_2 : 2\n", "mimic_group_2\n", "dennis_rayed 36\n", "postman_yellowbar 1\n", "Name: count, dtype: int64\n", "mimic_group_3 : 1\n", "mimic_group_3\n", "green 36\n", "Name: count, dtype: int64\n", "\n" ] } ], "source": [ "for df in [full_df_mimic_gp, heli_df_mimic_gp, dorsal_df_mimic_gp]:\n", " for col in [\"mimic_group\", \"mimic_group_2\", \"mimic_group_3\"]:\n", " print(col, \": \", df[col].nunique())\n", " print(df[col].value_counts())\n", " print()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Save Mimic Group CSVs" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "full_df_mimic_gp.to_csv(\"../Jiggins_Zenodo_Img_Master.csv\",index = False)\n", "dorsal_df_mimic_gp.to_csv(\"../Jiggins_Zenodo_dorsal_Img_Master.csv\", index = False)\n", "heli_df_mimic_gp.to_csv(\"../Jiggins_Heliconius_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" } }, "nbformat": 4, "nbformat_minor": 2 }