Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions SCCAF/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,8 @@ def SCCAF_optimize(ad,
dist_cutoff=8,
classifier="LR",
mplotlib_backend=None,
min_acc=1):
min_acc=1,
legend=False):
"""
This is a self-projection confusion matrix directed cluster optimization function.

Expand Down Expand Up @@ -767,6 +768,8 @@ def SCCAF_optimize(ad,
PdfPages).
min_acc: `float`
the minimum total accuracy to be achieved. Above this threshold, the optimization will stop.
legend: `bool` optional (default: False)
If also plot legend for the ROC curve.

return
-----
Expand All @@ -782,7 +785,7 @@ def SCCAF_optimize(ad,
raise ValueError("`adata.obsm['X_pca']` doesn't exist. Run `sc.pp.pca` first.")
X = ad.obsm['X_pca']
elif 'X_%s'%use in ad.obsm.dtype.fields:
X = ad.obsm['X_%s'%use]
X = ad.obsm['X_%s'%use]
else:
X = ad[:,ad.var['highly_variable']].X

Expand All @@ -801,7 +804,7 @@ def SCCAF_optimize(ad,
ad.obs['%s_self-projection' % old_id] = clf.predict(X)

if plot:
aucs = plot_roc(y_prob, y_test, clf, cvsm=cvsm, acc=acc, title="Self-project ROC {}".format(old_id))
aucs = plot_roc(y_prob, y_test, clf, cvsm=cvsm, acc=acc, title="Self-project ROC {}".format(old_id), legend=legend)
if mplotlib_backend:
mplotlib_backend.savefig()
plt.clf()
Expand Down Expand Up @@ -1017,7 +1020,7 @@ def plot_heatmap_gray(X, title='', save=None, mplotlib_backend=None):
plt.show()


def plot_roc(y_prob, y_test, clf, plot='both', save=None, title='', colors=None, cvsm=None, acc=None, fontsize=16):
def plot_roc(y_prob, y_test, clf, plot='both', save=None, title='', colors=None, cvsm=None, acc=None, fontsize=16, legend=False):
"""
y_prob, y_test, clf, plot=True, save=False, title ='', colors=None, cvsm=None, acc=None, fontsize=16):
"""
Expand Down Expand Up @@ -1076,7 +1079,9 @@ def plot_roc(y_prob, y_test, clf, plot='both', save=None, title='', colors=None,
ax[1].plot(Xs[i], Ys[i], c=colors[i], lw=2, label=cell_type)
ax[1].set_xlabel('Recall')
ax[1].set_ylabel('Precision')

## add legend if required
if legend == True:
ax[1].legend(bbox_to_anchor=(1.04,0.5), loc="center left")
ax[0].annotate(r'$AUC_{min}: %.3f$' % min_auc_rc, (0.5, 0.4), fontsize=fontsize)
ax[0].annotate(r'$AUC_{max}: %.3f$' % max_auc_rc, (0.5, 0.3), fontsize=fontsize)
ax[1].annotate(r'$AUC_{min}: %.3f$' % min_auc_rp, (0.5, 0.4), fontsize=fontsize)
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def readme():

setup(
name='SCCAF',
version='0.0.10',
version='0.0.11',
description='Single-Cell Clustering Assessment Framework',
long_description=readme(),
long_description_content_type='text/markdown',
Expand All @@ -20,9 +20,10 @@ def readme():
'louvain',
'scikit-learn',
'psutil',
'scanpy==1.4.6'],
'scanpy==1.9.2'],
scripts=['cli/sccaf', 'cli/sccaf-assess', 'cli/sccaf-assess-merger', 'cli/sccaf-regress-out'],
author='Chichau Miau',
author_email='zmiao@ebi.ac.uk',
license='MIT'
)
# modified by Yuyao Song <ysong@ebi.ac.uk> on Oct 2023 to bump scanpy version