rcannood / princurve

Fits a Principal Curve in Arbitrary Dimension ⤵
41 stars 6 forks source link

Index out of bound error #35

Closed hsiaoyi0504 closed 4 years ago

hsiaoyi0504 commented 4 years ago

This might be similar to #27, I use a package calling pathifier as well. In my case, I get the following error message:

skipping pathway  1  k1= 2
skipping pathway  2  k1= 2
skipping pathway  3  k1= 2
Error in project_to_curve(x = x, s = start, stretch = stretch) :
  Row index is out of bounds: [index=1; row extent=1].
Calls: lilikoi.PDSfun ... .score_pathway -> principal_curve -> project_to_curve

Would you mind helping me figure out what's the root cause of the index out of bounds? Here are the values that were feeding into the principal_curve function

>print(X)
...
[250, ]
[ reached getOption("max.print") --- omitted 677 rows]
>dim(X)
[1] 927 4
>print(start)
       PC1            PC2            PC3            PC4
[1,]  0.0008062692   -0.001178584    -0.001530541   -4.123432e-05
>print(thresh)
[1] 5e
>print(maxit)
[1] 200
rcannood commented 4 years ago

Hello @hsiaoyi0504!

start should always contain at least two rows. I changed princurve to print an error message if s contains only 1 or fewer rows. However, this doesn't solve your problem -- this issue should be moved to pathifier.

Kind regards, Robrecht