| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| import pandas as pd |
| import seaborn as sns |
| import plotly.express as px |
|
|
| sns.set_style("whitegrid") |
| sns.set(rc = {'figure.figsize': (10,10)}) |
|
|
| |
| |
|
|
| |
| df = pd.read_csv("../data/catalog.csv") |
|
|
| |
| |
| df.loc[df['inat21_filename'].notna(), 'data_source'] = 'iNat21' |
| df.loc[df['bioscan_filename'].notna(), 'data_source'] = 'BIOSCAN' |
| df.loc[df['eol_content_id'].notna(), 'data_source'] = 'EOL' |
|
|
| |
| taxa = list(df.columns[9:16]) |
| taxa |
|
|
| |
| |
|
|
| |
| columns = taxa.copy() |
| columns.insert(0, 'data_source') |
| columns.append('common') |
|
|
| |
| df_taxa = df[columns] |
| df_taxa.head() |
|
|
| |
| |
|
|
| |
| |
| df_phylum = df_taxa.loc[df_taxa.phylum.notna()] |
|
|
| |
| |
| df_phylum = df_phylum.fillna('unknown') |
|
|
| |
| |
|
|
| |
| phyla = list(df_phylum.phylum.unique()) |
| colors = px.colors.qualitative.Bold |
|
|
| |
| color_map = {} |
| i = 0 |
| for phylum in phyla: |
| |
| i = i%10 |
| color_map[phylum] = colors[i] |
| i += 1 |
|
|
| |
| |
| |
|
|
| fig_phyla = px.treemap(df_phylum, path = ['phylum', 'class', 'order', 'family'], |
| color = 'phylum', |
| color_discrete_map = color_map) |
|
|
| fig_phyla.update_scenes(aspectratio = {'x': 2, 'y': 1}) |
| fig_phyla.update_layout(font = {'size': 18}, |
| margin = { |
| 'l': 0, |
| 'r': 0, |
| 't': 0, |
| 'b': 0 |
| }) |
| fig_phyla.show() |
|
|
| |
| fig_phyla.write_html("../visuals/phyla_ToL_tree.html") |
|
|
| |
| |
|
|
| |
| fig_phyla.write_image("../visuals/phyla_ToL_tree.pdf", width = 900, height = 450) |
|
|
| |
| |
|
|
| |
| df_kingdom = df_taxa.loc[df_taxa.kingdom.notna()] |
| df_kingdom.head() |
|
|
| |
| |
| df_kingdom = df_taxa.loc[df_taxa.kingdom.notna()] |
|
|
| |
| |
| df_kingdom = df_kingdom.fillna('unknown') |
|
|
| |
| |
|
|
| |
| kingdoms = list(df_kingdom.kingdom.unique()) |
| |
|
|
| |
| king_color_map = {} |
| i = 0 |
| for kingdom in kingdoms: |
| |
| i = i%10 |
| king_color_map[kingdom] = colors[i] |
| i += 1 |
|
|
| |
| |
| |
|
|
| fig_king = px.treemap(df_kingdom, path = ['kingdom', 'phylum', 'class', 'order', 'family'], |
| color = 'kingdom', |
| color_discrete_map = king_color_map) |
|
|
| fig_king.update_scenes(aspectratio = {'x': 2, 'y': 1}) |
| fig_king.update_layout(font = {'size': 14}, |
| margin = { |
| 'l': 0, |
| 'r': 0, |
| 't': 0, |
| 'b': 0 |
| }) |
| fig_king.show() |
|
|
| |
| fig_king.write_html("../visuals/kingdom_ToL_tree.html") |
|
|
| |
| |
|
|
| |
| fig_king.write_image("../visuals/kingdom_ToL_tree.pdf", width = 900, height = 450) |
|
|
| |
| |
|
|
| |
| fig = px.histogram(df_kingdom, |
| x = 'kingdom', |
| |
| color = 'kingdom', |
| color_discrete_sequence = px.colors.qualitative.Bold, |
| labels = { |
| 'kingdom': "Kingdom", |
| |
| }, |
| |
| ) |
| fig.update_layout(title = "Number of Images by Kingdom", |
| yaxis_title = "Number of Images") |
|
|
| fig.show() |
|
|
| |
|
|