From d510e092e318a0b504a90ad72eb9b6b47dd85038 Mon Sep 17 00:00:00 2001 From: flatberg Date: Tue, 14 Aug 2007 16:16:31 +0000 Subject: [PATCH] Added SAM and conditioned enrichment analysis --- workflows/smokers.py | 128 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 109 insertions(+), 19 deletions(-) diff --git a/workflows/smokers.py b/workflows/smokers.py index 39718ba..f7694a0 100644 --- a/workflows/smokers.py +++ b/workflows/smokers.py @@ -25,11 +25,6 @@ class SmallTestWorkflow(workflow.Workflow): #load.add_function(DatasetLoadFunctionCYCLE()) self.add_stage(load) - # PREPROCESSING - # prep = workflow.Stage('prep', 'Preprocessing') - # prep.add_function(LogFunction()) - # self.add_stage(prep) - # NETWORK PREPROCESSING #net = workflow.Stage('net', 'Network integration') #net.add_function(DiffKernelFunction()) @@ -42,6 +37,7 @@ class SmallTestWorkflow(workflow.Workflow): model.add_function(blmfuncs.PCA()) model.add_function(blmfuncs.PLS()) model.add_function(blmfuncs.LPLS()) + model.add_function(SAM()) #model.add_function(bioconFuncs.SAM(app)) self.add_stage(model) @@ -60,6 +56,7 @@ class SmallTestWorkflow(workflow.Workflow): # go.add_function(gobrowser.TTestFunction()) go.add_function(gobrowser.PlotDagFunction()) go.add_function(GoEnrichment()) + go.add_function(GoEnrichmentCond()) self.add_stage(go) # EXTRA PLOTS @@ -144,8 +141,60 @@ class DatasetLoadFunctionCYCLE(workflow.Function): ##### WORKFLOW SPECIFIC FUNCTIONS ###### - +class SAM(workflow.Function): + def __init__(self, id='sam', name='SAM'): + workflow.Function.__init__(self, id, name) + def run(self, x, y): + + n_iter = 50 #B + alpha = 0.01 #cut off on qvals + + ############### + + # Main function call + + # setup prelimenaries + import rpy + rpy.r.library("siggenes") + rpy.r.library("multtest") + + cl = scipy.dot(y.asarray(), scipy.diag([1,2,3]) ).sum(1) + data = x.asarray().T + sam = rpy.r.sam(data, cl=cl, B=n_iter, var_equal=False,med=False,s0=scipy.nan,rand=scipy.nan) + qvals = scipy.asarray(rpy.r.slot(sam, "p.value")) + pvals = scipy.asarray(rpy.r.slot(sam, "q.value")) + + sam_index = (qvals