Exemplo n.º 1
0
def make_cluster_column(ATelement,Elementclusters):
	cluster = []
	for i in ATelement.T.index:
		included=False
		for j in Elementclusters.keys():
			if i in Elementclusters[j]:
				cluster.append(j)
				included=True
		if not included:
			cluster.append(None)
	return cluster
Exemplo n.º 2
0
def clusters_at(tree, sampled, cutpoint):
    """ returns a list of lists of clusters occuring after cutpoint """
    branches = branches_sampled(tree, sampled)
    branches = list(branches)
    branches.sort(key=lambda x: x.i_time)
    clusters = []

    for branch in branches:
        if branch.i_time > cutpoint:
            children = all_children_of(tree, branch)
            if branch in sampled:
                children.append(branch)
            cluster = []
            for child in children:
                if child in sampled:
                    cluster.append(child)
                    sampled.remove(child)
            clusters.append(cluster)

    return clusters
Exemplo n.º 3
0
def clusters_at(tree, sampled, cutpoint):
	""" returns a list of lists of clusters occuring after cutpoint """
	branches = branches_sampled(tree, sampled)
	branches = list(branches)
	branches.sort(key=lambda x: x.i_time)
	clusters = []
	
	for branch in branches:
		if branch.i_time > cutpoint:
			children = all_children_of(tree, branch)
			if branch in sampled:
				children.append(branch)
			cluster = []
			for child in children:
				if child in sampled:
					cluster.append(child)
					sampled.remove(child)
			clusters.append(cluster)
	
	return clusters
Exemplo n.º 4
0
def brown_clusters(tree, sampled, s_time):
    """ returns a list of lists of clusters in tree
		according to the standard in Brown et al. """
    cbound = s_time - 12
    clusterlist = []
    clustered = []

    bpoints = branches_sampled(tree, sampled)

    for bp in sorted(bpoints, key=lambda x: x.i_time):

        if bp.i_time >= cbound:
            cluster = []
            childs = all_children_of(tree, bp)
            print childs
            for cbp in childs:
                if cbp in sampled and cbp not in clustered:
                    cluster.append(cbp)
                    clustered.append(cbp)
            clusterlist.append(cluster)

    print len(clustered), clustered
    return clusterlist
Exemplo n.º 5
0
def brown_clusters(tree, sampled, s_time):
	""" returns a list of lists of clusters in tree
		according to the standard in Brown et al. """
	cbound = s_time - 12
	clusterlist = []
	clustered = []
	
	bpoints = branches_sampled(tree, sampled)
	
	for bp in sorted(bpoints, key=lambda x: x.i_time):

		if bp.i_time >= cbound:
			cluster = []
			childs = all_children_of(tree, bp)
			print childs
			for cbp in childs:
				if cbp in sampled and cbp not in clustered:
					cluster.append(cbp)
					clustered.append(cbp)
			clusterlist.append(cluster)
				
	print len(clustered), clustered
	return clusterlist						
Exemplo n.º 6
0
def get_cluster(id, labels):
    cluster = []
    for i in range(len(labels)):
        if labels[i] == id:
            cluster.append(i)
    return cluster