This repository contains the code of the method presented in "DREAMS: Preserving both Local and Global Structure in Dimensionality Reduction" (arXiv).
DREAMS (Dimensionality Reduction Enhanced Across Multiple Scales) combines the local structure preservation of
The code builds upon openTSNE, which is the
To use the method you must follow these steps:
git clone --branch tp --single-branch https://github.com/berenslab/DREAMS.git
cd DREAMS
python setup.py install
DREAMS is using a precomputed reference embedding that is responsible for the global layout of the embedding. Per default DREAMS is using the PCA embedding, but other embeddings such as the MDS embedding can be used as well. The regularization strength determines the influence of the regularization-embedding on the final embedding. Its default regualrization strength is
Here is an example on the Tasic et al. dataset1 (which is not part of this repository but the preprocessed data can be found here):
import openTSNE
from openTSNE import TSNE
import numpy as np # to load data
import matplotlib.pyplot as plt # for plotting
# Load data
tasic_data = np.load('data/tasic/tasic-pca50.npy')
# Scaled first 2 PCs
tasic_pca2 = tasic_data[:, :2]
tasic_reg_emb = tasic_pca2 / tasic_pca2[:,0].std()
# DREAMS
embedder = TSNE(initialization=tasic_reg_emb,
regularization=True,
reg_lambda=0.1,
reg_embedding=tasic_reg_emb)
tasic_dreams = embedder.fit(data)
# Plot the embedding
tasic_colors = np.load('data/tasic/tasic-colors.npy')
plt.figure()
plt.scatter(*tasic_dreams.T, c=tasic_colors, alpha=0.5, s=1.0, edgecolor="none")
plt.gca().set_aspect("equal")
plt.axis("off")
plt.title("DREAMS on Tasic et al.")
plt.show()Footnotes
-
Bosiljka Tasic, Zizhen Yao, Lucas T Graybuck, Kimberly A Smith, Thuc Nghi Nguyen, Darren Bertag- nolli, Jeff Goldy, Emma Garren, Michael N Economo, Sarada Viswanathan, et al. Shared and distinct transcriptomic cell types across neocortical areas. Nature, 563(7729):72–78, 2018. ↩

