Closed quantixed closed 2 years ago
Thanks @fadelvalle - I created a new issue for this.
I confirm that I get a different but related error with this file:
Error in nls(hdata$countsCum ~ (1 - D2 * exp(-hdata$mid^2/(4 * D1 * timeRes)) - : step factor 0.000488281 reduced below 'minFactor' of 0.000976562
The problem is that jump distance fitting is done using a guess at the parameters:
if(nPop == 2) {init = list(D1 = 0.001, D2 = 0.4, D3 = 0.1)}
With the test data fittingJD(df = jdDF, mode = "ECDF", nPop = 2, breaks = 100, timeRes = jumptime, init = list(D1 = 0.0001, D2 = 0.4, D3 = 0.01))
produces a good fit. However, there is no current way to feed new parameters into the Report/Summary workflow.
The fitting step here and in jump distance needs to be improved or at least any errors should dealt with better. I will try to fix.
Also, when trying the functions individually , for example with the calculateMSD() I get the following.
calculateMSD(tmObj) Error in matrix(data = NA, nrow = tListmax, ncol = length(traceList)) : invalid 'nrow' value (too large or NA)
Also, when trying the functions individually , for example with the calculateMSD() I get the following.
calculateMSD(tmObj) Error in matrix(data = NA, nrow = tListmax, ncol = length(traceList)) : invalid 'nrow' value (too large or NA)
That is because you need to give calculateMSD()
a data frame and you are sending tmObj
which is a list of two data frames. If you do tmDF <- tmObj[[1]]
first and then calculateMSD(tmDF)
it should work.
Yes, it works that way. When I try to plot the result with plot_tm_MSD() using as input msdcalc<-calculateMSD(tmDF) it just works with the first first element : plot_tm_MSD(msdcalc[[1]]) and gives this graph:
when I try the command plot_tm_MSD(msdcalc) it gives this error:
plot_tm_MSD(msdcalc) Error in df[1:4, ] : incorrect number of dimensions
That's not a bug. But I can change it so that if a user feeds in the wrong this it's handled better.
thanks again for all this fast and very useful feedback !
@fadelvalle here is a script to make a report from a TrackMate XML file like the one you uploaded. I thought I would send you this so you can look at your data without waiting for me to fix the nls error. testScript.R.zip
Thank you so much. I will take a look into the script so I can compare data
I have fixed this problem which was caused by the initial guesses for jump distance fitting being too rigid. Now fittingJD()
takes a better guess at the initial parameters (using the average jump distance, the time resolution and binning of the distance data to make the guess). Second, if this fails, the error does not prevent the report from being made. Third, users can now fine tune the fitting either if they want to or if they get an error from the automatic guessing procedure.
https://github.com/quantixed/TrackMateR/commit/2681bd12a6f2e58fe6924e132706c88644758f6f
Thanks ! Now it works for the example dataset, but when trying this datased (attached file, xml from trackmate) I get this error when using the report command:
Error in nls(hdata$countsCum ~ (1 - D2 exp(-hdata$mid^2/(4 D1 * timeRes)) - : singular gradient
xml.zip
Originally posted by @fadelvalle in https://github.com/quantixed/TrackMateR/issues/1#issuecomment-1240649539