Skip to content

Commit

Permalink
Displays scatter plot in notebook.
Browse files Browse the repository at this point in the history
  • Loading branch information
kairukuma committed Nov 16, 2023
1 parent 01b679f commit 80e3b40
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion modules/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,6 @@ def sc_compartment2embedding(embeds_path,data_dir,output_file="tutorial_scatterp
ax.legend(handles=handles, labels=labels, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
plt.tight_layout()
plt.savefig(output_file, dpi=300)
plt.close('all')
plt.close('all')

return (vec,label,pal)
12 changes: 11 additions & 1 deletion tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,24 @@
"name": "stdout",
"output_type": "stream",
"text": [
"(4238, 5432)\n",
"(4238, 5432)\n"
]
}
],
"source": [
"from modules.analysis import sc_compartment2embedding\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"\n",
"sc_compartment2embedding('./tutorial_embeds.hdf5','/mnt/e/data/pfc/','tutorial_scatter.pdf')"
"(vec,label,pal) = sc_compartment2embedding('./tutorial_embeds.hdf5','/mnt/e/data/pfc/','tutorial_scatter.pdf')\n",
"\n",
"fig, ax = plt.subplots(figsize=(7, 5))\n",
"sns.scatterplot(x=vec[:, 0], y=vec[:, 1], hue=label, linewidth=0, s=2, alpha=1.0, palette=pal)\n",
"\n",
"handles, labels = ax.get_legend_handles_labels()\n",
"labels, handles = zip(*sorted(zip(labels, handles), key=lambda t: t[0]))\n",
"ax.legend(handles=handles, labels=labels, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)"
]
}
],
Expand Down

0 comments on commit 80e3b40

Please sign in to comment.