Skip to content

Commit

Permalink
clarify comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Morris committed Jul 1, 2024
1 parent 9977fae commit a54d5f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cyto_dl/models/contrastive/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .contrastive import Contrastive
from .contrastive import Contrastive
3 changes: 2 additions & 1 deletion cyto_dl/models/contrastive/contrastive.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,20 @@ def plot_neighbors(self, embedding1, embedding2):
pca = PCA(n_components=2)
pca.fit(embedding1)

# plot PC1 vs PC2 as heatmap
embedding1 = pca.transform(embedding1)
fig, ax = plt.subplots()
counts, xedges, yedges = np.histogram2d(embedding1[:, 0], embedding1[:, 1], bins=30)
ax.imshow(counts, extent=[xedges[0], xedges[-1], yedges[0], yedges[-1]], origin="lower")
fig.savefig(Path(self.hparams.save_dir) / f"{self.current_epoch}_heatmap.png")
plt.close(fig)

# Plot anchor/positive relationship for a subsample
random_examples = np.random.choice(embedding1.shape[0], 10)
embedding1 = embedding1[random_examples]
embedding2 = pca.transform(embedding2[random_examples])

fig, ax = plt.subplots()

# plot anchor embeddings in gray
ax.scatter(embedding1[:, 0], embedding1[:, 1], c="green")

Expand Down

0 comments on commit a54d5f1

Please sign in to comment.