Giter VIP home page Giter VIP logo

trajr's Issues

Error when trying TrajsMergeStats

Hello.
I have been trying to run TrajsMergeStats on multiple .csv files and I have been getting this error:

Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  : 
  arguments imply differing number of rows: 1, 0

I tried tracing back the error and this is what I got:

8: stop(gettextf("arguments imply differing number of rows: %s", 
       paste(unique(nrows), collapse = ", ")), domain = NA)
7: (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, 
       fix.empty.names = TRUE, stringsAsFactors = FALSE) 
   {
       data.row.names <- if (check.rows && is.null(row.names)) 
           function(current, new, i) {
               if (is.character(current)) 
                   new <- as.character(new)
               if (is.character(new)) 
                   current <- as.character(current)
               if (anyDuplicated(new)) 
                   return(current)
               if (is.null(current)) 
                   return(new)
               if (all(current == new) || all(current == "")) 
                   return(new)
               stop(gettextf("mismatch of row names in arguments of 'data.frame', item %d", 
                   i), domain = NA)
           }
       else function(current, new, i) {
           if (is.null(current)) {
    ...
6: do.call(data.frame, c(x, alis))
5: as.data.frame.list(row, stringsAsFactors = FALSE, check.names = check.names)
4: as.data.frame(row, stringsAsFactors = FALSE, check.names = check.names)
3: tryCatchList(expr, classes, parentenv, handlers)
2: tryCatch({
       result <- data.frame()
       nc <- NA
       for (trj in trjs) {
           pb()
           row <- statsFn(trj, ...)
           row[sapply(row, is.null)] <- NA
           if (is.na(nc)) 
               nc <- length(row)
           else if (nc != length(row)) 
               stop(sprintf("Statistics for trajectory %d contains %d values, but expected %d", 
                   nrow(result), length(row), nc))
           dfrow <- as.data.frame(row, stringsAsFactors = FALSE, 
               check.names = check.names)
           result <- rbind(result, dfrow)
       }
       result
   }, finally = pb(close = TRUE))
1: TrajsMergeStats(CSHL_trjs_raw, masterTrajectory, progressBar = "win")

Any idea what the issue is? my csv files have the same number of columns and I even tried making them the same number of rows and still got the same error.

Issue with TrajFromCoords

Hi There,

I'm having issues applying TrajFromCoords to a list of dataframes.

This is probably an easy fix, but I've tried all the dumb things to fix and am still coming up empty. I have a list called nosetracks, which is the x,y coordinates for nose position of a mouse on a table. It consists of 178 elements, each element is a dataframe named for the mouseID_trialnumber_date. All the dataframes have the same structure: 3 columns, "x", "y", and "nose.frame", in that order. "x" and "y" are the coordinates of the nose in the arena and "nose.frame" is the video frame (50 fps).

I am using the following code to apply the function to my list of dataframes.
nosetracks <- lapply(nosetracks, TrajFromCoords)

When I try to apply the function TrajFromCoords over the list, I get the error:
Error in .checkCoords(trj) :
Trajectory contains missing coordinate or time values, first row with NA is 409

I have tried to troubleshoot this as much as I can:

  1. I have checked through the dataframes in the list, looking for rows where either x or y has a missing value. As far as I can tell, there are no missing values in any of my columns (have tried to look using multiple approaches, but admit it is possible that my approaches are not doing what I think they are doing).
  2. I have pulled out random dataframes from the list as their own dataframe and applied the function with no problem, so it is not the structure of the dataframes itself.
  3. I have successfully run the above code using lapply on a different list with the same structure (but different trajectory dataframes) with no problem.

So I guess my question is - what am I doing wrong? Is a missing value actually the problem, or is something else not getting called correctly? Suggestions for how to diagnose the problematic dataframe (given that the list contains over 100 elements, going through them indvidually isn't really very appealing).

Thanks in advance!

TrajsBuild *doesn't* have the option of not smoothing trajectories

The function is described as: Reads multiple trajectories from files, performs some basic sanity checks on them, and optionally smooths and scales them. Attempts to collect and report errors for multiple trajectories in a single call.
However, although smoothP = 3, smoothN = 41, are changeable smoothing parameters, you can't actually set these to zero or give TrajsBuild() the command to NOT apply smoothing.

3D

Would be very useful!

csvReadFn doesn't work with functions like readr::read_csv()

Internally, csvReadFn is automatically called with the "stringsAsFactors = FALSE" as an argument, an argument which isn't universal to CSV-reading functions: it only works with utils::read.csv() and utils::read.csv2().
With the tidyverse "readr" package, read_csv() doesn't have "stringsAsFactors" as an accepted argument, so when the internal coordList <- csvReadFn(fileName, stringsAsFactors = FALSE) runs, I get an error. I had to make a wrapper function for read_csv() that accepted the "stringsAsFactors" argument and never used it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.