DistanceToSelectionFunction
This commit is contained in:
parent
3f5d45d7af
commit
75c7c51708
|
@ -297,6 +297,42 @@ class GOWeightDialog(gtk.Dialog):
|
||||||
options['rank_threshold'] = self._rank_spin.get_value()
|
options['rank_threshold'] = self._rank_spin.get_value()
|
||||||
|
|
||||||
|
|
||||||
|
class DistanceToSelectionFunction(workflow.Function):
|
||||||
|
def __init__(self):
|
||||||
|
workflow.Function.__init__(self, 'dist-to-sel', 'Dist. to Selection')
|
||||||
|
self.options = DistanceToSelectionOptions()
|
||||||
|
|
||||||
|
def run(self, similarities, selection):
|
||||||
|
self.show_gui(similarities, self.options)
|
||||||
|
|
||||||
|
retval = []
|
||||||
|
|
||||||
|
dims = similarities.get_dim_name()
|
||||||
|
if dims[0] != "_%s" %dims[1] and dims[1] != "_%s" %dims[0]:
|
||||||
|
logger.log('warning', 'Are you sure this is a similarity matrix?')
|
||||||
|
|
||||||
|
dim = dims[0]
|
||||||
|
print "dim", dim
|
||||||
|
|
||||||
|
print "selection", selection[dim]
|
||||||
|
print "indices", similarities.get_indices(dim, selection[dim])
|
||||||
|
indices = similarities.get_indices(dim, selection[dim])
|
||||||
|
m = apply_along_axis(max, 1, similarities.asarray().take(indices, 1))
|
||||||
|
retval.append(dataset.Dataset(m, [(dim, similarities[dim]),
|
||||||
|
("_dummy", '0')]))
|
||||||
|
|
||||||
|
return retval
|
||||||
|
|
||||||
|
def show_gui(self, similarities, options, edit=True):
|
||||||
|
dialog = DistanceToSelectionOptionsDialog([similarities], self.options)
|
||||||
|
response = dialog.run()
|
||||||
|
dialog.hide()
|
||||||
|
if response == gtk.RESPONSE_OK:
|
||||||
|
dialog.set_output()
|
||||||
|
return dialog.get_options()
|
||||||
|
else:
|
||||||
|
return options
|
||||||
|
|
||||||
class GOWeightFunction(workflow.Function):
|
class GOWeightFunction(workflow.Function):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
workflow.Function.__init__(self, 'load-go-ann', 'GO Influence')
|
workflow.Function.__init__(self, 'load-go-ann', 'GO Influence')
|
||||||
|
@ -334,6 +370,11 @@ class GOWeightFunction(workflow.Function):
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
|
||||||
|
class DistanceToSelectionOptionsDialog(workflow.OptionsDialog):
|
||||||
|
def __init__(self, data, options):
|
||||||
|
workflow.OptionsDialog.__init__(self, data, options, ['X'])
|
||||||
|
|
||||||
|
|
||||||
class TTestOptionsDialog(workflow.OptionsDialog):
|
class TTestOptionsDialog(workflow.OptionsDialog):
|
||||||
|
|
||||||
def __init__(self, data, options):
|
def __init__(self, data, options):
|
||||||
|
@ -373,13 +414,13 @@ class TTestFunction(workflow.Function):
|
||||||
|
|
||||||
print "Out data:", self.options['out_data']
|
print "Out data:", self.options['out_data']
|
||||||
tds = dataset.Dataset(tscores[0], [('gene_id', x['gene_id']),
|
tds = dataset.Dataset(tscores[0], [('gene_id', x['gene_id']),
|
||||||
('t', ['0'])],
|
('_t', ['0'])],
|
||||||
name='t-values')
|
name='t-values')
|
||||||
if 't-value' in self.options['out_data']:
|
if 't-value' in self.options['out_data']:
|
||||||
retval.append(tds)
|
retval.append(tds)
|
||||||
|
|
||||||
pds = dataset.Dataset(tscores[1], [('gene_id', x['gene_id']),
|
pds = dataset.Dataset(tscores[1], [('gene_id', x['gene_id']),
|
||||||
('p', ['0'])],
|
('_p', ['0'])],
|
||||||
name='p-values')
|
name='p-values')
|
||||||
if 'p-value' in self.options['out_data']:
|
if 'p-value' in self.options['out_data']:
|
||||||
retval.append(pds)
|
retval.append(pds)
|
||||||
|
@ -387,6 +428,14 @@ class TTestFunction(workflow.Function):
|
||||||
if ProbabilityHistogramPlot in self.options['out_plots']:
|
if ProbabilityHistogramPlot in self.options['out_plots']:
|
||||||
retval.append(ProbabilityHistogramPlot(pds))
|
retval.append(ProbabilityHistogramPlot(pds))
|
||||||
|
|
||||||
|
if VolcanoPlot in self.options['out_plots']:
|
||||||
|
fc = apply_along_axis(mean, 0, ns) / apply_along_axis(mean, 0, cs)
|
||||||
|
fcds = dataset.Dataset(fc, [('gene_id', x['gene_id']),
|
||||||
|
('_dummy', ['0'])],
|
||||||
|
name="Fold change")
|
||||||
|
|
||||||
|
retval.append(VolcanoPlot(fcds, pds, 'gene_id'))
|
||||||
|
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
def show_gui(self, x, categories):
|
def show_gui(self, x, categories):
|
||||||
|
@ -404,13 +453,20 @@ class TTestOptions(workflow.Options):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
workflow.Options.__init__(self)
|
workflow.Options.__init__(self)
|
||||||
self['all_plots'] = [(ProbabilityHistogramPlot, 'Histogram', True)]
|
self['all_plots'] = [(ProbabilityHistogramPlot, 'Histogram', True),
|
||||||
|
(VolcanoPlot, 'Histogram', True)]
|
||||||
self['all_data'] = [('t-value', 't-values', True),
|
self['all_data'] = [('t-value', 't-values', True),
|
||||||
('p-value', 'Probabilities', True),
|
('p-value', 'Probabilities', True),
|
||||||
('categories', 'Categories', False)]
|
('categories', 'Categories', False)]
|
||||||
self['out_data'] = ['t-value', 'p-value']
|
self['out_data'] = ['t-value', 'p-value']
|
||||||
|
|
||||||
|
|
||||||
|
class DistanceToSelectionOptions(workflow.Options):
|
||||||
|
def __init__(self):
|
||||||
|
workflow.Options.__init__(self)
|
||||||
|
self['all_data'] = [('mindist', 'Minimum distance', True)]
|
||||||
|
|
||||||
|
|
||||||
class GOWeightOptions(workflow.Options):
|
class GOWeightOptions(workflow.Options):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
workflow.Options.__init__(self)
|
workflow.Options.__init__(self)
|
||||||
|
@ -420,6 +476,13 @@ class GOWeightOptions(workflow.Options):
|
||||||
|
|
||||||
class ProbabilityHistogramPlot(plots.HistogramPlot):
|
class ProbabilityHistogramPlot(plots.HistogramPlot):
|
||||||
def __init__(self, ds):
|
def __init__(self, ds):
|
||||||
plots.HistogramPlot.__init__(self, ds, name="Confidence")
|
plots.HistogramPlot.__init__(self, ds, name="Confidence", bins=50)
|
||||||
|
|
||||||
|
|
||||||
|
class VolcanoPlot(plots.ScatterPlot):
|
||||||
|
def __init__(self, fold_ds, p_ds, dim, **kw):
|
||||||
|
plots.ScatterPlot.__init__(self, fold_ds, p_ds, 'gene_id', '_dummy',
|
||||||
|
'0', '0',
|
||||||
|
name="Volcano plot",
|
||||||
|
sel_dim_2='_p', **kw)
|
||||||
|
|
||||||
|
|
Reference in New Issue