Commit 7708a0ca authored by fabrice's avatar fabrice
Browse files

onlyreport option

parent 8e4a6f6d
No preview for this file type
No preview for this file type
......@@ -177,6 +177,9 @@ class AriaEcCommand:
default=None, help="Do not use contact list "
"filter and select top n "
"contacts")
parser.add_argument("--onlyreport", dest="onlyreport",
action="store_true",
default=False, help="Generate only report file")
parser.add_argument("--ssidx", dest="ssidx", action="store_true",
default=False,
help="Use secondary structure index")
......
No preview for this file type
......@@ -90,7 +90,8 @@ class AriaEcContactMap(object):
outdir = self.settings.outdir
prefix = "_".join((self.outprefix, mapt, self.reftype))
if mapt == self.reftype:
if mapt == self.reftype and not \
self.settings.contactmap.args.get("onlyreport", False):
refmap.write_contacts("_".join((self.outprefix, mapt)),
outdir=outdir,
scoremap=self.refmap.get("scoremap",
......@@ -128,26 +129,30 @@ class AriaEcContactMap(object):
# TODO: only one function for output files
# Write contact list in txt file
cmpmap.write_contacts("_".join((self.outprefix, mapt)),
scoremap=scoremap,
outdir=outdir)
# Write cmp stats
cmpmap.compare_contactmap(refmap, cmplist, prefix,
distmap=self.refmap["distmap"],
human_idx=True,
outdir=outdir)
refmap.report(cmpmap, scoremap=scoremap, outprefix=prefix,
outdir=outdir, plotdir=self.settings.infra.get("graphics", outdir))
outdir=outdir,
plotag=not self.settings.contactmap.args.get(
"onlyreport"),
plotdir=self.settings.infra.get("graphics", outdir))
# Contact map comparison plot
# TODO: elementwise error with compare method
refmap.compareplot(cmpmap, outprefix=prefix,
outdir=outdir,
save_fig=self.settings.contactmap.config.get(
"save_fig"),
alpha=self.settings.contactmap.config.get(
"alpha"),
**plotparams)
# Contingency table
# print(cmpmap.to_series())
# logger.info(pd.crosstab(cmpmap.values, refmap.values,
# rownames=[mapt], colnames=[self.reftype]))
# Write cmp stats
if not self.settings.contactmap.args.get("onlyreport", False):
cmpmap.write_contacts("_".join((self.outprefix, mapt)),
scoremap=scoremap,
outdir=outdir)
cmpmap.compare_contactmap(refmap, cmplist, prefix,
distmap=self.refmap["distmap"],
human_idx=True,
outdir=outdir)
refmap.compareplot(cmpmap, outprefix=prefix,
outdir=outdir,
save_fig=self.settings.contactmap.config.get(
"save_fig"),
alpha=self.settings.contactmap.config.get(
"alpha"),
**plotparams)
# Contingency table
# print(cmpmap.to_series())
# logger.info(pd.crosstab(cmpmap.values, refmap.values,
# rownames=[mapt], colnames=[self.reftype]))
No preview for this file type
No preview for this file type
......@@ -294,7 +294,7 @@ class ProteinMap(Map):
self.saveplot(**kwargs)
def report(self, cmpmap, scoremap=None, outprefix="", outdir="", plotdir="",
plot_ext="pdf"):
plot_ext="pdf", plotag=True):
reportpath = "%s/%s.report" % (outdir, outprefix)
logger.info("Generate report file (%s)" % reportpath)
with open(reportpath, 'w') as reportf:
......@@ -320,36 +320,39 @@ class ProteinMap(Map):
allfpr, alltpr, rocthresholds = skm.roc_curve(y_true, y_scores,
pos_label=1)
roc_auc = skm.roc_auc_score(y_true, y_scores)
plotpath = os.path.join(plotdir, "%s.roc.%s" % (outprefix,
plot_ext))
plt.figure()
plt.plot(allfpr, alltpr, label='ROC curve (area = %0.2f)' % roc_auc)
plt.plot([0, 1], [0, 1], 'k--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.0])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Receiver operating characteristic %s vs. %s' % (
map1name, map2name))
plt.legend(loc="lower right")
plt.savefig(plotpath)
allprec, allrec, prthresholds = skm.precision_recall_curve(
y_true, y_scores)
aver_prec = skm.average_precision_score(y_true, y_scores)
plotpath = os.path.join(plotdir, "%s.precall.%s" % (outprefix,
if plotag:
plotpath = os.path.join(plotdir, "%s.roc.%s" % (outprefix,
plot_ext))
# Precision recall curve
plt.clf()
plt.plot(allrec, allprec, label='Precision-Recall curve')
plt.xlabel('Recall')
plt.ylabel('Precision')
plt.ylim([0.0, 1.0])
plt.xlim([0.0, 1.0])
plt.title('Precision-Recall {1} vs. {2}: AUC={0:0.2f}'.format(
aver_prec, map1name, map2name))
plt.legend(loc="lower left")
plt.savefig(plotpath)
plt.figure()
plt.plot(allfpr, alltpr, label='ROC curve (area = %0.2f)' % roc_auc)
plt.plot([0, 1], [0, 1], 'k--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.0])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Receiver operating characteristic %s vs. %s' % (
map1name, map2name))
plt.legend(loc="lower right")
plt.savefig(plotpath)
plotpath = os.path.join(plotdir, "%s.precall.%s" % (outprefix,
plot_ext))
# Precision recall curve
plt.clf()
plt.plot(allrec, allprec, label='Precision-Recall curve')
plt.xlabel('Recall')
plt.ylabel('Precision')
plt.ylim([0.0, 1.0])
plt.xlim([0.0, 1.0])
plt.title('Precision-Recall {1} vs. {2}: AUC={0:0.2f}'.format(
aver_prec, map1name, map2name))
plt.legend(loc="lower left")
plt.savefig(plotpath)
msg = """\
## Report {map1name} vs. {map2name}
......
No preview for this file type
No preview for this file type
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment