MultiK icon indicating copy to clipboard operation
MultiK copied to clipboard

Function findOptK cannot find optimal K if there are slope = 0 in tog

Open JerryZhang-1222 opened this issue 5 months ago • 0 comments

Error in if (lineseg.df.sub[lineseg.df.sub$p1 == which.k2 | lineseg.df.sub$p2 ==  : 
  argument is of length zero

I was running DiagMultiKPlot and ran into the error as described in the title.

Please change the following code in MultiK_Helper.R, line 223 from

# step 2: see if a line segment with negative slope coming out
  if ( all(lineseg.df[lineseg.df$p1==which.k | lineseg.df$p2==which.k, ]$slope > 0) ) {
    optK <- which.k
  }
  else {

to

# step 2: see if a line segment with negative slope coming out
  if ( all(lineseg.df[lineseg.df$p1==which.k | lineseg.df$p2==which.k, ]$slope >= 0) ) {
    optK <- which.k
  }
  else {

I think this will fix the issue. But without detailed annotation of the script, it's hard to understand what is the correct way to actually solve the issue.

Best, Feiyang.

JerryZhang-1222 avatar Sep 02 '24 11:09 JerryZhang-1222