Created
October 10, 2020 13:10
-
-
Save monogenea/3e377abb8fff97240f418b934bddad14 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define UMAP | |
brain_umap = umap.UMAP(random_state=999, n_neighbors=30, min_dist=.25) | |
# Fit UMAP and extract latent vars 1-2 | |
embedding = pd.DataFrame(brain_umap.fit_transform(matrix), columns = ['UMAP1','UMAP2']) | |
# Produce sns.scatterplot and pass metadata.subclasses as color | |
sns_plot = sns.scatterplot(x='UMAP1', y='UMAP2', data=embedding, | |
hue=metadata.subclass_label.to_list(), | |
alpha=.1, linewidth=0, s=1) | |
# Adjust legend | |
sns_plot.legend(loc='center left', bbox_to_anchor=(1, .5)) | |
# Save PNG | |
sns_plot.figure.savefig('umap_scatter.png', bbox_inches='tight', dpi=500) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment