Closed Zymeth0211 closed 9 months ago
I am not sure what "integrate" means. Could you please clarify what you mean?
Dear Moshi4
Thank you for your rapid response.
In my case, the tree data and heat map data frame are not correctly synchronized. For example, Cl_1995 has to be lighter in terms of color due to its small value. Is there any way to fix by synchronizing between newick and matrix data?
I am not going to explain the code in detail, so please try to understand the content yourself.
Code Example
from pycirclize import Circos
import pandas as pd
# Initialize circos tree
tree_file = "./tree_test/abs alignment_tree.nwk"
circos, tv = Circos.initialize_from_tree(
tree_file,
start=5,
end=355,
leaf_label_size=10,
align_leaf_label=True,
ladderize=True,
r_lim=(0, 60),
leaf_label_rmargin=12,
ignore_branch_length=True,
)
# Read CSV & sort by order of leaf labels
df = pd.read_csv("./tree_test/abs_abundance.csv", index_col=0)
sorted_df = df.loc[tv.leaf_labels]
print(sorted_df)
# Set colorbar
vmin, vmax = 0, sorted_df.to_numpy().max()
circos.colorbar(bounds=(1.0, 0.35, 0.02, 0.3), cmap="Reds", vmin=vmin, vmax=vmax)
# 4R heatmap
sector = circos.sectors[0]
track1 = sector.add_track((60, 65))
track1.heatmap(sorted_df["4R"].to_numpy(), cmap="Reds", vmin=vmin, vmax=vmax, show_value=True)
circos.text("4R", r=track1.r_center)
# 3R heatmap
track2 = sector.add_track((65, 70))
track2.heatmap(sorted_df["3R"].to_numpy(), cmap="Reds", vmin=vmin, vmax=vmax, show_value=True)
circos.text("3R", r=track2.r_center)
circos.savefig("example.png")
example.png
Dear Moshi04.
Thank you for your perfect system to create a beautiful combination of tree and heatmap.
I have a question about data integration between heatmap data and tree leaves. How do you integrate between them?
output
Here is zip containing nwk and abundance data for heat map.
I apologize to ask you basic things. tree_test.zip
Thank you Best regards.