cells2numbers / migrationminer

MigrationmineR is a R package to analyse and profile in vitro cell tracking and migration data. It is belongs to the cytominer-verse used for morphological profiling and allows to create temporal or dynamic profiles.
Other
5 stars 0 forks source link

added colnames for x, y and time coordinates as input to displace #13

Closed cells2numbers closed 6 years ago

cells2numbers commented 6 years ago

First function was rewritten with colnames of x, y and time coordinates as input.

Basically, the old code

  dplyr::mutate(Track_dX = Location_Center_X.x - Location_Center_X.y) %>%
  dplyr::mutate(Track_dY = Location_Center_Y.x - Location_Center_Y.y) %>%
  dplyr::select(-Location_Center_X.x, -Location_Center_Y.x) %>%
  dplyr::rename(Location_Center_X = Location_Center_X.y) %>%
  dplyr::rename(Location_Center_Y = Location_Center_Y.y) %>%
  dplyr::rename(Metadata_timePoint = Metadata_timePoint2) %>%

becomes

 dplyr::mutate(
    Track_dX =
      (!!(as.name(stringr::str_c(x_var, ".x")))) -
      (!!(as.name(stringr::str_c(x_var, ".y"))))
  ) %>%
  dplyr::mutate(
    Track_dY =
      (!!(as.name(stringr::str_c(y_var, ".x")))) -
      (!!(as.name(stringr::str_c(y_var, ".y"))))
  ) %>%
  dplyr::select(
    - (!!(as.name(stringr::str_c(x_var, ".x")))),
    - (!!(as.name(stringr::str_c(y_var, ".x"))))
  ) %>%
    #
    # when using rename with expression "=" needs to be replaced with ":=", see
    # https://github.com/tidyverse/dplyr/issues/1600
    # also see vignette("programming")
  dplyr::rename(
    !!x_var := !!stringr::str_c(x_var, ".y")
  ) %>%
  dplyr::rename(
    !!y_var := !!stringr::str_c(y_var, ".y")
  ) %>%

ToDo: look for a better solution to calculate the displacement. Better = without the need of the helper column!

Helpful sources: https://github.com/tidyverse/dplyr/issues/1600, also see vignette("programming")

codecov[bot] commented 6 years ago

Codecov Report

Merging #13 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #13   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines         144    159   +15     
=====================================
+ Hits          144    159   +15
Impacted Files Coverage Δ
R/track.R 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 7832aac...00b8c62. Read the comment docs.

cells2numbers commented 6 years ago

Missing functions that need to be updated: