Esempio n. 1
0
    scps = SpectralClusterParamSearch(geneDistancePath,dtype='distance')
    scps.run(chunks=15)

## plot the parameter search 
psFigureFile = os.path.join(homeDir,"param-scan-%s.png"%(_aspect))
if not os.path.exists(psFigureFile):
    scr = SpectralClusterResults(silvalFile,clustersFile)
    scr.plot(figName=psFigureFile)

## run spectral clustering
k = 20
sigma = 0.08

labelsPath = os.path.join(homeDir,"sc-labels-%s.csv"%(_aspect))
if not os.path.exists(labelsPath):
    sc = SpectralCluster(geneDistancePath,dtype='distance')
    sc.run(k,sk=None,sigma=sigma,verbose=True)
    sc.save(labelsPath=labelsPath)

## Save gene sets
bm = BlastMapper()
bmap = bm.load_summary('blast-parsed-summary.csv',best=False,taxaList=['8355','8364'])

transcriptMin,transcriptMax = 9,1000  
gsFile = os.path.join(homeDir,"%s.gmt"%(_aspect))                                                                                                       
if not os.path.exists(gsFile):
    gsc = GeneSetCollection(labelsPath,gene2go)
    gsc.write(blastMap=bmap,transcriptMin=transcriptMin,transcriptMax=transcriptMax,outFile=gsFile)

print("process complete.")
Esempio n. 2
0
## plot the parameter search
psFigureFile = os.path.join(gsaDir, "param-scan-%s.png" % (_aspect))
if not os.path.exists(psFigureFile):
    scr = SpectralClusterResults(silvalFile, clustersFile)
    scr.plot(figName=psFigureFile)

## run spectral clustering
k = 3
sigma = 0.43

labelsPath = os.path.join(gsaDir, "sc-labels-%s.csv" % (_aspect))

if not os.path.exists(labelsPath):
    sc = SpectralCluster(geneDistancePath, dtype='distance')
    sc.run(k, sk=None, sigma=sigma, verbose=True)
    sc.save(labelsPath=labelsPath)

import networkx
from parse_KGML import KGML2Graph
from KeggPathway import KeggPathway

p = KeggPathway()
#p.add_node('gene1', data={'type': 'gene', })
#p.get_node('gene1')
#{'type': 'gene'}

graphfile = "%s.xml" % pathway
graph = KGML2Graph(graphfile)[1]

#To get a list of the nodes, use the .nodes() method
print graph.nodes()