Exemple #1
0
 def geomModel(sim,
               cellCenter=lm.point(*micron(2.0, 2.0, 2.0)),
               nucleusRadius=micron(0.4),
               cellRadius=micron(2.0)):
     # Add locations
     cytoplasm = lm.Sphere(cellCenter, cellRadius,
                           sim.siteTypes["Cytoplasm"])
     nucleus = lm.Sphere(cellCenter, nucleusRadius,
                         sim.siteTypes["Nucleus"])
     sim.addShape(cytoplasm)
     sim.addShape(nucleus)
Exemple #2
0
def geometryModel(sim,
                  cellCenter=lm.point(*micron(9, 9, 9)),
                  cellRadius=micron(8.9),
                  membraneThickness=micron(0.128),
                  nuclSize=micron(4.15),
                  speckleRadius=micron(0.35),
                  cajalRadius=micron(0.5),
                  poreRadius=micron(0.083),
                  n_cajals=4,
                  n_speckles=20,
                  n_NPCs=1515,
                  n_mito=2000,
                  n_ribo=750,
                  fb=0.9,
                  fd=0.8,
                  steps=11,
                  lsize=288,
                  buildER=True,
                  limits=[lambda x: x <= 65.0**2, lambda x: x > 139.0**2]):

    # Create cell components
    CellWall = lm.Sphere(cellCenter, cellRadius, sim.siteTypes['CellWall'])
    Cytoplasm = lm.Sphere(cellCenter, cellRadius - membraneThickness,
                          sim.siteTypes['Cytoplasm'])
    NucEnv = lm.Sphere(cellCenter, nuclSize, sim.siteTypes['NucEnv'])
    Nucleus = lm.Sphere(cellCenter, nuclSize - membraneThickness,
                        sim.siteTypes['Nucleus'])
    CellWall.thisown = 0
    Cytoplasm.thisown = 0
    NucEnv.thisown = 0
    Nucleus.thisown = 0

    ###### Cajal body: "n_cajal" with radius "cajalRadius" #############################
    dist = []
    listdist = []
    Cajalpre = []
    accepted = []
    np_accepted = []
    cc = 1
    point = 0
    while cc < n_cajals + 1:
        x, y, z = np.random.uniform(-0.5, 0.5, 3)
        Rp = nuclSize - cajalRadius - micron(0.1)
        xpp = x * Rp + cellCenter.x
        ypp = y * Rp + cellCenter.y
        zpp = z * Rp + cellCenter.z
        caj = [xpp, ypp, zpp]
        listdist = []
        point += 1
        if (point == 1):
            accepted.append(caj)
            np_accepted = np.array(accepted)
        for i in range(0, cc):
            dist = np.sqrt(np.sum((np.array(caj) - np_accepted[i])**2))
            listdist.append(dist)
        np_dist = np.array(listdist)
        if (np.all(np_dist > 2 * cajalRadius + micron(0.05))):
            accepted.append(caj)
            np_accepted = np.array(accepted)
            listdist = []
            cc += 1
    NCajal = np.array(accepted)

    cc = []
    Cajal = lm.UnionSet(sim.siteTypes['Cajal'])
    Cajal.thisown = 0
    for k in range(0, n_cajals):
        w = lm.Sphere(lm.point(NCajal[k][0], NCajal[k][1], NCajal[k][2]),
                      cajalRadius, sim.siteTypes['Cajal'])
        w.thisown = 0
        cc.append(w)
        Cajal.addShape(w)
    print("Cajal done!")

    ################ Nuclear Speckles: "n_speckles" with radius "speckleRadius" ##########################
    counter = 0
    taken = 0
    listdist = []
    np_acceptspeck = []
    acceptspeck = []
    while counter < n_speckles + 1:
        u = np.random.uniform(-1, 1)
        thet = np.random.uniform(0, 2.0 * math.pi)
        rad = np.random.uniform(speckleRadius * 1e6,
                                nuclSize * 1e6 - (speckleRadius * 1e6 + 0.1))
        xm = micron(rad * math.sqrt(1 - u**2) * np.cos(thet)) + cellCenter.x
        ym = micron(rad * math.sqrt(1 - u**2) * np.sin(thet)) + cellCenter.y
        zm = micron(rad * u) + cellCenter.z
        point = [xm, ym, zm]
        listdist = []
        dist = 0
        np_dist = []
        taken += 1
        if (taken == 1):
            acceptspeck.append(point)
            np_acceptspeck = np.array(acceptspeck)
        for i in range(0, counter):
            dist = np.sqrt(np.sum((point - np_acceptspeck[i])**2))
            listdist.append(dist)
        np_dist = np.array(listdist)
        tt = 0
        if (np.all(np_dist > 2 * speckleRadius + micron(0.1))):
            for k in range(0, n_cajals):
                if (np.sqrt(np.sum((np.array(point) - NCajal[k])**2)) >
                        speckleRadius + cajalRadius + micron(0.1)):
                    tt += 1
            if (tt == 4):
                acceptspeck.append(point)
                np_acceptspeck = np.array(acceptspeck)
                counter += 1
                listdist = []
    NSpeck = np.array(acceptspeck)

    collection = []
    j = 0
    Speckle = lm.UnionSet(sim.siteTypes['Speckle'])
    Speckle.thisown = 0
    for k in range(0, n_speckles):
        q = lm.Sphere(
            lm.point(NSpeck[k][j], NSpeck[k][j + 1], NSpeck[k][j + 2]),
            speckleRadius, sim.siteTypes['Speckle'])
        q.thisown = 0
        collection.append(q)
        Speckle.addShape(q)
    print("Speckles done!")

    ################# NPC #########################
    NPCpre = []
    taken = 0

    ldist = []
    npcdist = 0
    np_npcdist = []
    acceptnpc = []
    npc = 0

    while npc < n_NPCs + 1:
        x, y, z = np.random.uniform(-0.5, 0.5, 3)
        r = math.sqrt(x**2 + y**2 + z**2)
        Rp = (nuclSize - sim.latticeSpacing) / r
        xpp = x * Rp + cellCenter.x
        ypp = y * Rp + cellCenter.y
        zpp = z * Rp + cellCenter.z
        pores = [xpp, ypp, zpp]
        NPCpre.append(pores)
        ldist = []
        np_npcdist = []
        taken += 1
        if (taken == 1):
            acceptnpc.append(pores)
            np_acceptnpc = np.array(acceptnpc)
        for i in range(0, npc):
            npcdist = np.sqrt(np.sum((np.array(pores) - np_acceptnpc[i])**2))
            ldist.append(npcdist)
        np_npcdist = np.array(ldist)
        if (np.all(np_npcdist > 0.2e-6)):
            acceptnpc.append(pores)
            np_acceptnpc = np.array(acceptnpc)
            ldist = []
            npc += 1

    NP = np.array(NPCpre)

    collect = []
    j = 0
    NPC = lm.UnionSet(sim.siteTypes['NPC'])
    NPC.thisown = 0
    for k in range(0, n_NPCs):
        s = lm.Sphere(lm.point(NP[k][j], NP[k][j + 1], NP[k][j + 2]),
                      poreRadius, sim.siteTypes['NPC'])
        s.thisown = 0
        collect.append(s)
        NPC.addShape(s)

    print("NPCs done!")

    ####################### Golgi Apparatus  #################################################
    m1 = lm.Sphere(lm.point(*micron(15, 15, 15)), micron(3.5),
                   sim.siteTypes['Golgi'])
    m11 = lm.Sphere(lm.point(*micron(15, 15, 15)), micron(3.308),
                    sim.siteTypes['Golgi'])
    m12 = lm.Sphere(lm.point(*micron(15, 15, 15)), micron(3.116),
                    sim.siteTypes['Golgi'])
    m13 = lm.Sphere(lm.point(*micron(15, 15, 15)), micron(2.924),
                    sim.siteTypes['Golgi'])
    m14 = lm.Sphere(lm.point(*micron(15, 15, 15)), micron(2.732),
                    sim.siteTypes['Golgi'])

    m2 = lm.Cone(cellCenter, micron(2), micron(6.5), sim.siteTypes['Golgi'],
                 lm.vector(1.0, 1.0, 1.0))
    m22 = lm.Cone(cellCenter, micron(2.5), micron(8), sim.siteTypes['Golgi'],
                  lm.vector(1.0, 1.0, 1.0))
    m23 = lm.Cone(cellCenter, micron(3), micron(9.5), sim.siteTypes['Golgi'],
                  lm.vector(1.0, 1.0, 1.0))
    m24 = lm.Cone(cellCenter, micron(3.5), micron(10.5),
                  sim.siteTypes['Golgi'], lm.vector(1.0, 1.0, 1.0))

    Gol1 = lm.Difference(m1, m11, sim.siteTypes['Golgi'])
    Gol2 = lm.Difference(m11, m12, sim.siteTypes['Golgi'])
    Gol3 = lm.Difference(m12, m13, sim.siteTypes['Golgi'])
    Gol4 = lm.Difference(m13, m14, sim.siteTypes['Golgi'])

    G1 = lm.Intersection(Gol1, m2, sim.siteTypes['Golgi'])
    G2 = lm.Intersection(Gol2, m22, sim.siteTypes['Golgi'])
    G3 = lm.Intersection(Gol3, m23, sim.siteTypes['Golgi'])
    G4 = lm.Intersection(Gol4, m24, sim.siteTypes['Golgi'])

    G11 = lm.Union(G1, G2, sim.siteTypes['Golgi'])
    G22 = lm.Union(G3, G4, sim.siteTypes['Golgi'])
    Golgi = lm.Union(G11, G22, sim.siteTypes['Golgi'])
    Golgi.thisown = 0
    print("Golgi done!")

    ######################## Mitochondria ###############################3
    mit = []
    pp1 = []
    pp2 = []
    Mito = lm.UnionSet(sim.siteTypes['Mito'])
    Mito.thisown = 0
    for i in range(1, n_mito + 1):
        u = np.random.uniform(-1, 1)
        thet = np.random.uniform(0, 2.0 * math.pi)
        rad = np.random.uniform(4.706, 8.5)
        xm = micron(rad * math.sqrt(1 - u**2) * np.cos(thet)) + micron(9)
        ym = micron(rad * math.sqrt(1 - u**2) * np.sin(thet)) + micron(9)
        zm = micron(rad * u) + micron(9)
        centers = [xm, ym, zm]
        if i < 666:
            point1 = [xm - micron(0.125), ym - micron(0.125), zm]
            point2 = [xm + micron(0.125), ym + micron(0.125), zm]
        elif i >= 666 and i < 1332:
            point1 = [xm, ym - micron(0.125), zm - micron(0.125)]
            point2 = [xm, ym + micron(0.125), zm + micron(0.125)]
        elif i >= 1332:
            point1 = [xm - micron(0.125), ym, zm - micron(0.125)]
            point2 = [xm + micron(0.125), ym, zm + micron(0.125)]

        pp1.append(point1)
        pp2.append(point2)
    mp1 = np.array(pp1)
    mp2 = np.array(pp2)

    for h in range(0, n_mito):
        m = lm.Capsule(lm.point(mp1[h][0], mp1[h][1], mp1[h][2]),
                       lm.point(mp2[h][0], mp2[h][1], mp2[h][2]),
                       micron(0.249), sim.siteTypes['Mito'])
        m.thisown = 0
        mit.append(m)
        Mito.addShape(m)
    print("Mito done!")

    # Add all geometries to the simulation
    sim.lm_builder.addRegion(CellWall)
    sim.lm_builder.addRegion(Cytoplasm)
    sim.lm_builder.addRegion(NucEnv)
    sim.lm_builder.addRegion(Nucleus)
    sim.lm_builder.addRegion(NPC)
    sim.lm_builder.addRegion(Cajal)
    sim.lm_builder.addRegion(Speckle)
    sim.lm_builder.addRegion(Mito)
    sim.lm_builder.addRegion(Golgi)

    ######################### ER #########################################
    print("Building ER")

    if buildER:
        deathLimitFxn = lambda s: int(fd * 27 *
                                      (steps - 0.25 * s)**2 / steps**2)
        birthNumberFxn = lambda s: int(fb * 27)
        im = createERCellularAutomaton(lsize,
                                       dimensions=3,
                                       survivalRate=0.85,
                                       deathLimitFxn=deathLimitFxn,
                                       birthNumberFxn=birthNumberFxn,
                                       steps=steps,
                                       limits=limits)

        # Save the grid to a 3D lattice as a numpy array; this can be loaded with np.load()
        np.save("ER.npy", np.array(im, dtype="float"))
        print("Done building ER")

    print("Loading ER")
    ER = np.load("ER.npy")
    print("Discretizing")
    lattice = sim.getLattice()
    print("Setting ER")
    for x in range(ER.shape[0]):
        for y in range(ER.shape[1]):
            for z in range(ER.shape[2]):
                idx = (x, y, z)
                if ER[x, y, z]:
                    sim.setLatticeSite(idx, "ER")

    print("ER Done")

    ######################### Ribosomes #########################################
    # Add 750 ribosomes to the cell's cytoplasm randomly
    if n_ribo > 0:
        added = 0
        for x, y, z in np.random(5 * n_ribo * 3).reshape(
            (5 * n_ribo, 3)) * cellRadius:
            if Cytoplasm.intersects(lm.Sphere(lm.Point(x, y, z)), nm(32),
                                    sim.siteTypes['Cytoplasm']):
                sim.setLatticeSite((x, y, z), 'Ribosome')
                added += 1

            if added >= n_ribo:
                break
Exemple #3
0
def geometryModel(sim,
                  cellCenter = lm.point(*micron(2.755,2.755,2.755)),
                  cellRadius1 = micron(2.625), # Long dimension of ellipsoid for cell
                  cellRadius2 = micron(1.75), # Short dimension of ellipsoid for cell
                  membraneThickness= nm(28.7), # As determined from the Earnest et al. manuscript
                  nuclSize1 = micron(1.09), # Long dimension of ellipsoid for nucleus
                  nuclSize2 = micron(0.911), # Short dimension of ellipsoid for nucleus
                  speckleRadius=micron(0.05), # Size reduced for smaller nuclear volume
                  cajalRadius=micron(0.07), # Size reduced for smaller nuclear volume
                  poreRadius=micron(0.040), # As determined in Earnest et al.
                  n_cajals=4,
                  n_speckles=20,
                  n_NPCs=139, # As determined in Earnest et al.
                  n_mito=95, # Scaled by ratio of yeast:HeLa cell volume
    ):

    ##########################
    # Create cell components #
    ##########################
    # Create an ellipsoid aligned along the X-axis with an
    #  aspect ratio of 1.5 as determined in the Earnest et al. manuscript
    CellWall  = lm.Ellipse(cellCenter, cellRadius1, cellRadius2, cellRadius2, sim.siteTypes['CellWall'])
    Cytoplasm = lm.Ellipse(cellCenter, cellRadius1-membraneThickness, cellRadius2-membraneThickness, cellRadius2-membraneThickness, sim.siteTypes['Cytoplasm'])

    # Create an ellipsoid aligned along the X-axis with an
    #  aspect ratio of 1.2 as determined in the Earnest et al. manuscript
    NucEnv    = lm.Ellipsoid(cellCenter, nuclSize1, nuclSize2, nuclSize2 sim.siteTypes['NucEnv'])
    Nucleus   = lm.Ellipsoide(cellCenter, nuclSize1-membraneThickness, nuclSize2-membraneThickness, nuclSize2-membraneThickness, sim.siteTypes['Nucleus'])


    # The following code snippets are required to prevent python from 
    #  garbage collecting the objects when the function exits, allowing
    #  lattice microbes to refer to them later when building the cell
    CellWall.thisown = 0
    Cytoplasm.thisown = 0
    NucEnv.thisown = 0
    Nucleus.thisown = 0

    ###### Cajal body: "n_cajal" with radius "cajalRadius" #############################
    dist = [] ; listdist = []
    Cajalpre = []
    accepted = []
    np_accepted = []
    cc = 1 ; point = 0
    while cc < n_cajals + 1:
        x,y,z = np.random.uniform(-0.5,0.5,3)
        Rp = nuclSize2 - cajalRadius - micron(0.1)  
        # Account for elliposoidal nature of nucleus in X-axis
        xpp = 1.2*x*Rp + cellCenter.x
        ypp = y*Rp + cellCenter.y  
        zpp = z*Rp + cellCenter.z 
        caj = [xpp,ypp,zpp]
        listdist = []
        point += 1
        if (point == 1 ):
            accepted.append(caj)
            np_accepted = np.array(accepted)
        for i in range (0, cc):
            dist =  np.sqrt(np.sum((np.array(caj)-np_accepted[i])**2))
            listdist.append(dist) 
        np_dist = np.array(listdist)
        if(np.all(np_dist > 2*cajalRadius + micron(0.05))):
            accepted.append(caj)
            np_accepted = np.array(accepted)
            listdist = []
            cc += 1
    NCajal = np.array(accepted)

    cc = [] 
    Cajal = lm.UnionSet(sim.siteTypes['Cajal'])
    Cajal.thisown = 0
    for k in range(0, n_cajals):
        w = lm.Sphere(lm.point(NCajal[k][0],
                               NCajal[k][1],
                               NCajal[k][2]),
                      cajalRadius,
                      sim.siteTypes['Cajal'])
        w.thisown=0
        cc.append(w)
        Cajal.addShape(w)
    print("Cajal done!")

    ################ Nuclear Speckles: "n_speckles" with radius "speckleRadius" ##########################
    counter = 0
    taken = 0 
    listdist = [] ; np_acceptspeck = [] ; acceptspeck = [] 
    while counter < n_speckles + 1:
        u = np.random.uniform(-1, 1)
        thet = np.random.uniform(0, 2.0*math.pi)
        rad = np.random.uniform(speckleRadius*1e6 , nuclSize2*1e6 - (speckleRadius*1e6 + 0.1))
        # Account for elliposoidal nature of nucleus
        xm = 1.2*micron(rad*math.sqrt(1-u**2)*np.cos(thet)) + cellCenter.x
        ym = micron(rad*math.sqrt(1-u**2)*np.sin(thet)) + cellCenter.y
        zm = micron(rad*u) + cellCenter.z
        point = [xm, ym, zm]
        listdist = [] ; dist = 0 ; np_dist = []
        taken += 1
        if ( taken == 1 ):
            acceptspeck.append(point)
            np_acceptspeck = np.array(acceptspeck)
        for i in range (0, counter):
            dist =  np.sqrt(np.sum((point-np_acceptspeck[i])**2))
            listdist.append(dist)
        np_dist = np.array(listdist)
        tt = 0
        if(np.all(np_dist > 2*speckleRadius + micron(0.1))):
            for k in range (0, n_cajals):
                if (np.sqrt(np.sum((np.array(point)-NCajal[k])**2)) > speckleRadius + cajalRadius + micron(0.1)):
                    tt += 1
            if (tt == 4):
                acceptspeck.append(point)
                np_acceptspeck = np.array(acceptspeck)
                counter += 1
                listdist = []
    NSpeck = np.array(acceptspeck)

    collection = []
    j = 0
    Speckle = lm.UnionSet(sim.siteTypes['Speckle'])
    Speckle.thisown = 0
    for k in range(0, n_speckles):
        q = lm.Sphere(lm.point(NSpeck[k][j],
                               NSpeck[k][j+1],
                               NSpeck[k][j+2]),
                      speckleRadius,
                      sim.siteTypes['Speckle'])
        q.thisown=0
        collection.append(q)
        Speckle.addShape(q)
    print("Speckles done!")

    ################# NPC #########################
    NPCpre = []
    taken = 0

    ldist = [] ; npcdist = 0 ; np_npcdist = []
    acceptnpc = []
    npc = 0

    while npc < n_NPCs + 1:   
        x,y,z = np.random.uniform(-0.5,0.5,3)
        r = math.sqrt(x**2 + y**2 + z**2) 
        # Account for elliposoidal nature of nucleus
        Rp = (nuclSize2 - sim.latticeSpacing)/r
        xpp = 1.2*x*Rp + cellCenter.x
        ypp = y*Rp + cellCenter.y
        zpp = z*Rp + cellCenter.z
        pores = [xpp,ypp,zpp]
        NPCpre.append(pores)
        ldist = [] ; np_npcdist = []
        taken += 1
        if (taken == 1 ):
            acceptnpc.append(pores)
            np_acceptnpc = np.array(acceptnpc)
        for i in range (0, npc):
            npcdist =  np.sqrt(np.sum((np.array(pores)-np_acceptnpc[i])**2))
            ldist.append(npcdist)
        np_npcdist = np.array(ldist)
        if(np.all(np_npcdist > 0.2e-6)):
            acceptnpc.append(pores)
            np_acceptnpc = np.array(acceptnpc)
            ldist = []
            npc += 1

    NP = np.array(NPCpre)

    collect = []
    j = 0
    NPC = lm.UnionSet(sim.siteTypes['NPC'])
    NPC.thisown = 0
    for k in range(0, n_NPCs):
        s = lm.Sphere(lm.point(NP[k][j],
                               NP[k][j+1],
                               NP[k][j+2]),
                      poreRadius,
                      sim.siteTypes['NPC'])
        s.thisown=0
        collect.append(s)
        NPC.addShape(s)

    print("NPCs done!")

    ####################### Golgi Apparatus  #################################################
    # Skip golgi apparatus as done in Earnest et al.

    ######################## Mitochondria ###############################3
    mit = []
    pp1 = []
    pp2 = []
    Mito = lm.UnionSet(sim.siteTypes['Mito'])
    Mito.thisown=0
    for i in range(1, n_mito+1):
        u = np.random.uniform(-1, 1)
        thet = np.random.uniform(0, 2.0*math.pi)
        rad = np.random.uniform(0.5, 2.5) # Modified for smaller cell
        xm = 1.5*micron(rad*math.sqrt(1-u**2)*np.cos(thet)) + micron(9) 
        ym = micron(rad*math.sqrt(1-u**2)*np.sin(thet)) + micron(9) 
        zm = micron(rad*u) + micron(9)
        centers = [xm, ym, zm]
        if i < 666 :
            point1 = [xm - micron(0.125), ym-micron(0.125) , zm]
            point2 = [xm + micron(0.125), ym+micron(0.125) , zm]
        elif  i >= 666 and i < 1332 :
            point1 = [xm, ym - micron(0.125), zm- micron(0.125)]
            point2 = [xm, ym + micron(0.125), zm+ micron(0.125)]
        elif  i >= 1332 :
            point1 = [xm - micron(0.125), ym , zm - micron(0.125)]
            point2 = [xm + micron(0.125), ym , zm + micron(0.125)]
            
        pp1.append(point1)
        pp2.append(point2)
    mp1 = np.array(pp1)
    mp2 = np.array(pp2)

    for h in range(0, n_mito):
        m = lm.Capsule(lm.point(mp1[h][0], mp1[h][1], mp1[h][2]),
                       lm.point(mp2[h][0], mp2[h][1], mp2[h][2]),
                       micron(0.249),
                       sim.siteTypes['Mito'])
        m.thisown = 0
        mit.append(m)
        Mito.addShape(m)
    print("Mito done!")



    # Add all geometries to the simulation
    sim.lm_builder.addRegion(CellWall)
    sim.lm_builder.addRegion(Cytoplasm)
    sim.lm_builder.addRegion(NucEnv)
    sim.lm_builder.addRegion(Nucleus)
    sim.lm_builder.addRegion(NPC)
    sim.lm_builder.addRegion(Cajal)
    #sim.lm_builder.addRegion(Cajal) # Removed
    sim.lm_builder.addRegion(Speckle)
    sim.lm_builder.addRegion(Mito)