theislab / scvelo

RNA Velocity generalized through dynamical modeling
https://scvelo.org
BSD 3-Clause "New" or "Revised" License
417 stars 102 forks source link

dynamic_model dimensionality problem #1106

Closed akattapuram-insitro closed 1 year ago

akattapuram-insitro commented 1 year ago

dimensions seem to be non-conformable when scaling dm.alpha, beta, gamma, t, tau, pars

.pars[:3] is a numpy array of dimension (3,10) (in our dataset) whereas the other variables are floats. Safer to scale individually to catch edge cases such as this one.

if dm is not None and dm.recoverable:
        dm.m = m[idx]

        #dm.alpha, dm.beta, dm.gamma, dm.pars[:3] = (                                                                                                   
        #    np.array([dm.alpha, dm.beta, dm.gamma, dm.pars[:3]]) / dm.m[-1]                                                                            
        #)                                                                                                                                              

        dm.alpha=dm.alpha/dm.m[-1]
        dm.beta=dm.beta/dm.m[-1]
    dm.gamma=dm.gamma/dm.m[-1]
        dm.pars[:3]=dm.pars[:3]/dm.m[-1]

        #dm.t, dm.tau, dm.t_, dm.pars[4] = (                                                                                                            
        #    np.array([dm.t, dm.tau, dm.t_, dm.pars[4]]) * dm.m[-1]                                                                                     
    #)                                                                                                                                              
        dm.t=dm.t*dm.m[-1]
        dm.tau=dm.tau*dm.m[-1]
        dm.t_=dm.t_*dm.m[-1]
        dm.pars[4]=dm.pars[4]*dm.m[-1]

(the commented out lines are what's in scvelo, the non-commented out lines are the proposed fix)

WeilerP commented 1 year ago

Duplicate of #1087. Please check open/resolved issues and PRs before opening new ones and use the provided issue templates.