Skip to content

onertipaday/pyCOMPASSR

Repository files navigation

pyCOMPASSR

pyCOMPASSR is a R wrapper to the python library pyCOMPASS which allows querying COMPASS (COMpendia Programmatic Access Support Software) a software layer that provides a GraphQL endpoint to query compendia built using COMMAND>_ doi technology.

Build Status

Travis-CI Build Status rstudio mirror downloads rstudio mirror downloads

Installation

1. Install python and pip

1.1. Install python 3 (>= 3.3) (download page)

1.2. Install pip for python

1.3. Install reticulate for R

install.packages("reticulate")

1.4. Check that reticulate can now find python. You may have to restart RStudio.

reticulate::py_config()

You will see information about your python configuration, including one or more system paths where python is installed.

1.5. Check that pip can be found

system("pip --version")

You will see something like pip 19.1.1 from /usr/lib/python3.7/site-packages/pip (python 3.7)

2. Install pyCOMPASS

2.1. Find the default python path that reticulate is using

reticulate::py_config()

Take note of the path in the first line (e.g., "/usr/bin/python").

2.2. Find the path that the system pip command is using

system("pip --version")

For example, in "pip 19.1.1 from /usr/lib/python3.7/site-packages/pip (python 3.7)" the python path is "/usr/lib/python3.7". If the path here does not match the py_config() path, then you may need to manually set the path using use_python().

reticulate::use_python("/usr/lib/python3.7", required = TRUE)

You may have to restart RStudio before setting the path if you have run other reticulate operations.

2.3. Install pycompass from R

# create a new environment 
virtualenv_create("pycompassr")
# install pycompass
virtualenv_install("pycompassr", "pycompass")

2.3. Install pyCOMPASS using pip

system("pip install pycompass")

Or alternatively, run this command in the system terminal (sudo pip install pycompass for Mac users).

2.4. Check if you can now import pyCOMPASS. You may have to restart RStudio.

pycompass <- reticulate::import("pycompass")

3. Install pyCOMPASSR

3.1. Finally, you can install pyCOMPASSR.

remotes::install_github("onertipaday/pyCOMPASSR")

Usage

Load the library

library(pyCOMPASSR)

Connect to Vitis vinifera compendium

vv_compendium <- get_compendium(species = 'vitis_vinifera')
print(vv_compendium$description)

Let's build our module starting from a bunch of genes

gene_names <-c('VIT_05s0094g00350','VIT_07s0031g02630','VIT_19s0015g02480','VIT_08s0007g08840','VIT_01s0026g00520','VIT_03s0017g02170','VIT_19s0014g05330','VIT_02s0154g00130','VIT_02s0025g04330','VIT_13s0067g00490','VIT_09s0002g01200','VIT_14s0030g00140','VIT_03s0063g00120','VIT_05s0029g01480','VIT_11s0052g01650','VIT_02s0087g01020','VIT_09s0070g00160','VIT_13s0019g02180','VIT_07s0095g00550','VIT_04s0008g06570','VIT_04s0069g00860','VIT_04s0210g00060','VIT_07s0104g00430','VIT_15s0107g00210','VIT_16s0039g00970','VIT_10s0003g01730','VIT_17s0000g07060','VIT_16s0100g00510','VIT_02s0154g00590')

We can query the compendium with the list of gene names and get a list of BiologicalFeature objects that represents our genes of interest.

genes <- get_bf(compendium = vv_compendium, gene_names = as.list(gene_names))

We are now ready to create our first module: the compendium will need the list of genes (BiologicalFeature objects) and the name of the normalization we want to use in order to automatically select the "best" conditions.¶

mod1 <- create_module(compendium = vv_compendium, biofeatures = genes)

A module is a matrix that represent a portion of genes and a portion of conditions of the whole compendium. Let's see its values.

mod1$compendium$compendium_full_name
mod1$values

Now we will plot the heatmap for this module using the Plot object. The plot_heatmap method will return normal HTML + Javascript code. We can use RStudio viewer to visualize the html.

my_plot_html <- plot_heatmap(mod1)
tempDir <- tempfile()
dir.create(tempDir)
htmlFile <- file.path(tempDir, "plot_heatmap.html")
write_html(my_plot_html,file=htmlFile)
rstudioapi::viewer(htmlFile)

Citation

Moretto, M., Sonego, P., Villaseñor-Altamirano, A.B. et al. First step toward gene expression data integration: transcriptomic data acquisition with COMMAND>_. BMC Bioinformatics 20, 54 (2019). doi:10.1186/s12859-019-2643-6.

Package maintainers / authors

About

An R interface to COMPASS, the gene expression compendia GraphQL endpoint

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published