farrellja / URD

URD - Reconstruction of Branching Developmental Trajectories
GNU General Public License v3.0
117 stars 41 forks source link

pseudotimeWeightTransitionMatrix & simulateRandomWalksFromTips #5

Closed lushjia closed 6 years ago

lushjia commented 6 years ago

Hi, farrellja,

I got the problem that after running pseudotimeWeightTransitionMatrix to get the axial.biased.tm (using my own data) and then running simulateRandomWalksFromTips and use axial.biased.tm as transiting matrix parameter, it will make the error like, Error in transition.matrix["current.cell", ] : subscript out of bounds

I think this error is produced because after running pseudotimeWeightTransitionMatrix, it deletes some cells which do not have pseudotime.vec, but they are still included in tip.cells when running simulateRandomWalksFromTips.

Are there some other reasons which would cause error like this, or how to solve this problem without deleting them from tip.cells.

Thank you very much.

farrellja commented 6 years ago

Hi lushjia,

You are probably correct about the reason for that error. I will introduce some checking routine for that in a future update.

Indeed, if a cell has NA pseudotime, then it will be removed when you bias the transition matrix. (The biased probabilities are based on the difference in cells' pseudotimes, so if a cell doesn't have a pseudotime, its transitions cannot be biased.) The solution is, indeed, to remove any cells with NA pseudotime from your tip definitions.

In general, a cell with NA pseudotime is poorly connected to the rest of your data -- it means that by default fewer than 40% of the pseudotime simulations actually reached that cell before there were iterations that visited no new cells. So, generally it wouldn't be great to use them as starting points for your random walk anyway. Usually, there will only be a few cells that have NA pseudotime. If you have many cells (or large blocks of cells) with NA pseudotime, it may indicate that the parameters for your diffusion map are not appropriate (for instance, too small sigma will create huge disconnections in the data).