egrace479 commited on
Commit
8da3621
1 Parent(s): f99d846

Update master files

Browse files

Remove references to v1 of record 3082688 (deduplication)
Add in taxonomic information for 3 homogeneous records missing taxa info.

Jiggins_Heliconius_Master.csv CHANGED
The diff for this file is too large to render. See raw diff
 
Jiggins_Zenodo_Img_Master.csv CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:75f4effe4a36aaf206c6047537ab75e4037bba7b56dbd376209983f52822b7c6
3
- size 13583175
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fe79fdb62909be50eff6f7016f02301c56ce09c9c0b164dce680810ec4149b2a
3
+ size 15528648
Jiggins_Zenodo_dorsal_Img_Master.csv CHANGED
The diff for this file is too large to render. See raw diff
 
notebooks/standardize_datasets.ipynb ADDED
@@ -0,0 +1,2635 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "import pandas as pd"
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "markdown",
14
+ "metadata": {},
15
+ "source": [
16
+ "It turns out [record 3082688](https://zenodo.org/records/3082688) is version 2 of [record 1247307](https://zenodo.org/records/1247307), where some mislabeling was fixed. Images from record 1247307 should not be used, so we will remove them here.\n",
17
+ "\n",
18
+ "Will also add `hybrid_stat` and `file_url` columns so these can be explored with all functionality of the [data dashboard](https://huggingface.co/spaces/imageomics/dashboard-prototype)."
19
+ ]
20
+ },
21
+ {
22
+ "cell_type": "code",
23
+ "execution_count": 2,
24
+ "metadata": {},
25
+ "outputs": [],
26
+ "source": [
27
+ "df = pd.read_csv(\"../Jiggins_Zenodo_Img_Master.csv\", low_memory=False)"
28
+ ]
29
+ },
30
+ {
31
+ "cell_type": "code",
32
+ "execution_count": 3,
33
+ "metadata": {},
34
+ "outputs": [
35
+ {
36
+ "data": {
37
+ "text/plain": [
38
+ "CAMID 12586\n",
39
+ "X 49359\n",
40
+ "Image_name 37821\n",
41
+ "View 7\n",
42
+ "zenodo_name 36\n",
43
+ "zenodo_link 32\n",
44
+ "Sequence 11301\n",
45
+ "Taxonomic_Name 363\n",
46
+ "Locality 645\n",
47
+ "Sample_accession 1571\n",
48
+ "Collected_by 12\n",
49
+ "Other_ID 3088\n",
50
+ "Date 810\n",
51
+ "Dataset 8\n",
52
+ "Store 142\n",
53
+ "Brood 226\n",
54
+ "Death_Date 82\n",
55
+ "Cross_Type 30\n",
56
+ "Stage 1\n",
57
+ "Sex 3\n",
58
+ "Unit_Type 6\n",
59
+ "file_type 3\n",
60
+ "record_number 32\n",
61
+ "species 246\n",
62
+ "subspecies 155\n",
63
+ "genus 94\n",
64
+ "dtype: int64"
65
+ ]
66
+ },
67
+ "execution_count": 3,
68
+ "metadata": {},
69
+ "output_type": "execute_result"
70
+ }
71
+ ],
72
+ "source": [
73
+ "df.nunique()"
74
+ ]
75
+ },
76
+ {
77
+ "cell_type": "code",
78
+ "execution_count": 4,
79
+ "metadata": {},
80
+ "outputs": [
81
+ {
82
+ "name": "stdout",
83
+ "output_type": "stream",
84
+ "text": [
85
+ "<class 'pandas.core.series.Series'>\n",
86
+ "RangeIndex: 49359 entries, 0 to 49358\n",
87
+ "Series name: record_number\n",
88
+ "Non-Null Count Dtype\n",
89
+ "-------------- -----\n",
90
+ "49359 non-null int64\n",
91
+ "dtypes: int64(1)\n",
92
+ "memory usage: 385.7 KB\n"
93
+ ]
94
+ }
95
+ ],
96
+ "source": [
97
+ "df.record_number.info()"
98
+ ]
99
+ },
100
+ {
101
+ "cell_type": "code",
102
+ "execution_count": 5,
103
+ "metadata": {},
104
+ "outputs": [
105
+ {
106
+ "data": {
107
+ "text/plain": [
108
+ "CAMID 12586\n",
109
+ "X 46439\n",
110
+ "Image_name 37821\n",
111
+ "View 7\n",
112
+ "zenodo_name 35\n",
113
+ "zenodo_link 31\n",
114
+ "Sequence 11301\n",
115
+ "Taxonomic_Name 363\n",
116
+ "Locality 645\n",
117
+ "Sample_accession 1571\n",
118
+ "Collected_by 12\n",
119
+ "Other_ID 3088\n",
120
+ "Date 810\n",
121
+ "Dataset 8\n",
122
+ "Store 142\n",
123
+ "Brood 226\n",
124
+ "Death_Date 82\n",
125
+ "Cross_Type 30\n",
126
+ "Stage 1\n",
127
+ "Sex 3\n",
128
+ "Unit_Type 6\n",
129
+ "file_type 3\n",
130
+ "record_number 31\n",
131
+ "species 246\n",
132
+ "subspecies 155\n",
133
+ "genus 94\n",
134
+ "dtype: int64"
135
+ ]
136
+ },
137
+ "execution_count": 5,
138
+ "metadata": {},
139
+ "output_type": "execute_result"
140
+ }
141
+ ],
142
+ "source": [
143
+ "df = df.loc[df.record_number != 1247307]\n",
144
+ "df.nunique()"
145
+ ]
146
+ },
147
+ {
148
+ "cell_type": "markdown",
149
+ "metadata": {},
150
+ "source": [
151
+ "Checking all records on Zenodo for the [Butterfly Genetics Group](https://zenodo.org/communities/butterfly/records) (the overall source of the Jiggins data), [record 3477891](https://zenodo.org/records/3477891) and [record 2548678](https://zenodo.org/records/2548678) are marked as version 2 of records 3477412 & 1880783, respectively. Let's check that the first versions are not included.\n",
152
+ "\n",
153
+ "It is also noted in [record 2548678](https://zenodo.org/records/2548678):\n",
154
+ ">Some images overlap with 'Cambridge butterfly wing collection batch 1', taken by Eva Whiltshire. Images here differ in having a white reflectance standard for calibration. Information on duplicates can be found in 'CAM.coll.patricio.batch2.csv'.\n",
155
+ "\n",
156
+ "Note that this is a reference to [record 1247307](https://zenodo.org/records/1247307), so the overlap is in fact with Cambridge butterfly wing collection batch 1- version 2 ([record 3082688](https://zenodo.org/records/3082688)); it is unclear as yet if the duplication information will be acurate considering the mislabelings fixed between the versions."
157
+ ]
158
+ },
159
+ {
160
+ "cell_type": "code",
161
+ "execution_count": 6,
162
+ "metadata": {},
163
+ "outputs": [
164
+ {
165
+ "data": {
166
+ "text/plain": [
167
+ "(0, 26)"
168
+ ]
169
+ },
170
+ "execution_count": 6,
171
+ "metadata": {},
172
+ "output_type": "execute_result"
173
+ }
174
+ ],
175
+ "source": [
176
+ "v1s = [3477412, 1880783]\n",
177
+ "df.loc[df[\"record_number\"].isin(v1s)].shape"
178
+ ]
179
+ },
180
+ {
181
+ "cell_type": "markdown",
182
+ "metadata": {},
183
+ "source": [
184
+ "The good news is that neither of these earlier versions seem to have been picked up, so we can move on to assessing this and adding the `hybrid_stat` and `file_url` columns."
185
+ ]
186
+ },
187
+ {
188
+ "cell_type": "code",
189
+ "execution_count": 7,
190
+ "metadata": {},
191
+ "outputs": [
192
+ {
193
+ "data": {
194
+ "text/plain": [
195
+ "file_type\n",
196
+ "jpg 34152\n",
197
+ "raw 12226\n",
198
+ "tif 61\n",
199
+ "Name: count, dtype: int64"
200
+ ]
201
+ },
202
+ "execution_count": 7,
203
+ "metadata": {},
204
+ "output_type": "execute_result"
205
+ }
206
+ ],
207
+ "source": [
208
+ "df.file_type.value_counts()"
209
+ ]
210
+ },
211
+ {
212
+ "cell_type": "code",
213
+ "execution_count": 8,
214
+ "metadata": {},
215
+ "outputs": [
216
+ {
217
+ "data": {
218
+ "text/plain": [
219
+ "View\n",
220
+ "dorsal 22022\n",
221
+ "ventral 21704\n",
222
+ "forewing dorsal 406\n",
223
+ "hindwing dorsal 406\n",
224
+ "forewing ventral 406\n",
225
+ "hindwing ventral 406\n",
226
+ "dorsal and ventral 18\n",
227
+ "Name: count, dtype: int64"
228
+ ]
229
+ },
230
+ "execution_count": 8,
231
+ "metadata": {},
232
+ "output_type": "execute_result"
233
+ }
234
+ ],
235
+ "source": [
236
+ "df.View.value_counts()"
237
+ ]
238
+ },
239
+ {
240
+ "cell_type": "markdown",
241
+ "metadata": {},
242
+ "source": [
243
+ "We have 31 unique records represented in the full dataset. When we reduce down to just the Heliconius images, this will probably be less."
244
+ ]
245
+ },
246
+ {
247
+ "cell_type": "markdown",
248
+ "metadata": {},
249
+ "source": [
250
+ "### Add File URL Column"
251
+ ]
252
+ },
253
+ {
254
+ "cell_type": "code",
255
+ "execution_count": 9,
256
+ "metadata": {},
257
+ "outputs": [
258
+ {
259
+ "data": {
260
+ "text/html": [
261
+ "<div>\n",
262
+ "<style scoped>\n",
263
+ " .dataframe tbody tr th:only-of-type {\n",
264
+ " vertical-align: middle;\n",
265
+ " }\n",
266
+ "\n",
267
+ " .dataframe tbody tr th {\n",
268
+ " vertical-align: top;\n",
269
+ " }\n",
270
+ "\n",
271
+ " .dataframe thead th {\n",
272
+ " text-align: right;\n",
273
+ " }\n",
274
+ "</style>\n",
275
+ "<table border=\"1\" class=\"dataframe\">\n",
276
+ " <thead>\n",
277
+ " <tr style=\"text-align: right;\">\n",
278
+ " <th></th>\n",
279
+ " <th>CAMID</th>\n",
280
+ " <th>X</th>\n",
281
+ " <th>Image_name</th>\n",
282
+ " <th>View</th>\n",
283
+ " <th>zenodo_name</th>\n",
284
+ " <th>zenodo_link</th>\n",
285
+ " <th>Sequence</th>\n",
286
+ " <th>Taxonomic_Name</th>\n",
287
+ " <th>Locality</th>\n",
288
+ " <th>Sample_accession</th>\n",
289
+ " <th>...</th>\n",
290
+ " <th>Cross_Type</th>\n",
291
+ " <th>Stage</th>\n",
292
+ " <th>Sex</th>\n",
293
+ " <th>Unit_Type</th>\n",
294
+ " <th>file_type</th>\n",
295
+ " <th>record_number</th>\n",
296
+ " <th>species</th>\n",
297
+ " <th>subspecies</th>\n",
298
+ " <th>genus</th>\n",
299
+ " <th>file_url</th>\n",
300
+ " </tr>\n",
301
+ " </thead>\n",
302
+ " <tbody>\n",
303
+ " <tr>\n",
304
+ " <th>34925</th>\n",
305
+ " <td>CAM041457</td>\n",
306
+ " <td>38799</td>\n",
307
+ " <td>CAM041457_d.CR2</td>\n",
308
+ " <td>dorsal</td>\n",
309
+ " <td>0.gmk.broods.all.csv</td>\n",
310
+ " <td>https://zenodo.org/record/4291095</td>\n",
311
+ " <td>41,457</td>\n",
312
+ " <td>Heliconius timareta</td>\n",
313
+ " <td>Reventador road 2</td>\n",
314
+ " <td>NaN</td>\n",
315
+ " <td>...</td>\n",
316
+ " <td>NaN</td>\n",
317
+ " <td>NaN</td>\n",
318
+ " <td>Male</td>\n",
319
+ " <td>NaN</td>\n",
320
+ " <td>raw</td>\n",
321
+ " <td>4291095</td>\n",
322
+ " <td>Heliconius timareta</td>\n",
323
+ " <td>NaN</td>\n",
324
+ " <td>Heliconius</td>\n",
325
+ " <td>https://zenodo.org/record/4291095/files/CAM041...</td>\n",
326
+ " </tr>\n",
327
+ " <tr>\n",
328
+ " <th>28286</th>\n",
329
+ " <td>CAM036145</td>\n",
330
+ " <td>41369</td>\n",
331
+ " <td>CAM036145_v.JPG</td>\n",
332
+ " <td>ventral</td>\n",
333
+ " <td>Filelist.csv</td>\n",
334
+ " <td>https://zenodo.org/record/5561246</td>\n",
335
+ " <td>36,145</td>\n",
336
+ " <td>Methona singularis</td>\n",
337
+ " <td>Guaribas - RG16</td>\n",
338
+ " <td>NaN</td>\n",
339
+ " <td>...</td>\n",
340
+ " <td>NaN</td>\n",
341
+ " <td>NaN</td>\n",
342
+ " <td>Male</td>\n",
343
+ " <td>NaN</td>\n",
344
+ " <td>jpg</td>\n",
345
+ " <td>5561246</td>\n",
346
+ " <td>Methona singularis</td>\n",
347
+ " <td>NaN</td>\n",
348
+ " <td>Methona</td>\n",
349
+ " <td>https://zenodo.org/record/5561246/files/CAM036...</td>\n",
350
+ " </tr>\n",
351
+ " <tr>\n",
352
+ " <th>21858</th>\n",
353
+ " <td>CAM017409</td>\n",
354
+ " <td>19047</td>\n",
355
+ " <td>CAM017409_d.CR2</td>\n",
356
+ " <td>dorsal</td>\n",
357
+ " <td>CAM.coll.PS.list.individuals.haplotagging.new....</td>\n",
358
+ " <td>https://zenodo.org/record/4153502</td>\n",
359
+ " <td>17,409</td>\n",
360
+ " <td>Heliconius erato ssp. lativitta</td>\n",
361
+ " <td>San Pedro de Arajuno, Río Arajuno</td>\n",
362
+ " <td>ERS353373</td>\n",
363
+ " <td>...</td>\n",
364
+ " <td>NaN</td>\n",
365
+ " <td>NaN</td>\n",
366
+ " <td>Female</td>\n",
367
+ " <td>wild</td>\n",
368
+ " <td>raw</td>\n",
369
+ " <td>4153502</td>\n",
370
+ " <td>Heliconius erato</td>\n",
371
+ " <td>lativitta</td>\n",
372
+ " <td>Heliconius</td>\n",
373
+ " <td>https://zenodo.org/record/4153502/files/CAM017...</td>\n",
374
+ " </tr>\n",
375
+ " <tr>\n",
376
+ " <th>12708</th>\n",
377
+ " <td>CAM010412</td>\n",
378
+ " <td>26792</td>\n",
379
+ " <td>CAM010412_v.CR2</td>\n",
380
+ " <td>ventral</td>\n",
381
+ " <td>2001_2.broods.batch.1.csv</td>\n",
382
+ " <td>https://zenodo.org/record/2549524</td>\n",
383
+ " <td>10,412</td>\n",
384
+ " <td>Heliconius sp.</td>\n",
385
+ " <td>NaN</td>\n",
386
+ " <td>NaN</td>\n",
387
+ " <td>...</td>\n",
388
+ " <td>NaN</td>\n",
389
+ " <td>NaN</td>\n",
390
+ " <td>Unknown</td>\n",
391
+ " <td>reared</td>\n",
392
+ " <td>raw</td>\n",
393
+ " <td>2549524</td>\n",
394
+ " <td>Heliconius sp.</td>\n",
395
+ " <td>NaN</td>\n",
396
+ " <td>Heliconius</td>\n",
397
+ " <td>https://zenodo.org/record/2549524/files/CAM010...</td>\n",
398
+ " </tr>\n",
399
+ " </tbody>\n",
400
+ "</table>\n",
401
+ "<p>4 rows × 27 columns</p>\n",
402
+ "</div>"
403
+ ],
404
+ "text/plain": [
405
+ " CAMID X Image_name View \\\n",
406
+ "34925 CAM041457 38799 CAM041457_d.CR2 dorsal \n",
407
+ "28286 CAM036145 41369 CAM036145_v.JPG ventral \n",
408
+ "21858 CAM017409 19047 CAM017409_d.CR2 dorsal \n",
409
+ "12708 CAM010412 26792 CAM010412_v.CR2 ventral \n",
410
+ "\n",
411
+ " zenodo_name \\\n",
412
+ "34925 0.gmk.broods.all.csv \n",
413
+ "28286 Filelist.csv \n",
414
+ "21858 CAM.coll.PS.list.individuals.haplotagging.new.... \n",
415
+ "12708 2001_2.broods.batch.1.csv \n",
416
+ "\n",
417
+ " zenodo_link Sequence \\\n",
418
+ "34925 https://zenodo.org/record/4291095 41,457 \n",
419
+ "28286 https://zenodo.org/record/5561246 36,145 \n",
420
+ "21858 https://zenodo.org/record/4153502 17,409 \n",
421
+ "12708 https://zenodo.org/record/2549524 10,412 \n",
422
+ "\n",
423
+ " Taxonomic_Name Locality \\\n",
424
+ "34925 Heliconius timareta Reventador road 2 \n",
425
+ "28286 Methona singularis Guaribas - RG16 \n",
426
+ "21858 Heliconius erato ssp. lativitta San Pedro de Arajuno, Río Arajuno \n",
427
+ "12708 Heliconius sp. NaN \n",
428
+ "\n",
429
+ " Sample_accession ... Cross_Type Stage Sex Unit_Type file_type \\\n",
430
+ "34925 NaN ... NaN NaN Male NaN raw \n",
431
+ "28286 NaN ... NaN NaN Male NaN jpg \n",
432
+ "21858 ERS353373 ... NaN NaN Female wild raw \n",
433
+ "12708 NaN ... NaN NaN Unknown reared raw \n",
434
+ "\n",
435
+ " record_number species subspecies genus \\\n",
436
+ "34925 4291095 Heliconius timareta NaN Heliconius \n",
437
+ "28286 5561246 Methona singularis NaN Methona \n",
438
+ "21858 4153502 Heliconius erato lativitta Heliconius \n",
439
+ "12708 2549524 Heliconius sp. NaN Heliconius \n",
440
+ "\n",
441
+ " file_url \n",
442
+ "34925 https://zenodo.org/record/4291095/files/CAM041... \n",
443
+ "28286 https://zenodo.org/record/5561246/files/CAM036... \n",
444
+ "21858 https://zenodo.org/record/4153502/files/CAM017... \n",
445
+ "12708 https://zenodo.org/record/2549524/files/CAM010... \n",
446
+ "\n",
447
+ "[4 rows x 27 columns]"
448
+ ]
449
+ },
450
+ "execution_count": 9,
451
+ "metadata": {},
452
+ "output_type": "execute_result"
453
+ }
454
+ ],
455
+ "source": [
456
+ "df[\"file_url\"] = df[\"zenodo_link\"] + \"/files/\" + df[\"Image_name\"]\n",
457
+ "df.sample(4)"
458
+ ]
459
+ },
460
+ {
461
+ "cell_type": "markdown",
462
+ "metadata": {},
463
+ "source": [
464
+ "### Add Proper Taxonomic Name for Crosstypes\n",
465
+ "\n",
466
+ "We want the cross types to also have full taxonomic names (`Heliconius <species> <subspecies>`) so this can be used in downloading to appropriate branches and also for easier diversity counts. Cross Types will still be easily filtered using the `Cross_Type` column."
467
+ ]
468
+ },
469
+ {
470
+ "cell_type": "code",
471
+ "execution_count": 10,
472
+ "metadata": {},
473
+ "outputs": [
474
+ {
475
+ "data": {
476
+ "text/plain": [
477
+ "subspecies\n",
478
+ "(malleti x plesseni) x malleti 1007\n",
479
+ "plesseni x (malleti x plesseni) 462\n",
480
+ "(plesseni x malleti) x (malleti x plesseni) 348\n",
481
+ "(plesseni x malleti) x plesseni 345\n",
482
+ "malleti x (plesseni x malleti) 324\n",
483
+ "(plesseni x malleti) x (plesseni x malleti) 228\n",
484
+ "(malleti x plesseni) x plesseni 216\n",
485
+ "plesseni x malleti 212\n",
486
+ "malleti x plesseni 156\n",
487
+ "lativitta x notabilis 111\n",
488
+ "plesseni x (plesseni x malleti) 106\n",
489
+ "(lativitta x notabilis) x notabilis 90\n",
490
+ "(lativitta x notabilis) x lativitta 90\n",
491
+ "(malleti x plesseni) x (malleti x plesseni) 81\n",
492
+ "(plesseni x malleti) x malleti 80\n",
493
+ "(malleti x plesseni) x (plesseni x malleti) 42\n",
494
+ "malleti 28\n",
495
+ "plesseni 28\n",
496
+ "(latRo x notabilis) x notabilis 12\n",
497
+ "latRo x notabilis 4\n",
498
+ "lativitta 4\n",
499
+ "Name: count, dtype: int64"
500
+ ]
501
+ },
502
+ "execution_count": 10,
503
+ "metadata": {},
504
+ "output_type": "execute_result"
505
+ }
506
+ ],
507
+ "source": [
508
+ "df.loc[df[\"Cross_Type\"].notna(), \"subspecies\"].value_counts()"
509
+ ]
510
+ },
511
+ {
512
+ "cell_type": "code",
513
+ "execution_count": 11,
514
+ "metadata": {},
515
+ "outputs": [
516
+ {
517
+ "data": {
518
+ "text/plain": [
519
+ "Cross_Type\n",
520
+ "Test cross (4 spots x 4 spots) 150\n",
521
+ "Test cross (N heterozygocity - NBNN x malleti - thin) 114\n",
522
+ "Test cross (N heterozygozity) 78\n",
523
+ "Test cross (short HW bar) 54\n",
524
+ "Test cross (4 spots x 2 banded) 48\n",
525
+ "2 banded 16\n",
526
+ "hybrid 10\n",
527
+ "Ac heterozygote 4\n",
528
+ "Test cross (2 banded F2 x 2 banded F2) 4\n",
529
+ "Name: count, dtype: int64"
530
+ ]
531
+ },
532
+ "execution_count": 11,
533
+ "metadata": {},
534
+ "output_type": "execute_result"
535
+ }
536
+ ],
537
+ "source": [
538
+ "df.loc[(df[\"Cross_Type\"].notna()) & (df[\"subspecies\"].isna()), \"Cross_Type\"].value_counts()"
539
+ ]
540
+ },
541
+ {
542
+ "cell_type": "markdown",
543
+ "metadata": {},
544
+ "source": [
545
+ "Notice that we have hybrids here which should be indicated as such though they don't all have an ` x ` in their name. We'll remember this for the `hybrid_stat` column and generate using the Cross Type indicator. Our only non-hybrid Cross Types are `malleti`, `plesseni`, and `lativitta`."
546
+ ]
547
+ },
548
+ {
549
+ "cell_type": "code",
550
+ "execution_count": 12,
551
+ "metadata": {},
552
+ "outputs": [
553
+ {
554
+ "data": {
555
+ "text/plain": [
556
+ "array(['hybrid', 'Ac heterozygote', '2 banded',\n",
557
+ " 'Test cross (2 banded F2 x 2 banded F2)',\n",
558
+ " 'Test cross (4 spots x 2 banded)', 'Test cross (N heterozygozity)',\n",
559
+ " 'Test cross (short HW bar)', 'Test cross (4 spots x 4 spots)',\n",
560
+ " 'Test cross (N heterozygocity - NBNN x malleti - thin)'],\n",
561
+ " dtype=object)"
562
+ ]
563
+ },
564
+ "execution_count": 12,
565
+ "metadata": {},
566
+ "output_type": "execute_result"
567
+ }
568
+ ],
569
+ "source": [
570
+ "non_specific_cross_hybrids = df.loc[(df[\"Cross_Type\"].notna()) & (df[\"subspecies\"].isna()), \"Cross_Type\"].unique()\n",
571
+ "non_specific_cross_hybrids"
572
+ ]
573
+ },
574
+ {
575
+ "cell_type": "code",
576
+ "execution_count": 13,
577
+ "metadata": {},
578
+ "outputs": [
579
+ {
580
+ "data": {
581
+ "text/plain": [
582
+ "array(['cythera', 'cyrbia', 'venus', 'venus x chestertonii', 'vulcanus',\n",
583
+ " 'chestertonii', 'vulcanus x melpomene', 'lativitta', 'malleti',\n",
584
+ " 'erato', 'ssp.nov.P', 'melpomene', 'willmotti',\n",
585
+ " 'chestertonii x venus', 'eleuchia', 'cydnides', 'weymeri',\n",
586
+ " 'chioneus', 'demophoon', 'hydara', 'sapho', 'numata', 'iulia',\n",
587
+ " 'melpomene x thelxiope', 'wallacei', 'rosina', 'formosus',\n",
588
+ " 'melpomene x rosina', 'menapis', 'hydara x petiverana', 'decumana',\n",
589
+ " 'relata', 'agna', 'isthmia', 'bicoloratus', 'euphrasius',\n",
590
+ " 'salapia', 'matronalis', 'ethica', 'agnosia', 'andromica',\n",
591
+ " 'hippocrenis', 'saturata', 'evanides', 'lyra', 'pagasa',\n",
592
+ " 'staudingeri', 'valora', 'cassotis', 'chiriquensis', 'alithea',\n",
593
+ " 'timareta', 'plesseni', 'notabilis', 'amaryllis', 'thelxinoe',\n",
594
+ " 'doris', 'amaryllis x aglaope', 'aglaope', 'carbo', 'lycaste',\n",
595
+ " 'idae', 'macrinus', 'abida', 'notilla', 'neustetteri', 'giulia',\n",
596
+ " 'panamensis', 'eleusinus', 'agalla', 'xanthina', 'ecuadorensis',\n",
597
+ " 'congener', 'etylus', 'derasa', 'lenaeus', 'petiverana',\n",
598
+ " 'melicerta', 'thelxiopeia', 'meriana', 'plesseni x malleti',\n",
599
+ " 'notabilis x lativitta', 'sara', 'silvana', 'amalfreda',\n",
600
+ " 'hydara x amalfreda', 'flavescens', 'hydara x erato',\n",
601
+ " 'meriana x melpomene', 'nanna', 'daetina', 'nesaea', 'phyllis',\n",
602
+ " 'laphria', 'paraiya', 'lysimnia', 'daeta', 'yanetta', 'pyrrha',\n",
603
+ " 'casabranca', 'tristero', 'dignus', 'bellula',\n",
604
+ " 'dignus x lativitta', 'malleti x bellula', 'napoensis',\n",
605
+ " 'clysonymus', 'sotericus', 'primularis', 'sprucei', 'bassleri',\n",
606
+ " 'eximius', 'manabiana', 'nigrippus', 'hygiana', 'neildi',\n",
607
+ " 'clysonomus', 'hierax', 'magdalena', 'calathus', 'corena',\n",
608
+ " 'zelinde', 'florencia', 'weymeri f. gustavi', 'weymeri f. weymeri',\n",
609
+ " 'wanningeri', 'cydno', 'cordula', 'linaresi', 'lisethae',\n",
610
+ " 'hermogenes', 'martinae', 'vicina', 'malleti x vicina',\n",
611
+ " 'reductimacula', 'sergestus', 'felix', 'aerotome'], dtype=object)"
612
+ ]
613
+ },
614
+ "execution_count": 13,
615
+ "metadata": {},
616
+ "output_type": "execute_result"
617
+ }
618
+ ],
619
+ "source": [
620
+ "df.loc[df[\"Cross_Type\"].isna(), \"subspecies\"].dropna().unique()"
621
+ ]
622
+ },
623
+ {
624
+ "cell_type": "code",
625
+ "execution_count": 14,
626
+ "metadata": {},
627
+ "outputs": [],
628
+ "source": [
629
+ "def get_cross_taxa_name(species, cross_type):\n",
630
+ " # label unspecified hybrids as such\n",
631
+ " if cross_type in non_specific_cross_hybrids:\n",
632
+ " return species + \" \" + \"cross hybrid\"\n",
633
+ " \n",
634
+ " # separate out hybrids from non-hybrids\n",
635
+ " subsp_cross_list = cross_type.split(\"(\")\n",
636
+ " if len(subsp_cross_list) > 1:\n",
637
+ " subsp_cross = subsp_cross_list[1].split(\")\")[0]\n",
638
+ " else:\n",
639
+ " subsp_cross = cross_type\n",
640
+ " \n",
641
+ " # Ensure order of hybrid names is consistent so they get placed in same folders (using scripts/download_jiggins.py)\n",
642
+ " # And so counts by taxonomic name aren't needlessly skewed\n",
643
+ " if subsp_cross == \"malleti x plesseni\":\n",
644
+ " subsp_cross = \"plesseni x malleti\"\n",
645
+ " elif subsp_cross == \"lativitta x notabilis\":\n",
646
+ " subsp_cross = \"notabilis x lativitta\"\n",
647
+ " \n",
648
+ " # Set taxa_name as with non cross types labeled to subspecies\n",
649
+ " taxa_name = species + \" ssp. \" + subsp_cross\n",
650
+ " return taxa_name"
651
+ ]
652
+ },
653
+ {
654
+ "cell_type": "code",
655
+ "execution_count": 15,
656
+ "metadata": {},
657
+ "outputs": [
658
+ {
659
+ "name": "stdout",
660
+ "output_type": "stream",
661
+ "text": [
662
+ "H.sp. ssp. malleti\n",
663
+ "H.sp. ssp. plesseni x malleti\n",
664
+ "H.sp. ssp. plesseni\n",
665
+ "H.sp. ssp. plesseni x malleti\n",
666
+ "H.sp. ssp. latRo x notabilis\n",
667
+ "H.sp. ssp. latRo x notabilis\n",
668
+ "H.sp. ssp. plesseni x malleti\n",
669
+ "H.sp. ssp. plesseni x malleti\n",
670
+ "H.sp. ssp. plesseni x malleti\n",
671
+ "H.sp. ssp. plesseni x malleti\n",
672
+ "H.sp. ssp. notabilis x lativitta\n",
673
+ "H.sp. ssp. plesseni x malleti\n",
674
+ "H.sp. ssp. plesseni x malleti\n",
675
+ "H.sp. ssp. plesseni x malleti\n",
676
+ "H.sp. ssp. plesseni x malleti\n",
677
+ "H.sp. ssp. plesseni x malleti\n",
678
+ "H.sp. cross hybrid\n",
679
+ "H.sp. ssp. plesseni x malleti\n",
680
+ "H.sp. ssp. notabilis x lativitta\n",
681
+ "H.sp. ssp. notabilis x lativitta\n",
682
+ "H.sp. cross hybrid\n",
683
+ "H.sp. ssp. plesseni x malleti\n",
684
+ "H.sp. cross hybrid\n",
685
+ "H.sp. ssp. lativitta\n",
686
+ "H.sp. cross hybrid\n",
687
+ "H.sp. cross hybrid\n",
688
+ "H.sp. cross hybrid\n",
689
+ "H.sp. cross hybrid\n",
690
+ "H.sp. cross hybrid\n",
691
+ "H.sp. cross hybrid\n"
692
+ ]
693
+ }
694
+ ],
695
+ "source": [
696
+ "for cross_type in list(df[\"Cross_Type\"].dropna().unique()):\n",
697
+ " print(get_cross_taxa_name(\"H.sp.\", cross_type))"
698
+ ]
699
+ },
700
+ {
701
+ "cell_type": "code",
702
+ "execution_count": 16,
703
+ "metadata": {},
704
+ "outputs": [
705
+ {
706
+ "data": {
707
+ "text/plain": [
708
+ "array(['Heliconius melpomene', 'Heliconius erato'], dtype=object)"
709
+ ]
710
+ },
711
+ "execution_count": 16,
712
+ "metadata": {},
713
+ "output_type": "execute_result"
714
+ }
715
+ ],
716
+ "source": [
717
+ "df.loc[df[\"Cross_Type\"].notna(), \"species\"].unique()"
718
+ ]
719
+ },
720
+ {
721
+ "cell_type": "code",
722
+ "execution_count": 17,
723
+ "metadata": {},
724
+ "outputs": [
725
+ {
726
+ "data": {
727
+ "text/plain": [
728
+ "array(['Heliconius melpomene ssp. malleti',\n",
729
+ " 'Heliconius melpomene ssp. plesseni x malleti',\n",
730
+ " 'Heliconius melpomene ssp. plesseni',\n",
731
+ " 'Heliconius erato ssp. latRo x notabilis',\n",
732
+ " 'Heliconius erato ssp. notabilis x lativitta',\n",
733
+ " 'Heliconius erato cross hybrid',\n",
734
+ " 'Heliconius melpomene cross hybrid',\n",
735
+ " 'Heliconius erato ssp. lativitta'], dtype=object)"
736
+ ]
737
+ },
738
+ "execution_count": 17,
739
+ "metadata": {},
740
+ "output_type": "execute_result"
741
+ }
742
+ ],
743
+ "source": [
744
+ "# https://stackoverflow.com/a/52854800\n",
745
+ "df.loc[df[\"Cross_Type\"].notna(), \"Taxonomic_Name\"] = df.loc[df[\"Cross_Type\"].notna()].apply(lambda x: get_cross_taxa_name(x[\"species\"], x[\"Cross_Type\"]), axis = 1)\n",
746
+ "df.loc[df[\"Cross_Type\"].notna(), \"Taxonomic_Name\"].unique()"
747
+ ]
748
+ },
749
+ {
750
+ "cell_type": "code",
751
+ "execution_count": 18,
752
+ "metadata": {},
753
+ "outputs": [
754
+ {
755
+ "data": {
756
+ "text/plain": [
757
+ "366"
758
+ ]
759
+ },
760
+ "execution_count": 18,
761
+ "metadata": {},
762
+ "output_type": "execute_result"
763
+ }
764
+ ],
765
+ "source": [
766
+ "df.Taxonomic_Name.nunique()"
767
+ ]
768
+ },
769
+ {
770
+ "cell_type": "markdown",
771
+ "metadata": {},
772
+ "source": [
773
+ "So we've added 3 more unique values of `Taxonomic_Name`, that checks out: `Heliconius erato ssp. latRo x notabilis`, `Heliconius erato cross hybrid`, and `Heliconius melpomene cross hybrid`."
774
+ ]
775
+ },
776
+ {
777
+ "cell_type": "markdown",
778
+ "metadata": {},
779
+ "source": [
780
+ "### Add Hybrid Status Column"
781
+ ]
782
+ },
783
+ {
784
+ "cell_type": "code",
785
+ "execution_count": 19,
786
+ "metadata": {},
787
+ "outputs": [
788
+ {
789
+ "data": {
790
+ "text/plain": [
791
+ "20"
792
+ ]
793
+ },
794
+ "execution_count": 19,
795
+ "metadata": {},
796
+ "output_type": "execute_result"
797
+ }
798
+ ],
799
+ "source": [
800
+ "hybrids = [taxa_name for taxa_name in list(df[\"Taxonomic_Name\"].dropna().unique()) if (\" x \" in taxa_name) or (\"hybrid\" in taxa_name)]\n",
801
+ "len(hybrids)"
802
+ ]
803
+ },
804
+ {
805
+ "cell_type": "code",
806
+ "execution_count": 20,
807
+ "metadata": {},
808
+ "outputs": [
809
+ {
810
+ "data": {
811
+ "text/plain": [
812
+ "['Heliconius erato ssp. venus x chestertonii',\n",
813
+ " 'Heliconius melpomene ssp. vulcanus x melpomene',\n",
814
+ " 'Heliconius erato ssp. chestertonii x venus',\n",
815
+ " 'Heliconius melpomene ssp. melpomene x thelxiope',\n",
816
+ " 'Heliconius melpomene ssp. melpomene x rosina',\n",
817
+ " 'Heliconius hybrid',\n",
818
+ " 'Heliconius erato ssp. hydara x petiverana',\n",
819
+ " 'Heliconius melpomene ssp. amaryllis x aglaope',\n",
820
+ " 'Anartia fatima x amathea',\n",
821
+ " 'Heliconius melpomene ssp. plesseni x malleti',\n",
822
+ " 'Heliconius erato ssp. notabilis x lativitta',\n",
823
+ " 'Heliconius erato ssp. latRo x notabilis',\n",
824
+ " 'Heliconius erato cross hybrid',\n",
825
+ " 'Heliconius melpomene cross hybrid',\n",
826
+ " 'Heliconius erato ssp. hydara x amalfreda',\n",
827
+ " 'Heliconius erato ssp. hydara x erato',\n",
828
+ " 'Heliconius melpomene ssp. meriana x melpomene',\n",
829
+ " 'Heliconius melpomene ssp. dignus x lativitta',\n",
830
+ " 'Heliconius melpomene ssp. malleti x bellula',\n",
831
+ " 'Heliconius melpomene ssp. malleti x vicina']"
832
+ ]
833
+ },
834
+ "execution_count": 20,
835
+ "metadata": {},
836
+ "output_type": "execute_result"
837
+ }
838
+ ],
839
+ "source": [
840
+ "hybrids"
841
+ ]
842
+ },
843
+ {
844
+ "cell_type": "markdown",
845
+ "metadata": {},
846
+ "source": [
847
+ "Observe that we have one species-level hybrid: `Anartia fatima x amathea`."
848
+ ]
849
+ },
850
+ {
851
+ "cell_type": "code",
852
+ "execution_count": 21,
853
+ "metadata": {},
854
+ "outputs": [],
855
+ "source": [
856
+ "sp_hybrid_parents = [\"Anartia fatima\", \"Anartia amathea\"]"
857
+ ]
858
+ },
859
+ {
860
+ "cell_type": "code",
861
+ "execution_count": 22,
862
+ "metadata": {},
863
+ "outputs": [],
864
+ "source": [
865
+ "df[\"hybrid_stat\"] = None\n",
866
+ "df.loc[df[\"subspecies\"].notna(), \"hybrid_stat\"] = \"non-hybrid\"\n",
867
+ "df.loc[df[\"species\"].isin(sp_hybrid_parents), \"hybrid_stat\"] = \"non-hybrid\"\n",
868
+ "\n",
869
+ "df.loc[df[\"Taxonomic_Name\"].isin(hybrids), \"hybrid_stat\"] = \"hybrid\""
870
+ ]
871
+ },
872
+ {
873
+ "cell_type": "code",
874
+ "execution_count": 23,
875
+ "metadata": {},
876
+ "outputs": [
877
+ {
878
+ "data": {
879
+ "text/html": [
880
+ "<div>\n",
881
+ "<style scoped>\n",
882
+ " .dataframe tbody tr th:only-of-type {\n",
883
+ " vertical-align: middle;\n",
884
+ " }\n",
885
+ "\n",
886
+ " .dataframe tbody tr th {\n",
887
+ " vertical-align: top;\n",
888
+ " }\n",
889
+ "\n",
890
+ " .dataframe thead th {\n",
891
+ " text-align: right;\n",
892
+ " }\n",
893
+ "</style>\n",
894
+ "<table border=\"1\" class=\"dataframe\">\n",
895
+ " <thead>\n",
896
+ " <tr style=\"text-align: right;\">\n",
897
+ " <th></th>\n",
898
+ " <th>CAMID</th>\n",
899
+ " <th>X</th>\n",
900
+ " <th>Image_name</th>\n",
901
+ " <th>View</th>\n",
902
+ " <th>zenodo_name</th>\n",
903
+ " <th>zenodo_link</th>\n",
904
+ " <th>Sequence</th>\n",
905
+ " <th>Taxonomic_Name</th>\n",
906
+ " <th>Locality</th>\n",
907
+ " <th>Sample_accession</th>\n",
908
+ " <th>...</th>\n",
909
+ " <th>Stage</th>\n",
910
+ " <th>Sex</th>\n",
911
+ " <th>Unit_Type</th>\n",
912
+ " <th>file_type</th>\n",
913
+ " <th>record_number</th>\n",
914
+ " <th>species</th>\n",
915
+ " <th>subspecies</th>\n",
916
+ " <th>genus</th>\n",
917
+ " <th>file_url</th>\n",
918
+ " <th>hybrid_stat</th>\n",
919
+ " </tr>\n",
920
+ " </thead>\n",
921
+ " <tbody>\n",
922
+ " <tr>\n",
923
+ " <th>7326</th>\n",
924
+ " <td>CAM002890</td>\n",
925
+ " <td>8482</td>\n",
926
+ " <td>CAM002890_v.JPG</td>\n",
927
+ " <td>ventral</td>\n",
928
+ " <td>CAM.coll.images.batch5.csv</td>\n",
929
+ " <td>https://zenodo.org/record/2684906</td>\n",
930
+ " <td>2,890</td>\n",
931
+ " <td>Anartia fatima</td>\n",
932
+ " <td>El Tirao,</td>\n",
933
+ " <td>NaN</td>\n",
934
+ " <td>...</td>\n",
935
+ " <td>NaN</td>\n",
936
+ " <td>Female</td>\n",
937
+ " <td>wild</td>\n",
938
+ " <td>jpg</td>\n",
939
+ " <td>2684906</td>\n",
940
+ " <td>Anartia fatima</td>\n",
941
+ " <td>NaN</td>\n",
942
+ " <td>Anartia</td>\n",
943
+ " <td>https://zenodo.org/record/2684906/files/CAM002...</td>\n",
944
+ " <td>non-hybrid</td>\n",
945
+ " </tr>\n",
946
+ " <tr>\n",
947
+ " <th>7327</th>\n",
948
+ " <td>CAM002890</td>\n",
949
+ " <td>45376</td>\n",
950
+ " <td>CAM002890_v.JPG</td>\n",
951
+ " <td>ventral</td>\n",
952
+ " <td>occurences_and_multimedia.csv</td>\n",
953
+ " <td>https://zenodo.org/record/3477891</td>\n",
954
+ " <td>2,890</td>\n",
955
+ " <td>Anartia fatima</td>\n",
956
+ " <td>El Tirao,</td>\n",
957
+ " <td>NaN</td>\n",
958
+ " <td>...</td>\n",
959
+ " <td>NaN</td>\n",
960
+ " <td>Female</td>\n",
961
+ " <td>wild</td>\n",
962
+ " <td>jpg</td>\n",
963
+ " <td>3477891</td>\n",
964
+ " <td>Anartia fatima</td>\n",
965
+ " <td>NaN</td>\n",
966
+ " <td>Anartia</td>\n",
967
+ " <td>https://zenodo.org/record/3477891/files/CAM002...</td>\n",
968
+ " <td>non-hybrid</td>\n",
969
+ " </tr>\n",
970
+ " <tr>\n",
971
+ " <th>7328</th>\n",
972
+ " <td>CAM002890</td>\n",
973
+ " <td>45375</td>\n",
974
+ " <td>CAM002890_d.JPG</td>\n",
975
+ " <td>dorsal</td>\n",
976
+ " <td>occurences_and_multimedia.csv</td>\n",
977
+ " <td>https://zenodo.org/record/3477891</td>\n",
978
+ " <td>2,890</td>\n",
979
+ " <td>Anartia fatima</td>\n",
980
+ " <td>El Tirao,</td>\n",
981
+ " <td>NaN</td>\n",
982
+ " <td>...</td>\n",
983
+ " <td>NaN</td>\n",
984
+ " <td>Female</td>\n",
985
+ " <td>wild</td>\n",
986
+ " <td>jpg</td>\n",
987
+ " <td>3477891</td>\n",
988
+ " <td>Anartia fatima</td>\n",
989
+ " <td>NaN</td>\n",
990
+ " <td>Anartia</td>\n",
991
+ " <td>https://zenodo.org/record/3477891/files/CAM002...</td>\n",
992
+ " <td>non-hybrid</td>\n",
993
+ " </tr>\n",
994
+ " <tr>\n",
995
+ " <th>7329</th>\n",
996
+ " <td>CAM002890</td>\n",
997
+ " <td>8481</td>\n",
998
+ " <td>CAM002890_d.JPG</td>\n",
999
+ " <td>dorsal</td>\n",
1000
+ " <td>CAM.coll.images.batch5.csv</td>\n",
1001
+ " <td>https://zenodo.org/record/2684906</td>\n",
1002
+ " <td>2,890</td>\n",
1003
+ " <td>Anartia fatima</td>\n",
1004
+ " <td>El Tirao,</td>\n",
1005
+ " <td>NaN</td>\n",
1006
+ " <td>...</td>\n",
1007
+ " <td>NaN</td>\n",
1008
+ " <td>Female</td>\n",
1009
+ " <td>wild</td>\n",
1010
+ " <td>jpg</td>\n",
1011
+ " <td>2684906</td>\n",
1012
+ " <td>Anartia fatima</td>\n",
1013
+ " <td>NaN</td>\n",
1014
+ " <td>Anartia</td>\n",
1015
+ " <td>https://zenodo.org/record/2684906/files/CAM002...</td>\n",
1016
+ " <td>non-hybrid</td>\n",
1017
+ " </tr>\n",
1018
+ " </tbody>\n",
1019
+ "</table>\n",
1020
+ "<p>4 rows × 28 columns</p>\n",
1021
+ "</div>"
1022
+ ],
1023
+ "text/plain": [
1024
+ " CAMID X Image_name View \\\n",
1025
+ "7326 CAM002890 8482 CAM002890_v.JPG ventral \n",
1026
+ "7327 CAM002890 45376 CAM002890_v.JPG ventral \n",
1027
+ "7328 CAM002890 45375 CAM002890_d.JPG dorsal \n",
1028
+ "7329 CAM002890 8481 CAM002890_d.JPG dorsal \n",
1029
+ "\n",
1030
+ " zenodo_name zenodo_link \\\n",
1031
+ "7326 CAM.coll.images.batch5.csv https://zenodo.org/record/2684906 \n",
1032
+ "7327 occurences_and_multimedia.csv https://zenodo.org/record/3477891 \n",
1033
+ "7328 occurences_and_multimedia.csv https://zenodo.org/record/3477891 \n",
1034
+ "7329 CAM.coll.images.batch5.csv https://zenodo.org/record/2684906 \n",
1035
+ "\n",
1036
+ " Sequence Taxonomic_Name Locality Sample_accession ... Stage Sex \\\n",
1037
+ "7326 2,890 Anartia fatima El Tirao, NaN ... NaN Female \n",
1038
+ "7327 2,890 Anartia fatima El Tirao, NaN ... NaN Female \n",
1039
+ "7328 2,890 Anartia fatima El Tirao, NaN ... NaN Female \n",
1040
+ "7329 2,890 Anartia fatima El Tirao, NaN ... NaN Female \n",
1041
+ "\n",
1042
+ " Unit_Type file_type record_number species subspecies genus \\\n",
1043
+ "7326 wild jpg 2684906 Anartia fatima NaN Anartia \n",
1044
+ "7327 wild jpg 3477891 Anartia fatima NaN Anartia \n",
1045
+ "7328 wild jpg 3477891 Anartia fatima NaN Anartia \n",
1046
+ "7329 wild jpg 2684906 Anartia fatima NaN Anartia \n",
1047
+ "\n",
1048
+ " file_url hybrid_stat \n",
1049
+ "7326 https://zenodo.org/record/2684906/files/CAM002... non-hybrid \n",
1050
+ "7327 https://zenodo.org/record/3477891/files/CAM002... non-hybrid \n",
1051
+ "7328 https://zenodo.org/record/3477891/files/CAM002... non-hybrid \n",
1052
+ "7329 https://zenodo.org/record/2684906/files/CAM002... non-hybrid \n",
1053
+ "\n",
1054
+ "[4 rows x 28 columns]"
1055
+ ]
1056
+ },
1057
+ "execution_count": 23,
1058
+ "metadata": {},
1059
+ "output_type": "execute_result"
1060
+ }
1061
+ ],
1062
+ "source": [
1063
+ "df.loc[df[\"species\"].isin(sp_hybrid_parents)]"
1064
+ ]
1065
+ },
1066
+ {
1067
+ "cell_type": "code",
1068
+ "execution_count": 24,
1069
+ "metadata": {},
1070
+ "outputs": [
1071
+ {
1072
+ "data": {
1073
+ "text/html": [
1074
+ "<div>\n",
1075
+ "<style scoped>\n",
1076
+ " .dataframe tbody tr th:only-of-type {\n",
1077
+ " vertical-align: middle;\n",
1078
+ " }\n",
1079
+ "\n",
1080
+ " .dataframe tbody tr th {\n",
1081
+ " vertical-align: top;\n",
1082
+ " }\n",
1083
+ "\n",
1084
+ " .dataframe thead th {\n",
1085
+ " text-align: right;\n",
1086
+ " }\n",
1087
+ "</style>\n",
1088
+ "<table border=\"1\" class=\"dataframe\">\n",
1089
+ " <thead>\n",
1090
+ " <tr style=\"text-align: right;\">\n",
1091
+ " <th></th>\n",
1092
+ " <th>CAMID</th>\n",
1093
+ " <th>X</th>\n",
1094
+ " <th>Image_name</th>\n",
1095
+ " <th>View</th>\n",
1096
+ " <th>zenodo_name</th>\n",
1097
+ " <th>zenodo_link</th>\n",
1098
+ " <th>Sequence</th>\n",
1099
+ " <th>Taxonomic_Name</th>\n",
1100
+ " <th>Locality</th>\n",
1101
+ " <th>Sample_accession</th>\n",
1102
+ " <th>...</th>\n",
1103
+ " <th>Stage</th>\n",
1104
+ " <th>Sex</th>\n",
1105
+ " <th>Unit_Type</th>\n",
1106
+ " <th>file_type</th>\n",
1107
+ " <th>record_number</th>\n",
1108
+ " <th>species</th>\n",
1109
+ " <th>subspecies</th>\n",
1110
+ " <th>genus</th>\n",
1111
+ " <th>file_url</th>\n",
1112
+ " <th>hybrid_stat</th>\n",
1113
+ " </tr>\n",
1114
+ " </thead>\n",
1115
+ " <tbody>\n",
1116
+ " </tbody>\n",
1117
+ "</table>\n",
1118
+ "<p>0 rows × 28 columns</p>\n",
1119
+ "</div>"
1120
+ ],
1121
+ "text/plain": [
1122
+ "Empty DataFrame\n",
1123
+ "Columns: [CAMID, X, Image_name, View, zenodo_name, zenodo_link, Sequence, Taxonomic_Name, Locality, Sample_accession, Collected_by, Other_ID, Date, Dataset, Store, Brood, Death_Date, Cross_Type, Stage, Sex, Unit_Type, file_type, record_number, species, subspecies, genus, file_url, hybrid_stat]\n",
1124
+ "Index: []\n",
1125
+ "\n",
1126
+ "[0 rows x 28 columns]"
1127
+ ]
1128
+ },
1129
+ "execution_count": 24,
1130
+ "metadata": {},
1131
+ "output_type": "execute_result"
1132
+ }
1133
+ ],
1134
+ "source": [
1135
+ "df.loc[df[\"species\"].str.lower() == \"amathea\"] #not represented in the dataset"
1136
+ ]
1137
+ },
1138
+ {
1139
+ "cell_type": "code",
1140
+ "execution_count": 25,
1141
+ "metadata": {},
1142
+ "outputs": [
1143
+ {
1144
+ "data": {
1145
+ "text/plain": [
1146
+ "Taxonomic_Name\n",
1147
+ "Anartia fatima x amathea 60\n",
1148
+ "Anartia fatima 4\n",
1149
+ "Name: count, dtype: int64"
1150
+ ]
1151
+ },
1152
+ "execution_count": 25,
1153
+ "metadata": {},
1154
+ "output_type": "execute_result"
1155
+ }
1156
+ ],
1157
+ "source": [
1158
+ "df.loc[df[\"genus\"] == \"Anartia\", \"Taxonomic_Name\"].value_counts()"
1159
+ ]
1160
+ },
1161
+ {
1162
+ "cell_type": "code",
1163
+ "execution_count": 26,
1164
+ "metadata": {},
1165
+ "outputs": [
1166
+ {
1167
+ "data": {
1168
+ "text/html": [
1169
+ "<div>\n",
1170
+ "<style scoped>\n",
1171
+ " .dataframe tbody tr th:only-of-type {\n",
1172
+ " vertical-align: middle;\n",
1173
+ " }\n",
1174
+ "\n",
1175
+ " .dataframe tbody tr th {\n",
1176
+ " vertical-align: top;\n",
1177
+ " }\n",
1178
+ "\n",
1179
+ " .dataframe thead th {\n",
1180
+ " text-align: right;\n",
1181
+ " }\n",
1182
+ "</style>\n",
1183
+ "<table border=\"1\" class=\"dataframe\">\n",
1184
+ " <thead>\n",
1185
+ " <tr style=\"text-align: right;\">\n",
1186
+ " <th></th>\n",
1187
+ " <th>CAMID</th>\n",
1188
+ " <th>X</th>\n",
1189
+ " <th>Image_name</th>\n",
1190
+ " <th>View</th>\n",
1191
+ " <th>zenodo_name</th>\n",
1192
+ " <th>zenodo_link</th>\n",
1193
+ " <th>Sequence</th>\n",
1194
+ " <th>Taxonomic_Name</th>\n",
1195
+ " <th>Locality</th>\n",
1196
+ " <th>Sample_accession</th>\n",
1197
+ " <th>...</th>\n",
1198
+ " <th>Stage</th>\n",
1199
+ " <th>Sex</th>\n",
1200
+ " <th>Unit_Type</th>\n",
1201
+ " <th>file_type</th>\n",
1202
+ " <th>record_number</th>\n",
1203
+ " <th>species</th>\n",
1204
+ " <th>subspecies</th>\n",
1205
+ " <th>genus</th>\n",
1206
+ " <th>file_url</th>\n",
1207
+ " <th>hybrid_stat</th>\n",
1208
+ " </tr>\n",
1209
+ " </thead>\n",
1210
+ " <tbody>\n",
1211
+ " <tr>\n",
1212
+ " <th>40498</th>\n",
1213
+ " <td>CAM043842</td>\n",
1214
+ " <td>32098</td>\n",
1215
+ " <td>CAM043842_hwv.JPG</td>\n",
1216
+ " <td>hindwing ventral</td>\n",
1217
+ " <td>batch2.Peru.image.names.Zenodo.csv</td>\n",
1218
+ " <td>https://zenodo.org/record/4287444</td>\n",
1219
+ " <td>43,842</td>\n",
1220
+ " <td>Catoblepia berecynthia</td>\n",
1221
+ " <td>B1prim3</td>\n",
1222
+ " <td>NaN</td>\n",
1223
+ " <td>...</td>\n",
1224
+ " <td>NaN</td>\n",
1225
+ " <td>NaN</td>\n",
1226
+ " <td>NaN</td>\n",
1227
+ " <td>jpg</td>\n",
1228
+ " <td>4287444</td>\n",
1229
+ " <td>Catoblepia berecynthia</td>\n",
1230
+ " <td>NaN</td>\n",
1231
+ " <td>Catoblepia</td>\n",
1232
+ " <td>https://zenodo.org/record/4287444/files/CAM043...</td>\n",
1233
+ " <td>None</td>\n",
1234
+ " </tr>\n",
1235
+ " <tr>\n",
1236
+ " <th>9192</th>\n",
1237
+ " <td>CAM008567</td>\n",
1238
+ " <td>46249</td>\n",
1239
+ " <td>CAM008567_v.JPG</td>\n",
1240
+ " <td>ventral</td>\n",
1241
+ " <td>occurences_and_multimedia.csv</td>\n",
1242
+ " <td>https://zenodo.org/record/3477891</td>\n",
1243
+ " <td>8,567</td>\n",
1244
+ " <td>Heliconius demeter</td>\n",
1245
+ " <td>Tarapoto-Yurimaguas (Km15), Tunel Cumbre, Fond...</td>\n",
1246
+ " <td>NaN</td>\n",
1247
+ " <td>...</td>\n",
1248
+ " <td>NaN</td>\n",
1249
+ " <td>Male</td>\n",
1250
+ " <td>wild</td>\n",
1251
+ " <td>jpg</td>\n",
1252
+ " <td>3477891</td>\n",
1253
+ " <td>Heliconius demeter</td>\n",
1254
+ " <td>NaN</td>\n",
1255
+ " <td>Heliconius</td>\n",
1256
+ " <td>https://zenodo.org/record/3477891/files/CAM008...</td>\n",
1257
+ " <td>None</td>\n",
1258
+ " </tr>\n",
1259
+ " <tr>\n",
1260
+ " <th>14127</th>\n",
1261
+ " <td>CAM010971</td>\n",
1262
+ " <td>27577</td>\n",
1263
+ " <td>CAM010971_d.CR2</td>\n",
1264
+ " <td>dorsal</td>\n",
1265
+ " <td>2001_2.broods.batch.1.csv</td>\n",
1266
+ " <td>https://zenodo.org/record/2549524</td>\n",
1267
+ " <td>10,971</td>\n",
1268
+ " <td>Heliconius sp.</td>\n",
1269
+ " <td>NaN</td>\n",
1270
+ " <td>NaN</td>\n",
1271
+ " <td>...</td>\n",
1272
+ " <td>NaN</td>\n",
1273
+ " <td>Male</td>\n",
1274
+ " <td>reared</td>\n",
1275
+ " <td>raw</td>\n",
1276
+ " <td>2549524</td>\n",
1277
+ " <td>Heliconius sp.</td>\n",
1278
+ " <td>NaN</td>\n",
1279
+ " <td>Heliconius</td>\n",
1280
+ " <td>https://zenodo.org/record/2549524/files/CAM010...</td>\n",
1281
+ " <td>None</td>\n",
1282
+ " </tr>\n",
1283
+ " <tr>\n",
1284
+ " <th>5315</th>\n",
1285
+ " <td>CAM000537</td>\n",
1286
+ " <td>6676</td>\n",
1287
+ " <td>CAM000537_d.JPG</td>\n",
1288
+ " <td>dorsal</td>\n",
1289
+ " <td>CAM.coll.images.batch3.csv</td>\n",
1290
+ " <td>https://zenodo.org/record/2682458</td>\n",
1291
+ " <td>537</td>\n",
1292
+ " <td>Heliconius melpomene ssp. rosina</td>\n",
1293
+ " <td>Pipeline road 4km,</td>\n",
1294
+ " <td>NaN</td>\n",
1295
+ " <td>...</td>\n",
1296
+ " <td>NaN</td>\n",
1297
+ " <td>Male</td>\n",
1298
+ " <td>wild</td>\n",
1299
+ " <td>jpg</td>\n",
1300
+ " <td>2682458</td>\n",
1301
+ " <td>Heliconius melpomene</td>\n",
1302
+ " <td>rosina</td>\n",
1303
+ " <td>Heliconius</td>\n",
1304
+ " <td>https://zenodo.org/record/2682458/files/CAM000...</td>\n",
1305
+ " <td>non-hybrid</td>\n",
1306
+ " </tr>\n",
1307
+ " <tr>\n",
1308
+ " <th>585</th>\n",
1309
+ " <td>19N0204</td>\n",
1310
+ " <td>19553</td>\n",
1311
+ " <td>19N0204_d.JPG</td>\n",
1312
+ " <td>dorsal</td>\n",
1313
+ " <td>0.sheffield.ps.nn.ikiam.batch1.csv</td>\n",
1314
+ " <td>https://zenodo.org/record/4288311</td>\n",
1315
+ " <td>204</td>\n",
1316
+ " <td>Heliconius erato ssp. lativitta</td>\n",
1317
+ " <td>Ikiam Mariposario</td>\n",
1318
+ " <td>NaN</td>\n",
1319
+ " <td>...</td>\n",
1320
+ " <td>NaN</td>\n",
1321
+ " <td>Male</td>\n",
1322
+ " <td>reared</td>\n",
1323
+ " <td>jpg</td>\n",
1324
+ " <td>4288311</td>\n",
1325
+ " <td>Heliconius erato</td>\n",
1326
+ " <td>lativitta</td>\n",
1327
+ " <td>Heliconius</td>\n",
1328
+ " <td>https://zenodo.org/record/4288311/files/19N020...</td>\n",
1329
+ " <td>non-hybrid</td>\n",
1330
+ " </tr>\n",
1331
+ " <tr>\n",
1332
+ " <th>38875</th>\n",
1333
+ " <td>CAM043366</td>\n",
1334
+ " <td>30469</td>\n",
1335
+ " <td>CAM043366_v.CR2</td>\n",
1336
+ " <td>ventral</td>\n",
1337
+ " <td>batch1.Peru.image.names.Zenodo.csv</td>\n",
1338
+ " <td>https://zenodo.org/record/3569598</td>\n",
1339
+ " <td>43,366</td>\n",
1340
+ " <td>Eunica pusilla</td>\n",
1341
+ " <td>B6rec3</td>\n",
1342
+ " <td>NaN</td>\n",
1343
+ " <td>...</td>\n",
1344
+ " <td>NaN</td>\n",
1345
+ " <td>NaN</td>\n",
1346
+ " <td>NaN</td>\n",
1347
+ " <td>raw</td>\n",
1348
+ " <td>3569598</td>\n",
1349
+ " <td>Eunica pusilla</td>\n",
1350
+ " <td>NaN</td>\n",
1351
+ " <td>Eunica</td>\n",
1352
+ " <td>https://zenodo.org/record/3569598/files/CAM043...</td>\n",
1353
+ " <td>None</td>\n",
1354
+ " </tr>\n",
1355
+ " <tr>\n",
1356
+ " <th>19226</th>\n",
1357
+ " <td>CAM016687</td>\n",
1358
+ " <td>18917</td>\n",
1359
+ " <td>CAM016687_d.CR2</td>\n",
1360
+ " <td>dorsal</td>\n",
1361
+ " <td>CAM.coll.PS.list.individuals.haplotagging.new....</td>\n",
1362
+ " <td>https://zenodo.org/record/4153502</td>\n",
1363
+ " <td>16,687</td>\n",
1364
+ " <td>Heliconius melpomene ssp. plesseni</td>\n",
1365
+ " <td>El Topo, Baños - Puyo road,</td>\n",
1366
+ " <td>SRS7540355</td>\n",
1367
+ " <td>...</td>\n",
1368
+ " <td>NaN</td>\n",
1369
+ " <td>Male</td>\n",
1370
+ " <td>wild</td>\n",
1371
+ " <td>raw</td>\n",
1372
+ " <td>4153502</td>\n",
1373
+ " <td>Heliconius melpomene</td>\n",
1374
+ " <td>plesseni</td>\n",
1375
+ " <td>Heliconius</td>\n",
1376
+ " <td>https://zenodo.org/record/4153502/files/CAM016...</td>\n",
1377
+ " <td>non-hybrid</td>\n",
1378
+ " </tr>\n",
1379
+ " </tbody>\n",
1380
+ "</table>\n",
1381
+ "<p>7 rows × 28 columns</p>\n",
1382
+ "</div>"
1383
+ ],
1384
+ "text/plain": [
1385
+ " CAMID X Image_name View \\\n",
1386
+ "40498 CAM043842 32098 CAM043842_hwv.JPG hindwing ventral \n",
1387
+ "9192 CAM008567 46249 CAM008567_v.JPG ventral \n",
1388
+ "14127 CAM010971 27577 CAM010971_d.CR2 dorsal \n",
1389
+ "5315 CAM000537 6676 CAM000537_d.JPG dorsal \n",
1390
+ "585 19N0204 19553 19N0204_d.JPG dorsal \n",
1391
+ "38875 CAM043366 30469 CAM043366_v.CR2 ventral \n",
1392
+ "19226 CAM016687 18917 CAM016687_d.CR2 dorsal \n",
1393
+ "\n",
1394
+ " zenodo_name \\\n",
1395
+ "40498 batch2.Peru.image.names.Zenodo.csv \n",
1396
+ "9192 occurences_and_multimedia.csv \n",
1397
+ "14127 2001_2.broods.batch.1.csv \n",
1398
+ "5315 CAM.coll.images.batch3.csv \n",
1399
+ "585 0.sheffield.ps.nn.ikiam.batch1.csv \n",
1400
+ "38875 batch1.Peru.image.names.Zenodo.csv \n",
1401
+ "19226 CAM.coll.PS.list.individuals.haplotagging.new.... \n",
1402
+ "\n",
1403
+ " zenodo_link Sequence \\\n",
1404
+ "40498 https://zenodo.org/record/4287444 43,842 \n",
1405
+ "9192 https://zenodo.org/record/3477891 8,567 \n",
1406
+ "14127 https://zenodo.org/record/2549524 10,971 \n",
1407
+ "5315 https://zenodo.org/record/2682458 537 \n",
1408
+ "585 https://zenodo.org/record/4288311 204 \n",
1409
+ "38875 https://zenodo.org/record/3569598 43,366 \n",
1410
+ "19226 https://zenodo.org/record/4153502 16,687 \n",
1411
+ "\n",
1412
+ " Taxonomic_Name \\\n",
1413
+ "40498 Catoblepia berecynthia \n",
1414
+ "9192 Heliconius demeter \n",
1415
+ "14127 Heliconius sp. \n",
1416
+ "5315 Heliconius melpomene ssp. rosina \n",
1417
+ "585 Heliconius erato ssp. lativitta \n",
1418
+ "38875 Eunica pusilla \n",
1419
+ "19226 Heliconius melpomene ssp. plesseni \n",
1420
+ "\n",
1421
+ " Locality Sample_accession \\\n",
1422
+ "40498 B1prim3 NaN \n",
1423
+ "9192 Tarapoto-Yurimaguas (Km15), Tunel Cumbre, Fond... NaN \n",
1424
+ "14127 NaN NaN \n",
1425
+ "5315 Pipeline road 4km, NaN \n",
1426
+ "585 Ikiam Mariposario NaN \n",
1427
+ "38875 B6rec3 NaN \n",
1428
+ "19226 El Topo, Baños - Puyo road, SRS7540355 \n",
1429
+ "\n",
1430
+ " ... Stage Sex Unit_Type file_type record_number \\\n",
1431
+ "40498 ... NaN NaN NaN jpg 4287444 \n",
1432
+ "9192 ... NaN Male wild jpg 3477891 \n",
1433
+ "14127 ... NaN Male reared raw 2549524 \n",
1434
+ "5315 ... NaN Male wild jpg 2682458 \n",
1435
+ "585 ... NaN Male reared jpg 4288311 \n",
1436
+ "38875 ... NaN NaN NaN raw 3569598 \n",
1437
+ "19226 ... NaN Male wild raw 4153502 \n",
1438
+ "\n",
1439
+ " species subspecies genus \\\n",
1440
+ "40498 Catoblepia berecynthia NaN Catoblepia \n",
1441
+ "9192 Heliconius demeter NaN Heliconius \n",
1442
+ "14127 Heliconius sp. NaN Heliconius \n",
1443
+ "5315 Heliconius melpomene rosina Heliconius \n",
1444
+ "585 Heliconius erato lativitta Heliconius \n",
1445
+ "38875 Eunica pusilla NaN Eunica \n",
1446
+ "19226 Heliconius melpomene plesseni Heliconius \n",
1447
+ "\n",
1448
+ " file_url hybrid_stat \n",
1449
+ "40498 https://zenodo.org/record/4287444/files/CAM043... None \n",
1450
+ "9192 https://zenodo.org/record/3477891/files/CAM008... None \n",
1451
+ "14127 https://zenodo.org/record/2549524/files/CAM010... None \n",
1452
+ "5315 https://zenodo.org/record/2682458/files/CAM000... non-hybrid \n",
1453
+ "585 https://zenodo.org/record/4288311/files/19N020... non-hybrid \n",
1454
+ "38875 https://zenodo.org/record/3569598/files/CAM043... None \n",
1455
+ "19226 https://zenodo.org/record/4153502/files/CAM016... non-hybrid \n",
1456
+ "\n",
1457
+ "[7 rows x 28 columns]"
1458
+ ]
1459
+ },
1460
+ "execution_count": 26,
1461
+ "metadata": {},
1462
+ "output_type": "execute_result"
1463
+ }
1464
+ ],
1465
+ "source": [
1466
+ "df.sample(7)"
1467
+ ]
1468
+ },
1469
+ {
1470
+ "cell_type": "markdown",
1471
+ "metadata": {},
1472
+ "source": [
1473
+ "## Investigate entries with no Taxonomic Information"
1474
+ ]
1475
+ },
1476
+ {
1477
+ "cell_type": "code",
1478
+ "execution_count": 27,
1479
+ "metadata": {},
1480
+ "outputs": [
1481
+ {
1482
+ "name": "stdout",
1483
+ "output_type": "stream",
1484
+ "text": [
1485
+ "<class 'pandas.core.frame.DataFrame'>\n",
1486
+ "Index: 3886 entries, 0 to 49350\n",
1487
+ "Data columns (total 28 columns):\n",
1488
+ " # Column Non-Null Count Dtype \n",
1489
+ "--- ------ -------------- ----- \n",
1490
+ " 0 CAMID 3886 non-null object\n",
1491
+ " 1 X 3886 non-null int64 \n",
1492
+ " 2 Image_name 3886 non-null object\n",
1493
+ " 3 View 3594 non-null object\n",
1494
+ " 4 zenodo_name 3886 non-null object\n",
1495
+ " 5 zenodo_link 3886 non-null object\n",
1496
+ " 6 Sequence 2951 non-null object\n",
1497
+ " 7 Taxonomic_Name 0 non-null object\n",
1498
+ " 8 Locality 70 non-null object\n",
1499
+ " 9 Sample_accession 24 non-null object\n",
1500
+ " 10 Collected_by 0 non-null object\n",
1501
+ " 11 Other_ID 30 non-null object\n",
1502
+ " 12 Date 70 non-null object\n",
1503
+ " 13 Dataset 461 non-null object\n",
1504
+ " 14 Store 345 non-null object\n",
1505
+ " 15 Brood 5 non-null object\n",
1506
+ " 16 Death_Date 2 non-null object\n",
1507
+ " 17 Cross_Type 0 non-null object\n",
1508
+ " 18 Stage 9 non-null object\n",
1509
+ " 19 Sex 35 non-null object\n",
1510
+ " 20 Unit_Type 47 non-null object\n",
1511
+ " 21 file_type 3886 non-null object\n",
1512
+ " 22 record_number 3886 non-null int64 \n",
1513
+ " 23 species 0 non-null object\n",
1514
+ " 24 subspecies 0 non-null object\n",
1515
+ " 25 genus 0 non-null object\n",
1516
+ " 26 file_url 3886 non-null object\n",
1517
+ " 27 hybrid_stat 0 non-null object\n",
1518
+ "dtypes: int64(2), object(26)\n",
1519
+ "memory usage: 880.4+ KB\n"
1520
+ ]
1521
+ }
1522
+ ],
1523
+ "source": [
1524
+ "df.loc[df.Taxonomic_Name.isna()].info()"
1525
+ ]
1526
+ },
1527
+ {
1528
+ "cell_type": "markdown",
1529
+ "metadata": {},
1530
+ "source": [
1531
+ "Wow, there are a surprising number of images with no taxonomic information."
1532
+ ]
1533
+ },
1534
+ {
1535
+ "cell_type": "code",
1536
+ "execution_count": 28,
1537
+ "metadata": {},
1538
+ "outputs": [
1539
+ {
1540
+ "data": {
1541
+ "text/plain": [
1542
+ "0"
1543
+ ]
1544
+ },
1545
+ "execution_count": 28,
1546
+ "metadata": {},
1547
+ "output_type": "execute_result"
1548
+ }
1549
+ ],
1550
+ "source": [
1551
+ "no_taxa_cams = list(df.loc[df[\"Taxonomic_Name\"].isna(), \"CAMID\"].unique())\n",
1552
+ "no_taxa_entries = list(df.loc[df[\"Taxonomic_Name\"].isna(), \"X\"])\n",
1553
+ "\n",
1554
+ "no_taxa_cam_match = [camid for camid in list(df.loc[~df[\"X\"].isin(no_taxa_entries), \"CAMID\"]) if camid in no_taxa_cams]\n",
1555
+ "len(no_taxa_cam_match)"
1556
+ ]
1557
+ },
1558
+ {
1559
+ "cell_type": "markdown",
1560
+ "metadata": {},
1561
+ "source": [
1562
+ "There are no CAMIDs that these can match to for taxonomic info recovery. Last option is to check the records they come from, then we'll remove them."
1563
+ ]
1564
+ },
1565
+ {
1566
+ "cell_type": "code",
1567
+ "execution_count": 29,
1568
+ "metadata": {},
1569
+ "outputs": [
1570
+ {
1571
+ "name": "stdout",
1572
+ "output_type": "stream",
1573
+ "text": [
1574
+ "21\n"
1575
+ ]
1576
+ },
1577
+ {
1578
+ "data": {
1579
+ "text/plain": [
1580
+ "zenodo_link\n",
1581
+ "https://zenodo.org/record/5526257 1324\n",
1582
+ "https://zenodo.org/record/2554218 492\n",
1583
+ "https://zenodo.org/record/4288311 486\n",
1584
+ "https://zenodo.org/record/2555086 440\n",
1585
+ "https://zenodo.org/record/5731587 388\n",
1586
+ "Name: count, dtype: int64"
1587
+ ]
1588
+ },
1589
+ "execution_count": 29,
1590
+ "metadata": {},
1591
+ "output_type": "execute_result"
1592
+ }
1593
+ ],
1594
+ "source": [
1595
+ "print(df.loc[df[\"X\"].isin(no_taxa_entries), \"record_number\"].nunique())\n",
1596
+ "df.loc[df[\"X\"].isin(no_taxa_entries), \"zenodo_link\"].value_counts()[:5]"
1597
+ ]
1598
+ },
1599
+ {
1600
+ "cell_type": "markdown",
1601
+ "metadata": {},
1602
+ "source": [
1603
+ "These are across most of the records. We can check the one with the most, but otherwise they should likely be dropped (can save them in a separate CSV in case they are to be assessed at a later point).\n",
1604
+ "\n",
1605
+ "The first appear to be all _Heliconius erato ssp. cyrbia_, so those could be realigned.\n",
1606
+ "\n",
1607
+ "The second indicates all _Heliconius erato_.\n",
1608
+ "\n",
1609
+ "The third is a mix, so not resolvable without an expert.\n",
1610
+ "\n",
1611
+ "It seems record 2555086 is all bred specimens of _Heliconius erato demophoon_.\n",
1612
+ "\n",
1613
+ "The fifth record is a mix, and not all are labeled in the excel file (in fact, there's a lot of red which is probably why they were excluded)."
1614
+ ]
1615
+ },
1616
+ {
1617
+ "cell_type": "code",
1618
+ "execution_count": 30,
1619
+ "metadata": {},
1620
+ "outputs": [
1621
+ {
1622
+ "name": "stdout",
1623
+ "output_type": "stream",
1624
+ "text": [
1625
+ "<class 'pandas.core.series.Series'>\n",
1626
+ "Index: 1324 entries, 45868 to 47191\n",
1627
+ "Series name: Taxonomic_Name\n",
1628
+ "Non-Null Count Dtype \n",
1629
+ "-------------- ----- \n",
1630
+ "0 non-null object\n",
1631
+ "dtypes: object(1)\n",
1632
+ "memory usage: 20.7+ KB\n"
1633
+ ]
1634
+ }
1635
+ ],
1636
+ "source": [
1637
+ "df.loc[df[\"record_number\"] == 5526257, \"Taxonomic_Name\"].info()"
1638
+ ]
1639
+ },
1640
+ {
1641
+ "cell_type": "markdown",
1642
+ "metadata": {},
1643
+ "source": [
1644
+ "Ah, so these are all null, but all are of the same subspecies, so they can be labeled."
1645
+ ]
1646
+ },
1647
+ {
1648
+ "cell_type": "code",
1649
+ "execution_count": 31,
1650
+ "metadata": {},
1651
+ "outputs": [
1652
+ {
1653
+ "data": {
1654
+ "text/plain": [
1655
+ "4"
1656
+ ]
1657
+ },
1658
+ "execution_count": 31,
1659
+ "metadata": {},
1660
+ "output_type": "execute_result"
1661
+ }
1662
+ ],
1663
+ "source": [
1664
+ "pot_single_taxa_records = []\n",
1665
+ "for record_num in (df.loc[df[\"X\"].isin(no_taxa_entries), \"record_number\"].unique()):\n",
1666
+ " temp = df.loc[df[\"record_number\"] == record_num]\n",
1667
+ " if temp.loc[temp[\"Taxonomic_Name\"].notna()].shape[0] == 0:\n",
1668
+ " pot_single_taxa_records.append(record_num)\n",
1669
+ "\n",
1670
+ "len(pot_single_taxa_records)"
1671
+ ]
1672
+ },
1673
+ {
1674
+ "cell_type": "code",
1675
+ "execution_count": 32,
1676
+ "metadata": {},
1677
+ "outputs": [
1678
+ {
1679
+ "data": {
1680
+ "text/plain": [
1681
+ "[5731587, 5526257, 2554218, 2555086]"
1682
+ ]
1683
+ },
1684
+ "execution_count": 32,
1685
+ "metadata": {},
1686
+ "output_type": "execute_result"
1687
+ }
1688
+ ],
1689
+ "source": [
1690
+ "pot_single_taxa_records"
1691
+ ]
1692
+ },
1693
+ {
1694
+ "cell_type": "code",
1695
+ "execution_count": 33,
1696
+ "metadata": {},
1697
+ "outputs": [
1698
+ {
1699
+ "data": {
1700
+ "text/html": [
1701
+ "<div>\n",
1702
+ "<style scoped>\n",
1703
+ " .dataframe tbody tr th:only-of-type {\n",
1704
+ " vertical-align: middle;\n",
1705
+ " }\n",
1706
+ "\n",
1707
+ " .dataframe tbody tr th {\n",
1708
+ " vertical-align: top;\n",
1709
+ " }\n",
1710
+ "\n",
1711
+ " .dataframe thead th {\n",
1712
+ " text-align: right;\n",
1713
+ " }\n",
1714
+ "</style>\n",
1715
+ "<table border=\"1\" class=\"dataframe\">\n",
1716
+ " <thead>\n",
1717
+ " <tr style=\"text-align: right;\">\n",
1718
+ " <th></th>\n",
1719
+ " <th>CAMID</th>\n",
1720
+ " <th>X</th>\n",
1721
+ " <th>Image_name</th>\n",
1722
+ " <th>View</th>\n",
1723
+ " <th>zenodo_name</th>\n",
1724
+ " <th>zenodo_link</th>\n",
1725
+ " <th>Sequence</th>\n",
1726
+ " <th>Taxonomic_Name</th>\n",
1727
+ " <th>Locality</th>\n",
1728
+ " <th>Sample_accession</th>\n",
1729
+ " <th>...</th>\n",
1730
+ " <th>Stage</th>\n",
1731
+ " <th>Sex</th>\n",
1732
+ " <th>Unit_Type</th>\n",
1733
+ " <th>file_type</th>\n",
1734
+ " <th>record_number</th>\n",
1735
+ " <th>species</th>\n",
1736
+ " <th>subspecies</th>\n",
1737
+ " <th>genus</th>\n",
1738
+ " <th>file_url</th>\n",
1739
+ " <th>hybrid_stat</th>\n",
1740
+ " </tr>\n",
1741
+ " </thead>\n",
1742
+ " <tbody>\n",
1743
+ " <tr>\n",
1744
+ " <th>46747</th>\n",
1745
+ " <td>CAM045219</td>\n",
1746
+ " <td>43439</td>\n",
1747
+ " <td>CAM045219_d.JPG</td>\n",
1748
+ " <td>dorsal</td>\n",
1749
+ " <td>image.names.cook.island.erato.csv</td>\n",
1750
+ " <td>https://zenodo.org/record/5526257</td>\n",
1751
+ " <td>45,219</td>\n",
1752
+ " <td>NaN</td>\n",
1753
+ " <td>NaN</td>\n",
1754
+ " <td>NaN</td>\n",
1755
+ " <td>...</td>\n",
1756
+ " <td>NaN</td>\n",
1757
+ " <td>NaN</td>\n",
1758
+ " <td>NaN</td>\n",
1759
+ " <td>jpg</td>\n",
1760
+ " <td>5526257</td>\n",
1761
+ " <td>NaN</td>\n",
1762
+ " <td>NaN</td>\n",
1763
+ " <td>NaN</td>\n",
1764
+ " <td>https://zenodo.org/record/5526257/files/CAM045...</td>\n",
1765
+ " <td>None</td>\n",
1766
+ " </tr>\n",
1767
+ " <tr>\n",
1768
+ " <th>47062</th>\n",
1769
+ " <td>CAM045298</td>\n",
1770
+ " <td>43756</td>\n",
1771
+ " <td>CAM045298_v.CR2</td>\n",
1772
+ " <td>ventral</td>\n",
1773
+ " <td>image.names.cook.island.erato.csv</td>\n",
1774
+ " <td>https://zenodo.org/record/5526257</td>\n",
1775
+ " <td>45,298</td>\n",
1776
+ " <td>NaN</td>\n",
1777
+ " <td>NaN</td>\n",
1778
+ " <td>NaN</td>\n",
1779
+ " <td>...</td>\n",
1780
+ " <td>NaN</td>\n",
1781
+ " <td>NaN</td>\n",
1782
+ " <td>NaN</td>\n",
1783
+ " <td>raw</td>\n",
1784
+ " <td>5526257</td>\n",
1785
+ " <td>NaN</td>\n",
1786
+ " <td>NaN</td>\n",
1787
+ " <td>NaN</td>\n",
1788
+ " <td>https://zenodo.org/record/5526257/files/CAM045...</td>\n",
1789
+ " <td>None</td>\n",
1790
+ " </tr>\n",
1791
+ " <tr>\n",
1792
+ " <th>37255</th>\n",
1793
+ " <td>CAM042050</td>\n",
1794
+ " <td>43982</td>\n",
1795
+ " <td>CAM042050_d.JPG</td>\n",
1796
+ " <td>dorsal</td>\n",
1797
+ " <td>Collection_August2019.csv</td>\n",
1798
+ " <td>https://zenodo.org/record/5731587</td>\n",
1799
+ " <td>42,050</td>\n",
1800
+ " <td>NaN</td>\n",
1801
+ " <td>NaN</td>\n",
1802
+ " <td>NaN</td>\n",
1803
+ " <td>...</td>\n",
1804
+ " <td>NaN</td>\n",
1805
+ " <td>NaN</td>\n",
1806
+ " <td>NaN</td>\n",
1807
+ " <td>jpg</td>\n",
1808
+ " <td>5731587</td>\n",
1809
+ " <td>NaN</td>\n",
1810
+ " <td>NaN</td>\n",
1811
+ " <td>NaN</td>\n",
1812
+ " <td>https://zenodo.org/record/5731587/files/CAM042...</td>\n",
1813
+ " <td>None</td>\n",
1814
+ " </tr>\n",
1815
+ " <tr>\n",
1816
+ " <th>46992</th>\n",
1817
+ " <td>CAM045281</td>\n",
1818
+ " <td>43687</td>\n",
1819
+ " <td>CAM045281_d.JPG</td>\n",
1820
+ " <td>dorsal</td>\n",
1821
+ " <td>image.names.cook.island.erato.csv</td>\n",
1822
+ " <td>https://zenodo.org/record/5526257</td>\n",
1823
+ " <td>45,281</td>\n",
1824
+ " <td>NaN</td>\n",
1825
+ " <td>NaN</td>\n",
1826
+ " <td>NaN</td>\n",
1827
+ " <td>...</td>\n",
1828
+ " <td>NaN</td>\n",
1829
+ " <td>NaN</td>\n",
1830
+ " <td>NaN</td>\n",
1831
+ " <td>jpg</td>\n",
1832
+ " <td>5526257</td>\n",
1833
+ " <td>NaN</td>\n",
1834
+ " <td>NaN</td>\n",
1835
+ " <td>NaN</td>\n",
1836
+ " <td>https://zenodo.org/record/5526257/files/CAM045...</td>\n",
1837
+ " <td>None</td>\n",
1838
+ " </tr>\n",
1839
+ " <tr>\n",
1840
+ " <th>49106</th>\n",
1841
+ " <td>F901</td>\n",
1842
+ " <td>38167</td>\n",
1843
+ " <td>F901_d.CR2</td>\n",
1844
+ " <td>dorsal</td>\n",
1845
+ " <td>Anniina.Mattila.Bred.F.csv</td>\n",
1846
+ " <td>https://zenodo.org/record/2555086</td>\n",
1847
+ " <td>NaN</td>\n",
1848
+ " <td>NaN</td>\n",
1849
+ " <td>NaN</td>\n",
1850
+ " <td>NaN</td>\n",
1851
+ " <td>...</td>\n",
1852
+ " <td>NaN</td>\n",
1853
+ " <td>NaN</td>\n",
1854
+ " <td>NaN</td>\n",
1855
+ " <td>raw</td>\n",
1856
+ " <td>2555086</td>\n",
1857
+ " <td>NaN</td>\n",
1858
+ " <td>NaN</td>\n",
1859
+ " <td>NaN</td>\n",
1860
+ " <td>https://zenodo.org/record/2555086/files/F901_d...</td>\n",
1861
+ " <td>None</td>\n",
1862
+ " </tr>\n",
1863
+ " </tbody>\n",
1864
+ "</table>\n",
1865
+ "<p>5 rows × 28 columns</p>\n",
1866
+ "</div>"
1867
+ ],
1868
+ "text/plain": [
1869
+ " CAMID X Image_name View \\\n",
1870
+ "46747 CAM045219 43439 CAM045219_d.JPG dorsal \n",
1871
+ "47062 CAM045298 43756 CAM045298_v.CR2 ventral \n",
1872
+ "37255 CAM042050 43982 CAM042050_d.JPG dorsal \n",
1873
+ "46992 CAM045281 43687 CAM045281_d.JPG dorsal \n",
1874
+ "49106 F901 38167 F901_d.CR2 dorsal \n",
1875
+ "\n",
1876
+ " zenodo_name zenodo_link \\\n",
1877
+ "46747 image.names.cook.island.erato.csv https://zenodo.org/record/5526257 \n",
1878
+ "47062 image.names.cook.island.erato.csv https://zenodo.org/record/5526257 \n",
1879
+ "37255 Collection_August2019.csv https://zenodo.org/record/5731587 \n",
1880
+ "46992 image.names.cook.island.erato.csv https://zenodo.org/record/5526257 \n",
1881
+ "49106 Anniina.Mattila.Bred.F.csv https://zenodo.org/record/2555086 \n",
1882
+ "\n",
1883
+ " Sequence Taxonomic_Name Locality Sample_accession ... Stage Sex \\\n",
1884
+ "46747 45,219 NaN NaN NaN ... NaN NaN \n",
1885
+ "47062 45,298 NaN NaN NaN ... NaN NaN \n",
1886
+ "37255 42,050 NaN NaN NaN ... NaN NaN \n",
1887
+ "46992 45,281 NaN NaN NaN ... NaN NaN \n",
1888
+ "49106 NaN NaN NaN NaN ... NaN NaN \n",
1889
+ "\n",
1890
+ " Unit_Type file_type record_number species subspecies genus \\\n",
1891
+ "46747 NaN jpg 5526257 NaN NaN NaN \n",
1892
+ "47062 NaN raw 5526257 NaN NaN NaN \n",
1893
+ "37255 NaN jpg 5731587 NaN NaN NaN \n",
1894
+ "46992 NaN jpg 5526257 NaN NaN NaN \n",
1895
+ "49106 NaN raw 2555086 NaN NaN NaN \n",
1896
+ "\n",
1897
+ " file_url hybrid_stat \n",
1898
+ "46747 https://zenodo.org/record/5526257/files/CAM045... None \n",
1899
+ "47062 https://zenodo.org/record/5526257/files/CAM045... None \n",
1900
+ "37255 https://zenodo.org/record/5731587/files/CAM042... None \n",
1901
+ "46992 https://zenodo.org/record/5526257/files/CAM045... None \n",
1902
+ "49106 https://zenodo.org/record/2555086/files/F901_d... None \n",
1903
+ "\n",
1904
+ "[5 rows x 28 columns]"
1905
+ ]
1906
+ },
1907
+ "execution_count": 33,
1908
+ "metadata": {},
1909
+ "output_type": "execute_result"
1910
+ }
1911
+ ],
1912
+ "source": [
1913
+ "df.loc[df.record_number.isin(pot_single_taxa_records)].sample(5)"
1914
+ ]
1915
+ },
1916
+ {
1917
+ "cell_type": "markdown",
1918
+ "metadata": {},
1919
+ "source": [
1920
+ "Christopher agrees that the following is sufficient to label images from the following three records:\n",
1921
+ ">3 records seem to have all of just one indicated species/subspecies: https://zenodo.org/record/5526257, https://zenodo.org/record/2554218, and https://zenodo.org/record/2555086. According to their Zenodo pages, the first appear to be all _Heliconius erato ssp. cyrbia_, the second indicates all _Heliconius erato_, and the third it seems is all bred specimens of _Heliconius erato demophoon_. \n",
1922
+ "\n",
1923
+ "`Unit_Type` and some other details could potentially be realigned at a later date, but we'll stick with taxonomic information for now."
1924
+ ]
1925
+ },
1926
+ {
1927
+ "cell_type": "code",
1928
+ "execution_count": 34,
1929
+ "metadata": {},
1930
+ "outputs": [],
1931
+ "source": [
1932
+ "df.loc[df[\"record_number\"] == 5526257, \"Taxonomic_Name\"] = \"Heliconius erato ssp. cyrbia\"\n",
1933
+ "df.loc[df[\"record_number\"] == 5526257, \"genus\"] = \"Heliconius\"\n",
1934
+ "df.loc[df[\"record_number\"] == 5526257, \"species\"] = \"Heliconius erato\"\n",
1935
+ "df.loc[df[\"record_number\"] == 5526257, \"subspecies\"] = \"cyrbia\"\n",
1936
+ "df.loc[df[\"record_number\"] == 5526257, \"hybrid_stat\"] = \"non-hybrid\""
1937
+ ]
1938
+ },
1939
+ {
1940
+ "cell_type": "code",
1941
+ "execution_count": 35,
1942
+ "metadata": {},
1943
+ "outputs": [],
1944
+ "source": [
1945
+ "df.loc[df[\"record_number\"] == 2554218, \"Taxonomic_Name\"] = \"Heliconius erato\"\n",
1946
+ "df.loc[df[\"record_number\"] == 2554218, \"genus\"] = \"Heliconius\"\n",
1947
+ "df.loc[df[\"record_number\"] == 2554218, \"species\"] = \"Heliconius erato\""
1948
+ ]
1949
+ },
1950
+ {
1951
+ "cell_type": "code",
1952
+ "execution_count": 36,
1953
+ "metadata": {},
1954
+ "outputs": [],
1955
+ "source": [
1956
+ "df.loc[df[\"record_number\"] == 2555086, \"Taxonomic_Name\"] = \"Heliconius erato ssp. demophoon\"\n",
1957
+ "df.loc[df[\"record_number\"] == 2555086, \"genus\"] = \"Heliconius\"\n",
1958
+ "df.loc[df[\"record_number\"] == 2555086, \"species\"] = \"Heliconius erato\"\n",
1959
+ "df.loc[df[\"record_number\"] == 2555086, \"subspecies\"] = \"demophoon\"\n",
1960
+ "df.loc[df[\"record_number\"] == 2555086, \"hybrid_stat\"] = \"non-hybrid\""
1961
+ ]
1962
+ },
1963
+ {
1964
+ "cell_type": "markdown",
1965
+ "metadata": {},
1966
+ "source": [
1967
+ "### Save record of entries with no Taxonomic Info"
1968
+ ]
1969
+ },
1970
+ {
1971
+ "cell_type": "code",
1972
+ "execution_count": 37,
1973
+ "metadata": {},
1974
+ "outputs": [
1975
+ {
1976
+ "data": {
1977
+ "text/plain": [
1978
+ "(1630, 28)"
1979
+ ]
1980
+ },
1981
+ "execution_count": 37,
1982
+ "metadata": {},
1983
+ "output_type": "execute_result"
1984
+ }
1985
+ ],
1986
+ "source": [
1987
+ "missing_taxa_df = df.loc[df.Taxonomic_Name.isna()]\n",
1988
+ "missing_taxa_df.shape"
1989
+ ]
1990
+ },
1991
+ {
1992
+ "cell_type": "code",
1993
+ "execution_count": 39,
1994
+ "metadata": {},
1995
+ "outputs": [],
1996
+ "source": [
1997
+ "missing_taxa_df.to_csv(\"../metadata/Missing_taxa_Jiggins_Zenodo_Master.csv\", index = False)"
1998
+ ]
1999
+ },
2000
+ {
2001
+ "cell_type": "markdown",
2002
+ "metadata": {},
2003
+ "source": [
2004
+ "### Drop Entries with no Taxonomic Information"
2005
+ ]
2006
+ },
2007
+ {
2008
+ "cell_type": "code",
2009
+ "execution_count": 40,
2010
+ "metadata": {},
2011
+ "outputs": [],
2012
+ "source": [
2013
+ "master_df = df.loc[df.Taxonomic_Name.notna()]"
2014
+ ]
2015
+ },
2016
+ {
2017
+ "cell_type": "markdown",
2018
+ "metadata": {},
2019
+ "source": [
2020
+ "## Final stats for all data in master file summarized here."
2021
+ ]
2022
+ },
2023
+ {
2024
+ "cell_type": "code",
2025
+ "execution_count": 41,
2026
+ "metadata": {},
2027
+ "outputs": [
2028
+ {
2029
+ "data": {
2030
+ "text/plain": [
2031
+ "CAMID 11991\n",
2032
+ "X 44809\n",
2033
+ "Image_name 36281\n",
2034
+ "View 7\n",
2035
+ "zenodo_name 33\n",
2036
+ "zenodo_link 30\n",
2037
+ "Sequence 10905\n",
2038
+ "Taxonomic_Name 366\n",
2039
+ "Locality 645\n",
2040
+ "Sample_accession 1559\n",
2041
+ "Collected_by 12\n",
2042
+ "Other_ID 3081\n",
2043
+ "Date 807\n",
2044
+ "Dataset 8\n",
2045
+ "Store 137\n",
2046
+ "Brood 224\n",
2047
+ "Death_Date 81\n",
2048
+ "Cross_Type 30\n",
2049
+ "Stage 1\n",
2050
+ "Sex 3\n",
2051
+ "Unit_Type 4\n",
2052
+ "file_type 3\n",
2053
+ "record_number 30\n",
2054
+ "species 246\n",
2055
+ "subspecies 155\n",
2056
+ "genus 94\n",
2057
+ "file_url 44794\n",
2058
+ "hybrid_stat 2\n",
2059
+ "dtype: int64"
2060
+ ]
2061
+ },
2062
+ "execution_count": 41,
2063
+ "metadata": {},
2064
+ "output_type": "execute_result"
2065
+ }
2066
+ ],
2067
+ "source": [
2068
+ "master_df.nunique()"
2069
+ ]
2070
+ },
2071
+ {
2072
+ "cell_type": "code",
2073
+ "execution_count": 42,
2074
+ "metadata": {},
2075
+ "outputs": [
2076
+ {
2077
+ "name": "stdout",
2078
+ "output_type": "stream",
2079
+ "text": [
2080
+ "<class 'pandas.core.frame.DataFrame'>\n",
2081
+ "Index: 44809 entries, 6 to 49358\n",
2082
+ "Data columns (total 28 columns):\n",
2083
+ " # Column Non-Null Count Dtype \n",
2084
+ "--- ------ -------------- ----- \n",
2085
+ " 0 CAMID 44809 non-null object\n",
2086
+ " 1 X 44809 non-null int64 \n",
2087
+ " 2 Image_name 44809 non-null object\n",
2088
+ " 3 View 44030 non-null object\n",
2089
+ " 4 zenodo_name 44809 non-null object\n",
2090
+ " 5 zenodo_link 44809 non-null object\n",
2091
+ " 6 Sequence 43877 non-null object\n",
2092
+ " 7 Taxonomic_Name 44809 non-null object\n",
2093
+ " 8 Locality 31708 non-null object\n",
2094
+ " 9 Sample_accession 4572 non-null object\n",
2095
+ " 10 Collected_by 3043 non-null object\n",
2096
+ " 11 Other_ID 14352 non-null object\n",
2097
+ " 12 Date 30730 non-null object\n",
2098
+ " 13 Dataset 37024 non-null object\n",
2099
+ " 14 Store 36220 non-null object\n",
2100
+ " 15 Brood 14258 non-null object\n",
2101
+ " 16 Death_Date 316 non-null object\n",
2102
+ " 17 Cross_Type 4452 non-null object\n",
2103
+ " 18 Stage 6 non-null object\n",
2104
+ " 19 Sex 33312 non-null object\n",
2105
+ " 20 Unit_Type 30923 non-null object\n",
2106
+ " 21 file_type 44809 non-null object\n",
2107
+ " 22 record_number 44809 non-null int64 \n",
2108
+ " 23 species 44809 non-null object\n",
2109
+ " 24 subspecies 24559 non-null object\n",
2110
+ " 25 genus 44809 non-null object\n",
2111
+ " 26 file_url 44809 non-null object\n",
2112
+ " 27 hybrid_stat 25139 non-null object\n",
2113
+ "dtypes: int64(2), object(26)\n",
2114
+ "memory usage: 9.9+ MB\n"
2115
+ ]
2116
+ }
2117
+ ],
2118
+ "source": [
2119
+ "master_df.info()"
2120
+ ]
2121
+ },
2122
+ {
2123
+ "cell_type": "markdown",
2124
+ "metadata": {},
2125
+ "source": [
2126
+ "### Update Master File with Hybrid Status and URL Columns (& unique records)"
2127
+ ]
2128
+ },
2129
+ {
2130
+ "cell_type": "code",
2131
+ "execution_count": 44,
2132
+ "metadata": {},
2133
+ "outputs": [],
2134
+ "source": [
2135
+ "master_df.to_csv(\"../Jiggins_Zenodo_Img_Master.csv\", index = False)"
2136
+ ]
2137
+ },
2138
+ {
2139
+ "cell_type": "markdown",
2140
+ "metadata": {},
2141
+ "source": [
2142
+ "## Make Heliconius Subset"
2143
+ ]
2144
+ },
2145
+ {
2146
+ "cell_type": "code",
2147
+ "execution_count": 45,
2148
+ "metadata": {},
2149
+ "outputs": [
2150
+ {
2151
+ "name": "stdout",
2152
+ "output_type": "stream",
2153
+ "text": [
2154
+ "<class 'pandas.core.frame.DataFrame'>\n",
2155
+ "Index: 34265 entries, 6 to 49358\n",
2156
+ "Data columns (total 28 columns):\n",
2157
+ " # Column Non-Null Count Dtype \n",
2158
+ "--- ------ -------------- ----- \n",
2159
+ " 0 CAMID 34265 non-null object\n",
2160
+ " 1 X 34265 non-null int64 \n",
2161
+ " 2 Image_name 34265 non-null object\n",
2162
+ " 3 View 33486 non-null object\n",
2163
+ " 4 zenodo_name 34265 non-null object\n",
2164
+ " 5 zenodo_link 34265 non-null object\n",
2165
+ " 6 Sequence 33333 non-null object\n",
2166
+ " 7 Taxonomic_Name 34265 non-null object\n",
2167
+ " 8 Locality 21180 non-null object\n",
2168
+ " 9 Sample_accession 4572 non-null object\n",
2169
+ " 10 Collected_by 3043 non-null object\n",
2170
+ " 11 Other_ID 6404 non-null object\n",
2171
+ " 12 Date 20244 non-null object\n",
2172
+ " 13 Dataset 29926 non-null object\n",
2173
+ " 14 Store 26526 non-null object\n",
2174
+ " 15 Brood 14242 non-null object\n",
2175
+ " 16 Death_Date 316 non-null object\n",
2176
+ " 17 Cross_Type 4452 non-null object\n",
2177
+ " 18 Stage 6 non-null object\n",
2178
+ " 19 Sex 30984 non-null object\n",
2179
+ " 20 Unit_Type 29055 non-null object\n",
2180
+ " 21 file_type 34265 non-null object\n",
2181
+ " 22 record_number 34265 non-null int64 \n",
2182
+ " 23 species 34265 non-null object\n",
2183
+ " 24 subspecies 23801 non-null object\n",
2184
+ " 25 genus 34265 non-null object\n",
2185
+ " 26 file_url 34265 non-null object\n",
2186
+ " 27 hybrid_stat 24317 non-null object\n",
2187
+ "dtypes: int64(2), object(26)\n",
2188
+ "memory usage: 7.6+ MB\n"
2189
+ ]
2190
+ }
2191
+ ],
2192
+ "source": [
2193
+ "heliconius_subset = master_df.loc[master_df.genus.str.lower() == \"heliconius\"]\n",
2194
+ "\n",
2195
+ "heliconius_subset.info()"
2196
+ ]
2197
+ },
2198
+ {
2199
+ "cell_type": "code",
2200
+ "execution_count": 46,
2201
+ "metadata": {},
2202
+ "outputs": [
2203
+ {
2204
+ "data": {
2205
+ "text/plain": [
2206
+ "CAMID 10109\n",
2207
+ "X 34265\n",
2208
+ "Image_name 29192\n",
2209
+ "View 3\n",
2210
+ "zenodo_name 33\n",
2211
+ "zenodo_link 30\n",
2212
+ "Sequence 9031\n",
2213
+ "Taxonomic_Name 132\n",
2214
+ "Locality 472\n",
2215
+ "Sample_accession 1559\n",
2216
+ "Collected_by 12\n",
2217
+ "Other_ID 1865\n",
2218
+ "Date 776\n",
2219
+ "Dataset 8\n",
2220
+ "Store 121\n",
2221
+ "Brood 224\n",
2222
+ "Death_Date 81\n",
2223
+ "Cross_Type 30\n",
2224
+ "Stage 1\n",
2225
+ "Sex 3\n",
2226
+ "Unit_Type 4\n",
2227
+ "file_type 3\n",
2228
+ "record_number 30\n",
2229
+ "species 37\n",
2230
+ "subspecies 110\n",
2231
+ "genus 1\n",
2232
+ "file_url 34250\n",
2233
+ "hybrid_stat 2\n",
2234
+ "dtype: int64"
2235
+ ]
2236
+ },
2237
+ "execution_count": 46,
2238
+ "metadata": {},
2239
+ "output_type": "execute_result"
2240
+ }
2241
+ ],
2242
+ "source": [
2243
+ "heliconius_subset.nunique()"
2244
+ ]
2245
+ },
2246
+ {
2247
+ "cell_type": "code",
2248
+ "execution_count": 47,
2249
+ "metadata": {},
2250
+ "outputs": [
2251
+ {
2252
+ "data": {
2253
+ "text/plain": [
2254
+ "View\n",
2255
+ "dorsal 16882\n",
2256
+ "ventral 16586\n",
2257
+ "dorsal and ventral 18\n",
2258
+ "Name: count, dtype: int64"
2259
+ ]
2260
+ },
2261
+ "execution_count": 47,
2262
+ "metadata": {},
2263
+ "output_type": "execute_result"
2264
+ }
2265
+ ],
2266
+ "source": [
2267
+ "heliconius_subset.View.value_counts()"
2268
+ ]
2269
+ },
2270
+ {
2271
+ "cell_type": "markdown",
2272
+ "metadata": {},
2273
+ "source": [
2274
+ "Note that this subset is distributed across 30 Zenodo records from the [Butterfly Genetics Group](https://zenodo.org/communities/butterfly?q=&l=list&p=1&s=10&sort=newest)."
2275
+ ]
2276
+ },
2277
+ {
2278
+ "cell_type": "markdown",
2279
+ "metadata": {},
2280
+ "source": [
2281
+ "### Save the Heliconius Subset to CSV\n"
2282
+ ]
2283
+ },
2284
+ {
2285
+ "cell_type": "code",
2286
+ "execution_count": 48,
2287
+ "metadata": {},
2288
+ "outputs": [],
2289
+ "source": [
2290
+ "heliconius_subset.to_csv(\"../Jiggins_Heliconius_Master.csv\", index = False)"
2291
+ ]
2292
+ },
2293
+ {
2294
+ "cell_type": "markdown",
2295
+ "metadata": {},
2296
+ "source": [
2297
+ "## Make Dorsal Subset"
2298
+ ]
2299
+ },
2300
+ {
2301
+ "cell_type": "code",
2302
+ "execution_count": 49,
2303
+ "metadata": {},
2304
+ "outputs": [
2305
+ {
2306
+ "name": "stdout",
2307
+ "output_type": "stream",
2308
+ "text": [
2309
+ "<class 'pandas.core.frame.DataFrame'>\n",
2310
+ "Index: 22175 entries, 7 to 49357\n",
2311
+ "Data columns (total 28 columns):\n",
2312
+ " # Column Non-Null Count Dtype \n",
2313
+ "--- ------ -------------- ----- \n",
2314
+ " 0 CAMID 22175 non-null object\n",
2315
+ " 1 X 22175 non-null int64 \n",
2316
+ " 2 Image_name 22175 non-null object\n",
2317
+ " 3 View 22175 non-null object\n",
2318
+ " 4 zenodo_name 22175 non-null object\n",
2319
+ " 5 zenodo_link 22175 non-null object\n",
2320
+ " 6 Sequence 21709 non-null object\n",
2321
+ " 7 Taxonomic_Name 22175 non-null object\n",
2322
+ " 8 Locality 15615 non-null object\n",
2323
+ " 9 Sample_accession 2294 non-null object\n",
2324
+ " 10 Collected_by 1533 non-null object\n",
2325
+ " 11 Other_ID 6916 non-null object\n",
2326
+ " 12 Date 15347 non-null object\n",
2327
+ " 13 Dataset 18250 non-null object\n",
2328
+ " 14 Store 18254 non-null object\n",
2329
+ " 15 Brood 6920 non-null object\n",
2330
+ " 16 Death_Date 106 non-null object\n",
2331
+ " 17 Cross_Type 2230 non-null object\n",
2332
+ " 18 Stage 3 non-null object\n",
2333
+ " 19 Sex 16403 non-null object\n",
2334
+ " 20 Unit_Type 15203 non-null object\n",
2335
+ " 21 file_type 22175 non-null object\n",
2336
+ " 22 record_number 22175 non-null int64 \n",
2337
+ " 23 species 22175 non-null object\n",
2338
+ " 24 subspecies 12040 non-null object\n",
2339
+ " 25 genus 22175 non-null object\n",
2340
+ " 26 file_url 22175 non-null object\n",
2341
+ " 27 hybrid_stat 12330 non-null object\n",
2342
+ "dtypes: int64(2), object(26)\n",
2343
+ "memory usage: 4.9+ MB\n"
2344
+ ]
2345
+ }
2346
+ ],
2347
+ "source": [
2348
+ "dorsal_views = [view for view in list(master_df.View.dropna().unique()) if \"dorsal\" in view]\n",
2349
+ "\n",
2350
+ "dorsal_subset = master_df.loc[master_df[\"View\"].isin(dorsal_views)]\n",
2351
+ "dorsal_subset.info()"
2352
+ ]
2353
+ },
2354
+ {
2355
+ "cell_type": "code",
2356
+ "execution_count": 50,
2357
+ "metadata": {},
2358
+ "outputs": [
2359
+ {
2360
+ "data": {
2361
+ "text/plain": [
2362
+ "CAMID 11776\n",
2363
+ "X 22175\n",
2364
+ "Image_name 17907\n",
2365
+ "View 4\n",
2366
+ "zenodo_name 33\n",
2367
+ "zenodo_link 30\n",
2368
+ "Sequence 10713\n",
2369
+ "Taxonomic_Name 362\n",
2370
+ "Locality 642\n",
2371
+ "Sample_accession 1552\n",
2372
+ "Collected_by 12\n",
2373
+ "Other_ID 2890\n",
2374
+ "Date 791\n",
2375
+ "Dataset 8\n",
2376
+ "Store 137\n",
2377
+ "Brood 215\n",
2378
+ "Death_Date 63\n",
2379
+ "Cross_Type 30\n",
2380
+ "Stage 1\n",
2381
+ "Sex 3\n",
2382
+ "Unit_Type 4\n",
2383
+ "file_type 3\n",
2384
+ "record_number 30\n",
2385
+ "species 245\n",
2386
+ "subspecies 152\n",
2387
+ "genus 94\n",
2388
+ "file_url 22168\n",
2389
+ "hybrid_stat 2\n",
2390
+ "dtype: int64"
2391
+ ]
2392
+ },
2393
+ "execution_count": 50,
2394
+ "metadata": {},
2395
+ "output_type": "execute_result"
2396
+ }
2397
+ ],
2398
+ "source": [
2399
+ "dorsal_subset.nunique()"
2400
+ ]
2401
+ },
2402
+ {
2403
+ "cell_type": "markdown",
2404
+ "metadata": {},
2405
+ "source": [
2406
+ "Observe that we still have duplicate samples (duplicated `CAMID`), so we'll add a column indicating this (`CAM_Dupe`). We will not leave the first instance as a non-duplicate to have a clear assessment of all duplication (eg., is it just across a couple records).\n",
2407
+ "\n",
2408
+ "Note that they will be duplicated for the images that are of a dorsal forewing or hindwing, so we will label those as `single_wing`."
2409
+ ]
2410
+ },
2411
+ {
2412
+ "cell_type": "code",
2413
+ "execution_count": 51,
2414
+ "metadata": {},
2415
+ "outputs": [
2416
+ {
2417
+ "name": "stderr",
2418
+ "output_type": "stream",
2419
+ "text": [
2420
+ "/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_21745/2272441064.py:1: SettingWithCopyWarning: \n",
2421
+ "A value is trying to be set on a copy of a slice from a DataFrame.\n",
2422
+ "Try using .loc[row_indexer,col_indexer] = value instead\n",
2423
+ "\n",
2424
+ "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
2425
+ " dorsal_subset[\"CAM_Dupe\"] = dorsal_subset.duplicated(subset = \"CAMID\", keep = False)\n"
2426
+ ]
2427
+ },
2428
+ {
2429
+ "data": {
2430
+ "text/plain": [
2431
+ "CAM_Dupe\n",
2432
+ "True 17213\n",
2433
+ "False 4170\n",
2434
+ "single-wing 792\n",
2435
+ "Name: count, dtype: int64"
2436
+ ]
2437
+ },
2438
+ "execution_count": 51,
2439
+ "metadata": {},
2440
+ "output_type": "execute_result"
2441
+ }
2442
+ ],
2443
+ "source": [
2444
+ "dorsal_subset[\"CAM_Dupe\"] = dorsal_subset.duplicated(subset = \"CAMID\", keep = False)\n",
2445
+ "dorsal_subset.loc[dorsal_subset[\"View\"].isin([\"forewing dorsal\", \"hindwing dorsal\"]), \"CAM_Dupe\"] = \"single-wing\"\n",
2446
+ "dorsal_subset[\"CAM_Dupe\"].value_counts()"
2447
+ ]
2448
+ },
2449
+ {
2450
+ "cell_type": "code",
2451
+ "execution_count": 52,
2452
+ "metadata": {},
2453
+ "outputs": [
2454
+ {
2455
+ "data": {
2456
+ "text/plain": [
2457
+ "29"
2458
+ ]
2459
+ },
2460
+ "execution_count": 52,
2461
+ "metadata": {},
2462
+ "output_type": "execute_result"
2463
+ }
2464
+ ],
2465
+ "source": [
2466
+ "dorsal_subset.loc[dorsal_subset[\"CAM_Dupe\"] == True, \"record_number\"].nunique()"
2467
+ ]
2468
+ },
2469
+ {
2470
+ "cell_type": "markdown",
2471
+ "metadata": {},
2472
+ "source": [
2473
+ "Okay, nearly all records have duplication even in the dorsal subset. That does make sense when we have just over half as many unique `CAMID`s as number of images."
2474
+ ]
2475
+ },
2476
+ {
2477
+ "cell_type": "code",
2478
+ "execution_count": 53,
2479
+ "metadata": {},
2480
+ "outputs": [
2481
+ {
2482
+ "data": {
2483
+ "text/plain": [
2484
+ "record_number\n",
2485
+ "4287444 396\n",
2486
+ "4288250 284\n",
2487
+ "3569598 112\n",
2488
+ "Name: count, dtype: int64"
2489
+ ]
2490
+ },
2491
+ "execution_count": 53,
2492
+ "metadata": {},
2493
+ "output_type": "execute_result"
2494
+ }
2495
+ ],
2496
+ "source": [
2497
+ "dorsal_subset.loc[dorsal_subset[\"CAM_Dupe\"] == \"single-wing\", \"record_number\"].value_counts()"
2498
+ ]
2499
+ },
2500
+ {
2501
+ "cell_type": "markdown",
2502
+ "metadata": {},
2503
+ "source": [
2504
+ "Single-wing images are constrained to 3 records."
2505
+ ]
2506
+ },
2507
+ {
2508
+ "cell_type": "code",
2509
+ "execution_count": 54,
2510
+ "metadata": {},
2511
+ "outputs": [
2512
+ {
2513
+ "data": {
2514
+ "text/plain": [
2515
+ "file_type\n",
2516
+ "jpg 11752\n",
2517
+ "raw 5440\n",
2518
+ "tif 21\n",
2519
+ "Name: count, dtype: int64"
2520
+ ]
2521
+ },
2522
+ "execution_count": 54,
2523
+ "metadata": {},
2524
+ "output_type": "execute_result"
2525
+ }
2526
+ ],
2527
+ "source": [
2528
+ "dorsal_subset.loc[dorsal_subset[\"CAM_Dupe\"] == True, \"file_type\"].value_counts()"
2529
+ ]
2530
+ },
2531
+ {
2532
+ "cell_type": "markdown",
2533
+ "metadata": {},
2534
+ "source": [
2535
+ "Some of this duplication is by file type."
2536
+ ]
2537
+ },
2538
+ {
2539
+ "cell_type": "code",
2540
+ "execution_count": 55,
2541
+ "metadata": {},
2542
+ "outputs": [
2543
+ {
2544
+ "data": {
2545
+ "text/plain": [
2546
+ "True 8415\n",
2547
+ "False 3337\n",
2548
+ "Name: count, dtype: int64"
2549
+ ]
2550
+ },
2551
+ "execution_count": 55,
2552
+ "metadata": {},
2553
+ "output_type": "execute_result"
2554
+ }
2555
+ ],
2556
+ "source": [
2557
+ "dorsal_subset.loc[(dorsal_subset[\"CAM_Dupe\"] == True) & (dorsal_subset[\"file_type\"] == \"jpg\")].duplicated(subset = \"CAMID\", keep = False).value_counts()"
2558
+ ]
2559
+ },
2560
+ {
2561
+ "cell_type": "code",
2562
+ "execution_count": 56,
2563
+ "metadata": {},
2564
+ "outputs": [
2565
+ {
2566
+ "data": {
2567
+ "text/plain": [
2568
+ "False 4106\n",
2569
+ "True 1334\n",
2570
+ "Name: count, dtype: int64"
2571
+ ]
2572
+ },
2573
+ "execution_count": 56,
2574
+ "metadata": {},
2575
+ "output_type": "execute_result"
2576
+ }
2577
+ ],
2578
+ "source": [
2579
+ "dorsal_subset.loc[(dorsal_subset[\"CAM_Dupe\"] == True) & (dorsal_subset[\"file_type\"] == \"raw\")].duplicated(subset = \"CAMID\", keep = False).value_counts()"
2580
+ ]
2581
+ },
2582
+ {
2583
+ "cell_type": "markdown",
2584
+ "metadata": {},
2585
+ "source": [
2586
+ "We have multiple jpg images & multiple raw images of the same specimen. Note that this does not necessarily mean these are duplicates of the same images. There are also jpg copies provided alongside raw images."
2587
+ ]
2588
+ },
2589
+ {
2590
+ "cell_type": "markdown",
2591
+ "metadata": {},
2592
+ "source": [
2593
+ "### Save Dorsal Subset to CSV"
2594
+ ]
2595
+ },
2596
+ {
2597
+ "cell_type": "code",
2598
+ "execution_count": 57,
2599
+ "metadata": {},
2600
+ "outputs": [],
2601
+ "source": [
2602
+ "dorsal_subset.to_csv(\"../Jiggins_Zenodo_dorsal_Img_Master.csv\", index = False)"
2603
+ ]
2604
+ },
2605
+ {
2606
+ "cell_type": "code",
2607
+ "execution_count": null,
2608
+ "metadata": {},
2609
+ "outputs": [],
2610
+ "source": []
2611
+ }
2612
+ ],
2613
+ "metadata": {
2614
+ "kernelspec": {
2615
+ "display_name": "std",
2616
+ "language": "python",
2617
+ "name": "python3"
2618
+ },
2619
+ "language_info": {
2620
+ "codemirror_mode": {
2621
+ "name": "ipython",
2622
+ "version": 3
2623
+ },
2624
+ "file_extension": ".py",
2625
+ "mimetype": "text/x-python",
2626
+ "name": "python",
2627
+ "nbconvert_exporter": "python",
2628
+ "pygments_lexer": "ipython3",
2629
+ "version": "3.11.3"
2630
+ },
2631
+ "orig_nbformat": 4
2632
+ },
2633
+ "nbformat": 4,
2634
+ "nbformat_minor": 2
2635
+ }