{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "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 10\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", "dtype: int64" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.nunique()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "file_type\n", "jpg 37072\n", "raw 12226\n", "tif 61\n", "Name: count, dtype: int64" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.file_type.value_counts()" ] }, { "cell_type": "code", "execution_count": 5, "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": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.View.value_counts()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Not great that `ventral` gets listed twice as lowercase and _again_ as `Ventral`.\n", "\n", "### Standardize `View` Column\n", "Let's standardize `View` so that there isn't a discrepancy based on case." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "View\n", "dorsal 23488\n", "ventral 21514\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": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[\"View\"] = df.View.str.lower()\n", "df.View.value_counts()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['dorsal' 'ventral' nan 'dorsal and ventral' 'ventral ' 'forewing dorsal'\n", " 'hindwing dorsal' 'forewing ventral' 'hindwing ventral']\n" ] } ], "source": [ "print(df.View.unique())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Yes, one has a space after it, so we'll replace that." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "View\n", "dorsal 23488\n", "ventral 23158\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.loc[df[\"View\"] == \"ventral \", \"View\"] = \"ventral\"\n", "df.View.value_counts() " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Add Record Number Column\n", "We'll add a `record_number` column for easier matching to the license/citation file." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "def get_record_number(url):\n", " num = url.split(sep = \"/\")[-1]\n", " return num" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "32" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[\"record_number\"] = df.zenodo_link.apply(get_record_number)\n", "df.record_number.nunique()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We have 32 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 `species` and `subspecies` Columns\n", "This will make some analysis easier and allow for easy viewing on the [Data Dashboard](https://huggingface.co./spaces/imageomics/dashboard-prototype)." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "def get_species(taxa_name):\n", " if type(taxa_name) != float: #taxa name not null\n", " species = taxa_name.split(sep = \" ssp\")[0]\n", " return species\n", " else:\n", " return taxa_name" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "def get_subspecies(taxa_name):\n", " if type(taxa_name) != float:\n", " if \"ssp.\" in taxa_name:\n", " subspecies = taxa_name.split(sep = \"ssp. \")[1]\n", " elif \"ssp \" in taxa_name:\n", " subspecies = taxa_name.split(sep = \"ssp \")[1]\n", " else:\n", " subspecies = None\n", " else:\n", " subspecies = None\n", " return subspecies" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "246" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[\"species\"] = df.Taxonomic_Name.apply(get_species)\n", "df.species.nunique()" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "139" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[\"subspecies\"] = df.Taxonomic_Name.apply(get_subspecies)\n", "df.subspecies.nunique()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Cross Types are labeled differently:\n", "They are all abbreviations, we have `malleti (mal), plesseni (ple), notabilis (not), lativitta (lat)`, and Neil would guess that `latRo` refers to lativitta with a rounded apical band (e.g., a phenotypic variant of lativitta), but he couldn't say for sure without some more digging, so that will have to stay as-is. We will leave the `Test cross...` ones, but there is not much more to do with them." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array(['mal', 'mal x ple', 'ple', 'ple x mal', 'latRo x not',\n", " '(latRo x not) x not', '(mal x ple) x mal', '(mal x ple) x ple',\n", " 'ple x (mal x ple)', '(ple x mal) x (mal x ple)', 'lat x not',\n", " '(ple x mal) x ple', '(mal x ple) x (mal x ple)',\n", " '(ple x mal) x mal', '(ple x mal) x (ple x mal)',\n", " '(mal x ple) x (ple x mal)', 'hybrid', 'mal x (ple x mal)',\n", " '(lat x not) x lat', '(lat x not) x not', 'Ac heterozygote',\n", " 'ple x (ple x mal)', '2 banded', 'lat',\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 mal - thin)'], dtype=object)" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.Cross_Type.dropna().unique()" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "def clean_cross_types(cross_type):\n", " if type(cross_type) != float:\n", " cross_type = cross_type.replace(\"mal\", \"malleti\")\n", " cross_type = cross_type.replace(\"ple\", \"plesseni\")\n", " cross_type = cross_type.replace(\"not\", \"notabilis\")\n", " if \"latRo\" not in cross_type:\n", " #latRo does not cross with lativitta, so only apply when latRo isn't present\n", " cross_type = cross_type.replace(\"lat\", \"lativitta\")\n", " return cross_type" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "df[\"Cross_Type\"] = df[\"Cross_Type\"].apply(clean_cross_types)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we can fill these cross types in for the `subspecies` column (all Cross Types are just labeled to the spceies level in `Taxonomic_Name`, so they did not get processed previously)." ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "156" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cross_type_subspecies = [ct for ct in list(df.Cross_Type.dropna().unique()) if \"Test\" not in ct and \"banded\" not in ct]\n", "cross_type_subspecies.remove(\"hybrid\")\n", "cross_type_subspecies.remove(\"Ac heterozygote\")\n", "\n", "for ct in cross_type_subspecies:\n", " df.loc[df[\"Cross_Type\"] == ct, \"subspecies\"] = ct\n", "\n", "df.subspecies.nunique()\n" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "21" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(cross_type_subspecies)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "subspecies\n", "(malleti x plesseni) x malleti 1204\n", "plesseni x (malleti x plesseni) 600\n", "malleti x (plesseni x malleti) 370\n", "(plesseni x malleti) x plesseni 363\n", "(plesseni x malleti) x (malleti x plesseni) 354\n", "(plesseni x malleti) x (plesseni x malleti) 286\n", "(malleti x plesseni) x plesseni 278\n", "plesseni x malleti 234\n", "malleti x plesseni 192\n", "lativitta x notabilis 136\n", "(lativitta x notabilis) x lativitta 110\n", "plesseni x (plesseni x malleti) 106\n", "(lativitta x notabilis) x notabilis 106\n", "(malleti x plesseni) x (malleti x plesseni) 98\n", "(plesseni x malleti) x malleti 80\n", "(malleti x plesseni) x (plesseni x malleti) 56\n", "malleti 28\n", "plesseni 28\n", "(latRo x notabilis) x notabilis 16\n", "latRo x notabilis 4\n", "lativitta 4\n", "Name: count, dtype: int64" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[df[\"Cross_Type\"].notna(), \"subspecies\"].value_counts()" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "4\n" ] }, { "data": { "text/plain": [ "['malleti', 'plesseni', 'plesseni x malleti', 'lativitta']" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "already_present_subspecies = []\n", "\n", "for subspecies in list(df.loc[df[\"Cross_Type\"].notna(), \"subspecies\"].dropna().unique()):\n", " if subspecies in list(df.loc[~df[\"Cross_Type\"].notna(), \"subspecies\"].dropna().unique()):\n", " already_present_subspecies.append(subspecies)\n", "\n", "print(len(already_present_subspecies))\n", "already_present_subspecies" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Perfect, this adds 17 more subspecies (`lativitta`, `plessani`, `maletti`, and `plesseni x malleti` were already represented). Note, this is based on _exact_ duplicates. `notabilis x lativitta` is also already in the dataset, but the order (where the cross types are concerned) general goes `maternal x paternal`." ] }, { "cell_type": "code", "execution_count": 22, "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", "
CAMIDXImage_nameViewzenodo_namezenodo_linkSequenceTaxonomic_NameLocalitySample_accession...BroodDeath_DateCross_TypeStageSexUnit_Typefile_typerecord_numberspeciessubspecies
198619N19892136919N1989_v.JPGventral0.sheffield.ps.nn.ikiam.batch2.csvhttps://zenodo.org/record/42883111,989Heliconius melpomene ssp. malletiIkiam MariposarioNaN...IKIAM.P44NaNNaNNaNMalerearedjpg4288311Heliconius melpomenemalleti
45062CAM04442334391CAM044423_d.CR2dorsalbatch2.Peru.image.names.Zenodo.csvhttps://zenodo.org/record/428744444,423Taygetis cleopatraB6old6NaN...NaNNaNNaNNaNNaNNaNraw4287444Taygetis cleopatraNone
48534E2337555E23_d.CR2dorsalAnniina.Matilla.Field.Caught.E.csvhttps://zenodo.org/record/2554218NaNNaNNaNNaN...NaNNaNNaNNaNNaNNaNraw2554218NaNNone
45206CAM04444537132CAM044445_d.JPGdorsalbatch3.Peru.image.names.Zenodo.csvhttps://zenodo.org/record/428825044,445Taygetis cleopatraB4old2NaN...NaNNaNNaNNaNNaNNaNjpg4288250Taygetis cleopatraNone
12212CAM0102382330710238v.jpgventralHeliconius_wing_old_photos_2001_2019_part1.csvhttps://zenodo.org/record/255237110,238Heliconius sp.NaNNaN...B043NaNNaNNaNFemalerearedjpg2552371Heliconius sp.None
39059CAM04341830654CAM043418_v.JPGventralbatch1.Peru.image.names.Zenodo.csvhttps://zenodo.org/record/356959843,418Archaeoprepona licomedesB6rec6NaN...NaNNaNNaNNaNNaNNaNjpg3569598Archaeoprepona licomedesNone
38163CAM04317029755CAM043170_d.CR2dorsalbatch1.Peru.image.names.Zenodo.csvhttps://zenodo.org/record/356959843,170Adelpha mesentinaF3rec2NaN...NaNNaNNaNNaNNaNNaNraw3569598Adelpha mesentinaNone
\n", "

7 rows × 25 columns

\n", "
" ], "text/plain": [ " CAMID X Image_name View \\\n", "1986 19N1989 21369 19N1989_v.JPG ventral \n", "45062 CAM044423 34391 CAM044423_d.CR2 dorsal \n", "48534 E23 37555 E23_d.CR2 dorsal \n", "45206 CAM044445 37132 CAM044445_d.JPG dorsal \n", "12212 CAM010238 23307 10238v.jpg ventral \n", "39059 CAM043418 30654 CAM043418_v.JPG ventral \n", "38163 CAM043170 29755 CAM043170_d.CR2 dorsal \n", "\n", " zenodo_name \\\n", "1986 0.sheffield.ps.nn.ikiam.batch2.csv \n", "45062 batch2.Peru.image.names.Zenodo.csv \n", "48534 Anniina.Matilla.Field.Caught.E.csv \n", "45206 batch3.Peru.image.names.Zenodo.csv \n", "12212 Heliconius_wing_old_photos_2001_2019_part1.csv \n", "39059 batch1.Peru.image.names.Zenodo.csv \n", "38163 batch1.Peru.image.names.Zenodo.csv \n", "\n", " zenodo_link Sequence \\\n", "1986 https://zenodo.org/record/4288311 1,989 \n", "45062 https://zenodo.org/record/4287444 44,423 \n", "48534 https://zenodo.org/record/2554218 NaN \n", "45206 https://zenodo.org/record/4288250 44,445 \n", "12212 https://zenodo.org/record/2552371 10,238 \n", "39059 https://zenodo.org/record/3569598 43,418 \n", "38163 https://zenodo.org/record/3569598 43,170 \n", "\n", " Taxonomic_Name Locality Sample_accession \\\n", "1986 Heliconius melpomene ssp. malleti Ikiam Mariposario NaN \n", "45062 Taygetis cleopatra B6old6 NaN \n", "48534 NaN NaN NaN \n", "45206 Taygetis cleopatra B4old2 NaN \n", "12212 Heliconius sp. NaN NaN \n", "39059 Archaeoprepona licomedes B6rec6 NaN \n", "38163 Adelpha mesentina F3rec2 NaN \n", "\n", " ... Brood Death_Date Cross_Type Stage Sex Unit_Type file_type \\\n", "1986 ... IKIAM.P44 NaN NaN NaN Male reared jpg \n", "45062 ... NaN NaN NaN NaN NaN NaN raw \n", "48534 ... NaN NaN NaN NaN NaN NaN raw \n", "45206 ... NaN NaN NaN NaN NaN NaN jpg \n", "12212 ... B043 NaN NaN NaN Female reared jpg \n", "39059 ... NaN NaN NaN NaN NaN NaN jpg \n", "38163 ... NaN NaN NaN NaN NaN NaN raw \n", "\n", " record_number species subspecies \n", "1986 4288311 Heliconius melpomene malleti \n", "45062 4287444 Taygetis cleopatra None \n", "48534 2554218 NaN None \n", "45206 4288250 Taygetis cleopatra None \n", "12212 2552371 Heliconius sp. None \n", "39059 3569598 Archaeoprepona licomedes None \n", "38163 3569598 Adelpha mesentina None \n", "\n", "[7 rows x 25 columns]" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.sample(7)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Add Genus Column\n", "\n", "This willl allow us to easily remove all non Heliconius samples, and make some image stats easier to see." ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "def get_genus(species):\n", " if type(species) != float: #taxa name not null\n", " return species.split(sep = \" \")[0]\n", " return species" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "94" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[\"genus\"] = df[\"species\"].apply(get_genus)\n", "df.genus.nunique()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Final stats for all data summarized here." ] }, { "cell_type": "code", "execution_count": 25, "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 156\n", "genus 94\n", "dtype: int64" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.nunique()" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "RangeIndex: 49359 entries, 0 to 49358\n", "Data columns (total 26 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", " 22 record_number 49359 non-null object\n", " 23 species 45473 non-null object\n", " 24 subspecies 25715 non-null object\n", " 25 genus 45473 non-null object\n", "dtypes: int64(1), object(25)\n", "memory usage: 9.8+ MB\n" ] } ], "source": [ "df.info()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Observe that not all images have a species label." ] }, { "cell_type": "code", "execution_count": 27, "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", "
CAMIDXImage_nameViewzenodo_namezenodo_linkSequenceTaxonomic_NameLocalitySample_accession...Death_DateCross_TypeStageSexUnit_Typefile_typerecord_numberspeciessubspeciesgenus
48538E2437559E24_d.CR2dorsalAnniina.Matilla.Field.Caught.E.csvhttps://zenodo.org/record/2554218NaNNaNNaNNaN...NaNNaNNaNNaNNaNraw2554218NaNNoneNaN
37246CAM04204543973CAM042045_v.JPGventralCollection_August2019.csvhttps://zenodo.org/record/573158742,045NaNNaNNaN...NaNNaNNaNNaNNaNjpg5731587NaNNoneNaN
37484CAM04216644211CAM042166_v.JPGventralCollection_August2019.csvhttps://zenodo.org/record/573158742,166NaNNaNNaN...NaNNaNNaNNaNNaNjpg5731587NaNNoneNaN
48780E8337777E83_v.CR2ventralAnniina.Matilla.Field.Caught.E.csvhttps://zenodo.org/record/2554218NaNNaNNaNNaN...NaNNaNNaNNaNNaNraw2554218NaNNoneNaN
311819N26272249819N2627_v.CR2NaN0.sheffield.ps.nn.ikiam.batch2.csvhttps://zenodo.org/record/42883110NaNNaNNaN...NaNNaNNaNNaNNaNraw4288311NaNNoneNaN
46111CAM04506042806CAM045060_v.CR2ventralimage.names.cook.island.erato.csvhttps://zenodo.org/record/552625745,060NaNNaNNaN...NaNNaNNaNNaNNaNraw5526257NaNNoneNaN
39502CAM04357631097CAM043576_v.CR2ventralbatch2.Peru.image.names.Zenodo.csvhttps://zenodo.org/record/428744443,576NaNNaNNaN...NaNNaNNaNNaNNaNraw4287444NaNNoneNaN
\n", "

7 rows × 26 columns

\n", "
" ], "text/plain": [ " CAMID X Image_name View \\\n", "48538 E24 37559 E24_d.CR2 dorsal \n", "37246 CAM042045 43973 CAM042045_v.JPG ventral \n", "37484 CAM042166 44211 CAM042166_v.JPG ventral \n", "48780 E83 37777 E83_v.CR2 ventral \n", "3118 19N2627 22498 19N2627_v.CR2 NaN \n", "46111 CAM045060 42806 CAM045060_v.CR2 ventral \n", "39502 CAM043576 31097 CAM043576_v.CR2 ventral \n", "\n", " zenodo_name zenodo_link \\\n", "48538 Anniina.Matilla.Field.Caught.E.csv https://zenodo.org/record/2554218 \n", "37246 Collection_August2019.csv https://zenodo.org/record/5731587 \n", "37484 Collection_August2019.csv https://zenodo.org/record/5731587 \n", "48780 Anniina.Matilla.Field.Caught.E.csv https://zenodo.org/record/2554218 \n", "3118 0.sheffield.ps.nn.ikiam.batch2.csv https://zenodo.org/record/4288311 \n", "46111 image.names.cook.island.erato.csv https://zenodo.org/record/5526257 \n", "39502 batch2.Peru.image.names.Zenodo.csv https://zenodo.org/record/4287444 \n", "\n", " Sequence Taxonomic_Name Locality Sample_accession ... Death_Date \\\n", "48538 NaN NaN NaN NaN ... NaN \n", "37246 42,045 NaN NaN NaN ... NaN \n", "37484 42,166 NaN NaN NaN ... NaN \n", "48780 NaN NaN NaN NaN ... NaN \n", "3118 0 NaN NaN NaN ... NaN \n", "46111 45,060 NaN NaN NaN ... NaN \n", "39502 43,576 NaN NaN NaN ... NaN \n", "\n", " Cross_Type Stage Sex Unit_Type file_type record_number species \\\n", "48538 NaN NaN NaN NaN raw 2554218 NaN \n", "37246 NaN NaN NaN NaN jpg 5731587 NaN \n", "37484 NaN NaN NaN NaN jpg 5731587 NaN \n", "48780 NaN NaN NaN NaN raw 2554218 NaN \n", "3118 NaN NaN NaN NaN raw 4288311 NaN \n", "46111 NaN NaN NaN NaN raw 5526257 NaN \n", "39502 NaN NaN NaN NaN raw 4287444 NaN \n", "\n", " subspecies genus \n", "48538 None NaN \n", "37246 None NaN \n", "37484 None NaN \n", "48780 None NaN \n", "3118 None NaN \n", "46111 None NaN \n", "39502 None NaN \n", "\n", "[7 rows x 26 columns]" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.loc[df.species.isna()].sample(7)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Update Master File with Genus through Subspecies Columns" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "df.to_csv(\"../Jiggins_Zenodo_Img_Master.csv\", index = False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Make Heliconius Subset" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Index: 34929 entries, 6 to 49358\n", "Data columns (total 26 columns):\n", " # Column Non-Null Count Dtype \n", "--- ------ -------------- ----- \n", " 0 CAMID 34929 non-null object\n", " 1 X 34929 non-null int64 \n", " 2 Image_name 34929 non-null object\n", " 3 View 34150 non-null object\n", " 4 zenodo_name 34929 non-null object\n", " 5 zenodo_link 34929 non-null object\n", " 6 Sequence 34929 non-null object\n", " 7 Taxonomic_Name 34929 non-null object\n", " 8 Locality 23417 non-null object\n", " 9 Sample_accession 5860 non-null object\n", " 10 Collected_by 5280 non-null object\n", " 11 Other_ID 6404 non-null object\n", " 12 Date 23162 non-null object\n", " 13 Dataset 32846 non-null object\n", " 14 Store 29446 non-null object\n", " 15 Brood 14921 non-null object\n", " 16 Death_Date 316 non-null object\n", " 17 Cross_Type 5133 non-null object\n", " 18 Stage 6 non-null object\n", " 19 Sex 33880 non-null object\n", " 20 Unit_Type 31975 non-null object\n", " 21 file_type 34929 non-null object\n", " 22 record_number 34929 non-null object\n", " 23 species 34929 non-null object\n", " 24 subspecies 24953 non-null object\n", " 25 genus 34929 non-null object\n", "dtypes: int64(1), object(25)\n", "memory usage: 7.2+ MB\n" ] } ], "source": [ "heliconius_subset = df.loc[df.genus.str.lower() == \"heliconius\"]\n", "\n", "heliconius_subset.info()" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "CAMID 9546\n", "X 34929\n", "Image_name 26946\n", "View 3\n", "zenodo_name 31\n", "zenodo_link 28\n", "Sequence 8701\n", "Taxonomic_Name 129\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 28\n", "species 37\n", "subspecies 110\n", "genus 1\n", "dtype: int64" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "heliconius_subset.nunique()" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "View\n", "dorsal 17218\n", "ventral 16914\n", "dorsal and ventral 18\n", "Name: count, dtype: int64" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "heliconius_subset.View.value_counts()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that this subset is distributed across 28 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", "We'll drop the `genus` column, since they're all `Heliconius`." ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [], "source": [ "heliconius_subset[list(heliconius_subset.columns)[:-1]].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" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }