Creating and running your own browser requires both Python and R. We recommend using R to install Python and setup your environment.

If you prefer to work on the command line, please see the troubleshooting section below.

First ensure you have R and RStudio installed. This project was developed using R version 4.1.0 and RStudio v1.4.1717.

Setting up R and Python

First, let’s install the R tools we’ll use to create and manage our other installations:

install.packages("devtools")
install.packages("reticulate")

Installing the omicser browser package in the next section will also install additional R packages as dependencies.

We will use a conda environment to manage the Python packages handling data on the back end of the browser application. Although python virtual environments or other python installations can be configured via reticulate [“TODO:link to other python configurations”] we recommend using conda via the reticulate mini-conda installation as described here.

We can use R to install Python version 3.8 and other necessary Python packages by creating a conda environment using reticulate. For curation we need to make sure we also install the scanpy package.

OMICSER_PYTHON <- "my_py_env_name"

reticulate::install_miniconda() #in case it is not already installed
# simpler pip pypi install
packages <- c("scanpy[leiden]")
reticulate::conda_create(OMICSER_PYTHON, python_version = 3.8)
reticulate::conda_install(envname=OMICSER_PYTHON,
                          channel = "conda-forge",
                          pip = TRUE,
                          packages =  packages )

Start a fresh R-session and force reticulate to use our OMICSER_PYTHON by calling reticulate::use_condaenv.

reticulate::use_condaenv(condaenv = OMICSER_PYTHON,
                                conda = reticulate::conda_binary(),
                                required = TRUE)

Installing omicser

Now that we’ve set up our environment, we can install the package from which we’ll build the browser application. using the devtools package:

devtools::install_github("ndcn/omicser")

We are relying on this command to install not only the omicser package, but a large number of additional packages that will support data formatting and app development. If you are prompted to install and/or update any of these packages, we recommend you do so.

If you receive a message indicating a package failed to install (resulting in a failure to install omicser), please see the troubleshooting section R packages failing to load.

If you have successfully complete all steps in this section, you are now ready for data curation.

dev Installation

If you also intend to develop the code to contribute features to the opensource project or just to extend the functionality for you use, you should download the repo code and use the golem framework tools to help load the code locally.
For instance after cloning the repo, make sure you are in the repo directory (i.e. omicser/) and run:

library("golem")
OMICSER_RUN_DIR <- getwd()
golem::document_and_reload(pkg = OMICSER_RUN_DIR)

which will load the omicser package into your R-session exposing all of the omicser functions.

Troubleshooting

reticulate and conda

If you have difficulty loading scanpy (e.g., “ModuleNotFoundError: No module named ‘scanpy’”), you can check the details of your Python environment:

reticulate::py_discover_config()

Because you used reticulate to create an environment for you with the relevant packages installed, you should see your environment name listed in the Python paths (e.g., r-miniconda/envs/my_py_env_name/bin/python).

If you do not see your environment listed in the paths, you can set the RETICULATED_PYTHON:

reticulate::use_condaenv(condaenv = "my_py_env_name", required = TRUE)

This may also require you to restart your R session. For more information, please see the reticulate website

R packages failing to load

If you receive output in your console indicating one of these additional packages did not install correctly, you can manually install it. This may also be necessary in a later step of this series of tutorials, if you realize a function and/or package are not available.

For example, the download for vroom may have stalled, resulting in an error in your console saying the package isn’t available. You can install this package alone using the Packages interface in RStudio, or using the following code:

You may need to re-install and/or reload other packages as well (if they are dependent on the package you manually installed).