From 4919af9e60a30cd7dbb010e3b58a8a1324454fd6 Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Wed, 3 May 2023 14:47:01 +0200 Subject: [PATCH 1/5] fixes #66 --- R/PALMSpyshiny.R | 7 ++++--- R/myApp.R | 12 +++++++----- inst/NEWS.Rd | 6 +++++- man/PALMSpyshiny.Rd | 9 ++++++++- man/myApp.Rd | 6 ++++-- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/R/PALMSpyshiny.R b/R/PALMSpyshiny.R index 717c4d3..a39895b 100644 --- a/R/PALMSpyshiny.R +++ b/R/PALMSpyshiny.R @@ -2,20 +2,21 @@ #' #' @param outputdir Path to output directory #' @param gpsdir Path to GPS files +#' @param envConda character to specify path conda environment used for PALMSpy #' @param count_file_location Path to count files #' @return no object is returned, only a new file is created in the output directory #' @export -PALMSpyshiny = function(outputdir, gpsdir, count_file_location) { +PALMSpyshiny = function(outputdir, gpsdir, count_file_location, envConda = "~/miniconda3/bin/conda") { if (tolower(Sys.getenv("USERNAME")) %in% c("ucloud", "", "shiny") == FALSE) { #assuming palmspy is in a local conda environment" # assuming unbuffer is available in Ubuntu(apt install expect) - palmspypath = " /home/vincent/miniconda3/bin/conda run --no-capture-output -n palmspy " + palmspypath = paste0(envConda, " run --no-capture-output -n palmspy ") } else { #assuming palmspy is directly available from command line (ucloud) palmspypath = "" } - basecommand = paste0("cd ",outputdir, "; nohup unbuffer", palmspypath, " palmspy --gps-path ", gpsdir, + basecommand = paste0("cd ",outputdir, "; nohup unbuffer ", palmspypath, " palmspy --gps-path ", gpsdir, " --acc-path ", count_file_location, " --config-file ", paste0(outputdir, "/config.json"), " > ", outputdir, "/PALMSpy.log 2>&1 &") diff --git a/R/myApp.R b/R/myApp.R index ea5ddf4..337f8d1 100644 --- a/R/myApp.R +++ b/R/myApp.R @@ -1,6 +1,7 @@ #' myApp #' -#' @param homedir character to specify home directory +#' @param homedir character to specify path to home directory +#' @param envConda character to specify path conda environment used for PALMSpy #' @param ... No input needed, function runs the app #' @return no object is returned, just an app #' @import shiny @@ -16,7 +17,7 @@ # create temp log file -myApp <- function(homedir=getwd(), ...) { +myApp <- function(homedir=getwd(), envConda = "~/miniconda3/bin/conda", ...) { stdout_GGIR_tmp <- tempfile(fileext = ".log") stdout_palmsplusr_tmp <- tempfile(fileext = ".log") stdout_PALMSpy_tmp <- tempfile(fileext = ".log") @@ -751,13 +752,14 @@ overflow-y:scroll; max-height: 300px; background: ghostwhite;}")), # # Start PALMSpy - x_palmspy <- r_bg(func = function(PALMSpyshiny, outputdir, gpsdir, count_file_location) { - PALMSpyshiny(outputdir, gpsdir, count_file_location) + x_palmspy <- r_bg(func = function(PALMSpyshiny, outputdir, gpsdir, count_file_location, envConda) { + PALMSpyshiny(outputdir, gpsdir, count_file_location, envConda) }, args = list(PALMSpyshiny = PALMSpyshiny, outputdir = global$data_out, gpsdir = global$gps_in, - count_file_location = count_file_location), + count_file_location = count_file_location, + envConda = envConda), stdout = "", stderr = "") diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index 4740fe7..47e6e30 100755 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -1,7 +1,11 @@ \name{NEWS} \title{News for Package \pkg{HabitusGUI}} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} - +\section{Changes in version 0.1.8 (GitHub-only-release date: ??-??-2023)}{ + \itemize{ + \item Allowing package user to specify the local conda environment location needed for PALMSpy + } +} \section{Changes in version 0.1.7 (GitHub-only-release date: 01-05-2023)}{ \itemize{ \item Revised tsv file for GGIR configuration diff --git a/man/PALMSpyshiny.Rd b/man/PALMSpyshiny.Rd index 85bbc94..77d13f4 100644 --- a/man/PALMSpyshiny.Rd +++ b/man/PALMSpyshiny.Rd @@ -4,7 +4,12 @@ \alias{PALMSpyshiny} \title{PALMSpyshiny} \usage{ -PALMSpyshiny(outputdir, gpsdir, count_file_location) +PALMSpyshiny( + outputdir, + gpsdir, + count_file_location, + envConda = "~/miniconda3/bin/conda" +) } \arguments{ \item{outputdir}{Path to output directory} @@ -12,6 +17,8 @@ PALMSpyshiny(outputdir, gpsdir, count_file_location) \item{gpsdir}{Path to GPS files} \item{count_file_location}{Path to count files} + +\item{envConda}{character to specify path conda environment used for PALMSpy} } \value{ no object is returned, only a new file is created in the output directory diff --git a/man/myApp.Rd b/man/myApp.Rd index 1f4f034..19a0408 100644 --- a/man/myApp.Rd +++ b/man/myApp.Rd @@ -4,10 +4,12 @@ \alias{myApp} \title{myApp} \usage{ -myApp(homedir = getwd(), ...) +myApp(homedir = getwd(), envConda = "~/miniconda3/bin/conda", ...) } \arguments{ -\item{homedir}{character to specify home directory} +\item{homedir}{character to specify path to home directory} + +\item{envConda}{character to specify path conda environment used for PALMSpy} \item{...}{No input needed, function runs the app} } From 476abad0f284a512be2eb2aa80280fe2229a630f Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Wed, 3 May 2023 15:30:10 +0200 Subject: [PATCH 2/5] update R package dependencies installation --- UCloud_files/ucloud_HabitusGUI_installation.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/UCloud_files/ucloud_HabitusGUI_installation.sh b/UCloud_files/ucloud_HabitusGUI_installation.sh index 71d45aa..97cc47d 100644 --- a/UCloud_files/ucloud_HabitusGUI_installation.sh +++ b/UCloud_files/ucloud_HabitusGUI_installation.sh @@ -41,11 +41,16 @@ sudo apt-get update && sudo apt-get install -y \ libgdal-dev \ libudunits2-dev -R -e 'install.packages(c("shinyFiles", "shiny", "GGIR", "jsonlite", "DT", "waiter"), repos = "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", dependencies = TRUE)' -R -e 'install.packages(c("activityCounts", "remotes", "shinyjs", "dplyr", "magrittr"), repos = "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", dependencies = TRUE)' +# Shiny dependencies +R -e 'install.packages(c("shinyFiles", "shiny", "jsonlite", "DT", "waiter", "bslib"), repos = "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", dependencies = TRUE)' +# GGIR and its dependencies +R -e 'install.packages(c("GGIR", "actilifecounts", "ActCR", "GGIRread", "read.gt3x"), repos = "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", dependencies = TRUE)' +# palmsplusr dependencies +R -e 'install.packages(c("remotes", "shinyjs", "dplyr", "magrittr"), repos = "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", dependencies = TRUE)' R -e 'install.packages(c("sf", "readr", "tidyr", "stringr", "sp", "raster", "lwgeom", "tidyverse"), repos = "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", dependencies = TRUE)' -R -e 'remotes::install_github("rstudio/bslib", dependencies = TRUE)' # development version because CRAN version has bug that affects us +# palmsplusr itself R -e 'remotes::install_github("vincentvanhees/palmsplusr", dependencies = TRUE)' +# The HabitusGUI itself R -e 'remotes::install_github("habitus-eu/HabitusGUI", dependencies = TRUE)' From 0e6771eecec9beb8836f494bee7d901a61fa264d Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Thu, 4 May 2023 12:56:19 +0200 Subject: [PATCH 3/5] minor correction to make sure this branch is used during testing, once merge the HabitusGUI ref needs to be removed --- UCloud_files/ucloud_HabitusGUI_installation.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UCloud_files/ucloud_HabitusGUI_installation.sh b/UCloud_files/ucloud_HabitusGUI_installation.sh index 97cc47d..ed699ca 100644 --- a/UCloud_files/ucloud_HabitusGUI_installation.sh +++ b/UCloud_files/ucloud_HabitusGUI_installation.sh @@ -51,7 +51,7 @@ R -e 'install.packages(c("sf", "readr", "tidyr", "stringr", "sp", "raster", "lwg # palmsplusr itself R -e 'remotes::install_github("vincentvanhees/palmsplusr", dependencies = TRUE)' # The HabitusGUI itself -R -e 'remotes::install_github("habitus-eu/HabitusGUI", dependencies = TRUE)' +R -e 'remotes::install_github("habitus-eu/HabitusGUI", ref = "issue66_replace_hardcodedpath", dependencies = TRUE)' # Assuming that app.R is in the same folder as this script From 2cee0cf050674f164e635045bf1856352ae18bd4 Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Mon, 29 May 2023 13:25:12 +0200 Subject: [PATCH 4/5] change default for domains to TRUE --- .../config_palmsplusr.csv | 94 +++++++++---------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/inst/testfiles_palmsplusr/config_palmsplusr.csv b/inst/testfiles_palmsplusr/config_palmsplusr.csv index 47ce596..8783061 100755 --- a/inst/testfiles_palmsplusr/config_palmsplusr.csv +++ b/inst/testfiles_palmsplusr/config_palmsplusr.csv @@ -1,47 +1,47 @@ -"context","name","formula","domain_field","after_conversion" -"palmsplus_field","weekday","dow < 6",FALSE,NA -"palmsplus_field","weekend","dow > 5",FALSE,NA -"palmsplus_field","indoors","iov == 3",FALSE,NA -"palmsplus_field","outdoors","iov == 1",FALSE,NA -"palmsplus_field","in_vehicle","iov == 2",FALSE,NA -"palmsplus_field","inserted","fixtypecode == 6",FALSE,NA -"palmsplus_field","pedestrian","tripmot == 1",FALSE,NA -"palmsplus_field","bicycle","tripmot == 2",FALSE,NA -"palmsplus_field","vehicle","tripmot == 3",FALSE,NA -"palmsplus_field","nonwear","activityintensity < 0",TRUE,NA -"palmsplus_field","wear","activityintensity >= 0",TRUE,NA -"palmsplus_field","sedentary","activityintensity == 0",TRUE,NA -"palmsplus_field","light","activityintensity == 1",TRUE,NA -"palmsplus_field","moderate","activityintensity == 2",TRUE,NA -"palmsplus_field","vigorous","activityintensity == 3",TRUE,NA -"palmsplus_field","mvpa","moderate + vigorous",TRUE,NA -"trajectory_field","mot","first(tripmot)",NA,FALSE -"trajectory_field","date","first(as.Date(datetime))",NA,FALSE -"trajectory_field","start","datetime[triptype==1]",NA,FALSE -"trajectory_field","end","datetime[triptype==4]",NA,FALSE -"trajectory_field","duration","as.numeric(difftime(end, start, units = ""secs"") + 30)",NA,FALSE -"trajectory_field","nonwear","sum(activityintensity < 0) * 15",NA,FALSE -"trajectory_field","wear","sum(activityintensity >= 0) * 15",NA,FALSE -"trajectory_field","sedentary","sum(activityintensity == 1) * 15",NA,FALSE -"trajectory_field","light","sum(activityintensity == 1) * 15",NA,FALSE -"trajectory_field","moderate","sum(activityintensity == 2) * 15",NA,FALSE -"trajectory_field","vigorous","sum(activityintensity == 3) * 15",NA,FALSE -"trajectory_field","mvpa","moderate + vigorous",NA,FALSE -"trajectory_field","length","as.numeric(st_length(geometry))",NA,TRUE -"trajectory_field","speed","(length / duration) * 3.6",NA,TRUE -"multimodal_field","duration","sum",NA,NA -"multimodal_field","nonwear","sum",NA,NA -"multimodal_field","wear","sum",NA,NA -"multimodal_field","sedentary","sum",NA,NA -"multimodal_field","light","sum",NA,NA -"multimodal_field","moderate","sum",NA,NA -"multimodal_field","vigorous","sum",NA,NA -"multimodal_field","mvpa","sum",NA,NA -"multimodal_field","length","sum",NA,NA -"multimodal_field","speed","mean",NA,NA -"palmsplus_domain","home","at_home",FALSE,NA -"palmsplus_domain","school","(!at_home & at_school)",FALSE,NA -"palmsplus_domain","transport","!at_home & !(at_school) & (pedestrian | bicycle | vehicle)",FALSE,NA -"palmsplus_domain","home_nbh","!at_home & !(at_school) & (!pedestrian & !bicycle & !vehicle) & at_home_nbh",FALSE,NA -"palmsplus_domain","school_nbh","!at_home & !(at_school) & (!pedestrian & !bicycle & !vehicle) & !(at_home_nbh) & at_school_nbh",FALSE,NA -"palmsplus_domain","other","!at_home & !(at_school) & (!pedestrian & !bicycle & !vehicle) & !(at_home_nbh) & !(at_school_nbh)",FALSE,NA +context,name,formula,domain_field,after_conversion +palmsplus_field,weekday,dow < 6,FALSE,NA +palmsplus_field,weekend,dow > 5,FALSE,NA +palmsplus_field,indoors,iov == 3,FALSE,NA +palmsplus_field,outdoors,iov == 1,FALSE,NA +palmsplus_field,in_vehicle,iov == 2,FALSE,NA +palmsplus_field,inserted,fixtypecode == 6,FALSE,NA +palmsplus_field,pedestrian,tripmot == 1,FALSE,NA +palmsplus_field,bicycle,tripmot == 2,FALSE,NA +palmsplus_field,vehicle,tripmot == 3,FALSE,NA +palmsplus_field,nonwear,activityintensity < 0,TRUE,NA +palmsplus_field,wear,activityintensity >= 0,TRUE,NA +palmsplus_field,sedentary,activityintensity == 0,TRUE,NA +palmsplus_field,light,activityintensity == 1,TRUE,NA +palmsplus_field,moderate,activityintensity == 2,TRUE,NA +palmsplus_field,vigorous,activityintensity == 3,TRUE,NA +palmsplus_field,mvpa,moderate + vigorous,TRUE,NA +trajectory_field,mot,first(tripmot),NA,FALSE +trajectory_field,date,first(as.Date(datetime)),NA,FALSE +trajectory_field,start,datetime[triptype==1],NA,FALSE +trajectory_field,end,datetime[triptype==4],NA,FALSE +trajectory_field,duration,"as.numeric(difftime(end, start, units = ""secs"") + 30)",NA,FALSE +trajectory_field,nonwear,sum(activityintensity < 0) * 15,NA,FALSE +trajectory_field,wear,sum(activityintensity >= 0) * 15,NA,FALSE +trajectory_field,sedentary,sum(activityintensity == 1) * 15,NA,FALSE +trajectory_field,light,sum(activityintensity == 1) * 15,NA,FALSE +trajectory_field,moderate,sum(activityintensity == 2) * 15,NA,FALSE +trajectory_field,vigorous,sum(activityintensity == 3) * 15,NA,FALSE +trajectory_field,mvpa,moderate + vigorous,NA,FALSE +trajectory_field,length,as.numeric(st_length(geometry)),NA,TRUE +trajectory_field,speed,(length / duration) * 3.6,NA,TRUE +multimodal_field,duration,sum,NA,NA +multimodal_field,nonwear,sum,NA,NA +multimodal_field,wear,sum,NA,NA +multimodal_field,sedentary,sum,NA,NA +multimodal_field,light,sum,NA,NA +multimodal_field,moderate,sum,NA,NA +multimodal_field,vigorous,sum,NA,NA +multimodal_field,mvpa,sum,NA,NA +multimodal_field,length,sum,NA,NA +multimodal_field,speed,mean,NA,NA +palmsplus_domain,home,at_home,TRUE,NA +palmsplus_domain,school,(!at_home & at_school),TRUE,NA +palmsplus_domain,transport,!at_home & !(at_school) & (pedestrian | bicycle | vehicle),TRUE,NA +palmsplus_domain,home_nbh,!at_home & !(at_school) & (!pedestrian & !bicycle & !vehicle) & at_home_nbh,TRUE,NA +palmsplus_domain,school_nbh,!at_home & !(at_school) & (!pedestrian & !bicycle & !vehicle) & !(at_home_nbh) & at_school_nbh,TRUE,NA +palmsplus_domain,other,!at_home & !(at_school) & (!pedestrian & !bicycle & !vehicle) & !(at_home_nbh) & !(at_school_nbh),TRUE,NA From c0322ac44eefc2a0fe1cdfd8ab70c9d7932c7b1e Mon Sep 17 00:00:00 2001 From: Vincent van Hees Date: Fri, 30 Jun 2023 21:33:43 +0200 Subject: [PATCH 5/5] prepare for new 0.1.8 release --- DESCRIPTION | 4 ++-- inst/NEWS.Rd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2a1b5c5..98934a2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: HabitusGUI Title: R Shiny App for Processing Behavioural Data Description: Shiny app to ease processing behavioural data with research software such as GGIR, activityCounts, PALMSpy,and palmsplusr. -Version: 0.1.6 -Date: 2022-03-15 +Version: 0.1.8 +Date: 2022-06-30 Authors@R: c(person(given = "Vincent", family = "van Hees", diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index 18d57a2..98bd5a8 100755 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -1,9 +1,10 @@ \name{NEWS} \title{News for Package \pkg{HabitusGUI}} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} -\section{Changes in version 0.1.8 (GitHub-only-release date: ??-??-2023)}{ +\section{Changes in version 0.1.8 (GitHub-only-release date: 30-06-2023)}{ \itemize{ \item Allowing package user to specify the local conda environment location needed for PALMSpy + \item Shiny state is saved and used if available when refreshing the app. } } \section{Changes in version 0.1.7 (GitHub-only-release date: 01-05-2023)}{ @@ -12,7 +13,6 @@ \item Testfile for config GGIR updated \item Now able to handle acc.metric in GGIR \item HabitusGUI and use-case GGIR can now run again in Windows, this was broken ince 0.1.5 release - \item Shiny state is saved and used if available when refreshing the app. } } \section{Changes in version 0.1.6 (GitHub-only-release date: 15-03-2023)}{