Skip to content

farrelllab/daniocell_desktop

Repository files navigation

DaniocellDesktop logo

DaniocellDesktop

Running portable R Shiny with Electron is based on https://github.com/COVAIL/electron-quick-start. This application uses electron-packager for packaging.

Learn how an Electron app works with Electron Quick Start Guide.

Install Node

Node.js (which comes with npm)

Install dependencies with npm

# Go to the application directory
cd daniocell_shiny_electron
# Install dependent packages
npm install

Set up R Portable

Mac

# Example from parent directory
cd ..
# Download R Portable
wget https://github.com/selkamand/r-portable-mac/archive/refs/tags/R-4.2.3-patch2.tar.gz
tar -xzf ./R-4.2.3-patch2.tar.gz
mv ./r-portable-mac-R-4.2.3-patch2 ./daniocell_shiny_electron/R-Portable-Mac
rm R-4.2.3-patch2.tar.gz
# Download Presto
wget https://github.com/immunogenomics/presto/archive/refs/heads/master.zip
unzip ./master.zip

Windows

# Example from parent directory
cd ..
# Download R Portable
curl https://github.com/selkamand/r-portable-windows/releases/download/R-4.2.3/r-portable-windows-R-4.2.3.zip -o R-4.2.3.zip
Expand-Archive .\R-4.2.3.zip -destination .\daniocell_shiny_electron\
Move-Item -Path .\r-portable-windows-R-4.2.3 -Destination .\daniocell_shiny_electron\R-Portable-Win
# Download Presto
curl https://github.com/immunogenomics/presto/archive/refs/heads/master.zip -o presto-master.zip
Expand-Archive .\presto-master.zip -destination .

Install R Packages

Start R from within the R-Portable-* directory unzipped.

# For Windows, use R-Portable-Win
cd daniocell_shiny_electron/R-Portable-Mac
# Start R from R portable script
./bin/R

Install R packages within R Portable

install.packages(c("shiny", "shinyWidgets", "shinyjs", "shinyhttr", "DT", "bslib", "bsicons", "dplyr", "reshape2", "ggplot2", "scales", "gridExtra", "colorspace", "httr", "Matrix", "bigsparser", "data.table", "tidyr", "purrr", "RcppArmadillo", "ggrepel", "svglite", "shinyFiles"), repos = "http://cran.us.r-project.org", type = "binary", dependencies = c("Depends", "Imports"))
install.packages("../../presto-master", repos=NULL, type = "source")
install.packages(c("ggplot2", "bslib"), repos = "http://cran.us.r-project.org", type = "source", dependencies = c("Depends", "Imports"))

Note for arm64-based Macs

If using an arm64-based Mac (i.e., Apple silicon, M1, etc.), if arm64 compilers are listed in a ~/.R/Makevars file, they may cause an "incompatible architecture" error to occur when building presto.

  1. Run your R portable, check the value of R_PLATFORM with Sys.getenv("R_PLATFORM"), copy the value.
  2. Create an empty file to override Makevars for that platform, e.g. touch ~/.R/Makevars-x86_64-apple-darwin17.0.
  3. Go back to R and rebuild presto: install.packages("../../presto-master", repos=NULL, type = "source", INSTALL_opts = "--preclean").

Mac

cd daniocell_shiny_electron
npm run start-mac

Windows

cd daniocell_shiny_electron
npm run start-windows

Build and Package DaniocellDesktop

To build an executable, use npm run , followed by the package command for the OS and architecture.

  • package-mac64
  • package-macintel
  • package-win32
  • package-win64
  • package-winarm
  • package-linux

Example for macOS with amd/intel architecture:

cd daniocell_shiny_electron
npm run package-macintel

This will place the packaged application as a subdirectory of daniocell_shiny_electron/packages with the naming convention DaniocellDesktop-<platform>-<arch>.

Sign and Notarize for Mac

Signing the package

  • Make sure to include the necessary entitlements (i.e. what your signed code is supposed to be allowed to do)
  • Get the SHA-1 Fingerprint for your Developer Certificate:
    • Right click on the certificate in Keychain, pick Get Info, scroll to bottom, copy the 40-character SHA-1 fingerprint, delete all spaces.
export DEBUG=electron-osx-sign*
npx electron-osx-sign DaniocellDesktopMacArm64/DaniocellDesktop-darwin-arm64/DaniocellDesktop.app --identity=[Certificate SHA-1 Fingerprint]

Notarizing the package

Cannot submit the .app bundle directly. Make a zip file. (Must use ditto, regular zip does not respect some permissions.)

/usr/bin/ditto -c -k --keepParent DaniocellDesktop.app DaniocellDesktop-Mac-AppleSilicon.zip

Submit for notarization using Apple's XCode command-line tools

xcrun notarytool submit DaniocellDesktop-Mac-AppleSilicon.zip --force --verbose --apple-id [your AppleID] --password [App-specific Password] --team-id [Your Team ID (In parentheses behind your name in your signing certificate)]

Check notarization progress

xcrun notarytool info [Submission ID] --apple-id [your appleID ] --password [app-specific password] --team-id [Team ID]
xcrun notarytool log [Submission ID] --apple-id [your appleID ] --password [app-specific password] --team-id [Team ID] DaniocellDesktop-notarization-log.json

Check notarization issues

https://developer.apple.com/documentation/security/resolving-common-notarization-issues

Then staple certificate directly to the .app bundle and re-zip for distribution

xcrun stapler staple "DaniocellDesktop.app"
/usr/bin/ditto -c -k --keepParent DaniocellDesktop.app DaniocellDesktop-Mac-AppleSilicon-Dist.zip

About

R shiny + electron Mac/Win app for local re-analysis of Daniocell data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors