gseapy/gsea.py
def _save(self, outdir):
        """save es and stats"""
        # save raw ES to one csv file
        samplesRawES = pd.DataFrame(self.resultsOnSamples)
        samplesRawES.index.name = 'Term|ES'
        # normalize enrichment scores by using the entire data set, as indicated
        # by Barbie et al., 2009, online methods, pg. 2
        samplesNES = samplesRawES / (samplesRawES.values.max() - samplesRawES.values.min())
        samplesNES = samplesNES.copy()
        samplesNES.index.rename('Term|NES', inplace=True)
        self.res2d = samplesNES
        self._logger.info("Congratulations. GSEApy runs successfully................\n")
        if self._outdir is None: return
        # write es
        outESfile = os.path.join(outdir, "gseapy.samples.raw.es.txt")
        with open(outESfile, 'a') as f:
            if self.scale:
                f.write('# scale the enrichment scores by number of genes in the gene sets\n')
                f.write('# this normalization has not effects on the final NES, ' + \
                        'as indicated by Barbie et al., 2009, online methods, pg. 2\n')
            else:
                f.write('# raw enrichment scores of all data\n')
                f.write('# no scale es by numbers of genes in the gene sets\n')
            samplesRawES.to_csv(f, sep='\t')

        outNESfile = os.path.join(outdir, "gseapy.samples.normalized.es.txt")
        with open(outNESfile, 'a') as f:
            f.write('# normalize enrichment scores by using the entire data set\n')
            f.write('# as indicated by Barbie et al., 2009, online methods, pg. 2\n')
            samplesNES.to_csv(f, sep='\t')
        return
def _save(self, outdir):
        # save raw ES to one csv file
        samplesRawES = pd.DataFrame(self.resultsOnSamples)
        samplesRawES.index.name = 'Term|ES'
        # normalize enrichment scores by using the entire data set, as indicated
        # by Barbie et al., 2009, online methods, pg. 2
        samplesNES = samplesRawES / (samplesRawES.values.max() - samplesRawES.values.min())
        samplesNES = samplesNES.copy()
        samplesNES.index.rename('Term|NES', inplace=True)
        self.res2d = samplesNES
        self._logger.info("Congratulations. GSEApy runs successfully................\n")
        if self._outdir is None: return
        # write es
        outESfile = os.path.join(outdir, "gseapy.samples.raw.es.txt")
        with open(outESfile, 'a') as f:
            if self.scale:
                f.write('# scale the enrichment scores by number of genes in the gene sets\n')
                f.write('# this normalization has not effects on the final NES, ' + \
                        'as indicated by Barbie et al., 2009, online methods, pg. 2\n')
            else:
                f.write('# raw enrichment scores of all data\n')
                f.write('# no scale es by numbers of genes in the gene sets\n')
            samplesRawES.to_csv(f, sep='\t')

        outNESfile = os.path.join(outdir, "gseapy.samples.normalized.es.txt")
        with open(outNESfile, 'a') as f:
            f.write('# normalize enrichment scores by using the entire data set\n')
            f.write('# as indicated by Barbie et al., 2009, online methods, pg. 2\n')
            samplesNES.to_csv(f, sep='\t')
        return
def _save ( self , outdir ) : # save raw ES to one csv file samplesRawES = pd . DataFrame ( self . resultsOnSamples ) samplesRawES . index . name = 'Term|ES' # normalize enrichment scores by using the entire data set, as indicated # by Barbie et al., 2009, online methods, pg. 2 samplesNES = samplesRawES / ( samplesRawES . values . max ( ) - samplesRawES . values . min ( ) ) samplesNES = samplesNES . copy ( ) samplesNES . index . rename ( 'Term|NES' , inplace = True ) self . res2d = samplesNES self . _logger . info ( "Congratulations. GSEApy runs successfully................\n" ) if self . _outdir is None : return # write es outESfile = os . path . join ( outdir , "gseapy.samples.raw.es.txt" ) with open ( outESfile , 'a' ) as f : if self . scale : f . write ( '# scale the enrichment scores by number of genes in the gene sets\n' ) f . write ( '# this normalization has not effects on the final NES, ' + 'as indicated by Barbie et al., 2009, online methods, pg. 2\n' ) else : f . write ( '# raw enrichment scores of all data\n' ) f . write ( '# no scale es by numbers of genes in the gene sets\n' ) samplesRawES . to_csv ( f , sep = '\t' ) outNESfile = os . path . join ( outdir , "gseapy.samples.normalized.es.txt" ) with open ( outNESfile , 'a' ) as f : f . write ( '# normalize enrichment scores by using the entire data set\n' ) f . write ( '# as indicated by Barbie et al., 2009, online methods, pg. 2\n' ) samplesNES . to_csv ( f , sep = '\t' ) return
save es and stats
save es and stats