def gsea_compute(data, gmt, n, weighted_score_type, permutation_type,<EOL>method, pheno_pos, pheno_neg, classes, ascending,<EOL>processes=<NUM_LIT:1>, seed=None, single=False, scale=False):
w = weighted_score_type<EOL>subsets = sorted(gmt.keys())<EOL>es = []<EOL>RES=[]<EOL>hit_ind=[]<EOL>esnull = [ [] for a in range(len(subsets)) ]<EOL>logging.debug("<STR_LIT>")<EOL>if permutation_type == "<STR_LIT>":<EOL><INDENT>logging.debug("<STR_LIT>")<EOL>rs = np.random.RandomState(seed)<EOL>genes_mat, cor_mat = ranking_metric_tensor(exprs=data, method=method,<EOL>permutation_num=n,<EOL>pos=pheno_pos, neg=pheno_neg,<EOL>classes=classes,<EOL>ascending=ascending, rs=rs)<EOL>logging.debug("<STR_LIT>")<EOL>es, esnull, hit_ind, RES = enrichment_score_tensor(gene_mat=genes_mat,<EOL>cor_mat=cor_mat,<EOL>gene_sets=gmt,<EOL>weighted_score_type=w,<EOL>nperm=n, rs=rs,<EOL>single=False, scale=False,)<EOL><DEDENT>else:<EOL><INDENT>gl, cor_vec = data.index.values, data.values<EOL>logging.debug("<STR_LIT>")<EOL>temp_esnu=[]<EOL>pool_esnu = Pool(processes=processes)<EOL>for subset in subsets:<EOL><INDENT>rs = np.random.RandomState(seed)<EOL>temp_esnu.append(pool_esnu.apply_async(enrichment_score,<EOL>args=(gl, cor_vec, gmt.get(subset), w,<EOL>n, rs, single, scale)))<EOL><DEDENT>pool_esnu.close()<EOL>pool_esnu.join()<EOL>for si, temp in enumerate(temp_esnu):<EOL><INDENT>e, enu, hit, rune = temp.get()<EOL>esnull[si] = enu<EOL>es.append(e)<EOL>RES.append(rune)<EOL>hit_ind.append(hit)<EOL><DEDENT><DEDENT>return gsea_significance(es, esnull), hit_ind, RES, subsets<EOL>
compute enrichment scores and enrichment nulls.

        :param data: preprocessed expression dataframe or a pre-ranked file if prerank=True.
        :param dict gmt: all gene sets in .gmt file. need to call load_gmt() to get results.
        :param int n: permutation number. default: 1000.
        :param str method: ranking_metric method. see above.
        :param str pheno_pos: one of labels of phenotype's names.
        :param str pheno_neg: one of labels of phenotype's names.
        :param list classes: a list of phenotype labels, to specify which column of dataframe belongs to what category of phenotype.
        :param float weighted_score_type: default:1
        :param bool ascending: sorting order of rankings. Default: False.
        :param seed: random seed. Default: np.random.RandomState()
        :param bool scale: if true, scale es by gene number.

        :return: a tuple contains::

                | zipped results of es, nes, pval, fdr.
                | nested list of hit indices of input gene_list.
                | nested list of ranked enrichment score of each input gene_sets.
                | list of enriched terms