Show the code
# Load library
from pylifemap import Lifemap, aggregate_count, get_duplicated_taxids, aggregate_freq, aggregate_num
import pandas as pd
# Get all metagenomics read data (kraken)
df = pd.read_parquet("data/wuhan_taxid_kraken2.parquet", engine='pyarrow')
# Get all taxids in the reference database at the time of the study
alltaxid = pd.read_parquet("data/kraken2_nt_28112022_inspect_tax_id.parquet", engine="pyarrow")
# Get all taxids belonging to amniota
amniota_taxid = pd.read_csv("data/amniota_taxid_list.csv")
amniota_taxid = amniota_taxid["taxid"].tolist()
# Subsample datasets to only amniota
df_amniota = df[df["taxid"].isin(amniota_taxid)].copy()
alltaxid_amniota = alltaxid[alltaxid["taxid"].isin(amniota_taxid)].copy()
# Aggregate along tree nodes
alltaxid_amniota_agg = aggregate_count(alltaxid_amniota)
# Get species present in Wuhan market
wuhan_taxid_df = pd.read_csv("data/wuhan_taxid_df.csv")
# PLOT
(
Lifemap(
theme="lightgrey",
center=32524,
zoom=12.5
)
.layer_lines(
alltaxid_amniota_agg,
color="#f4aa44",
width=1.5
)
.layer_icons(
wuhan_taxid_df,
icon="img/cross.png",
scale=0.2,
popup=False,
declutter=False
)
.layer_points(
df_amniota[df_amniota["count"]>=1000],
radius="count",
fill="count",
radius_range = [4,25],
scheme="YlOrRd"
)
.show()
)Warning: 2 taxids have not been found in Lifemap database: [None, 1576478].
Warning: 1 taxids have not been found in Lifemap database: [None].