https://github.com/gosling-lang/grosling
R interface to 'Gos'
https://github.com/gosling-lang/grosling
hidivelab
Last synced: 5 months ago
JSON representation
R interface to 'Gos'
- Host: GitHub
- URL: https://github.com/gosling-lang/grosling
- Owner: gosling-lang
- License: mit
- Created: 2022-07-21T22:58:29.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-23T14:38:49.000Z (over 3 years ago)
- Last Synced: 2025-12-03T13:30:57.096Z (6 months ago)
- Topics: hidivelab
- Language: R
- Homepage: https://gosling-lang.github.io/grosling
- Size: 56.6 KB
- Stars: 39
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
```{r, echo = FALSE}
knitr::opts_chunk$set(collapse = TRUE)
```
**Here be dragons** 🐉
# g(r)osling
The goal of **g(r)osling** is to help you build interactive genomics visualizations with
[Gosling](https://github.com/gosling-lang/gosling.js). This package uses
[reticulate](https://rstudio.github.io/reticulate/) to provide an interface
to the [Gos](https://github.com/gosling-lang/gos) Python package.
## Example
```{r, eval = FALSE}
library(gosling)
data <- gos$bigwig(
url = "https://s3.amazonaws.com/gosling-lang.org/data/ExcitatoryNeurons-insertions_bin100_RIPnorm.bw",
column = "position",
value = "peak"
)
track <- gos$Track(data, height = 100)$mark_point()$encode(
x = gos$X("position:G"),
y = gos$Y("peak:Q")
)
track$view()
```

## Installation
You can install the development version of gosling like so:
``` r
devtools::install_github("gosling-lang/grosling")
```
Because of Python, there may be some additional installation steps.
1.) Python must be installed on your system. We recommend `conda`.
2.) Create a conda environment called `"r-reticulate"`. It is [recommended](https://rstudio.github.io/reticulate/articles/python_packages.html)
to use this environment name for all packages that use reticulate.
3.) Install Gos into your `"r-reticulate"` environment using `gosling::install_gosling()`.
You may wish to add a line like this to the `.First()` function in your `.Rprofile`:
```r
reticulate::use_condaenv("r-reticulate")
```
The `use_condaenv()` function is called to provide a hint to reticulate on which Python environment to use.
## Local Data
Gos [transparently serves](https://gosling-lang.github.io/gos/user_guide/local_data.html)
local and in-memory datasets for the Gosling client via a background data server.
This feature is enabled automatically whenever a local file path is
detected (rather than a URL).
Due to [a temporary limitation with `reticulate`](https://github.com/rstudio/reticulate/issues/515#issuecomment-1196609327),
some additional setup is required to enable this feature in **grosling**. Hopefully
this will be resolved in `reticulate` soon, but the current workaround is shown below.
```{r load_loop, eval = FALSE}
library(gosling)
### Setup reticulate to continually yield R <> Python. You only need to run this *once*.
local({
reticulate::py_run_string("from time import sleep")
py_yield_and_register_next_yield <- function() {
reticulate::py_eval("sleep(0.001)")
later::later(py_yield_and_register_next_yield, .001)
invisible()
}
later::later(py_yield_and_register_next_yield)
})
###
file <- "./ExcitatoryNeurons-insertions_bin100_RIPnorm.bw" # local file
data <- gos$bigwig(file, column = "position", value = "peak")
track <- gos$Track(data, height = 100, width = 750)$mark_bar()$encode(
x = gos$X("position:G"),
y = gos$Y("peak:Q"),
color = gos$Color("peak:Q")
)
track$view()
```
