import plotly.express as px
import pandas as pd
# Sample dataset: Representing biological pathways and their associated counts
data = {
"Category": ["Metabolism", "Metabolism", "Metabolism",
"Cellular Processes", "Cellular Processes", "Cellular Processes",
"Information Storage", "Information Storage"],
"Subcategory": ["Carbohydrate metabolism", "Lipid metabolism", "Amino acid metabolism",
"Signal transduction", "Cell cycle", "Transport",
"DNA replication", "RNA processing"],
"Count": [150, 120, 90, 100, 85, 70, 110, 95]
}
# Convert data to a DataFrame
df = pd.DataFrame(data)
# Create the treemap
fig = px.treemap(
df,
path=["Category", "Subcategory"], # Hierarchical levels
values="Count", # Size of the treemap blocks
color="Count", # Color based on the count values
color_continuous_scale="Viridis" # Color scale
)
# Add a title
fig.update_layout(title="Treemap: Hierarchical Data Representation in Bioinformatics")
# Show the plot
fig.show()