def run(profile,tndiff,tstart,tend,left=None,right=None):

        MRTp, MRTs, RFDs, Rept_time, single_mol_exp, pos_time_activated_ori, It,wRFD = get_fast_MRT_RFDs(
            nsim, profile, tndiff, kon=kon,
            fork_speed=fork_speed, dori=20*5/resolution,single_mol_exp=False,continuous=args.continuous,wholeRFD=True)
        #print("check", np.sum(d3p), np.sum(np.ones_like(d3p)*np.sum(d3p)*0.1/len(d3p)))

        #print("Start, end",tstart,tend,tndiff)
        # Compare to exp data
        """
        MRTpearson, MRTstd, MRT = compare(
            MRTp[::10//resolution], "MRT", cell, res=10, ch=ch, start=start, end=end, return_exp=True)
        RFDpearson, RFDstd, RFD = compare(RFDs, "OKSeq", cell, res=resolution, ch=ch,
                                          start=start, end=end, return_exp=True, rescale=1/resolution)

        """
        if left is not None:
            RFDs += 1.5*left
        if right is not None:
            RFDs += 1.5*right
        if cell != "Cerevisae":
            MRTpearson, MRTstd, MRT = compare(
                MRTp[::10//resolution], "MRT", cell, res=10, ch=ch, start=tstart, end=tend, return_exp=True)
            RFDpearson, RFDstd, RFD = compare(RFDs, "OKSeq", cell, res=resolution, ch=ch,
                                              start=tstart, end=tend, return_exp=True, rescale=1/resolution)
        else:
            MRTpearson, MRTstd, MRT = compare(
                MRTp, "MRT", cell, res=1, ch=ch, start=tstart, end=tend, return_exp=True)
            RFDpearson, RFDstd, RFD = compare(RFDs, "OKSeq", cell, res=1, ch=ch,
                                              start=tstart, end=tend, return_exp=True, rescale=1,nanpolate=True,smoothf=2)
            RFDs = smooth(RFDs,2)

        if args.RFDo:
            #print(RFDstd)
            return RFDstd,MRTp,MRT,RFD,RFDs,wRFD
        else:
            return MRTstd+RFDstd,MRTp,MRT,RFD,RFDs,wRFD
Esempio n. 2
0
if args.cutholes:
    #Get masks and recompute ndiffs:
    tot_diff = 0

    for i, ((start, end, ch, diff),
            (x, d3p, stallp)) in enumerate(zip(list_task, d3pl)):

        #To get masks
        MRTpearson, MRTstd, MRT, [mask_MRT,
                                  l] = compare(d3p[::mrt_res // resolution],
                                               "MRT",
                                               comp,
                                               res=mrt_res,
                                               ch=ch,
                                               start=start,
                                               end=end,
                                               return_exp=True,
                                               trunc=True,
                                               pad=True,
                                               return_mask=True,
                                               masking=masking,
                                               propagateNan=propagateNan)

        RFDpearson, RFDstd, RFD, [mask_RFD,
                                  l] = compare(d3p,
                                               expRFD,
                                               cellseq,
                                               res=resolution,
                                               ch=ch,
                                               start=start,
                                               end=end,
def run(profile, tndiff, tstart, tend, actualProfile=None):

    res = args.resolution
    if actualProfile is not None:

        tmpProfile = actualProfile.copy()
        #print(tmpProfile.shape,np.array(profile).shape,start,tstart,tend,tmpProfile[tstart-start:tend-start].shape,tstart-start,tend-start)
        weight_t = np.sum(tmpProfile[tstart - start:tend - start])
        tmpProfile[tstart - start:tend -
                   start] = weight_t * np.array(profile) / np.sum(profile)
    else:
        tmpProfile = profile
    MRTp, MRTs, RFDs, Rept_time, single_mol_exp, pos_time_activated_ori, It, wRFD = get_fast_MRT_RFDs(
        nsim,
        tmpProfile,
        tndiff,
        kon=kon,
        fork_speed=fork_speed,
        dori=20 * 5 / resolution,
        single_mol_exp=False,
        continuous=args.continuous,
        wholeRFD=True)
    #print("check", np.sum(d3p), np.sum(np.ones_like(d3p)*np.sum(d3p)*0.1/len(d3p)))

    #print("Start, end",tstart,tend,tndiff)
    # Compare to exp data
    """
        MRTpearson, MRTstd, MRT = compare(
            MRTp[::10//resolution], "MRT", cell, res=10, ch=ch, start=start, end=end, return_exp=True)
        RFDpearson, RFDstd, RFD = compare(RFDs, "OKSeq", cell, res=resolution, ch=ch,
                                          start=start, end=end, return_exp=True, rescale=1/resolution)

        """

    if cell != "Cerevisae":
        if actualProfile is not None:
            MRTpearsonl, MRTstdl, MRTl = compare(
                MRTp[int((tstart - start) / res):int((tend - start) /
                                                     res)][::10 // resolution],
                "MRT",
                cell,
                res=10,
                ch=ch,
                start=tstart,
                end=tend,
                return_exp=True)
            RFDpearsonl, RFDstdl, RFDl = compare(
                RFDs[int((tstart - start) / res):int((tend - start) / res)],
                "OKSeq",
                cell,
                res=resolution,
                ch=ch,
                start=tstart,
                end=tend,
                return_exp=True,
                rescale=1 / resolution)
        else:
            RFDstdl = 0

        MRTpearson, MRTstd, MRT = compare(MRTp[::10 // resolution],
                                          "MRT",
                                          cell,
                                          res=10,
                                          ch=ch,
                                          start=start,
                                          end=end,
                                          return_exp=True)
        RFDpearson, RFDstd, RFD = compare(RFDs,
                                          "OKSeq",
                                          cell,
                                          res=resolution,
                                          ch=ch,
                                          start=start,
                                          end=end,
                                          return_exp=True,
                                          rescale=1 / resolution)
    else:
        if actualProfile is not None:
            MRTpearsonl, MRTstdl, MRTl = compare(
                MRTp[int((tstart - start) / res):int((tend - start) / res)],
                "MRT",
                cell,
                res=1,
                ch=ch,
                start=tstart,
                end=tend,
                return_exp=True)
            RFDpearsonl, RFDstdl, RFDl = compare(
                RFDs[int((tstart - start) / res):int((tend - start) / res)],
                "OKSeq",
                cell,
                res=1,
                ch=ch,
                start=tstart,
                end=tend,
                return_exp=True,
                rescale=1,
                nanpolate=True,
                smoothf=2)
        else:
            RFDstdl = 0

        MRTpearson, MRTstd, MRT = compare(MRTp,
                                          "MRT",
                                          cell,
                                          res=1,
                                          ch=ch,
                                          start=start,
                                          end=end,
                                          return_exp=True)
        RFDpearson, RFDstd, RFD = compare(RFDs,
                                          "OKSeq",
                                          cell,
                                          res=1,
                                          ch=ch,
                                          start=start,
                                          end=end,
                                          return_exp=True,
                                          rescale=1,
                                          nanpolate=True,
                                          smoothf=2)

        RFDs = smooth(RFDs, 2)

    if args.RFDo:
        print(RFDstd, RFDstdl)
        return RFDstd + RFDstdl, MRTp, MRT, RFD, RFDs, wRFD
    else:
        return MRTstd + RFDstd, MRTp, MRT, RFD, RFDs, wRFD
                                              start=start, end=end,
                                              resolution=5, raw=False)
                    CNV[CNV == 0] = 2
                    d3p /= CNV
                d3p[np.isnan(d3p)] = 0

                print("Simu")
                sim = get_fast_MRT_RFDs(
                    nsim, d3p+np.ones_like(d3p)*np.sum(d3p)*random_activation/len(d3p), ndiff, kon=kon,
                    fork_speed=fork_speed, dori=dori)
                with open(filename, "wb") as f:
                    pickle.dump(sim, f)

            MRTp, MRTs, RFDs, Rep_Time, single_mol_exp, pos_time_activated_ori, It = sim
            # Compare to exp data
            MRTpearson, MRTstd, MRT = compare(
                MRTp[::2], "MRT", compMRT, res=10, ch=ch, start=start, end=end, return_exp=True)
            RFDpearson, RFDstd, RFD = compare(RFDs, "OKSeq", compRFD, res=5, ch=ch,
                                              start=start, end=end, return_exp=True, rescale=1/5)

            print(MRTpearson, MRTstd, RFDpearson, RFDstd)

            M.append(mark)
            D.append(ndiff)
            R.append(random_activation)
            Do.append(dori)
            P.append(p)
            SM.append(smooth)
            MRT_std.append(MRTstd)
            RFD_std.append(RFDstd)
            MRT_pearson.append(MRTpearson)
            RFD_pearson.append(RFDpearson)