GEM Rasters

Plotting Guide Setup

In [1]:
import os
import numpy as np

import holoviews as hv
hv.extension(
    'bokeh',
    'matplotlib'
)

import GSForge as gsf

Declare used paths

In [2]:
# OS-independent path management.
from os import fspath, environ
from pathlib import Path
In [3]:
OSF_PATH = Path(environ.get("GSFORGE_DEMO_DATA", default="~/GSForge_demo_data")).expanduser()
AGEM_PATH = OSF_PATH.joinpath("osfstorage", "rice.nc")
BOR_COLL_PATH = OSF_PATH.joinpath("osfstorage", "boruta_gene_sets")
assert AGEM_PATH.exists()

Load an AnnotatedGEM

In [4]:
agem = gsf.AnnotatedGEM(AGEM_PATH)
agem
Out[4]:
<GSForge.AnnotatedGEM>
Name: Rice
Selected GEM Variable: 'counts'
    Gene   55986
    Sample 475
In [5]:
gsc = gsf.GeneSetCollection.from_folder(gem=agem, target_dir=BOR_COLL_PATH, 
                                        name="Boruta Results")
gsc
Out[5]:
<GSForge.GeneSetCollection>
Boruta Results
GeneSets (3 total): Support Count
    Boruta_Treatment: 681
    Boruta_Genotype: 661
    Boruta_Subspecies: 231

Creating a Count Matrix Raster

In [6]:
# Suppress numba warnings.
import warnings
warnings.filterwarnings('ignore')

Using the datashader library, we can create a dynamic raster of the entire GEM.

In [7]:
gsf.plots.RasterGEM(gsc).opts(width=500, height=300)
Out[7]:

Selecting a GeneSet from a collection provides a raster of just those supported genes.

In [8]:
gsf.plots.RasterGEM(gsc, selected_gene_sets=["Boruta_Genotype"], annotation_variables="Genotype",
                    count_transform=np.log2, count_mask="masked").opts(width=500, height=300)
Out[8]:


Right click to download this notebook from GitHub.