コード例 #1
0
ファイル: Matri-seqFinal.py プロジェクト: steffen12/scRutiNy
def formCellTypeTree(n, cells, cellTypeParents, cellTypeNumCells, cellTypeConstProps, transcriptionFactors, cellTypeMeans):
	cellTypeTree = Tree()

	parentCellType = -1
	projInit = np.ones(shape=n)
	constInit = np.zeros(shape=n)
	cellTypeMember = []
	cellTypeChildMember = list(range(cells))
	cellTypeMean = 0
	numCellTypes = len(cellTypeParents)

	projMatrix = np.zeros(shape = (numCellTypes, n))
	constMatrix = np.zeros(shape = (numCellTypes, n))

	headNode = cellTypeTree.add_head(parentCellType, cellTypeMember, constInit, projInit, cellTypeMean)
	headNode.setChildCellTypeMembers(cellTypeChildMember)

	numCellTypes = len(cellTypeParents)
	cellTypeMembers = [[] for i in range(numCellTypes)]

	cellNumPool = range(cells)
	for cellType in range(numCellTypes):
		numCells = cellTypeNumCells[cellType]
		cellTypeIndices = random.sample(cellNumPool, numCells)
		cellTypeMembers[cellType] = cellTypeIndices
		cellNumPool = list(set(cellNumPool) - set(cellTypeIndices))

	addTreeChildren(n, cellTypeTree, cellTypeParents, cellTypeMembers, cellTypeConstProps, projInit, constInit, projMatrix, constMatrix, cellTypeMeans, parentCellType, transcriptionFactors)
	
	#maxCellType = int(max(cellTypeParents)) #Highest cell type number corresponds to the highest cell type
	for node in cellTypeTree.traverse(-1):
		for field in node:
			print(field)

	return cellTypeTree, projMatrix, constMatrix
コード例 #2
0
ファイル: MatriSeq.py プロジェクト: steffen12/scRutiNy
def formCellTypeTree(n, cells, cellTypeParents, cellTypeNumCells,
                     cellTypeConstProps, transcriptionFactors, cellTypeMeans):
    """
    Parameters
    ----------
    n : int
        number of genes
    cells : int
        number of cells
    cellTypeParents :
        the value of index `i` is the parent of cell type `i`
    cellTypeNumCells :
        the value of index `i` is the number of cells of type `i` to end up with
    cellTypeConstProps :
        proportion of transcription factors to set constant indexed by cell type
    transcriptionFactors :
        list of genes with positive outdegree

    Returns
    -------
	cellTypeTree :
        a tree representation of cell development
    projMatrix :
        collection of 0/1 projection vectors, one for each cell type
    constMatrix :
        collection of constant vectors, one for each cell type
    """

    cellTypeTree = Tree()

    parentCellType = -1
    projInit = np.ones(shape=n)
    constInit = np.zeros(shape=n)
    cellTypeMember = []
    cellTypeChildMember = list(range(cells))
    cellTypeMean = 0
    numCellTypes = len(cellTypeParents)

    projMatrix = np.zeros(shape=(numCellTypes, n))
    constMatrix = np.zeros(shape=(numCellTypes, n))

    headNode = cellTypeTree.add_head(parentCellType, cellTypeMember, constInit,
                                     projInit, cellTypeMean)
    headNode.setChildCellTypeMembers(cellTypeChildMember)

    numCellTypes = len(cellTypeParents)
    cellTypeMembers = [[] for i in range(numCellTypes)]

    cellNumPool = range(cells)
    for cellType in range(numCellTypes):
        numCells = cellTypeNumCells[cellType]
        cellTypeIndices = random.sample(cellNumPool, numCells)
        cellTypeMembers[cellType] = cellTypeIndices
        cellNumPool = list(set(cellNumPool) - set(cellTypeIndices))

    addTreeChildren(n, cellTypeTree, cellTypeParents, cellTypeMembers,
                    cellTypeConstProps, projInit, constInit, projMatrix,
                    constMatrix, cellTypeMeans, parentCellType,
                    transcriptionFactors)

    #maxCellType = int(max(cellTypeParents)) #Highest cell type number corresponds to the highest cell type
    # for node in cellTypeTree.traverse(-1):
    #     for field in node:
    #         print(field)

    return cellTypeTree, projMatrix, constMatrix