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ution_count": 2,
|
15 |
+
"metadata": {},
|
16 |
+
"outputs": [],
|
17 |
+
"source": [
|
18 |
+
"df = pd.read_csv(\"../Jiggins_Zenodo_Img_Master.csv\", low_memory=False)"
|
19 |
+
]
|
20 |
+
},
|
21 |
+
{
|
22 |
+
"cell_type": "code",
|
23 |
+
"execution_count": 3,
|
24 |
+
"metadata": {},
|
25 |
+
"outputs": [
|
26 |
+
{
|
27 |
+
"data": {
|
28 |
+
"text/plain": [
|
29 |
+
"CAMID 12586\n",
|
30 |
+
"X 49359\n",
|
31 |
+
"Image_name 37821\n",
|
32 |
+
"View 10\n",
|
33 |
+
"zenodo_name 36\n",
|
34 |
+
"zenodo_link 32\n",
|
35 |
+
"Sequence 11301\n",
|
36 |
+
"Taxonomic_Name 363\n",
|
37 |
+
"Locality 645\n",
|
38 |
+
"Sample_accession 1571\n",
|
39 |
+
"Collected_by 12\n",
|
40 |
+
"Other_ID 3088\n",
|
41 |
+
"Date 810\n",
|
42 |
+
"Dataset 8\n",
|
43 |
+
"Store 142\n",
|
44 |
+
"Brood 226\n",
|
45 |
+
"Death_Date 82\n",
|
46 |
+
"Cross_Type 30\n",
|
47 |
+
"Stage 1\n",
|
48 |
+
"Sex 3\n",
|
49 |
+
"Unit_Type 6\n",
|
50 |
+
"file_type 3\n",
|
51 |
+
"dtype: int64"
|
52 |
+
]
|
53 |
+
},
|
54 |
+
"execution_count": 3,
|
55 |
+
"metadata": {},
|
56 |
+
"output_type": "execute_result"
|
57 |
+
}
|
58 |
+
],
|
59 |
+
"source": [
|
60 |
+
"df.nunique()"
|
61 |
+
]
|
62 |
+
},
|
63 |
+
{
|
64 |
+
"cell_type": "code",
|
65 |
+
"execution_count": 4,
|
66 |
+
"metadata": {},
|
67 |
+
"outputs": [
|
68 |
+
{
|
69 |
+
"data": {
|
70 |
+
"text/plain": [
|
71 |
+
"file_type\n",
|
72 |
+
"jpg 37072\n",
|
73 |
+
"raw 12226\n",
|
74 |
+
"tif 61\n",
|
75 |
+
"Name: count, dtype: int64"
|
76 |
+
]
|
77 |
+
},
|
78 |
+
"execution_count": 4,
|
79 |
+
"metadata": {},
|
80 |
+
"output_type": "execute_result"
|
81 |
+
}
|
82 |
+
],
|
83 |
+
"source": [
|
84 |
+
"df.file_type.value_counts()"
|
85 |
+
]
|
86 |
+
},
|
87 |
+
{
|
88 |
+
"cell_type": "code",
|
89 |
+
"execution_count": 5,
|
90 |
+
"metadata": {},
|
91 |
+
"outputs": [
|
92 |
+
{
|
93 |
+
"data": {
|
94 |
+
"text/plain": [
|
95 |
+
"View\n",
|
96 |
+
"dorsal 15128\n",
|
97 |
+
"ventral 13424\n",
|
98 |
+
"Dorsal 8360\n",
|
99 |
+
"Ventral 8090\n",
|
100 |
+
"ventral 1644\n",
|
101 |
+
"forewing dorsal 406\n",
|
102 |
+
"hindwing dorsal 406\n",
|
103 |
+
"forewing ventral 406\n",
|
104 |
+
"hindwing ventral 406\n",
|
105 |
+
"Dorsal and Ventral 18\n",
|
106 |
+
"Name: count, dtype: int64"
|
107 |
+
]
|
108 |
+
},
|
109 |
+
"execution_count": 5,
|
110 |
+
"metadata": {},
|
111 |
+
"output_type": "execute_result"
|
112 |
+
}
|
113 |
+
],
|
114 |
+
"source": [
|
115 |
+
"df.View.value_counts()"
|
116 |
+
]
|
117 |
+
},
|
118 |
+
{
|
119 |
+
"cell_type": "markdown",
|
120 |
+
"metadata": {},
|
121 |
+
"source": [
|
122 |
+
"Not great that `ventral` gets listed twice as lowercase and _again_ as `Ventral`.\n",
|
123 |
+
"\n",
|
124 |
+
"### Standardize `View` Column\n",
|
125 |
+
"Let's standardize `View` so that there isn't a discrepancy based on case."
|
126 |
+
]
|
127 |
+
},
|
128 |
+
{
|
129 |
+
"cell_type": "code",
|
130 |
+
"execution_count": 6,
|
131 |
+
"metadata": {},
|
132 |
+
"outputs": [
|
133 |
+
{
|
134 |
+
"data": {
|
135 |
+
"text/plain": [
|
136 |
+
"View\n",
|
137 |
+
"dorsal 23488\n",
|
138 |
+
"ventral 21514\n",
|
139 |
+
"ventral 1644\n",
|
140 |
+
"forewing dorsal 406\n",
|
141 |
+
"hindwing dorsal 406\n",
|
142 |
+
"forewing ventral 406\n",
|
143 |
+
"hindwing ventral 406\n",
|
144 |
+
"dorsal and ventral 18\n",
|
145 |
+
"Name: count, dtype: int64"
|
146 |
+
]
|
147 |
+
},
|
148 |
+
"execution_count": 6,
|
149 |
+
"metadata": {},
|
150 |
+
"output_type": "execute_result"
|
151 |
+
}
|
152 |
+
],
|
153 |
+
"source": [
|
154 |
+
"df[\"View\"] = df.View.str.lower()\n",
|
155 |
+
"df.View.value_counts()"
|
156 |
+
]
|
157 |
+
},
|
158 |
+
{
|
159 |
+
"cell_type": "code",
|
160 |
+
"execution_count": 7,
|
161 |
+
"metadata": {},
|
162 |
+
"outputs": [
|
163 |
+
{
|
164 |
+
"name": "stdout",
|
165 |
+
"output_type": "stream",
|
166 |
+
"text": [
|
167 |
+
"['dorsal' 'ventral' nan 'dorsal and ventral' 'ventral ' 'forewing dorsal'\n",
|
168 |
+
" 'hindwing dorsal' 'forewing ventral' 'hindwing ventral']\n"
|
169 |
+
]
|
170 |
+
}
|
171 |
+
],
|
172 |
+
"source": [
|
173 |
+
"print(df.View.unique())"
|
174 |
+
]
|
175 |
+
},
|
176 |
+
{
|
177 |
+
"cell_type": "markdown",
|
178 |
+
"metadata": {},
|
179 |
+
"source": [
|
180 |
+
"Yes, one has a space after it, so we'll replace that."
|
181 |
+
]
|
182 |
+
},
|
183 |
+
{
|
184 |
+
"cell_type": "code",
|
185 |
+
"execution_count": 8,
|
186 |
+
"metadata": {},
|
187 |
+
"outputs": [
|
188 |
+
{
|
189 |
+
"data": {
|
190 |
+
"text/plain": [
|
191 |
+
"View\n",
|
192 |
+
"dorsal 23488\n",
|
193 |
+
"ventral 23158\n",
|
194 |
+
"forewing dorsal 406\n",
|
195 |
+
"hindwing dorsal 406\n",
|
196 |
+
"forewing ventral 406\n",
|
197 |
+
"hindwing ventral 406\n",
|
198 |
+
"dorsal and ventral 18\n",
|
199 |
+
"Name: count, dtype: int64"
|
200 |
+
]
|
201 |
+
},
|
202 |
+
"execution_count": 8,
|
203 |
+
"metadata": {},
|
204 |
+
"output_type": "execute_result"
|
205 |
+
}
|
206 |
+
],
|
207 |
+
"source": [
|
208 |
+
"df.loc[df[\"View\"] == \"ventral \", \"View\"] = \"ventral\"\n",
|
209 |
+
"df.View.value_counts() "
|
210 |
+
]
|
211 |
+
},
|
212 |
+
{
|
213 |
+
"cell_type": "markdown",
|
214 |
+
"metadata": {},
|
215 |
+
"source": [
|
216 |
+
"### Add Record Number Column\n",
|
217 |
+
"We'll add a `record_number` column for easier matching to the license/citation file."
|
218 |
+
]
|
219 |
+
},
|
220 |
+
{
|
221 |
+
"cell_type": "code",
|
222 |
+
"execution_count": 9,
|
223 |
+
"metadata": {},
|
224 |
+
"outputs": [],
|
225 |
+
"source": [
|
226 |
+
"def get_record_number(url):\n",
|
227 |
+
" num = url.split(sep = \"/\")[-1]\n",
|
228 |
+
" return num"
|
229 |
+
]
|
230 |
+
},
|
231 |
+
{
|
232 |
+
"cell_type": "code",
|
233 |
+
"execution_count": 10,
|
234 |
+
"metadata": {},
|
235 |
+
"outputs": [
|
236 |
+
{
|
237 |
+
"data": {
|
238 |
+
"text/plain": [
|
239 |
+
"32"
|
240 |
+
]
|
241 |
+
},
|
242 |
+
"execution_count": 10,
|
243 |
+
"metadata": {},
|
244 |
+
"output_type": "execute_result"
|
245 |
+
}
|
246 |
+
],
|
247 |
+
"source": [
|
248 |
+
"df[\"record_number\"] = df.zenodo_link.apply(get_record_number)\n",
|
249 |
+
"df.record_number.nunique()"
|
250 |
+
]
|
251 |
+
},
|
252 |
+
{
|
253 |
+
"cell_type": "markdown",
|
254 |
+
"metadata": {},
|
255 |
+
"source": [
|
256 |
+
"We have 32 unique records represented in the full dataset. When we reduce down to just the Heliconius images, this will probably be less."
|
257 |
+
]
|
258 |
+
},
|
259 |
+
{
|
260 |
+
"cell_type": "markdown",
|
261 |
+
"metadata": {},
|
262 |
+
"source": [
|
263 |
+
"### Add `species` and `subspecies` Columns\n",
|
264 |
+
"This will make some analysis easier and allow for easy viewing on the [Data Dashboard](https://huggingface.co/spaces/imageomics/dashboard-prototype)."
|
265 |
+
]
|
266 |
+
},
|
267 |
+
{
|
268 |
+
"cell_type": "code",
|
269 |
+
"execution_count": 11,
|
270 |
+
"metadata": {},
|
271 |
+
"outputs": [],
|
272 |
+
"source": [
|
273 |
+
"def get_species(taxa_name):\n",
|
274 |
+
" if type(taxa_name) != float: #taxa name not null\n",
|
275 |
+
" species = taxa_name.split(sep = \" ssp\")[0]\n",
|
276 |
+
" return species\n",
|
277 |
+
" else:\n",
|
278 |
+
" return taxa_name"
|
279 |
+
]
|
280 |
+
},
|
281 |
+
{
|
282 |
+
"cell_type": "code",
|
283 |
+
"execution_count": 12,
|
284 |
+
"metadata": {},
|
285 |
+
"outputs": [],
|
286 |
+
"source": [
|
287 |
+
"def get_subspecies(taxa_name):\n",
|
288 |
+
" if type(taxa_name) != float:\n",
|
289 |
+
" if \"ssp.\" in taxa_name:\n",
|
290 |
+
" subspecies = taxa_name.split(sep = \"ssp. \")[1]\n",
|
291 |
+
" elif \"ssp \" in taxa_name:\n",
|
292 |
+
" subspecies = taxa_name.split(sep = \"ssp \")[1]\n",
|
293 |
+
" else:\n",
|
294 |
+
" subspecies = None\n",
|
295 |
+
" else:\n",
|
296 |
+
" subspecies = None\n",
|
297 |
+
" return subspecies"
|
298 |
+
]
|
299 |
+
},
|
300 |
+
{
|
301 |
+
"cell_type": "code",
|
302 |
+
"execution_count": 13,
|
303 |
+
"metadata": {},
|
304 |
+
"outputs": [
|
305 |
+
{
|
306 |
+
"data": {
|
307 |
+
"text/plain": [
|
308 |
+
"246"
|
309 |
+
]
|
310 |
+
},
|
311 |
+
"execution_count": 13,
|
312 |
+
"metadata": {},
|
313 |
+
"output_type": "execute_result"
|
314 |
+
}
|
315 |
+
],
|
316 |
+
"source": [
|
317 |
+
"df[\"species\"] = df.Taxonomic_Name.apply(get_species)\n",
|
318 |
+
"df.species.nunique()"
|
319 |
+
]
|
320 |
+
},
|
321 |
+
{
|
322 |
+
"cell_type": "code",
|
323 |
+
"execution_count": 14,
|
324 |
+
"metadata": {},
|
325 |
+
"outputs": [
|
326 |
+
{
|
327 |
+
"data": {
|
328 |
+
"text/plain": [
|
329 |
+
"139"
|
330 |
+
]
|
331 |
+
},
|
332 |
+
"execution_count": 14,
|
333 |
+
"metadata": {},
|
334 |
+
"output_type": "execute_result"
|
335 |
+
}
|
336 |
+
],
|
337 |
+
"source": [
|
338 |
+
"df[\"subspecies\"] = df.Taxonomic_Name.apply(get_subspecies)\n",
|
339 |
+
"df.subspecies.nunique()"
|
340 |
+
]
|
341 |
+
},
|
342 |
+
{
|
343 |
+
"cell_type": "markdown",
|
344 |
+
"metadata": {},
|
345 |
+
"source": [
|
346 |
+
"Cross Types are labeled differently:\n",
|
347 |
+
"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."
|
348 |
+
]
|
349 |
+
},
|
350 |
+
{
|
351 |
+
"cell_type": "code",
|
352 |
+
"execution_count": 15,
|
353 |
+
"metadata": {},
|
354 |
+
"outputs": [
|
355 |
+
{
|
356 |
+
"data": {
|
357 |
+
"text/plain": [
|
358 |
+
"array(['mal', 'mal x ple', 'ple', 'ple x mal', 'latRo x not',\n",
|
359 |
+
" '(latRo x not) x not', '(mal x ple) x mal', '(mal x ple) x ple',\n",
|
360 |
+
" 'ple x (mal x ple)', '(ple x mal) x (mal x ple)', 'lat x not',\n",
|
361 |
+
" '(ple x mal) x ple', '(mal x ple) x (mal x ple)',\n",
|
362 |
+
" '(ple x mal) x mal', '(ple x mal) x (ple x mal)',\n",
|
363 |
+
" '(mal x ple) x (ple x mal)', 'hybrid', 'mal x (ple x mal)',\n",
|
364 |
+
" '(lat x not) x lat', '(lat x not) x not', 'Ac heterozygote',\n",
|
365 |
+
" 'ple x (ple x mal)', '2 banded', 'lat',\n",
|
366 |
+
" 'Test cross (2 banded F2 x 2 banded F2)',\n",
|
367 |
+
" 'Test cross (4 spots x 2 banded)', 'Test cross (N heterozygozity)',\n",
|
368 |
+
" 'Test cross (short HW bar)', 'Test cross (4 spots x 4 spots)',\n",
|
369 |
+
" 'Test cross (N heterozygocity - NBNN x mal - thin)'], dtype=object)"
|
370 |
+
]
|
371 |
+
},
|
372 |
+
"execution_count": 15,
|
373 |
+
"metadata": {},
|
374 |
+
"output_type": "execute_result"
|
375 |
+
}
|
376 |
+
],
|
377 |
+
"source": [
|
378 |
+
"df.Cross_Type.dropna().unique()"
|
379 |
+
]
|
380 |
+
},
|
381 |
+
{
|
382 |
+
"cell_type": "code",
|
383 |
+
"execution_count": 16,
|
384 |
+
"metadata": {},
|
385 |
+
"outputs": [],
|
386 |
+
"source": [
|
387 |
+
"def clean_cross_types(cross_type):\n",
|
388 |
+
" if type(cross_type) != float:\n",
|
389 |
+
" cross_type = cross_type.replace(\"mal\", \"malleti\")\n",
|
390 |
+
" cross_type = cross_type.replace(\"ple\", \"plesseni\")\n",
|
391 |
+
" cross_type = cross_type.replace(\"not\", \"notabilis\")\n",
|
392 |
+
" if \"latRo\" not in cross_type:\n",
|
393 |
+
" #latRo does not cross with lativitta, so only apply when latRo isn't present\n",
|
394 |
+
" cross_type = cross_type.replace(\"lat\", \"lativitta\")\n",
|
395 |
+
" return cross_type"
|
396 |
+
]
|
397 |
+
},
|
398 |
+
{
|
399 |
+
"cell_type": "code",
|
400 |
+
"execution_count": 17,
|
401 |
+
"metadata": {},
|
402 |
+
"outputs": [],
|
403 |
+
"source": [
|
404 |
+
"df[\"Cross_Type\"] = df[\"Cross_Type\"].apply(clean_cross_types)"
|
405 |
+
]
|
406 |
+
},
|
407 |
+
{
|
408 |
+
"cell_type": "markdown",
|
409 |
+
"metadata": {},
|
410 |
+
"source": [
|
411 |
+
"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)."
|
412 |
+
]
|
413 |
+
},
|
414 |
+
{
|
415 |
+
"cell_type": "code",
|
416 |
+
"execution_count": 18,
|
417 |
+
"metadata": {},
|
418 |
+
"outputs": [
|
419 |
+
{
|
420 |
+
"data": {
|
421 |
+
"text/plain": [
|
422 |
+
"156"
|
423 |
+
]
|
424 |
+
},
|
425 |
+
"execution_count": 18,
|
426 |
+
"metadata": {},
|
427 |
+
"output_type": "execute_result"
|
428 |
+
}
|
429 |
+
],
|
430 |
+
"source": [
|
431 |
+
"cross_type_subspecies = [ct for ct in list(df.Cross_Type.dropna().unique()) if \"Test\" not in ct and \"banded\" not in ct]\n",
|
432 |
+
"cross_type_subspecies.remove(\"hybrid\")\n",
|
433 |
+
"cross_type_subspecies.remove(\"Ac heterozygote\")\n",
|
434 |
+
"\n",
|
435 |
+
"for ct in cross_type_subspecies:\n",
|
436 |
+
" df.loc[df[\"Cross_Type\"] == ct, \"subspecies\"] = ct\n",
|
437 |
+
"\n",
|
438 |
+
"df.subspecies.nunique()\n"
|
439 |
+
]
|
440 |
+
},
|
441 |
+
{
|
442 |
+
"cell_type": "code",
|
443 |
+
"execution_count": 19,
|
444 |
+
"metadata": {},
|
445 |
+
"outputs": [
|
446 |
+
{
|
447 |
+
"data": {
|
448 |
+
"text/plain": [
|
449 |
+
"21"
|
450 |
+
]
|
451 |
+
},
|
452 |
+
"execution_count": 19,
|
453 |
+
"metadata": {},
|
454 |
+
"output_type": "execute_result"
|
455 |
+
}
|
456 |
+
],
|
457 |
+
"source": [
|
458 |
+
"len(cross_type_subspecies)"
|
459 |
+
]
|
460 |
+
},
|
461 |
+
{
|
462 |
+
"cell_type": "code",
|
463 |
+
"execution_count": 20,
|
464 |
+
"metadata": {},
|
465 |
+
"outputs": [
|
466 |
+
{
|
467 |
+
"data": {
|
468 |
+
"text/plain": [
|
469 |
+
"subspecies\n",
|
470 |
+
"(malleti x plesseni) x malleti 1204\n",
|
471 |
+
"plesseni x (malleti x plesseni) 600\n",
|
472 |
+
"malleti x (plesseni x malleti) 370\n",
|
473 |
+
"(plesseni x malleti) x plesseni 363\n",
|
474 |
+
"(plesseni x malleti) x (malleti x plesseni) 354\n",
|
475 |
+
"(plesseni x malleti) x (plesseni x malleti) 286\n",
|
476 |
+
"(malleti x plesseni) x plesseni 278\n",
|
477 |
+
"plesseni x malleti 234\n",
|
478 |
+
"malleti x plesseni 192\n",
|
479 |
+
"lativitta x notabilis 136\n",
|
480 |
+
"(lativitta x notabilis) x lativitta 110\n",
|
481 |
+
"plesseni x (plesseni x malleti) 106\n",
|
482 |
+
"(lativitta x notabilis) x notabilis 106\n",
|
483 |
+
"(malleti x plesseni) x (malleti x plesseni) 98\n",
|
484 |
+
"(plesseni x malleti) x malleti 80\n",
|
485 |
+
"(malleti x plesseni) x (plesseni x malleti) 56\n",
|
486 |
+
"malleti 28\n",
|
487 |
+
"plesseni 28\n",
|
488 |
+
"(latRo x notabilis) x notabilis 16\n",
|
489 |
+
"latRo x notabilis 4\n",
|
490 |
+
"lativitta 4\n",
|
491 |
+
"Name: count, dtype: int64"
|
492 |
+
]
|
493 |
+
},
|
494 |
+
"execution_count": 20,
|
495 |
+
"metadata": {},
|
496 |
+
"output_type": "execute_result"
|
497 |
+
}
|
498 |
+
],
|
499 |
+
"source": [
|
500 |
+
"df.loc[df[\"Cross_Type\"].notna(), \"subspecies\"].value_counts()"
|
501 |
+
]
|
502 |
+
},
|
503 |
+
{
|
504 |
+
"cell_type": "code",
|
505 |
+
"execution_count": 21,
|
506 |
+
"metadata": {},
|
507 |
+
"outputs": [
|
508 |
+
{
|
509 |
+
"name": "stdout",
|
510 |
+
"output_type": "stream",
|
511 |
+
"text": [
|
512 |
+
"4\n"
|
513 |
+
]
|
514 |
+
},
|
515 |
+
{
|
516 |
+
"data": {
|
517 |
+
"text/plain": [
|
518 |
+
"['malleti', 'plesseni', 'plesseni x malleti', 'lativitta']"
|
519 |
+
]
|
520 |
+
},
|
521 |
+
"execution_count": 21,
|
522 |
+
"metadata": {},
|
523 |
+
"output_type": "execute_result"
|
524 |
+
}
|
525 |
+
],
|
526 |
+
"source": [
|
527 |
+
"already_present_subspecies = []\n",
|
528 |
+
"\n",
|
529 |
+
"for subspecies in list(df.loc[df[\"Cross_Type\"].notna(), \"subspecies\"].dropna().unique()):\n",
|
530 |
+
" if subspecies in list(df.loc[~df[\"Cross_Type\"].notna(), \"subspecies\"].dropna().unique()):\n",
|
531 |
+
" already_present_subspecies.append(subspecies)\n",
|
532 |
+
"\n",
|
533 |
+
"print(len(already_present_subspecies))\n",
|
534 |
+
"already_present_subspecies"
|
535 |
+
]
|
536 |
+
},
|
537 |
+
{
|
538 |
+
"cell_type": "markdown",
|
539 |
+
"metadata": {},
|
540 |
+
"source": [
|
541 |
+
"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`."
|
542 |
+
]
|
543 |
+
},
|
544 |
+
{
|
545 |
+
"cell_type": "code",
|
546 |
+
"execution_count": 22,
|
547 |
+
"metadata": {},
|
548 |
+
"outputs": [
|
549 |
+
{
|
550 |
+
"data": {
|
551 |
+
"text/html": [
|
552 |
+
"<div>\n",
|
553 |
+
"<style scoped>\n",
|
554 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
555 |
+
" vertical-align: middle;\n",
|
556 |
+
" }\n",
|
557 |
+
"\n",
|
558 |
+
" .dataframe tbody tr th {\n",
|
559 |
+
" vertical-align: top;\n",
|
560 |
+
" }\n",
|
561 |
+
"\n",
|
562 |
+
" .dataframe thead th {\n",
|
563 |
+
" text-align: right;\n",
|
564 |
+
" }\n",
|
565 |
+
"</style>\n",
|
566 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
567 |
+
" <thead>\n",
|
568 |
+
" <tr style=\"text-align: right;\">\n",
|
569 |
+
" <th></th>\n",
|
570 |
+
" <th>CAMID</th>\n",
|
571 |
+
" <th>X</th>\n",
|
572 |
+
" <th>Image_name</th>\n",
|
573 |
+
" <th>View</th>\n",
|
574 |
+
" <th>zenodo_name</th>\n",
|
575 |
+
" <th>zenodo_link</th>\n",
|
576 |
+
" <th>Sequence</th>\n",
|
577 |
+
" <th>Taxonomic_Name</th>\n",
|
578 |
+
" <th>Locality</th>\n",
|
579 |
+
" <th>Sample_accession</th>\n",
|
580 |
+
" <th>...</th>\n",
|
581 |
+
" <th>Brood</th>\n",
|
582 |
+
" <th>Death_Date</th>\n",
|
583 |
+
" <th>Cross_Type</th>\n",
|
584 |
+
" <th>Stage</th>\n",
|
585 |
+
" <th>Sex</th>\n",
|
586 |
+
" <th>Unit_Type</th>\n",
|
587 |
+
" <th>file_type</th>\n",
|
588 |
+
" <th>record_number</th>\n",
|
589 |
+
" <th>species</th>\n",
|
590 |
+
" <th>subspecies</th>\n",
|
591 |
+
" </tr>\n",
|
592 |
+
" </thead>\n",
|
593 |
+
" <tbody>\n",
|
594 |
+
" <tr>\n",
|
595 |
+
" <th>1986</th>\n",
|
596 |
+
" <td>19N1989</td>\n",
|
597 |
+
" <td>21369</td>\n",
|
598 |
+
" <td>19N1989_v.JPG</td>\n",
|
599 |
+
" <td>ventral</td>\n",
|
600 |
+
" <td>0.sheffield.ps.nn.ikiam.batch2.csv</td>\n",
|
601 |
+
" <td>https://zenodo.org/record/4288311</td>\n",
|
602 |
+
" <td>1,989</td>\n",
|
603 |
+
" <td>Heliconius melpomene ssp. malleti</td>\n",
|
604 |
+
" <td>Ikiam Mariposario</td>\n",
|
605 |
+
" <td>NaN</td>\n",
|
606 |
+
" <td>...</td>\n",
|
607 |
+
" <td>IKIAM.P44</td>\n",
|
608 |
+
" <td>NaN</td>\n",
|
609 |
+
" <td>NaN</td>\n",
|
610 |
+
" <td>NaN</td>\n",
|
611 |
+
" <td>Male</td>\n",
|
612 |
+
" <td>reared</td>\n",
|
613 |
+
" <td>jpg</td>\n",
|
614 |
+
" <td>4288311</td>\n",
|
615 |
+
" <td>Heliconius melpomene</td>\n",
|
616 |
+
" <td>malleti</td>\n",
|
617 |
+
" </tr>\n",
|
618 |
+
" <tr>\n",
|
619 |
+
" <th>45062</th>\n",
|
620 |
+
" <td>CAM044423</td>\n",
|
621 |
+
" <td>34391</td>\n",
|
622 |
+
" <td>CAM044423_d.CR2</td>\n",
|
623 |
+
" <td>dorsal</td>\n",
|
624 |
+
" <td>batch2.Peru.image.names.Zenodo.csv</td>\n",
|
625 |
+
" <td>https://zenodo.org/record/4287444</td>\n",
|
626 |
+
" <td>44,423</td>\n",
|
627 |
+
" <td>Taygetis cleopatra</td>\n",
|
628 |
+
" <td>B6old6</td>\n",
|
629 |
+
" <td>NaN</td>\n",
|
630 |
+
" <td>...</td>\n",
|
631 |
+
" <td>NaN</td>\n",
|
632 |
+
" <td>NaN</td>\n",
|
633 |
+
" <td>NaN</td>\n",
|
634 |
+
" <td>NaN</td>\n",
|
635 |
+
" <td>NaN</td>\n",
|
636 |
+
" <td>NaN</td>\n",
|
637 |
+
" <td>raw</td>\n",
|
638 |
+
" <td>4287444</td>\n",
|
639 |
+
" <td>Taygetis cleopatra</td>\n",
|
640 |
+
" <td>None</td>\n",
|
641 |
+
" </tr>\n",
|
642 |
+
" <tr>\n",
|
643 |
+
" <th>48534</th>\n",
|
644 |
+
" <td>E23</td>\n",
|
645 |
+
" <td>37555</td>\n",
|
646 |
+
" <td>E23_d.CR2</td>\n",
|
647 |
+
" <td>dorsal</td>\n",
|
648 |
+
" <td>Anniina.Matilla.Field.Caught.E.csv</td>\n",
|
649 |
+
" <td>https://zenodo.org/record/2554218</td>\n",
|
650 |
+
" <td>NaN</td>\n",
|
651 |
+
" <td>NaN</td>\n",
|
652 |
+
" <td>NaN</td>\n",
|
653 |
+
" <td>NaN</td>\n",
|
654 |
+
" <td>...</td>\n",
|
655 |
+
" <td>NaN</td>\n",
|
656 |
+
" <td>NaN</td>\n",
|
657 |
+
" <td>NaN</td>\n",
|
658 |
+
" <td>NaN</td>\n",
|
659 |
+
" <td>NaN</td>\n",
|
660 |
+
" <td>NaN</td>\n",
|
661 |
+
" <td>raw</td>\n",
|
662 |
+
" <td>2554218</td>\n",
|
663 |
+
" <td>NaN</td>\n",
|
664 |
+
" <td>None</td>\n",
|
665 |
+
" </tr>\n",
|
666 |
+
" <tr>\n",
|
667 |
+
" <th>45206</th>\n",
|
668 |
+
" <td>CAM044445</td>\n",
|
669 |
+
" <td>37132</td>\n",
|
670 |
+
" <td>CAM044445_d.JPG</td>\n",
|
671 |
+
" <td>dorsal</td>\n",
|
672 |
+
" <td>batch3.Peru.image.names.Zenodo.csv</td>\n",
|
673 |
+
" <td>https://zenodo.org/record/4288250</td>\n",
|
674 |
+
" <td>44,445</td>\n",
|
675 |
+
" <td>Taygetis cleopatra</td>\n",
|
676 |
+
" <td>B4old2</td>\n",
|
677 |
+
" <td>NaN</td>\n",
|
678 |
+
" <td>...</td>\n",
|
679 |
+
" <td>NaN</td>\n",
|
680 |
+
" <td>NaN</td>\n",
|
681 |
+
" <td>NaN</td>\n",
|
682 |
+
" <td>NaN</td>\n",
|
683 |
+
" <td>NaN</td>\n",
|
684 |
+
" <td>NaN</td>\n",
|
685 |
+
" <td>jpg</td>\n",
|
686 |
+
" <td>4288250</td>\n",
|
687 |
+
" <td>Taygetis cleopatra</td>\n",
|
688 |
+
" <td>None</td>\n",
|
689 |
+
" </tr>\n",
|
690 |
+
" <tr>\n",
|
691 |
+
" <th>12212</th>\n",
|
692 |
+
" <td>CAM010238</td>\n",
|
693 |
+
" <td>23307</td>\n",
|
694 |
+
" <td>10238v.jpg</td>\n",
|
695 |
+
" <td>ventral</td>\n",
|
696 |
+
" <td>Heliconius_wing_old_photos_2001_2019_part1.csv</td>\n",
|
697 |
+
" <td>https://zenodo.org/record/2552371</td>\n",
|
698 |
+
" <td>10,238</td>\n",
|
699 |
+
" <td>Heliconius sp.</td>\n",
|
700 |
+
" <td>NaN</td>\n",
|
701 |
+
" <td>NaN</td>\n",
|
702 |
+
" <td>...</td>\n",
|
703 |
+
" <td>B043</td>\n",
|
704 |
+
" <td>NaN</td>\n",
|
705 |
+
" <td>NaN</td>\n",
|
706 |
+
" <td>NaN</td>\n",
|
707 |
+
" <td>Female</td>\n",
|
708 |
+
" <td>reared</td>\n",
|
709 |
+
" <td>jpg</td>\n",
|
710 |
+
" <td>2552371</td>\n",
|
711 |
+
" <td>Heliconius sp.</td>\n",
|
712 |
+
" <td>None</td>\n",
|
713 |
+
" </tr>\n",
|
714 |
+
" <tr>\n",
|
715 |
+
" <th>39059</th>\n",
|
716 |
+
" <td>CAM043418</td>\n",
|
717 |
+
" <td>30654</td>\n",
|
718 |
+
" <td>CAM043418_v.JPG</td>\n",
|
719 |
+
" <td>ventral</td>\n",
|
720 |
+
" <td>batch1.Peru.image.names.Zenodo.csv</td>\n",
|
721 |
+
" <td>https://zenodo.org/record/3569598</td>\n",
|
722 |
+
" <td>43,418</td>\n",
|
723 |
+
" <td>Archaeoprepona licomedes</td>\n",
|
724 |
+
" <td>B6rec6</td>\n",
|
725 |
+
" <td>NaN</td>\n",
|
726 |
+
" <td>...</td>\n",
|
727 |
+
" <td>NaN</td>\n",
|
728 |
+
" <td>NaN</td>\n",
|
729 |
+
" <td>NaN</td>\n",
|
730 |
+
" <td>NaN</td>\n",
|
731 |
+
" <td>NaN</td>\n",
|
732 |
+
" <td>NaN</td>\n",
|
733 |
+
" <td>jpg</td>\n",
|
734 |
+
" <td>3569598</td>\n",
|
735 |
+
" <td>Archaeoprepona licomedes</td>\n",
|
736 |
+
" <td>None</td>\n",
|
737 |
+
" </tr>\n",
|
738 |
+
" <tr>\n",
|
739 |
+
" <th>38163</th>\n",
|
740 |
+
" <td>CAM043170</td>\n",
|
741 |
+
" <td>29755</td>\n",
|
742 |
+
" <td>CAM043170_d.CR2</td>\n",
|
743 |
+
" <td>dorsal</td>\n",
|
744 |
+
" <td>batch1.Peru.image.names.Zenodo.csv</td>\n",
|
745 |
+
" <td>https://zenodo.org/record/3569598</td>\n",
|
746 |
+
" <td>43,170</td>\n",
|
747 |
+
" <td>Adelpha mesentina</td>\n",
|
748 |
+
" <td>F3rec2</td>\n",
|
749 |
+
" <td>NaN</td>\n",
|
750 |
+
" <td>...</td>\n",
|
751 |
+
" <td>NaN</td>\n",
|
752 |
+
" <td>NaN</td>\n",
|
753 |
+
" <td>NaN</td>\n",
|
754 |
+
" <td>NaN</td>\n",
|
755 |
+
" <td>NaN</td>\n",
|
756 |
+
" <td>NaN</td>\n",
|
757 |
+
" <td>raw</td>\n",
|
758 |
+
" <td>3569598</td>\n",
|
759 |
+
" <td>Adelpha mesentina</td>\n",
|
760 |
+
" <td>None</td>\n",
|
761 |
+
" </tr>\n",
|
762 |
+
" </tbody>\n",
|
763 |
+
"</table>\n",
|
764 |
+
"<p>7 rows × 25 columns</p>\n",
|
765 |
+
"</div>"
|
766 |
+
],
|
767 |
+
"text/plain": [
|
768 |
+
" CAMID X Image_name View \\\n",
|
769 |
+
"1986 19N1989 21369 19N1989_v.JPG ventral \n",
|
770 |
+
"45062 CAM044423 34391 CAM044423_d.CR2 dorsal \n",
|
771 |
+
"48534 E23 37555 E23_d.CR2 dorsal \n",
|
772 |
+
"45206 CAM044445 37132 CAM044445_d.JPG dorsal \n",
|
773 |
+
"12212 CAM010238 23307 10238v.jpg ventral \n",
|
774 |
+
"39059 CAM043418 30654 CAM043418_v.JPG ventral \n",
|
775 |
+
"38163 CAM043170 29755 CAM043170_d.CR2 dorsal \n",
|
776 |
+
"\n",
|
777 |
+
" zenodo_name \\\n",
|
778 |
+
"1986 0.sheffield.ps.nn.ikiam.batch2.csv \n",
|
779 |
+
"45062 batch2.Peru.image.names.Zenodo.csv \n",
|
780 |
+
"48534 Anniina.Matilla.Field.Caught.E.csv \n",
|
781 |
+
"45206 batch3.Peru.image.names.Zenodo.csv \n",
|
782 |
+
"12212 Heliconius_wing_old_photos_2001_2019_part1.csv \n",
|
783 |
+
"39059 batch1.Peru.image.names.Zenodo.csv \n",
|
784 |
+
"38163 batch1.Peru.image.names.Zenodo.csv \n",
|
785 |
+
"\n",
|
786 |
+
" zenodo_link Sequence \\\n",
|
787 |
+
"1986 https://zenodo.org/record/4288311 1,989 \n",
|
788 |
+
"45062 https://zenodo.org/record/4287444 44,423 \n",
|
789 |
+
"48534 https://zenodo.org/record/2554218 NaN \n",
|
790 |
+
"45206 https://zenodo.org/record/4288250 44,445 \n",
|
791 |
+
"12212 https://zenodo.org/record/2552371 10,238 \n",
|
792 |
+
"39059 https://zenodo.org/record/3569598 43,418 \n",
|
793 |
+
"38163 https://zenodo.org/record/3569598 43,170 \n",
|
794 |
+
"\n",
|
795 |
+
" Taxonomic_Name Locality Sample_accession \\\n",
|
796 |
+
"1986 Heliconius melpomene ssp. malleti Ikiam Mariposario NaN \n",
|
797 |
+
"45062 Taygetis cleopatra B6old6 NaN \n",
|
798 |
+
"48534 NaN NaN NaN \n",
|
799 |
+
"45206 Taygetis cleopatra B4old2 NaN \n",
|
800 |
+
"12212 Heliconius sp. NaN NaN \n",
|
801 |
+
"39059 Archaeoprepona licomedes B6rec6 NaN \n",
|
802 |
+
"38163 Adelpha mesentina F3rec2 NaN \n",
|
803 |
+
"\n",
|
804 |
+
" ... Brood Death_Date Cross_Type Stage Sex Unit_Type file_type \\\n",
|
805 |
+
"1986 ... IKIAM.P44 NaN NaN NaN Male reared jpg \n",
|
806 |
+
"45062 ... NaN NaN NaN NaN NaN NaN raw \n",
|
807 |
+
"48534 ... NaN NaN NaN NaN NaN NaN raw \n",
|
808 |
+
"45206 ... NaN NaN NaN NaN NaN NaN jpg \n",
|
809 |
+
"12212 ... B043 NaN NaN NaN Female reared jpg \n",
|
810 |
+
"39059 ... NaN NaN NaN NaN NaN NaN jpg \n",
|
811 |
+
"38163 ... NaN NaN NaN NaN NaN NaN raw \n",
|
812 |
+
"\n",
|
813 |
+
" record_number species subspecies \n",
|
814 |
+
"1986 4288311 Heliconius melpomene malleti \n",
|
815 |
+
"45062 4287444 Taygetis cleopatra None \n",
|
816 |
+
"48534 2554218 NaN None \n",
|
817 |
+
"45206 4288250 Taygetis cleopatra None \n",
|
818 |
+
"12212 2552371 Heliconius sp. None \n",
|
819 |
+
"39059 3569598 Archaeoprepona licomedes None \n",
|
820 |
+
"38163 3569598 Adelpha mesentina None \n",
|
821 |
+
"\n",
|
822 |
+
"[7 rows x 25 columns]"
|
823 |
+
]
|
824 |
+
},
|
825 |
+
"execution_count": 22,
|
826 |
+
"metadata": {},
|
827 |
+
"output_type": "execute_result"
|
828 |
+
}
|
829 |
+
],
|
830 |
+
"source": [
|
831 |
+
"df.sample(7)"
|
832 |
+
]
|
833 |
+
},
|
834 |
+
{
|
835 |
+
"cell_type": "markdown",
|
836 |
+
"metadata": {},
|
837 |
+
"source": [
|
838 |
+
"### Add Genus Column\n",
|
839 |
+
"\n",
|
840 |
+
"This willl allow us to easily remove all non Heliconius samples, and make some image stats easier to see."
|
841 |
+
]
|
842 |
+
},
|
843 |
+
{
|
844 |
+
"cell_type": "code",
|
845 |
+
"execution_count": 23,
|
846 |
+
"metadata": {},
|
847 |
+
"outputs": [],
|
848 |
+
"source": [
|
849 |
+
"def get_genus(species):\n",
|
850 |
+
" if type(species) != float: #taxa name not null\n",
|
851 |
+
" return species.split(sep = \" \")[0]\n",
|
852 |
+
" return species"
|
853 |
+
]
|
854 |
+
},
|
855 |
+
{
|
856 |
+
"cell_type": "code",
|
857 |
+
"execution_count": 24,
|
858 |
+
"metadata": {},
|
859 |
+
"outputs": [
|
860 |
+
{
|
861 |
+
"data": {
|
862 |
+
"text/plain": [
|
863 |
+
"94"
|
864 |
+
]
|
865 |
+
},
|
866 |
+
"execution_count": 24,
|
867 |
+
"metadata": {},
|
868 |
+
"output_type": "execute_result"
|
869 |
+
}
|
870 |
+
],
|
871 |
+
"source": [
|
872 |
+
"df[\"genus\"] = df[\"species\"].apply(get_genus)\n",
|
873 |
+
"df.genus.nunique()"
|
874 |
+
]
|
875 |
+
},
|
876 |
+
{
|
877 |
+
"cell_type": "markdown",
|
878 |
+
"metadata": {},
|
879 |
+
"source": [
|
880 |
+
"Final stats for all data summarized here."
|
881 |
+
]
|
882 |
+
},
|
883 |
+
{
|
884 |
+
"cell_type": "code",
|
885 |
+
"execution_count": 25,
|
886 |
+
"metadata": {},
|
887 |
+
"outputs": [
|
888 |
+
{
|
889 |
+
"data": {
|
890 |
+
"text/plain": [
|
891 |
+
"CAMID 12586\n",
|
892 |
+
"X 49359\n",
|
893 |
+
"Image_name 37821\n",
|
894 |
+
"View 7\n",
|
895 |
+
"zenodo_name 36\n",
|
896 |
+
"zenodo_link 32\n",
|
897 |
+
"Sequence 11301\n",
|
898 |
+
"Taxonomic_Name 363\n",
|
899 |
+
"Locality 645\n",
|
900 |
+
"Sample_accession 1571\n",
|
901 |
+
"Collected_by 12\n",
|
902 |
+
"Other_ID 3088\n",
|
903 |
+
"Date 810\n",
|
904 |
+
"Dataset 8\n",
|
905 |
+
"Store 142\n",
|
906 |
+
"Brood 226\n",
|
907 |
+
"Death_Date 82\n",
|
908 |
+
"Cross_Type 30\n",
|
909 |
+
"Stage 1\n",
|
910 |
+
"Sex 3\n",
|
911 |
+
"Unit_Type 6\n",
|
912 |
+
"file_type 3\n",
|
913 |
+
"record_number 32\n",
|
914 |
+
"species 246\n",
|
915 |
+
"subspecies 156\n",
|
916 |
+
"genus 94\n",
|
917 |
+
"dtype: int64"
|
918 |
+
]
|
919 |
+
},
|
920 |
+
"execution_count": 25,
|
921 |
+
"metadata": {},
|
922 |
+
"output_type": "execute_result"
|
923 |
+
}
|
924 |
+
],
|
925 |
+
"source": [
|
926 |
+
"df.nunique()"
|
927 |
+
]
|
928 |
+
},
|
929 |
+
{
|
930 |
+
"cell_type": "code",
|
931 |
+
"execution_count": 26,
|
932 |
+
"metadata": {},
|
933 |
+
"outputs": [
|
934 |
+
{
|
935 |
+
"name": "stdout",
|
936 |
+
"output_type": "stream",
|
937 |
+
"text": [
|
938 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
939 |
+
"RangeIndex: 49359 entries, 0 to 49358\n",
|
940 |
+
"Data columns (total 26 columns):\n",
|
941 |
+
" # Column Non-Null Count Dtype \n",
|
942 |
+
"--- ------ -------------- ----- \n",
|
943 |
+
" 0 CAMID 49359 non-null object\n",
|
944 |
+
" 1 X 49359 non-null int64 \n",
|
945 |
+
" 2 Image_name 49359 non-null object\n",
|
946 |
+
" 3 View 48288 non-null object\n",
|
947 |
+
" 4 zenodo_name 49359 non-null object\n",
|
948 |
+
" 5 zenodo_link 49359 non-null object\n",
|
949 |
+
" 6 Sequence 48424 non-null object\n",
|
950 |
+
" 7 Taxonomic_Name 45473 non-null object\n",
|
951 |
+
" 8 Locality 34015 non-null object\n",
|
952 |
+
" 9 Sample_accession 5884 non-null object\n",
|
953 |
+
" 10 Collected_by 5280 non-null object\n",
|
954 |
+
" 11 Other_ID 14382 non-null object\n",
|
955 |
+
" 12 Date 33718 non-null object\n",
|
956 |
+
" 13 Dataset 40405 non-null object\n",
|
957 |
+
" 14 Store 39485 non-null object\n",
|
958 |
+
" 15 Brood 14942 non-null object\n",
|
959 |
+
" 16 Death_Date 318 non-null object\n",
|
960 |
+
" 17 Cross_Type 5133 non-null object\n",
|
961 |
+
" 18 Stage 15 non-null object\n",
|
962 |
+
" 19 Sex 36243 non-null object\n",
|
963 |
+
" 20 Unit_Type 33890 non-null object\n",
|
964 |
+
" 21 file_type 49359 non-null object\n",
|
965 |
+
" 22 record_number 49359 non-null object\n",
|
966 |
+
" 23 species 45473 non-null object\n",
|
967 |
+
" 24 subspecies 25715 non-null object\n",
|
968 |
+
" 25 genus 45473 non-null object\n",
|
969 |
+
"dtypes: int64(1), object(25)\n",
|
970 |
+
"memory usage: 9.8+ MB\n"
|
971 |
+
]
|
972 |
+
}
|
973 |
+
],
|
974 |
+
"source": [
|
975 |
+
"df.info()"
|
976 |
+
]
|
977 |
+
},
|
978 |
+
{
|
979 |
+
"cell_type": "markdown",
|
980 |
+
"metadata": {},
|
981 |
+
"source": [
|
982 |
+
"Observe that not all images have a species label."
|
983 |
+
]
|
984 |
+
},
|
985 |
+
{
|
986 |
+
"cell_type": "code",
|
987 |
+
"execution_count": 27,
|
988 |
+
"metadata": {},
|
989 |
+
"outputs": [
|
990 |
+
{
|
991 |
+
"data": {
|
992 |
+
"text/html": [
|
993 |
+
"<div>\n",
|
994 |
+
"<style scoped>\n",
|
995 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
996 |
+
" vertical-align: middle;\n",
|
997 |
+
" }\n",
|
998 |
+
"\n",
|
999 |
+
" .dataframe tbody tr th {\n",
|
1000 |
+
" vertical-align: top;\n",
|
1001 |
+
" }\n",
|
1002 |
+
"\n",
|
1003 |
+
" .dataframe thead th {\n",
|
1004 |
+
" text-align: right;\n",
|
1005 |
+
" }\n",
|
1006 |
+
"</style>\n",
|
1007 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
1008 |
+
" <thead>\n",
|
1009 |
+
" <tr style=\"text-align: right;\">\n",
|
1010 |
+
" <th></th>\n",
|
1011 |
+
" <th>CAMID</th>\n",
|
1012 |
+
" <th>X</th>\n",
|
1013 |
+
" <th>Image_name</th>\n",
|
1014 |
+
" <th>View</th>\n",
|
1015 |
+
" <th>zenodo_name</th>\n",
|
1016 |
+
" <th>zenodo_link</th>\n",
|
1017 |
+
" <th>Sequence</th>\n",
|
1018 |
+
" <th>Taxonomic_Name</th>\n",
|
1019 |
+
" <th>Locality</th>\n",
|
1020 |
+
" <th>Sample_accession</th>\n",
|
1021 |
+
" <th>...</th>\n",
|
1022 |
+
" <th>Death_Date</th>\n",
|
1023 |
+
" <th>Cross_Type</th>\n",
|
1024 |
+
" <th>Stage</th>\n",
|
1025 |
+
" <th>Sex</th>\n",
|
1026 |
+
" <th>Unit_Type</th>\n",
|
1027 |
+
" <th>file_type</th>\n",
|
1028 |
+
" <th>record_number</th>\n",
|
1029 |
+
" <th>species</th>\n",
|
1030 |
+
" <th>subspecies</th>\n",
|
1031 |
+
" <th>genus</th>\n",
|
1032 |
+
" </tr>\n",
|
1033 |
+
" </thead>\n",
|
1034 |
+
" <tbody>\n",
|
1035 |
+
" <tr>\n",
|
1036 |
+
" <th>48538</th>\n",
|
1037 |
+
" <td>E24</td>\n",
|
1038 |
+
" <td>37559</td>\n",
|
1039 |
+
" <td>E24_d.CR2</td>\n",
|
1040 |
+
" <td>dorsal</td>\n",
|
1041 |
+
" <td>Anniina.Matilla.Field.Caught.E.csv</td>\n",
|
1042 |
+
" <td>https://zenodo.org/record/2554218</td>\n",
|
1043 |
+
" <td>NaN</td>\n",
|
1044 |
+
" <td>NaN</td>\n",
|
1045 |
+
" <td>NaN</td>\n",
|
1046 |
+
" <td>NaN</td>\n",
|
1047 |
+
" <td>...</td>\n",
|
1048 |
+
" <td>NaN</td>\n",
|
1049 |
+
" <td>NaN</td>\n",
|
1050 |
+
" <td>NaN</td>\n",
|
1051 |
+
" <td>NaN</td>\n",
|
1052 |
+
" <td>NaN</td>\n",
|
1053 |
+
" <td>raw</td>\n",
|
1054 |
+
" <td>2554218</td>\n",
|
1055 |
+
" <td>NaN</td>\n",
|
1056 |
+
" <td>None</td>\n",
|
1057 |
+
" <td>NaN</td>\n",
|
1058 |
+
" </tr>\n",
|
1059 |
+
" <tr>\n",
|
1060 |
+
" <th>37246</th>\n",
|
1061 |
+
" <td>CAM042045</td>\n",
|
1062 |
+
" <td>43973</td>\n",
|
1063 |
+
" <td>CAM042045_v.JPG</td>\n",
|
1064 |
+
" <td>ventral</td>\n",
|
1065 |
+
" <td>Collection_August2019.csv</td>\n",
|
1066 |
+
" <td>https://zenodo.org/record/5731587</td>\n",
|
1067 |
+
" <td>42,045</td>\n",
|
1068 |
+
" <td>NaN</td>\n",
|
1069 |
+
" <td>NaN</td>\n",
|
1070 |
+
" <td>NaN</td>\n",
|
1071 |
+
" <td>...</td>\n",
|
1072 |
+
" <td>NaN</td>\n",
|
1073 |
+
" <td>NaN</td>\n",
|
1074 |
+
" <td>NaN</td>\n",
|
1075 |
+
" <td>NaN</td>\n",
|
1076 |
+
" <td>NaN</td>\n",
|
1077 |
+
" <td>jpg</td>\n",
|
1078 |
+
" <td>5731587</td>\n",
|
1079 |
+
" <td>NaN</td>\n",
|
1080 |
+
" <td>None</td>\n",
|
1081 |
+
" <td>NaN</td>\n",
|
1082 |
+
" </tr>\n",
|
1083 |
+
" <tr>\n",
|
1084 |
+
" <th>37484</th>\n",
|
1085 |
+
" <td>CAM042166</td>\n",
|
1086 |
+
" <td>44211</td>\n",
|
1087 |
+
" <td>CAM042166_v.JPG</td>\n",
|
1088 |
+
" <td>ventral</td>\n",
|
1089 |
+
" <td>Collection_August2019.csv</td>\n",
|
1090 |
+
" <td>https://zenodo.org/record/5731587</td>\n",
|
1091 |
+
" <td>42,166</td>\n",
|
1092 |
+
" <td>NaN</td>\n",
|
1093 |
+
" <td>NaN</td>\n",
|
1094 |
+
" <td>NaN</td>\n",
|
1095 |
+
" <td>...</td>\n",
|
1096 |
+
" <td>NaN</td>\n",
|
1097 |
+
" <td>NaN</td>\n",
|
1098 |
+
" <td>NaN</td>\n",
|
1099 |
+
" <td>NaN</td>\n",
|
1100 |
+
" <td>NaN</td>\n",
|
1101 |
+
" <td>jpg</td>\n",
|
1102 |
+
" <td>5731587</td>\n",
|
1103 |
+
" <td>NaN</td>\n",
|
1104 |
+
" <td>None</td>\n",
|
1105 |
+
" <td>NaN</td>\n",
|
1106 |
+
" </tr>\n",
|
1107 |
+
" <tr>\n",
|
1108 |
+
" <th>48780</th>\n",
|
1109 |
+
" <td>E83</td>\n",
|
1110 |
+
" <td>37777</td>\n",
|
1111 |
+
" <td>E83_v.CR2</td>\n",
|
1112 |
+
" <td>ventral</td>\n",
|
1113 |
+
" <td>Anniina.Matilla.Field.Caught.E.csv</td>\n",
|
1114 |
+
" <td>https://zenodo.org/record/2554218</td>\n",
|
1115 |
+
" <td>NaN</td>\n",
|
1116 |
+
" <td>NaN</td>\n",
|
1117 |
+
" <td>NaN</td>\n",
|
1118 |
+
" <td>NaN</td>\n",
|
1119 |
+
" <td>...</td>\n",
|
1120 |
+
" <td>NaN</td>\n",
|
1121 |
+
" <td>NaN</td>\n",
|
1122 |
+
" <td>NaN</td>\n",
|
1123 |
+
" <td>NaN</td>\n",
|
1124 |
+
" <td>NaN</td>\n",
|
1125 |
+
" <td>raw</td>\n",
|
1126 |
+
" <td>2554218</td>\n",
|
1127 |
+
" <td>NaN</td>\n",
|
1128 |
+
" <td>None</td>\n",
|
1129 |
+
" <td>NaN</td>\n",
|
1130 |
+
" </tr>\n",
|
1131 |
+
" <tr>\n",
|
1132 |
+
" <th>3118</th>\n",
|
1133 |
+
" <td>19N2627</td>\n",
|
1134 |
+
" <td>22498</td>\n",
|
1135 |
+
" <td>19N2627_v.CR2</td>\n",
|
1136 |
+
" <td>NaN</td>\n",
|
1137 |
+
" <td>0.sheffield.ps.nn.ikiam.batch2.csv</td>\n",
|
1138 |
+
" <td>https://zenodo.org/record/4288311</td>\n",
|
1139 |
+
" <td>0</td>\n",
|
1140 |
+
" <td>NaN</td>\n",
|
1141 |
+
" <td>NaN</td>\n",
|
1142 |
+
" <td>NaN</td>\n",
|
1143 |
+
" <td>...</td>\n",
|
1144 |
+
" <td>NaN</td>\n",
|
1145 |
+
" <td>NaN</td>\n",
|
1146 |
+
" <td>NaN</td>\n",
|
1147 |
+
" <td>NaN</td>\n",
|
1148 |
+
" <td>NaN</td>\n",
|
1149 |
+
" <td>raw</td>\n",
|
1150 |
+
" <td>4288311</td>\n",
|
1151 |
+
" <td>NaN</td>\n",
|
1152 |
+
" <td>None</td>\n",
|
1153 |
+
" <td>NaN</td>\n",
|
1154 |
+
" </tr>\n",
|
1155 |
+
" <tr>\n",
|
1156 |
+
" <th>46111</th>\n",
|
1157 |
+
" <td>CAM045060</td>\n",
|
1158 |
+
" <td>42806</td>\n",
|
1159 |
+
" <td>CAM045060_v.CR2</td>\n",
|
1160 |
+
" <td>ventral</td>\n",
|
1161 |
+
" <td>image.names.cook.island.erato.csv</td>\n",
|
1162 |
+
" <td>https://zenodo.org/record/5526257</td>\n",
|
1163 |
+
" <td>45,060</td>\n",
|
1164 |
+
" <td>NaN</td>\n",
|
1165 |
+
" <td>NaN</td>\n",
|
1166 |
+
" <td>NaN</td>\n",
|
1167 |
+
" <td>...</td>\n",
|
1168 |
+
" <td>NaN</td>\n",
|
1169 |
+
" <td>NaN</td>\n",
|
1170 |
+
" <td>NaN</td>\n",
|
1171 |
+
" <td>NaN</td>\n",
|
1172 |
+
" <td>NaN</td>\n",
|
1173 |
+
" <td>raw</td>\n",
|
1174 |
+
" <td>5526257</td>\n",
|
1175 |
+
" <td>NaN</td>\n",
|
1176 |
+
" <td>None</td>\n",
|
1177 |
+
" <td>NaN</td>\n",
|
1178 |
+
" </tr>\n",
|
1179 |
+
" <tr>\n",
|
1180 |
+
" <th>39502</th>\n",
|
1181 |
+
" <td>CAM043576</td>\n",
|
1182 |
+
" <td>31097</td>\n",
|
1183 |
+
" <td>CAM043576_v.CR2</td>\n",
|
1184 |
+
" <td>ventral</td>\n",
|
1185 |
+
" <td>batch2.Peru.image.names.Zenodo.csv</td>\n",
|
1186 |
+
" <td>https://zenodo.org/record/4287444</td>\n",
|
1187 |
+
" <td>43,576</td>\n",
|
1188 |
+
" <td>NaN</td>\n",
|
1189 |
+
" <td>NaN</td>\n",
|
1190 |
+
" <td>NaN</td>\n",
|
1191 |
+
" <td>...</td>\n",
|
1192 |
+
" <td>NaN</td>\n",
|
1193 |
+
" <td>NaN</td>\n",
|
1194 |
+
" <td>NaN</td>\n",
|
1195 |
+
" <td>NaN</td>\n",
|
1196 |
+
" <td>NaN</td>\n",
|
1197 |
+
" <td>raw</td>\n",
|
1198 |
+
" <td>4287444</td>\n",
|
1199 |
+
" <td>NaN</td>\n",
|
1200 |
+
" <td>None</td>\n",
|
1201 |
+
" <td>NaN</td>\n",
|
1202 |
+
" </tr>\n",
|
1203 |
+
" </tbody>\n",
|
1204 |
+
"</table>\n",
|
1205 |
+
"<p>7 rows × 26 columns</p>\n",
|
1206 |
+
"</div>"
|
1207 |
+
],
|
1208 |
+
"text/plain": [
|
1209 |
+
" CAMID X Image_name View \\\n",
|
1210 |
+
"48538 E24 37559 E24_d.CR2 dorsal \n",
|
1211 |
+
"37246 CAM042045 43973 CAM042045_v.JPG ventral \n",
|
1212 |
+
"37484 CAM042166 44211 CAM042166_v.JPG ventral \n",
|
1213 |
+
"48780 E83 37777 E83_v.CR2 ventral \n",
|
1214 |
+
"3118 19N2627 22498 19N2627_v.CR2 NaN \n",
|
1215 |
+
"46111 CAM045060 42806 CAM045060_v.CR2 ventral \n",
|
1216 |
+
"39502 CAM043576 31097 CAM043576_v.CR2 ventral \n",
|
1217 |
+
"\n",
|
1218 |
+
" zenodo_name zenodo_link \\\n",
|
1219 |
+
"48538 Anniina.Matilla.Field.Caught.E.csv https://zenodo.org/record/2554218 \n",
|
1220 |
+
"37246 Collection_August2019.csv https://zenodo.org/record/5731587 \n",
|
1221 |
+
"37484 Collection_August2019.csv https://zenodo.org/record/5731587 \n",
|
1222 |
+
"48780 Anniina.Matilla.Field.Caught.E.csv https://zenodo.org/record/2554218 \n",
|
1223 |
+
"3118 0.sheffield.ps.nn.ikiam.batch2.csv https://zenodo.org/record/4288311 \n",
|
1224 |
+
"46111 image.names.cook.island.erato.csv https://zenodo.org/record/5526257 \n",
|
1225 |
+
"39502 batch2.Peru.image.names.Zenodo.csv https://zenodo.org/record/4287444 \n",
|
1226 |
+
"\n",
|
1227 |
+
" Sequence Taxonomic_Name Locality Sample_accession ... Death_Date \\\n",
|
1228 |
+
"48538 NaN NaN NaN NaN ... NaN \n",
|
1229 |
+
"37246 42,045 NaN NaN NaN ... NaN \n",
|
1230 |
+
"37484 42,166 NaN NaN NaN ... NaN \n",
|
1231 |
+
"48780 NaN NaN NaN NaN ... NaN \n",
|
1232 |
+
"3118 0 NaN NaN NaN ... NaN \n",
|
1233 |
+
"46111 45,060 NaN NaN NaN ... NaN \n",
|
1234 |
+
"39502 43,576 NaN NaN NaN ... NaN \n",
|
1235 |
+
"\n",
|
1236 |
+
" Cross_Type Stage Sex Unit_Type file_type record_number species \\\n",
|
1237 |
+
"48538 NaN NaN NaN NaN raw 2554218 NaN \n",
|
1238 |
+
"37246 NaN NaN NaN NaN jpg 5731587 NaN \n",
|
1239 |
+
"37484 NaN NaN NaN NaN jpg 5731587 NaN \n",
|
1240 |
+
"48780 NaN NaN NaN NaN raw 2554218 NaN \n",
|
1241 |
+
"3118 NaN NaN NaN NaN raw 4288311 NaN \n",
|
1242 |
+
"46111 NaN NaN NaN NaN raw 5526257 NaN \n",
|
1243 |
+
"39502 NaN NaN NaN NaN raw 4287444 NaN \n",
|
1244 |
+
"\n",
|
1245 |
+
" subspecies genus \n",
|
1246 |
+
"48538 None NaN \n",
|
1247 |
+
"37246 None NaN \n",
|
1248 |
+
"37484 None NaN \n",
|
1249 |
+
"48780 None NaN \n",
|
1250 |
+
"3118 None NaN \n",
|
1251 |
+
"46111 None NaN \n",
|
1252 |
+
"39502 None NaN \n",
|
1253 |
+
"\n",
|
1254 |
+
"[7 rows x 26 columns]"
|
1255 |
+
]
|
1256 |
+
},
|
1257 |
+
"execution_count": 27,
|
1258 |
+
"metadata": {},
|
1259 |
+
"output_type": "execute_result"
|
1260 |
+
}
|
1261 |
+
],
|
1262 |
+
"source": [
|
1263 |
+
"df.loc[df.species.isna()].sample(7)"
|
1264 |
+
]
|
1265 |
+
},
|
1266 |
+
{
|
1267 |
+
"cell_type": "markdown",
|
1268 |
+
"metadata": {},
|
1269 |
+
"source": [
|
1270 |
+
"### Update Master File with Genus through Subspecies Columns"
|
1271 |
+
]
|
1272 |
+
},
|
1273 |
+
{
|
1274 |
+
"cell_type": "code",
|
1275 |
+
"execution_count": 28,
|
1276 |
+
"metadata": {},
|
1277 |
+
"outputs": [],
|
1278 |
+
"source": [
|
1279 |
+
"df.to_csv(\"../Jiggins_Zenodo_Img_Master.csv\", index = False)"
|
1280 |
+
]
|
1281 |
+
},
|
1282 |
+
{
|
1283 |
+
"cell_type": "markdown",
|
1284 |
+
"metadata": {},
|
1285 |
+
"source": [
|
1286 |
+
"### Make Heliconius Subset"
|
1287 |
+
]
|
1288 |
+
},
|
1289 |
+
{
|
1290 |
+
"cell_type": "code",
|
1291 |
+
"execution_count": 29,
|
1292 |
+
"metadata": {},
|
1293 |
+
"outputs": [
|
1294 |
+
{
|
1295 |
+
"name": "stdout",
|
1296 |
+
"output_type": "stream",
|
1297 |
+
"text": [
|
1298 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
1299 |
+
"Index: 34929 entries, 6 to 49358\n",
|
1300 |
+
"Data columns (total 26 columns):\n",
|
1301 |
+
" # Column Non-Null Count Dtype \n",
|
1302 |
+
"--- ------ -------------- ----- \n",
|
1303 |
+
" 0 CAMID 34929 non-null object\n",
|
1304 |
+
" 1 X 34929 non-null int64 \n",
|
1305 |
+
" 2 Image_name 34929 non-null object\n",
|
1306 |
+
" 3 View 34150 non-null object\n",
|
1307 |
+
" 4 zenodo_name 34929 non-null object\n",
|
1308 |
+
" 5 zenodo_link 34929 non-null object\n",
|
1309 |
+
" 6 Sequence 34929 non-null object\n",
|
1310 |
+
" 7 Taxonomic_Name 34929 non-null object\n",
|
1311 |
+
" 8 Locality 23417 non-null object\n",
|
1312 |
+
" 9 Sample_accession 5860 non-null object\n",
|
1313 |
+
" 10 Collected_by 5280 non-null object\n",
|
1314 |
+
" 11 Other_ID 6404 non-null object\n",
|
1315 |
+
" 12 Date 23162 non-null object\n",
|
1316 |
+
" 13 Dataset 32846 non-null object\n",
|
1317 |
+
" 14 Store 29446 non-null object\n",
|
1318 |
+
" 15 Brood 14921 non-null object\n",
|
1319 |
+
" 16 Death_Date 316 non-null object\n",
|
1320 |
+
" 17 Cross_Type 5133 non-null object\n",
|
1321 |
+
" 18 Stage 6 non-null object\n",
|
1322 |
+
" 19 Sex 33880 non-null object\n",
|
1323 |
+
" 20 Unit_Type 31975 non-null object\n",
|
1324 |
+
" 21 file_type 34929 non-null object\n",
|
1325 |
+
" 22 record_number 34929 non-null object\n",
|
1326 |
+
" 23 species 34929 non-null object\n",
|
1327 |
+
" 24 subspecies 24953 non-null object\n",
|
1328 |
+
" 25 genus 34929 non-null object\n",
|
1329 |
+
"dtypes: int64(1), object(25)\n",
|
1330 |
+
"memory usage: 7.2+ MB\n"
|
1331 |
+
]
|
1332 |
+
}
|
1333 |
+
],
|
1334 |
+
"source": [
|
1335 |
+
"heliconius_subset = df.loc[df.genus.str.lower() == \"heliconius\"]\n",
|
1336 |
+
"\n",
|
1337 |
+
"heliconius_subset.info()"
|
1338 |
+
]
|
1339 |
+
},
|
1340 |
+
{
|
1341 |
+
"cell_type": "code",
|
1342 |
+
"execution_count": 30,
|
1343 |
+
"metadata": {},
|
1344 |
+
"outputs": [
|
1345 |
+
{
|
1346 |
+
"data": {
|
1347 |
+
"text/plain": [
|
1348 |
+
"CAMID 9546\n",
|
1349 |
+
"X 34929\n",
|
1350 |
+
"Image_name 26946\n",
|
1351 |
+
"View 3\n",
|
1352 |
+
"zenodo_name 31\n",
|
1353 |
+
"zenodo_link 28\n",
|
1354 |
+
"Sequence 8701\n",
|
1355 |
+
"Taxonomic_Name 129\n",
|
1356 |
+
"Locality 472\n",
|
1357 |
+
"Sample_accession 1559\n",
|
1358 |
+
"Collected_by 12\n",
|
1359 |
+
"Other_ID 1865\n",
|
1360 |
+
"Date 776\n",
|
1361 |
+
"Dataset 8\n",
|
1362 |
+
"Store 121\n",
|
1363 |
+
"Brood 224\n",
|
1364 |
+
"Death_Date 81\n",
|
1365 |
+
"Cross_Type 30\n",
|
1366 |
+
"Stage 1\n",
|
1367 |
+
"Sex 3\n",
|
1368 |
+
"Unit_Type 4\n",
|
1369 |
+
"file_type 3\n",
|
1370 |
+
"record_number 28\n",
|
1371 |
+
"species 37\n",
|
1372 |
+
"subspecies 110\n",
|
1373 |
+
"genus 1\n",
|
1374 |
+
"dtype: int64"
|
1375 |
+
]
|
1376 |
+
},
|
1377 |
+
"execution_count": 30,
|
1378 |
+
"metadata": {},
|
1379 |
+
"output_type": "execute_result"
|
1380 |
+
}
|
1381 |
+
],
|
1382 |
+
"source": [
|
1383 |
+
"heliconius_subset.nunique()"
|
1384 |
+
]
|
1385 |
+
},
|
1386 |
+
{
|
1387 |
+
"cell_type": "code",
|
1388 |
+
"execution_count": 31,
|
1389 |
+
"metadata": {},
|
1390 |
+
"outputs": [
|
1391 |
+
{
|
1392 |
+
"data": {
|
1393 |
+
"text/plain": [
|
1394 |
+
"View\n",
|
1395 |
+
"dorsal 17218\n",
|
1396 |
+
"ventral 16914\n",
|
1397 |
+
"dorsal and ventral 18\n",
|
1398 |
+
"Name: count, dtype: int64"
|
1399 |
+
]
|
1400 |
+
},
|
1401 |
+
"execution_count": 31,
|
1402 |
+
"metadata": {},
|
1403 |
+
"output_type": "execute_result"
|
1404 |
+
}
|
1405 |
+
],
|
1406 |
+
"source": [
|
1407 |
+
"heliconius_subset.View.value_counts()"
|
1408 |
+
]
|
1409 |
+
},
|
1410 |
+
{
|
1411 |
+
"cell_type": "markdown",
|
1412 |
+
"metadata": {},
|
1413 |
+
"source": [
|
1414 |
+
"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)."
|
1415 |
+
]
|
1416 |
+
},
|
1417 |
+
{
|
1418 |
+
"cell_type": "markdown",
|
1419 |
+
"metadata": {},
|
1420 |
+
"source": [
|
1421 |
+
"### Save the Heliconius Subset to CSV\n",
|
1422 |
+
"We'll drop the `genus` column, since they're all `Heliconius`."
|
1423 |
+
]
|
1424 |
+
},
|
1425 |
+
{
|
1426 |
+
"cell_type": "code",
|
1427 |
+
"execution_count": 32,
|
1428 |
+
"metadata": {},
|
1429 |
+
"outputs": [],
|
1430 |
+
"source": [
|
1431 |
+
"heliconius_subset[list(heliconius_subset.columns)[:-1]].to_csv(\"../Jiggins_Heliconius_Master.csv\", index = False)"
|
1432 |
+
]
|
1433 |
+
},
|
1434 |
+
{
|
1435 |
+
"cell_type": "code",
|
1436 |
+
"execution_count": null,
|
1437 |
+
"metadata": {},
|
1438 |
+
"outputs": [],
|
1439 |
+
"source": []
|
1440 |
+
}
|
1441 |
+
],
|
1442 |
+
"metadata": {
|
1443 |
+
"kernelspec": {
|
1444 |
+
"display_name": "std",
|
1445 |
+
"language": "python",
|
1446 |
+
"name": "python3"
|
1447 |
+
},
|
1448 |
+
"language_info": {
|
1449 |
+
"codemirror_mode": {
|
1450 |
+
"name": "ipython",
|
1451 |
+
"version": 3
|
1452 |
+
},
|
1453 |
+
"file_extension": ".py",
|
1454 |
+
"mimetype": "text/x-python",
|
1455 |
+
"name": "python",
|
1456 |
+
"nbconvert_exporter": "python",
|
1457 |
+
"pygments_lexer": "ipython3",
|
1458 |
+
"version": "3.11.3"
|
1459 |
+
},
|
1460 |
+
"orig_nbformat": 4
|
1461 |
+
},
|
1462 |
+
"nbformat": 4,
|
1463 |
+
"nbformat_minor": 2
|
1464 |
+
}
|