{"id":23045580,"url":"https://github.com/fgcz/bfabricshiny","last_synced_at":"2025-08-14T23:32:15.162Z","repository":{"id":50114085,"uuid":"66529760","full_name":"fgcz/bfabricShiny","owner":"fgcz","description":"Manage life sciences data using R and b-fabric - a WSDL/REST interface and a tool box; main focus on MS data","archived":false,"fork":false,"pushed_at":"2024-09-03T09:04:50.000Z","size":1386,"stargazers_count":8,"open_issues_count":11,"forks_count":1,"subscribers_count":8,"default_branch":"bfabric12","last_synced_at":"2024-09-29T00:10:44.706Z","etag":null,"topics":["bfabric","experiments","mass-spectrometry","omics","shiny","wsdl"],"latest_commit_sha":null,"homepage":"http://fgcz-bfabric.uzh.ch","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fgcz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-25T06:05:27.000Z","updated_at":"2024-09-03T09:04:54.000Z","dependencies_parsed_at":"2024-07-15T17:47:22.817Z","dependency_job_id":"537b7f5b-ac5c-4e0f-bea8-ee977238c325","html_url":"https://github.com/fgcz/bfabricShiny","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgcz%2FbfabricShiny","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgcz%2FbfabricShiny/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgcz%2FbfabricShiny/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgcz%2FbfabricShiny/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fgcz","download_url":"https://codeload.github.com/fgcz/bfabricShiny/tar.gz/refs/heads/bfabric12","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229877184,"owners_count":18138124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bfabric","experiments","mass-spectrometry","omics","shiny","wsdl"],"created_at":"2024-12-15T21:27:07.332Z","updated_at":"2024-12-15T21:27:07.952Z","avatar_url":"https://github.com/fgcz.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n[![JIB](https://img.shields.io/badge/JIB-10.1515%2Fjib.2022.0031-brightgreen)](https://doi.org/10.1515/jib-2022-0031)\n[![codecov](https://codecov.io/gh/fgcz/bfabricShiny/branch/bfabric11/graph/badge.svg?token=Q9G0WFEH6K)](https://codecov.io/gh/fgcz/bfabricShiny)\n![Downloads](https://img.shields.io/github/downloads/fgcz/bfabricShiny/total)\n\n\n# bfabricShiny R package\n\n## Demonstration\n\n### Enables connecting R and bfabric using REST\n\n![bfabricPy-read-R](https://user-images.githubusercontent.com/4901987/65041207-7c757c80-d956-11e9-90ca-9c3e2e0ca724.gif)\n\n### Command line triggered analytics\n\nThe animated gif below illustrates the interaction between an application (performing quality control on mass spectrometric measurements using [rawDiag](https://pubs.acs.org/doi/10.1021/acs.jproteome.8b00173)) and the [B-Fabric](https://fgcz-bfabric.uzh.ch) platform on the command line level using the  R console.\n\n![code_snippet_demo](https://user-images.githubusercontent.com/4901987/181242377-a9bf3988-b193-494c-91c9-a010500ee3f2.gif)\n\nThe R code as used in the animated gif.\n```{r}\n## R --no-save \u003c code_snippet.R\n## devtools::install_github(\"fgcz/bfabricShiny\")\n## devtools::install_github(\"fgcz/rawDiag\")\nstopifnot(R.Version()['major'] \u003e= '4',\n    require('rawDiag'),\n    require('bfabricShiny'))\n\n## Define B-Fabric input workunit\nworkunitid \u003c- 165473\n\n## Query metadata from B-Fabric\nQ \u003c- bfabricShiny::read(login, webservicepassword,\n  endpoint = 'resource',\n  query = list('workunitid' = workunitid), as_data_frame=FALSE)\n\n## setting root directory\nrawfilenames \u003c- Q$res |\u003e\n    sapply(function(x)file.path('/srv/www/htdocs/', x$relativepath))\n\n## Extract MS data from BLOBs using the rawDiag R package\n## That requires storage access via SSH, NFS, or SAMBA\nRAW \u003c- rawfilenames |\u003e\n    parallel::mclapply(rawDiag::read.raw, mc.cores = 12) |\u003e\n    base::Reduce(f = rbind)\n\n## Print a summary\nRAW |\u003e rawDiag::summary.rawDiag()\n\n## Have fun with visualization https://doi.org/10.1021/acs.jproteome.8b00173\n## (a)\nRAW |\u003e rawDiag::PlotPrecursorHeatmap(bins = 25)\n## (b)\nRAW |\u003e rawDiag::PlotPrecursorHeatmap(bins = 25) +\n  ggplot2::facet_wrap(~ filename)\n## (c)\nRAW |\u003e rawDiag::PlotTicBasepeak(method = 'overlay')\n## (d)\nRAW |\u003e rawDiag::PlotInjectionTime(method = 'overlay')\n```\n\n\n## INSTALL\n\n\n```{bash}\n## Debian 12\napt-get install r-base libcurl4-openssl-dev lcmaps-openssl-interface -y\n```\n\nuse source code from GitHub\n\n```{r}\nif (!requireNamespace(\"devtools\", quietly = TRUE))\n    install.packages(\"devtools\")\n\nif (!requireNamespace(\"PKI\", quietly = TRUE))\n    install.packages('PKI')\n\ndevtools::install_github(\"cpanse/shinyStore\")\ndevtools::install_github('fgcz/bfabricShiny', build_vignettes = FALSE,\n  quiet = FALSE)\n```\n\n\n# Use cases\n\n## Run shiny based queue generator application\n\n\n```{r}\npkgs \u003c- c('devtools', 'tidyverse', 'shiny', 'affy', 'limma')\npkgs[!pkgs %in% installed.packages()] |\u003e \n  BiocManager::install()\n\ndevtools::install_github('protViz/SRMService', build_vignettes = FALSE,\n  quiet = FALSE)\n```\n\n```\nsystem.file(\"shiny\", \"queue_generator10\", package = \"bfabricShiny\") |\u003e\n  shiny::runApp(display.mode = \"normal\")\n```\n\n## JSON - SOAP proxy using python \n\n\n- run\n\n```{bash}\npython3 bfabric_flask.py \n```\nIf a certified key is available, Flask will use SSL certificate and run on port 5001. Otherwise it will run using http and port 5000.\nNote that the port configuration can be changed in the bfabric\\_flask.py script.\n```{python}\n# code snippet from bfabric_flask.py:\nif exists('/etc/ssl/fgcz-host.pem') and exists('/etc/ssl/private/fgcz-host_key.pem'):    \n    app.run(debug=False, host=\"0.0.0.0\", port=5001, ssl_context=('/etc/ssl/fgcz-host.pem', '/etc/ssl/private/fgcz-host_key.pem'))\nelse:\n   app.run(debug=False, host=\"127.0.0.1\", port=5000)\n```\nSee [bfabric\\_flask.py on GitHub](https://github.com/fgcz/bfabricPy/blob/bfabric12/bfabric/scripts/bfabric_flask.py) for more details.\n\n- simple tests \n\n```{bash}\ncurl http://127.0.0.1:5000/sample/1\n```\n```{r}\n# R\nrv \u003c- httr::POST(\"https://host:5001/read\", body = jsonlite::toJSON(list(login = \"login\", webservicepassword = \"webservicepassword\", endpoint = \"user\", query = list(\"login\" = \"cpanse\"))), encode = \"json\")\nhttr::content(rv)\n```\n\n## Sample Query\n\n```{r, eval=FALSE\nR\u003e (Q \u003c- query(login, webservicepassword, \n   endpoint = 'resource',\n   query = list('filechecksum' = \"65518d3ccc6b4f3c83c132dae147fc0e\")))\n$res\n$res[[1]]\n$res[[1]]$id\n[1] 1301179\n\n$res[[1]]$created\n[1] \"Thu, 11 Jul 2019 07:00:11 GMT\"\n\n$res[[1]]$createdby\n[1] \"pfeeder\"\n\n$res[[1]]$description\n[1] \"```{r}\\r\\nR\u003e library(bfabricShiny)\\r\\nR\u003e (Q \u003c- query(login, webservicepassword, endpoint = 'resource', query = list('filechecksum' = \\\"65518d3ccc6b4f3c83c132dae147fc0e\\\")))\\r\\n$res\\r\\n$res[[1]]\\r\\n$res[[1]]$id\\r\\n[1] 1301179\\r\\n\\r\\n$res[[1]]$created\\r\\n[1] \\\"Thu, 11 Jul 2019 07:00:11 GMT\\\"\\r\\n\\r\\n$res[[1]]$createdby\\r\\n[1] \\\"pfeeder\\\"\\r\\n\\r\\n$res[[1]]$filechecksum\\r\\n[1] \\\"65518d3ccc6b4f3c83c132dae147fc0e\\\"\\r\\n\\r\\n$res[[1]]$junk\\r\\n[1] FALSE\\r\\n\\r\\n$res[[1]]$modified\\r\\n[1] \\\"Thu, 11 Jul 2019 07:00:11 GMT\\\"\\r\\n\\r\\n$res[[1]]$modifiedby\\r\\n[1] \\\"pfeeder\\\"\\r\\n\\r\\n$res[[1]]$name\\r\\n[1] \\\"20190710_005_autoQC4L.raw\\\"\\r\\n\\r\\n$res[[1]]$project\\r\\n$res[[1]]$project$id\\r\\n[1] 3181\\r\\n\\r\\n$res[[1]]$relativepath\\r\\n[1] \\\"p3181/Proteomics/QEXACTIVEHFX_1/tobiasko_20190710/20190710_005_autoQC4L.raw\\\"\\r\\n\\r\\n$res[[1]]$sample\\r\\n$res[[1]]$sample$id\\r\\n[1] 200295\\r\\n\\r\\n$res[[1]]$size\\r\\n[1] 235625610\\r\\n\\r\\n$res[[1]]$status\\r\\n[1] \\\"available\\\"\\r\\n\\r\\n$res[[1]]$storage\\r\\n$res[[1]]$storage$id\\r\\n[1] 2\\r\\n\\r\\n$res[[1]]$uris\\r\\n$res[[1]]$uris[[1]]\\r\\n[1] \\\"http://fgcz-proteomics.uzh.ch/dm/p3181/Proteomics/QEXACTIVEHFX_1/tobiasko_20190710/20190710_005_autoQC4L.raw\\\"\\r\\n\\r\\n$res[[1]]$uris[[2]]\\r\\n[1] \\\"http://fgcz-proteomics.uzh.ch/p3181/Proteomics/QEXACTIVEHFX_1/tobiasko_20190710/20190710_005_autoQC4L.raw\\\"\\r\\n\\r\\n$res[[1]]$uris[[3]]\\r\\n[1] \\\"scp://fgcz-ms.uzh.ch/srv/www/htdocs/p3181/Proteomics/QEXACTIVEHFX_1/tobiasko_20190710/20190710_005_autoQC4L.raw\\\"\\r\\n\\r\\n$res[[1]]$uris[[4]]\\r\\n[1] \\\"scp://fgcz-r-021.uzh.ch/export/lv_iduzh01/projects/,/export/lv_iduzh02/projects/,/export/lv_iduzh03/projects/,/export/lv_iduzh04/projects/,/export/lv_iduzh05/PAS/p65/RawData_Archive/,/export/lv_iduzh06/projects/,/export/lv_iduzh07/projects/p3181/Proteomics/QEXACTIVEHFX_1/tobiasko_20190710/20190710_005_autoQC4L.raw\\\"\\r\\n\\r\\n$res[[1]]$url\\r\\n[1] \\\"scp://fgcz-ms.uzh.ch/srv/www/htdocs/p3181/Proteomics/QEXACTIVEHFX_1/tobiasko_20190710/20190710_005_autoQC4L.raw\\\"\\r\\n\\r\\n$res[[1]]$workunit\\r\\n$res[[1]]$workunit$id\\r\\n[1] 200896\\r\\n\\r\\nR\u003e \\r\\n\\r\\nR\u003e table(sapply((Q \u003c- query(login, webservicepassword, endpoint = 'resource', query = list('name' = \\\"%autoQC4L%\\\")))[[1]], function(x){x$project$id}))\\r\\n\\r\\n  65 1000 1147 1352 1654 1687 1875 1876 1951 2059 2069 2135 2175 2192 \\r\\n  13   74   12    6    3    1    2   16    2    1    2    3    1    1 \\r\\n2193 2211 2213 2272 2310 2342 2433 2447 2479 2501 2558 2621 2631 2687 \\r\\n   5    1    1    2    1    2    1    1    1    1    1    4    2    2 \\r\\n2692 2695 2702 2748 2749 2760 2799 2830 2858 2882 2885 2889 2898 2901 \\r\\n   1    2    2    2    5    2    2    2    1    1    8    2    3    1 \\r\\n2915 2916 2928 2933 2946 2954 2960 2961 2993 2995 2997 3000 3024 3025 \\r\\n   4    5    7    3    1    4    2    1    8    2    1   87    1    5 \\r\\n3026 3036 3047 3053 3061 3067 3075 3086 3101 3106 3127 3134 3144 3146 \\r\\n  12    1    3    1    3    1    1    4    2    5    1    6    4    3 \\r\\n3147 3165 3175 3180 3181 \\r\\n   1    1    2    2    1 \\r\\nR\u003e \\r\\n\\r\\n```\"\n\n$res[[1]]$filechecksum\n[1] \"65518d3ccc6b4f3c83c132dae147fc0e\"\n\n$res[[1]]$junk\n[1] FALSE\n\n$res[[1]]$modified\n[1] \"Tue, 23 Jul 2019 14:27:57 GMT\"\n\n$res[[1]]$modifiedby\n[1] \"cpanse\"\n\n$res[[1]]$name\n[1] \"20190710_005_autoQC4L.raw\"\n\n$res[[1]]$project\n$res[[1]]$project$id\n[1] 3181\n\n\n$res[[1]]$relativepath\n[1] \"p3181/Proteomics/QEXACTIVEHFX_1/tobiasko_20190710/20190710_005_autoQC4L.raw\"\n\n$res[[1]]$sample\n$res[[1]]$sample$id\n[1] 200295\n\n\n$res[[1]]$size\n[1] 235625610\n\n$res[[1]]$status\n[1] \"available\"\n\n$res[[1]]$storage\n$res[[1]]$storage$id\n[1] 2\n\n\n$res[[1]]$uris\n$res[[1]]$uris[[1]]\n[1] \"http://fgcz-proteomics.uzh.ch/dm/p3181/Proteomics/QEXACTIVEHFX_1/tobiasko_20190710/20190710_005_autoQC4L.raw\"\n\n$res[[1]]$uris[[2]]\n[1] \"http://fgcz-proteomics.uzh.ch/p3181/Proteomics/QEXACTIVEHFX_1/tobiasko_20190710/20190710_005_autoQC4L.raw\"\n\n$res[[1]]$uris[[3]]\n[1] \"scp://fgcz-ms.uzh.ch/srv/www/htdocs/p3181/Proteomics/QEXACTIVEHFX_1/tobiasko_20190710/20190710_005_autoQC4L.raw\"\n\n$res[[1]]$uris[[4]]\n[1] \"scp://fgcz-r-021.uzh.ch/export/lv_iduzh01/projects/,/export/lv_iduzh02/projects/,/export/lv_iduzh03/projects/,/export/lv_iduzh04/projects/,/export/lv_iduzh05/PAS/p65/RawData_Archive/,/export/lv_iduzh06/projects/,/export/lv_iduzh07/projects/p3181/Proteomics/QEXACTIVEHFX_1/tobiasko_20190710/20190710_005_autoQC4L.raw\"\n\n\n$res[[1]]$url\n[1] \"scp://fgcz-ms.uzh.ch/srv/www/htdocs/p3181/Proteomics/QEXACTIVEHFX_1/tobiasko_20190710/20190710_005_autoQC4L.raw\"\n\n$res[[1]]$workunit\n$res[[1]]$workunit$id\n[1] 200896\n\n\n\n\nR\u003e \n\n```\n\n```{r, eval=FALSE}\nR\u003e table(sapply((Q \u003c- query(login, webservicepassword,\n   endpoint = 'resource',\n   query = list('name' = \"%autoQC4L%\")))[[1]], function(x){x$project$id}))\n\n  65 1000 1147 1352 1654 1687 1875 1876 1951 2059 2069 2135 2175 2192 \n  13   74   12    6    3    1    2   16    2    1    2    3    1    1 \n2193 2211 2213 2272 2310 2342 2433 2447 2479 2501 2558 2621 2631 2687 \n   5    1    1    2    1    2    1    1    1    1    1    4    2    2 \n2692 2695 2702 2748 2749 2760 2799 2830 2858 2882 2885 2889 2898 2901 \n   1    2    2    2    5    2    2    2    1    1    8    2    3    1 \n2915 2916 2928 2933 2946 2954 2960 2961 2993 2995 2997 3000 3024 3025 \n   4    5    7    3    1    4    2    1    8    2    1   87    1    5 \n3026 3036 3047 3053 3061 3067 3075 3086 3101 3106 3127 3134 3144 3146 \n  12    1    3    1    3    1    1    4    2    5    1    6    4    3 \n3147 3165 3175 3180 3181 \n   1    1    2    2    1 \nR\u003e \n\n```\n\n### restart the shiny server\n\n```{r}\nservice shiny-server stop \u0026\u0026 service shiny-server start\n```\n\n## Shiny\n\n### queue generator application\n\n```{r}\nqgs \u003c- system.file(\"shiny\", \"queue_generator\", package = \"bfabricShiny\")\nshiny::runApp(qgs, display.mode = \"normal\")\n```\n\n\n### bfabric authentification\n```{r}\nbfabricauth \u003c- system.file(\"shiny\", \"simple_auth\", package = \"bfabricShiny\")\nshiny::runApp(bfabricauth, display.mode = \"normal\", port=8080)\n```\n#### On howto generate keys?\n\n```\ncd bfabricShiny/inst/keys \u0026\u0026  ssh-keygen -f $PWD/bfabricShiny.key -t rsa\n\n## generate public pem key file\nssh-keygen -f $PWD/bfabricShiny.key.pub -e -m PEM \u003e bfabricShiny.key.pub.pem\n\n## test\nR -q -e \"PKI::PKI.load.key(file = 'bfabricShiny.key.pub.pem')\"\n```\n\n### PTM-MarkerFinder \n\n```{r}\nptmmf \u003c- system.file(\"shiny\", \"PTM_MarkerFinder\", package = \"bfabricShiny\")\nshiny::runApp(ptmmf, display.mode = \"normal\", port=8080)\n```\n\n\n\n## SOP create your own application\n\nThe idea is to fetch a RData file stored in bfabric.\n\n### Setup\n\n\n* install the python package https://github.com/cpanse/bfabricPy\n* install `install_github(\"https://github.com/cpanse/bfabricShiny\")`\n* run the SOAP-REST proxy `python3 bfabric_flask.py` \n* manage the key thing for housing the bfabric login/webpassword\n* run RStudio - create a new shiny app\n* in the shiny `ui.R` change\n```{r}\n   mainPanel(\n      tabsetPanel(\n        tabPanel(\"bfabric\", bfabricInput(\"bfabric8\")),\n        tabPanel(\"plot\", plotOutput(\"distPlot\"))\n      )\n```\n* on the shiny `server.R`\n  * ```library(bfabricShiny)```\n  * add to shiny server function ```bf \u003c- callModule(bfabric, \"bfabric8\",  applicationid = c(155))```\n\n* run the shiny application; check `input$relativepath`\n\n\n### Data staging\n* on the shiny `server.R` - define the way you are going to ``stage'' the data\n\n```{r}\n.ssh_load_RData \u003c- function(host = 'fgcz-r-021.uzh.ch', user = 'cpanse', file = NULL){\n  e \u003c- new.env()\n\n  cmd \u003c- paste('cat ',  file)\n\n  ssh_cmd \u003c- paste(\"ssh \", user, \"@\", host, \" '\", cmd, \"'\", sep=\"\")\n  message(ssh_cmd)\n\n  S \u003c- load(pipe(ssh_cmd))\n\n  for (x in S){\n    assign(x, get(x), e)\n  }\n  e\n}\n\n.load_RData \u003c- function(file = NULL){\n  e \u003c- new.env()\n\n  S \u003c- load(file)\n\n  for (x in S){\n    assign(x, get(x), e)\n  }\n  e\n}\n```\n\n\n```{r}\n  # returns an env\n  getRDataEnv \u003c- eventReactive(input$load, {\n    # this is the ``output'' of the bfabric shiny module\n    message(input$relativepath)\n\n    filename \u003c- file.path('/srv/www/htdocs/', input$relativepath)\n\n    if (file.exists(filename)){\n      .load_RData(file=filename)\n    }else{\n      .ssh_load_RData(file = filename, host = 'fgcz-r-021.uzh.ch')\n    }\n  })\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgcz%2Fbfabricshiny","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffgcz%2Fbfabricshiny","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgcz%2Fbfabricshiny/lists"}