Esempio n. 1
0
    (idPref,idSuf) = idSamp.rsplit('_',1)
    if idPref.startswith('NCBI'):
        return taxaTree.getNode(int(idSuf))
    else:
        return None


opt,args = getProgOptions()

taxaTree = loadTaxaTreeNew()

micNodes = [ taxaTree.getNode(id) for id in micTaxids ]
phageNode = taxaTree.getNode(phageTailedTaxid)

if not os.path.isfile(opt.modDump):
    som = GHSOM(opt.inName)
    som.setModelDir('.')
    mod = som.loadModel(components=("unit","weights"))
    samp = n.concatenate([ loadSparseSeqsAsDense(inSamp) for inSamp in opt.inSamp ])
    mod.setSamples(samp)
    print "Mapping samples..."
    #mod.mapSamples(pmRadius=mod.paretoRadiusLenNormSamp)
    # Pareto radius is too large - U*-matrix is domnated by P-matrix
    mod.mapSamples(pmRadius=0.2) #0.2
    #mod.mapSamples(pmRadius=None)
    mod.makeData()
    dumpObj(mod,opt.modDump)
else:
    mod = loadObj(opt.modDump)
mod.makeUStarMatrix()
mod.makeUnit()
Esempio n. 2
0
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
#   See COPYING file distributed along with the MGTAXA package for the
#   copyright and license terms.
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##


from MGT.GHSOM import *
from MGT.Svm import *
import pdb
import pylab as pl

som = GHSOM("all")
som.setModelDir(os.path.join(options.testDataDir,"som/wd_2_0/grow"))
mod = som.loadModel(components=("unit","weights"))
mod.makeUMatrix()
data = loadSparseSeqsAsDense(inpFile=os.path.join(options.testDataDir,"som/wd_2_0/all.svm"))
mod.setSamples(data)
print "Mapping samples..."
mod.mapSamples(pmRadius=mod.paretoRadiusLenNormSamp)
#mod.mapSamples(pmRadius=0.5)
mod.makeUStarMatrix()
pl.imshow(mod.pmat.T,aspect="equal",interpolation="nearest")
pl.savefig("tmp.png")
#mod.paretoRadius()
Esempio n. 3
0

def getNCBINode(taxaTree,idSamp):
    return taxaTree.getNode(int(idSamp))


opt,args = getProgOptions()

taxaTree = loadTaxaTreeNew()

micNodes = [ taxaTree.getNode(id) for id in micTaxids ]
#phageNode = taxaTree.getNode(phageTailedTaxid)
virNode = taxaTree.getNode(virTaxid)

if not os.path.isfile(opt.modDump):
    som = GHSOM(opt.inName) #SOMCode(opt.inName)
    mod = som.loadModel()
    samp = n.concatenate([ loadSparseSeqsAsDense(inSamp) for inSamp in opt.inSamp ])
    mod.setSamples(samp)
    print "Mapping samples..."
    #mod.mapSamples(pmRadius=mod.paretoRadiusLenNormSamp)
    # Pareto radius is too large - U*-matrix is dominated by P-matrix
    mod.mapSamples(pmRadius=0.2) #0.2
    #mod.mapSamples(pmRadius=None)
    mod.makeData()
    dumpObj(mod,opt.modDump)
else:
    mod = loadObj(opt.modDump)
mod.makeUStarMatrix()
mod.makeUnit()
#umat = mod.umat