Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add env var to overwrite where user data is stored #80

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/eula.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ eula_have_agreed <- function() {
#' Path to directory that holds EULA agreement lock file
#' @noRd
eula_data_dir <- function() {
tools::R_user_dir("loupeR", "data")
get_user_data_dir()
}

#' Path to EULA agreement lock file
Expand Down
2 changes: 1 addition & 1 deletion R/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ verify_executable <- function(executable_path) {
#'
#' @noRd
default_executable_path <- function() {
basedir <- tools::R_user_dir("loupeR", "data")
basedir <- get_user_data_dir()
normalizePath(path.expand(file.path(basedir, executable_basename())), mustWork = FALSE)
}

Expand Down
19 changes: 19 additions & 0 deletions R/util.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Environment variable that allows overwriting the user data directory
# If unset, defaults to: tools::R_user_dir("loupeR", "data")
LOUPER_USER_DATA_DIR_ENV_VAR <- "LOUPER_USER_DATA_DIR" # nolint

#' Log a message
#'
#' @param ... a variable number of character message parts
Expand Down Expand Up @@ -278,3 +282,18 @@ print_lines <- function(strs, prefix = "") {
cat(sprintf("%s%s\n", prefix, s))
}
}

#' Gets the path to the user directory on the machine where data is stored.
#'
#' @return A filesystem path to the user directory where things like the EULA can be stored.
#'
#' @noRd
get_user_data_dir <- function() {
overwritten_data_dir <- Sys.getenv(LOUPER_USER_DATA_DIR_ENV_VAR)
overwritten_data_dir <- trimws(overwritten_data_dir)
if (overwritten_data_dir != "") {
return(overwritten_data_dir)
}

tools::R_user_dir("loupeR", "data")
}
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

Converting a Seurat object to a Loupe file is as simple as the following:

```R
```r
# import the library
library("loupeR")

Expand All @@ -36,7 +36,7 @@ create_loupe_from_seurat(seurat_obj)

Use the function `create_loupe` if you need more control in the clusters and projections that included in the Loupe file.

```R
```r
# import the library
library("loupeR")

Expand All @@ -56,7 +56,7 @@ create_loupe(

Additionally, use the utility function `read_feature_ids_from_tsv` to read the Ensemble ids from the 10x dataset. A Seurat object will only have imported the feature names or ids and attached these as rownames to the count matrix. In order for the Ensemble id links to work correctly within Loupe Browser, one must manually import them and include them.

```R
```r
# import the library
library("loupeR")

Expand Down Expand Up @@ -106,6 +106,10 @@ loupeR::setup()

If you are interested in automating LoupeR installation and execution (and are blocked by interactive license acceptance), please write to [support@10xgenomics.com](mailto:support@10xgenomics.com) for further assistance.

### Customizing the user data directory

By default the louper executable, which is the binary that understands and creates Loupe files, will be stored in the system's `tools::R_user_dir` directory. You can update this path by setting the environment variable `LOUPER_USER_DATA_DIR` to a directory of your choosing.

## Loupe Browser Compatibility

With new versions of the Loupe Browser, new version of LoupeR need to be released. The table below shows version requirements between the two.
Expand Down Expand Up @@ -159,7 +163,7 @@ For more in depth documentation and support please head to our [support page](ht

Additionally, we have provided utility functions to help gather useful information when contacting support or creating a Github issue.

```R
```r
# import the library
library("loupeR")

Expand Down
Loading