Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all-vs-all JSD score #212

Open
kelly-sovacool opened this issue Nov 20, 2024 · 1 comment
Open

all-vs-all JSD score #212

kelly-sovacool opened this issue Nov 20, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@kelly-sovacool
Copy link
Member

kelly-sovacool commented Nov 20, 2024

Jensen-Shannon Distance (JSD) plot

use deeptools npz output as input to jsd

encode: https://github.com/ENCODE-DCC/chip-seq-pipeline2/blob/master/src/encode_task_jsd.py

@kopardev
Copy link
Member

import numpy as np
from scipy.spatial.distance import jensenshannon
import seaborn as sns
import matplotlib.pyplot as plt

# Load data
data = np.load("summary.npz")
coverage_matrix = data["data"]
labels = data["labels"]

# Normalize per sample
coverage_matrix += 1e-10  # Handle zeros
normalized_matrix = coverage_matrix / coverage_matrix.sum(axis=0, keepdims=True)

# Compute JSD matrix
num_samples = normalized_matrix.shape[1]
jsd_matrix = np.zeros((num_samples, num_samples))

for i in range(num_samples):
    for j in range(num_samples):
        jsd_matrix[i, j] = jensenshannon(normalized_matrix[:, i], normalized_matrix[:, j])

# Plot heatmap
sns.heatmap(jsd_matrix, xticklabels=labels, yticklabels=labels, annot=True, fmt=".2f", cmap="viridis")
plt.title("Pairwise Jensen-Shannon Distances")
plt.show()

@kelly-sovacool kelly-sovacool added the enhancement New feature or request label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants