Circos plot
ขั้นตอนสุดท้าย จะสร้าง Circos plot ของเครือข่ายนี้กัน!
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การวิเคราะห์เครือข่ายเบื้องต้นด้วย Python
คำแนะนำการฝึกหัด
- สร้าง Circos plot ของเครือข่าย โดยจัดเรียง GitHub user ตาม degree และจัดกลุ่มพร้อมกำหนดสีตามคีย์
'grouping'ทำได้ดังนี้:- วนซ้ำผ่านโหนดทั้งหมดใน
Gพร้อมดึง metadata โดยระบุdata=True - ในแต่ละรอบของลูป ให้คำนวณ degree ของโหนด
nด้วยnx.degree()แล้วกำหนดเป็นแอตทริบิวต์'degree'ของโหนดนั้น - สร้าง
circosplotcโดยระบุพารามิเตอร์เพิ่มเติม 3 ตัวนอกจากกราฟGได้แก่ อาร์กิวเมนต์sort_byกำหนดเป็น'degree'และอาร์กิวเมนต์group_byกับnode_color_byกำหนดเป็น'grouping'ทั้งคู่ - แสดง
Circosplot บนหน้าจอ
- วนซ้ำผ่านโหนดทั้งหมดใน
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Import necessary modules
from nxviz import circos
import matplotlib.pyplot as plt
# Iterate over all the nodes, including the metadata
for n, d in ____:
# Calculate the degree of each node: G.node[n]['degree']
____ = ____
# Create the Circos plot: c
c = ____
# Draw the Circos plot to the screen
____
plt.show()