v3.3 update visualizations
#4
by
egrace479 - opened
- .gitattributes +4 -0
- README.md +6 -0
- notebooks/BioCLIP_taxa_viz.ipynb +3 -0
- notebooks/BioCLIP_taxa_viz.py +184 -0
- visuals/{fullData_phyla.png → category-v1-visuals/fullData_phyla.png} +0 -0
- visuals/{inat_phyla.png → category-v1-visuals/inat_phyla.png} +0 -0
- visuals/{num_images_class_y.png → category-v1-visuals/num_images_class_y.png} +0 -0
- visuals/{num_images_kingdom.png → category-v1-visuals/num_images_kingdom.png} +0 -0
- visuals/{num_images_order_y.png → category-v1-visuals/num_images_order_y.png} +0 -0
- visuals/{num_images_phylum_y.png → category-v1-visuals/num_images_phylum_y.png} +0 -0
- visuals/{num_phyla_kingdom.png → category-v1-visuals/num_phyla_kingdom.png} +0 -0
- visuals/{num_species_kingdom.png → category-v1-visuals/num_species_kingdom.png} +0 -0
- visuals/{phyla_ToL.pdf → category-v1-visuals/phyla_ToL.pdf} +0 -0
- visuals/{phyla_ToL.png → category-v1-visuals/phyla_ToL.png} +0 -0
- visuals/{phyla_ToL_scale1.pdf → category-v1-visuals/phyla_ToL_scale1.pdf} +0 -0
- visuals/category-v1-visuals/phyla_ToL_tree_cat-v1.html +0 -0
- visuals/{phyla_ToL_wh.pdf → category-v1-visuals/phyla_ToL_wh.pdf} +0 -0
- visuals/{phyla_iNat21.png → category-v1-visuals/phyla_iNat21.png} +0 -0
- visuals/kingdom_ToL_tree.html +0 -0
- visuals/kingdom_ToL_tree.pdf +3 -0
- visuals/phyla_ToL_tree.html +0 -0
- visuals/phyla_ToL_tree.pdf +3 -0
.gitattributes
CHANGED
|
@@ -53,9 +53,13 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 56 |
# Large notebooks and data
|
| 57 |
data/v1-dev-names.csv filter=lfs diff=lfs merge=lfs -text
|
| 58 |
notebooks/BioCLIP_taxa_viz_bySource.ipynb filter=lfs diff=lfs merge=lfs -text
|
| 59 |
statistics.csv filter=lfs diff=lfs merge=lfs -text
|
| 60 |
data/catalog*.csv filter=lfs diff=lfs merge=lfs -text
|
| 61 |
data/predicted-catalog.csv filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
|
| 57 |
# Large notebooks and data
|
| 58 |
data/v1-dev-names.csv filter=lfs diff=lfs merge=lfs -text
|
| 59 |
notebooks/BioCLIP_taxa_viz_bySource.ipynb filter=lfs diff=lfs merge=lfs -text
|
| 60 |
statistics.csv filter=lfs diff=lfs merge=lfs -text
|
| 61 |
data/catalog*.csv filter=lfs diff=lfs merge=lfs -text
|
| 62 |
data/predicted-catalog.csv filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
notebooks/BioCLIP_taxa_viz.ipynb filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
visuals/kingdom_ToL_tree.pdf filter=lfs diff=lfs merge=lfs -text
|
| 65 |
+
visuals/phyla_ToL_tree.pdf filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -29,6 +29,7 @@ The `notebooks` folder contains
|
|
| 29 |
- `ToL_catalog_EDA.py`: py file paired to `ToL_catalog_EDA.ipynb` to facilitate diff checking in case of cell text changes in notebook.
|
| 30 |
- `ToL_predicted-catalog_EDA.ipynb`: more full EDA of TreeOfLife10M dataset using `predicted-catalog.csv`. To be updated as `predicted-catalog.csv` is updated, i.e., as the dataset is updated.
|
| 31 |
- `ToL_predicted-catalog_EDA.py`: py file paired to `ToL_predicted-catalog_EDA.ipynb` to facilitate diff checking in case of cell text changes in notebook.
|
|
|
|
| 32 |
|
| 33 |
- `BioCLIP_data_viz.ipynb`: notebook with quick basic stats for `catalog-v1-dev.csv`, generates `taxa_counts.csv`.
|
| 34 |
- `BioCLIP_taxa_viz_bySource.ipynb`: generates data visualizations, in particular, the generation of visualizations in `visuals` folder and some histograms. The treemaps produced in the notebook are interactive.
|
|
@@ -41,4 +42,9 @@ direction of standardization efforts. Maintained for v1 reference, should not be
|
|
| 41 |
### Visuals
|
| 42 |
|
| 43 |
Visualizations generated to demonstrate the distribution and diversity within the phyla of TreeOfLife10M.
|
|
|
|
| 44 |
There is also one for just the iNat21 data included.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
- `ToL_catalog_EDA.py`: py file paired to `ToL_catalog_EDA.ipynb` to facilitate diff checking in case of cell text changes in notebook.
|
| 30 |
- `ToL_predicted-catalog_EDA.ipynb`: more full EDA of TreeOfLife10M dataset using `predicted-catalog.csv`. To be updated as `predicted-catalog.csv` is updated, i.e., as the dataset is updated.
|
| 31 |
- `ToL_predicted-catalog_EDA.py`: py file paired to `ToL_predicted-catalog_EDA.ipynb` to facilitate diff checking in case of cell text changes in notebook.
|
| 32 |
+
- `BioCLIP_taxa_viz.ipynb`: generates data visualizations, in particular, the generation of treemaps in `visuals` folder; also includes a histogram of kingdoms. The treemaps produced in the notebook are interactive and `HTML` interactive versions can also be found in [`visuals`](https://huggingface.co/datasets/imageomics/ToL-EDA/tree/main/visuals).
|
| 33 |
|
| 34 |
- `BioCLIP_data_viz.ipynb`: notebook with quick basic stats for `catalog-v1-dev.csv`, generates `taxa_counts.csv`.
|
| 35 |
- `BioCLIP_taxa_viz_bySource.ipynb`: generates data visualizations, in particular, the generation of visualizations in `visuals` folder and some histograms. The treemaps produced in the notebook are interactive.
|
|
|
|
| 42 |
### Visuals
|
| 43 |
|
| 44 |
Visualizations generated to demonstrate the distribution and diversity within the phyla of TreeOfLife10M.
|
| 45 |
+
- `category-v1-visuals`: visualizations made for the original `catalog-v1-dev.csv` using `BioCLIP_taxa_viz_bySource.ipynb`.
|
| 46 |
There is also one for just the iNat21 data included.
|
| 47 |
+
- `kingdom_ToL_tree.html`: interactive treemap from `kingdom` to `family` to demonstrate the distribution of the data. 2:1 aspect ratio.
|
| 48 |
+
- `kingdom_ToL_tree.pdf`: static treemap from `kingdom` to `family`to demonstrate the distribution of the data. 2:1 aspect ratio.
|
| 49 |
+
- `phyla_ToL_tree.html`: interactive treemap from `phylum` to `family` to demonstrate the distribution of the data. 2:1 aspect ratio.
|
| 50 |
+
- `kingdom_ToL_tree.pdf`: static treemap from `phylum` to `family` to demonstrate the distribution of the data. 2:1 aspect ratio.
|
notebooks/BioCLIP_taxa_viz.ipynb
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:71f9c4c70f74a43c869568b2eb5f46a782512391875833096ba8678b888f09ee
|
| 3 |
+
size 237174718
|
notebooks/BioCLIP_taxa_viz.py
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ---
|
| 2 |
+
# jupyter:
|
| 3 |
+
# jupytext:
|
| 4 |
+
# formats: ipynb,py:percent
|
| 5 |
+
# text_representation:
|
| 6 |
+
# extension: .py
|
| 7 |
+
# format_name: percent
|
| 8 |
+
# format_version: '1.3'
|
| 9 |
+
# jupytext_version: 1.15.2
|
| 10 |
+
# kernelspec:
|
| 11 |
+
# display_name: viz
|
| 12 |
+
# language: python
|
| 13 |
+
# name: python3
|
| 14 |
+
# ---
|
| 15 |
+
|
| 16 |
+
# %%
|
| 17 |
+
import pandas as pd
|
| 18 |
+
import seaborn as sns
|
| 19 |
+
import plotly.express as px
|
| 20 |
+
|
| 21 |
+
sns.set_style("whitegrid")
|
| 22 |
+
sns.set(rc = {'figure.figsize': (10,10)})
|
| 23 |
+
|
| 24 |
+
# %% [markdown]
|
| 25 |
+
# # Number of Images by Taxonomic Rank
|
| 26 |
+
|
| 27 |
+
# %%
|
| 28 |
+
df = pd.read_csv("../data/catalog.csv")
|
| 29 |
+
|
| 30 |
+
# %%
|
| 31 |
+
# Add data_source column for easier slicing
|
| 32 |
+
df.loc[df['inat21_filename'].notna(), 'data_source'] = 'iNat21'
|
| 33 |
+
df.loc[df['bioscan_filename'].notna(), 'data_source'] = 'BIOSCAN'
|
| 34 |
+
df.loc[df['eol_content_id'].notna(), 'data_source'] = 'EOL'
|
| 35 |
+
|
| 36 |
+
# %%
|
| 37 |
+
taxa = list(df.columns[9:16])
|
| 38 |
+
taxa
|
| 39 |
+
|
| 40 |
+
# %% [markdown]
|
| 41 |
+
# Shrink down to just columns we may want for graphing.
|
| 42 |
+
|
| 43 |
+
# %%
|
| 44 |
+
columns = taxa.copy()
|
| 45 |
+
columns.insert(0, 'data_source')
|
| 46 |
+
columns.append('common')
|
| 47 |
+
|
| 48 |
+
# %%
|
| 49 |
+
df_taxa = df[columns]
|
| 50 |
+
df_taxa.head()
|
| 51 |
+
|
| 52 |
+
# %% [markdown]
|
| 53 |
+
# Since the pie charts didn't show much change for phylum, let's try a treemap so we also get a sense of all the diversity inside.
|
| 54 |
+
|
| 55 |
+
# %%
|
| 56 |
+
# Drop null phylum values
|
| 57 |
+
df_phylum = df_taxa.loc[df_taxa.phylum.notna()]
|
| 58 |
+
|
| 59 |
+
# %%
|
| 60 |
+
# Fill null lower ranks with 'unknown' for graphing purposes
|
| 61 |
+
df_phylum = df_phylum.fillna('unknown')
|
| 62 |
+
|
| 63 |
+
# %% [markdown]
|
| 64 |
+
# Get list of all phyla and set color scheme. We'll then assign a color to each phylum so they're consistent across the two charts.
|
| 65 |
+
|
| 66 |
+
# %%
|
| 67 |
+
phyla = list(df_phylum.phylum.unique())
|
| 68 |
+
colors = px.colors.qualitative.Bold
|
| 69 |
+
|
| 70 |
+
# %%
|
| 71 |
+
color_map = {}
|
| 72 |
+
i = 0
|
| 73 |
+
for phylum in phyla:
|
| 74 |
+
# There are only 10 colors in the sequence, so we'll need to loop through it a few times to assign all 49 phyla
|
| 75 |
+
i = i%10
|
| 76 |
+
color_map[phylum] = colors[i]
|
| 77 |
+
i += 1
|
| 78 |
+
|
| 79 |
+
# %%
|
| 80 |
+
# Distribution of Phyla and Lower Taxa (to family) in TreeOfLife10M
|
| 81 |
+
# Minimize margins, set aspect ratio to 2:1
|
| 82 |
+
|
| 83 |
+
fig_phyla = px.treemap(df_phylum, path = ['phylum', 'class', 'order', 'family'],
|
| 84 |
+
color = 'phylum',
|
| 85 |
+
color_discrete_map = color_map)
|
| 86 |
+
|
| 87 |
+
fig_phyla.update_scenes(aspectratio = {'x': 2, 'y': 1})
|
| 88 |
+
fig_phyla.update_layout(font = {'size': 18},
|
| 89 |
+
margin = {
|
| 90 |
+
'l': 0,
|
| 91 |
+
'r': 0,
|
| 92 |
+
't': 0,
|
| 93 |
+
'b': 0
|
| 94 |
+
})
|
| 95 |
+
fig_phyla.show()
|
| 96 |
+
|
| 97 |
+
# %%
|
| 98 |
+
fig_phyla.write_html("../visuals/phyla_ToL_tree.html")
|
| 99 |
+
|
| 100 |
+
# %% [markdown]
|
| 101 |
+
# Aspect ratio set in the plot doesn't work for export (unless using the png export on the graph itself), so we'll set the size manually.
|
| 102 |
+
|
| 103 |
+
# %%
|
| 104 |
+
fig_phyla.write_image("../visuals/phyla_ToL_tree.pdf", width = 900, height = 450)
|
| 105 |
+
|
| 106 |
+
# %% [markdown]
|
| 107 |
+
# ## Images by Kingdom
|
| 108 |
+
|
| 109 |
+
# %%
|
| 110 |
+
df_kingdom = df_taxa.loc[df_taxa.kingdom.notna()]
|
| 111 |
+
df_kingdom.head()
|
| 112 |
+
|
| 113 |
+
# %%
|
| 114 |
+
# Drop null kingdom values
|
| 115 |
+
df_kingdom = df_taxa.loc[df_taxa.kingdom.notna()]
|
| 116 |
+
|
| 117 |
+
# %%
|
| 118 |
+
# Fill null lower ranks with 'unknown' for graphing purposes
|
| 119 |
+
df_kingdom = df_kingdom.fillna('unknown')
|
| 120 |
+
|
| 121 |
+
# %% [markdown]
|
| 122 |
+
# Get list of all kingdoms and set color scheme. We'll then assign a color to each kingdom so they're consistent across the two charts.
|
| 123 |
+
|
| 124 |
+
# %%
|
| 125 |
+
kingdoms = list(df_kingdom.kingdom.unique())
|
| 126 |
+
#colors = px.colors.qualitative.Bold
|
| 127 |
+
|
| 128 |
+
# %%
|
| 129 |
+
king_color_map = {}
|
| 130 |
+
i = 0
|
| 131 |
+
for kingdom in kingdoms:
|
| 132 |
+
# There are only 10 colors in the sequence, so we'll need to loop through it once to assign all 12 kingdoms
|
| 133 |
+
i = i%10
|
| 134 |
+
king_color_map[kingdom] = colors[i]
|
| 135 |
+
i += 1
|
| 136 |
+
|
| 137 |
+
# %%
|
| 138 |
+
# Distribution of Kingdoms and Lower Taxa in TreeOfLife10M
|
| 139 |
+
# Minimize margins, set aspect ratio to 2:1
|
| 140 |
+
|
| 141 |
+
fig_king = px.treemap(df_kingdom, path = ['kingdom', 'phylum', 'class', 'order', 'family'],
|
| 142 |
+
color = 'kingdom',
|
| 143 |
+
color_discrete_map = king_color_map)
|
| 144 |
+
|
| 145 |
+
fig_king.update_scenes(aspectratio = {'x': 2, 'y': 1})
|
| 146 |
+
fig_king.update_layout(font = {'size': 14},
|
| 147 |
+
margin = {
|
| 148 |
+
'l': 0,
|
| 149 |
+
'r': 0,
|
| 150 |
+
't': 0,
|
| 151 |
+
'b': 0
|
| 152 |
+
})
|
| 153 |
+
fig_king.show()
|
| 154 |
+
|
| 155 |
+
# %%
|
| 156 |
+
fig_king.write_html("../visuals/kingdom_ToL_tree.html")
|
| 157 |
+
|
| 158 |
+
# %% [markdown]
|
| 159 |
+
# Aspect ratio set in the plot doesn't work for export (unless using the png export on the graph itself), so we'll set the size manually.
|
| 160 |
+
|
| 161 |
+
# %%
|
| 162 |
+
fig_king.write_image("../visuals/kingdom_ToL_tree.pdf", width = 900, height = 450)
|
| 163 |
+
|
| 164 |
+
# %% [markdown]
|
| 165 |
+
# ### Histograms for Kingdom
|
| 166 |
+
|
| 167 |
+
# %%
|
| 168 |
+
fig = px.histogram(df_kingdom,
|
| 169 |
+
x = 'kingdom',
|
| 170 |
+
#y = 'num_species',
|
| 171 |
+
color = 'kingdom',
|
| 172 |
+
color_discrete_sequence = px.colors.qualitative.Bold,
|
| 173 |
+
labels = {
|
| 174 |
+
'kingdom': "Kingdom",
|
| 175 |
+
#'num_phyla' : "Number of distinct species"
|
| 176 |
+
},
|
| 177 |
+
#text_auto=False
|
| 178 |
+
)
|
| 179 |
+
fig.update_layout(title = "Number of Images by Kingdom",
|
| 180 |
+
yaxis_title = "Number of Images")
|
| 181 |
+
|
| 182 |
+
fig.show()
|
| 183 |
+
|
| 184 |
+
# %%
|
visuals/{fullData_phyla.png → category-v1-visuals/fullData_phyla.png}
RENAMED
|
File without changes
|
visuals/{inat_phyla.png → category-v1-visuals/inat_phyla.png}
RENAMED
|
File without changes
|
visuals/{num_images_class_y.png → category-v1-visuals/num_images_class_y.png}
RENAMED
|
File without changes
|
visuals/{num_images_kingdom.png → category-v1-visuals/num_images_kingdom.png}
RENAMED
|
File without changes
|
visuals/{num_images_order_y.png → category-v1-visuals/num_images_order_y.png}
RENAMED
|
File without changes
|
visuals/{num_images_phylum_y.png → category-v1-visuals/num_images_phylum_y.png}
RENAMED
|
File without changes
|
visuals/{num_phyla_kingdom.png → category-v1-visuals/num_phyla_kingdom.png}
RENAMED
|
File without changes
|
visuals/{num_species_kingdom.png → category-v1-visuals/num_species_kingdom.png}
RENAMED
|
File without changes
|
visuals/{phyla_ToL.pdf → category-v1-visuals/phyla_ToL.pdf}
RENAMED
|
File without changes
|
visuals/{phyla_ToL.png → category-v1-visuals/phyla_ToL.png}
RENAMED
|
File without changes
|
visuals/{phyla_ToL_scale1.pdf → category-v1-visuals/phyla_ToL_scale1.pdf}
RENAMED
|
File without changes
|
visuals/category-v1-visuals/phyla_ToL_tree_cat-v1.html
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
visuals/{phyla_ToL_wh.pdf → category-v1-visuals/phyla_ToL_wh.pdf}
RENAMED
|
File without changes
|
visuals/{phyla_iNat21.png → category-v1-visuals/phyla_iNat21.png}
RENAMED
|
File without changes
|
visuals/kingdom_ToL_tree.html
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
visuals/kingdom_ToL_tree.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:68df18d4984fdac00ab5373e3c460784093e6a057410bedb60d2a454e5817f5e
|
| 3 |
+
size 1187148
|
visuals/phyla_ToL_tree.html
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
visuals/phyla_ToL_tree.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:06e80b5ca147c493383554ce5fb2b23c0ec0b691c46c4d99475563a3a79b3a9a
|
| 3 |
+
size 1076084
|