bio-hi-c-analysis-hic-visualization
БесплатноЗапускает вложенные скриптыНе проверенVisualize Hi-C contact matrices, TADs, loops, and genomic features using matplotlib, cooltools, and HiCExplorer. Create triangle plots, virtual 4C, and…
от gabrielmoreira★ 23 звезды на GitHubОб этом скилле
Version Compatibility
Reference examples tested with: cooler 0.9+, cooltools 0.6+, matplotlib 3.8+, numpy 1.26+, pandas 2.2+
Before using code patterns, verify installed versions match. If versions differ:
- Python:
pip show <package>thenhelp(module.function)to check signatures - CLI:
<tool> --versionthen<tool> --helpto confirm flags
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Hi-C Visualization
"Plot my Hi-C contact matrix" → Create triangle heatmaps, virtual 4C profiles, and multi-track figures combining contact maps with genomic annotations.
- Python:
matplotlib.pyplot.imshow()on cooler matrices,cooltoolsfor aggregate plots - CLI:
hicPlotMatrix(HiCExplorer)
Visualize Hi-C contact matrices and genomic features.
Required Imports
import cooler
import cooltools
import cooltools.lib.plotting
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
import bioframe
Basic Contact Matrix Plot
clr = cooler.Cooler('matrix.mcool::resolutions/10000')
# Get matrix for a region
matrix = clr.matrix(balance=True).fetch('chr1:50000000-60000000')
fig, ax = plt.subplots(figsize=(8, 8))
im = ax.imshow(matrix, cmap='Reds', norm=LogNorm(vmin=0.001, vmax=0.1))
plt.colorbar(im, ax=ax, label='Balanced contacts')
ax.set_title('chr1:50-60Mb')
plt.savefig('contact_matrix.png', dpi=150)
Triangle (Upper Triangle) Plot
def plot_triangle(matrix, ax, cmap='Reds', vmin=None, vmax=None):
'''Plot Hi-C matrix as triangle (rotated 45 degrees)'''
n = matrix.shape[0]
# Create rotated matrix
rotated = np.zeros((n, 2*n))
for i in range(n):
for j in range(i, n):
y = j - i
x = i + j
rotated[y, x] = matrix[i, j]
# Plot
im = ax.imshow(rotated[:n//2, :], cmap=cmap, aspect='auto',
norm=LogNorm(vmin=vmin, vmax=vmax) if vmin else None)
ax.set_ylim(n//2, 0)
return im
matrix = clr.matrix(balance=True).fetch('chr1:50000000-60000000')
fig, ax = plt.subplots(figsize=(12, 4))
im = plot_triangle(matrix, ax, vmin=0.001, vmax=0.1)
plt.colorbar(im, ax=ax)
plt.savefig('triangle_plot.png', dpi=150)
Plot with TADs
import pandas as pd
matrix = clr.matrix(balance=True).fetch('chr1:50000000-60000000')
tads = pd.read_csv('tads.bed', sep='\t', names=['chrom', 'start', 'end'])
fig, ax = plt.subplots(figsize=(8, 8))
im = ax.imshow(matrix, cmap='Reds', norm=LogNorm(vmin=0.001, vmax=0.1))
# Overlay TAD boundaries
region_start = 50000000
bin_size = clr.binsize
for _, tad in tads[tads['chrom'] == 'chr1'].iterrows():
if region_start <= tad['start'] < 60000000:
pos = (tad['start'] - region_start) / bin_size
ax.axhline(pos, color='blue', linewidth=0.5, alpha=0.5)
ax.axvline(pos, color='blue', linewidth=0.5, alpha=0.5)
plt.colorbar(im, ax=ax)
plt.savefig('matrix_with_tads.png', dpi=150)
Plot with Loops
matrix = clr.matrix(balance=True).fetch('chr1:50000000-60000000')
loops = pd.read_csv('loops.bedpe', sep='\t')
fig, ax = plt.subplots(figsize=(8, 8))
im = ax.imshow(matrix, cmap='Reds', norm=LogNorm(vmin=0.001, vmax=0.1))
# Mark loops
region_start = 50000000
bin_size = clr.binsize
for _, loop in loops[loops['chrom1'] == 'chr1'].iterrows():
if (region_start <= loop['start1'] < 60000000 and
region_start <= loop['start2'] < 60000000):
x = (loop['start1'] - region_start) / bin_size
y = (loop['start2'] - region_start) / bin_size
circle = plt.Circle((y, x), 3, fill=False, color='blue', linewidth=1)
ax.add_patch(circle)
plt.colorbar(im, ax=ax)
plt.savefig('matrix_with_loops.png', dpi=150)
Compare Two Matrices
clr1 = cooler.Cooler('sample1.mcool::resolutions/10000')
clr2 = cooler.Cooler('sample2.mcool::resolutions/10000')
region = 'chr1:50000000-60000000'
mat1 = clr1.matrix(balance=True).fetch(region)
mat2 = clr2.matrix(balance=True).fetch(region)
fig, axes = plt.subplots(1, 3, figsize=(15, 5))
# Sample 1
im1 = axes[0].imshow(mat1, cmap='Reds', norm=LogNorm(vmin=0.001, vmax=0.1))
axes[0].set_title('Sample 1')
plt.colorbar(im1, ax=axes[0])
# Sample 2
im2 = axes[1].imshow(mat2, cmap='Reds', norm=LogNorm(vmin=0.001, vmax=0.1))
axes[1].set_title('Sample 2')
plt.colorbar(im2, ax=axes[1])
# Log2 fold change
log2fc = np.log2(mat2 / mat1)
log2fc[np.isinf(log2fc)] = np.nan
im3 = axes[2].imshow(log2fc, cmap='coolwarm', vmin=-2, vmax=2)
axes[2].set_title('Log2(Sample2/Sample1)')
plt.colorbar(im3, ax=axes[2])
plt.tight_layout()
plt.savefig('comparison.png', dpi=150)
Split View (Upper/Lower Triangle)
mat1 = clr1.matrix(balance=True).fetch(region)
mat2 = clr2.matrix(balance=True).fetch(region)
# Combine: upper triangle from mat1, lower from mat2
combined = np.triu(mat1) + np.tril(mat2, k=-1)
fig, ax = plt.sub
Установить bio-hi-c-analysis-hic-visualization в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл bio-hi-c-analysis-hic-visualization?
Visualize Hi-C contact matrices, TADs, loops, and genomic features using matplotlib, cooltools, and HiCExplorer. Create triangle plots, virtual 4C, and multi-track figures. Use when visualizing contact matrices or genomic features.
Как установить скилл bio-hi-c-analysis-hic-visualization?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл bio-hi-c-analysis-hic-visualization запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic