예제 #1
0
spfilter = d3bf.loadfilters("emap_filters.txt",
                            form.getvalue("spfilter", "none"))
level = form.getvalue("level")
fmethod = form.getvalue("fmethod", "PCA")
color = form.getvalue("color", "none")
shape = form.getvalue("shape", "none")
labels = form.getvalue("labels", "none")
resolution = form.getvalue("resolution", "low")

ilevel = int(level)
(data, volumes, mn, ml) = d3bf.loaddata("emap.txt")
(tags, tkeys) = d3bf.loadtags("emap_tags.txt", volumes)
(kdict, kdnames, kgnames, knorder,
 kdata) = d3bf.loadtaxonomy(data, ml, spfilter, ilevel)
(findex, mtags) = d3bf.processtags_m(volumes, tags, dfilter)
(edata, site_ids, species_ids) = d3bf.load_edata_m(data, ilevel, mn, ml, kdict,
                                                   volumes, findex, kdnames)

aedata = np.array(edata, dtype=float)
aenorm = np.sum(aedata, axis=1)
aedata /= aenorm.reshape(len(edata), 1)

rev = 0
if fmethod == "PCA (sklearn)":  #or fmethod == "MDS (sklearn)":
    rev = 1

cdata = d3bf.calc_distances(edata, aedata, dmethod, kdata, knorder, rev)

adist = np.array(cdata)
amax = np.amax(adist)
adist /= amax
alabels = ["", ""]
예제 #2
0
(tags, tkeys) = d3bf.loadtags("emap_tags.txt", volumes)
ilevel = int(level)
(kdict, kdnames, kgnames, knorder,
 kdata) = d3bf.loadtaxonomy(data, ml, spfilter, ilevel)
valhighlight = 0. if numhighlight == "all" else 0.01 * float(numhighlight[:-1])

if dgroup != "none":
    (findex, gtags) = d3bf.processtags(volumes, tags, dfilter, dgroup)
    edata = d3bf.load_edata(data, ilevel, ml, kdict, findex, gtags)
    stags = gtags
    site_ids = sorted(list(gtags.keys()), key=lambda k: gtags[k])
else:
    (findex, mtags) = d3bf.processtags_m(volumes, tags, dfilter)
    if datatype != "raw":
        (edata, site_ids,
         species_ids) = d3bf.load_edata_m(data, ilevel, mn, ml, kdict, volumes,
                                          findex, kdnames)
    else:
        (edata, site_ids,
         species_ids) = d3bf.load_edata_m_fp(data, ilevel, mn, ml, kdict,
                                             volumes, findex, kdnames)
    stags = {}
    for j in range(len(edata)):
        key = ""
        if order1 != "none":
            key = key + mtags[order1][j]
        if order2 != "none":
            key = key + mtags[order2][j]
        if labels != "none":
            key = key + mtags[labels][j]
        key = key + mtags["name"][j]
        stags[key] = j