SCAnalysis for single cell RNA-seq

This notebook details the usage of SCAnalysis for single cell RNA-seq data.

To view directly: https://nbviewer.jupyter.org/github/helenjin/scanalysis/blob/master/notebooks/SCAnalysis.ipynb (ignore if already here)

Introduction

SCAnalysis is a package for analyzing single cell data. It includes the Wishbone, MAGIC, and Palantir packages:

  • Wishbone is an algorithm to identify bifurcating developmental trajectories from single cell data. Wishbone can applied to single cell RNA-seq (not currently supported for mass cytometry datasets)

  • MAGIC (Markov-Affinity Based Graph Imputation of Cells) is an interactive tool to impute missing values in single-cell data and restore the structure of the data. It also provides data preprocessing functionality such as dimensionality reduction and gene expression visualization.

  • Palantir

Loading Data

First, import the package.


In [1]:
import scanalysis

Then, you can load the data using the load function in the loadsave file of the io folder. Here, we will be using the sample_scseq_data.csv data provided in the data folder as an example.


In [2]:
df = scanalysis.io.loadsave.load("~/scanalysis/data/sample_scseq_data.csv")


Successfully loaded /Users/hjin/scanalysis/data/sample_scseq_data.csv as a pd.DataFrame object

Also, import plotting and miscellaneous.


In [16]:
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec

%matplotlib inline

Data preprocessing

Data filtering


In [4]:
fig, ax = scanalysis.plots.plot.plot_molecules_per_cell_and_gene(df)


2.28555730901
4.07051809702

From these histograms, choose the appropriate cutoffs to filter the data. In this case, the data has already been filtered.


In [5]:
# Minimum molecules/cell value
CELL_MIN = 0

# Maximum molecules/cell values
CELL_MAX = 1000000

# Minimum number of nonzero cells/gene 
# (None if no filtering desired)
GENE_NONZERO = None

# Minimum number of molecules/gene
# (None if no filtering desired)
GENE_MOLECULES = None

In [6]:
df = scanalysis.io.preprocess.filter_scseq_data(df, filter_cell_min=CELL_MIN, filter_cell_max=CELL_MAX, 
                         filter_gene_nonzero=GENE_NONZERO, filter_gene_mols=GENE_MOLECULES)


Successfully filtered data

Data normalization


In [7]:
data = scanalysis.io.preprocess.normalize_scseq_data(df)


Successfully normalized data

Principal Component Analysis (PCA)

The first step in data processing for Wishbone is to determine metagenes using principal component analysis. This representation is necessary to overcome the extensive dropouts that are pervasive in single cell RNA-seq data.

For a visual representation of PCA results, see PCA visualization. However, note that the PCA visualization functions already run PCA within themselves, so there is no need to run PCA separately beforehand.


In [8]:
r1, r2 = scanalysis.utils.pca.run_pca(data)


Successfully ran PCA, and returning:
pca_projections
pca.explained_variance_ratio_
*Note: This sample dataset is especially sensitive, so we will be using the PCA of the original Wishbone package. (as shown below)

temp is the data after PCA is run on it.


In [9]:
import wishbone
import os

scdata = wishbone.wb.SCData.from_csv(os.path.expanduser('~/.wishbone/data/sample_scseq_data.csv'), data_type='sc-seq', normalize=True)
scdata.run_pca()


/usr/local/lib/python3.6/site-packages/matplotlib/__init__.py:1405: UserWarning: 
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

  warnings.warn(_use_error_msg)

In [10]:
from copy import deepcopy
import numpy as np
import pandas as pd

n_pca_components = 5
temp = deepcopy(scdata.data)
temp -= np.min(np.ravel(temp))
temp /= np.max(np.ravel(temp))
temp = pd.DataFrame(np.dot(temp, scdata.pca['loadings'].iloc[:, 0:n_pca_components]),
                    index=scdata.data.index)

Diffusion Maps

Diffusion maps is a non-linear dimensionality reduction technique to denoise the data and capture the major axes of variation. Diffusion maps can be determined by using the run_diffusion_map function and the diffusion components visualized on tSNE maps using plot_diffusion_components. See Diffusion map visualization

Note: PCA must be run separately on data before diffusion maps (i.e. PCA is not included in diffusion maps function)


In [11]:
tempEigvec, tempEigval = scanalysis.utils.diffusionmap.run_diffusion_map(temp)


Running Diffusion maps with the following parameters:
Normalization: smarkov
Number of nearest neighbors k: 10
Epsilon: 1.0000
(symmetric markov) ... 
0.24 seconds
Successfully ran diffusion map, and returning EigenVectors and EigenValues

tSNE

Note: PCA must be run separately on data before tSNE (i.e. PCA is not included in tSNE function)

For a visual representation of tSNE results, see tSNE visualization

Here, temp data has already been run through PCA, so we can simply apply tSNE:


In [12]:
t = scanalysis.utils.tsne.TSNE()
d = t.fit_transform(temp)

In [13]:
t1 = scanalysis.utils.tsne.TSNE()
d1 = t1.fit_transform(r1)

Saving Data

Data can be saved to a pickle file and loaded using the save and load functions. For example, data can be saved as "mouse_marrow_scdata.p" (which will appear in the notebooks folder of scanalysis)


In [14]:
scanalysis.io.loadsave.save(data, 'mouse_marrow_scdata.p')


WARNING: This file already exists!
Press enter to overwrite.
Press Ctrl-C to exit and try again with a different file name.
Successfully saved as mouse_marrow_scdata.p

General Plots

PCA visualization

Note: Run the plot_pca_variance_explained function WITHOUT running PCA on the data beforehand, since PCA will be run automatically.

Results shown below for plot_pca_variance_explained_v1, which is Wishbone's version of the function.


In [15]:
fig, ax = scanalysis.plots.plot.plot_pca_variance_explained_v1(data, n_components=40, random=True)


Results shown below for plot_pca_variance_explained_v2, which is MAGIC's version of the function.


In [16]:
fig, ax = scanalysis.plots.plot.plot_pca_variance_explained_v2(data, n_components=40, random=True)


tSNE visualization

Wishbone uses tSNE for visualization and tSNE can be run using the run_tsne function which takes the number of principal components as the parameter. From the above plot, 5 seems an appropriate number of components to use.

tSNE results can be visualized by the plot_tsne and plot_tsne_by_cell_sizes functions. The plot_tsne_by_cell_sizes function colors the cells by their molecule counts before normalization.


In [17]:
fig, ax = scanalysis.plots.plot.plot_tsne(d1)



In [18]:
fig = plt.figure(figsize=[5, 4])
scanalysis.plots.plot.plot_tsne_by_cell_sizes(df, d1, fig = fig)


Out[18]:
(<matplotlib.figure.Figure at 0x11c4be208>,
 <matplotlib.axes._subplots.AxesSubplot at 0x11c4c5048>)

In [19]:
fig, ax = scanalysis.plots.plot.plot_gene_expression(data, d1, genes = ['CD34', 'GATA2', 'GATA1', 'MPO'])


<matplotlib.figure.Figure at 0x11c4c9588>

Diffusion map visualization

Note: Please run diffusion maps and tSNE before plotting diffusion components (via plot_diffusion_components function).


In [20]:
fig, ax = scanalysis.plots.plot.plot_diffusion_components(d, tempEigvec, tempEigval)


The run_diffusion_map_correlations function is designed to work for single cell RNA-seq (not mass-cyt). Please run diffusion maps using run_diffusion_map before determining correlations.

Note: the component 0 is the trivial component and does not encode any information of the data.


In [21]:
dmap_corr = scanalysis.plots.plot.run_diffusion_map_correlations(data, tempEigvec)

After determining the diffusion map correlations, we can plot the gene component correlations (via plot_gene_component_correlations function).


In [22]:
scanalysis.plots.plot.plot_gene_component_correlations(dmap_corr)


Out[22]:
(<matplotlib.figure.Figure at 0x11b649828>,
 <matplotlib.axes._subplots.AxesSubplot at 0x11c98dac8>)

Gene Set Enrichment Analysis (GSEA)

For more info on the original software, see GSEA

The enrichments can be determined using the run_gsea function. This function needs the prefix for generating GSEA reports and a gmt file representing the different gene sets. The following invocation of the function shows the supported set of gmt files.

Note: Please make sure to run run_diffusion_map_correlations() before running GSEA to annotate those components.

Note: The gmt files package with Wishbone/SCAnalysis assume all the gene names to be upper case. This can be ensured using the following code to convert them to upper case.


In [ ]:
data.columns = data.columns.str.upper()

Note:

this was working perfectly fine before, but since I switched my computer, there is a PermissionError?


In [ ]:
scanalysis.tools.wb.gsea.run_gsea(dmap_corr, output_stem= os.path.expanduser('~/.scanalysis/tools/gsea/mouse_marrow'))

Since this is data from mouse, gmt_file parameter can be set to (mouse, gofat.bp.v1.0.gmt.txt)


In [ ]:
reports = scanalysis.tools.wb.gsea.run_gsea(dmap_corr, output_stem= os.path.expanduser('~/.scanalysis/gsea/mouse_marrow'), 
                          gmt_file=('mouse', 'gofat.bp.v1.0.gmt.txt'))

The detailed reports can be found at ~/.wishbone/gsea/


In [ ]:
!open ~/.scanalysis/gsea/

run_gsea function also returns the top enrichment gene sets along each component. GSEA determines enrichments that are either positively or negatively correlated with the gene component correlations. In this dataset, components 1 and 2 show relevant enrichments and are used for running Wishbone/SCAnalysis. Please see Selection of diffusion components for single cell RNA-seq section of the Supplementary Methods for more details.


In [ ]:
# Component 1 enrichments
reports[1]['neg']

In [ ]:
# Component 2 enrichments
reports[2]['pos']

Running Wishbone

For a visual representation of results, see Plotting Wishbone Results

Wishbone can be run by specifying the start cell and number of waypoints to be used. The start cell for this dataset was chosen based on high expression of CD34. (for each dataset, there is a corresponding start cell particular to that dataset)

Note: Keep in mind that Wishbone requires data that has been run through normalization, PCA, and diffusion maps.

Here, we will consider only 2 components.(?)


In [23]:
wb = scanalysis.tools.wb.wishbone.run_wishbone(tempEigvec.iloc[:,[1,2]], 'W30258', k=15, l=15, num_waypoints =250, branch=True)


Building lNN graph...
lNN computed in : 0.02 seconds
Determining waypoints if not specified...
Determining shortest path distances and perspectives....
..........................................................................................................................................................................................................................................................
Time for determining distances and perspectives: 56.49 seconds
Determining branch point and branch associations...
Running iterations...
Iteration: 2
Correlation with previous iteration:  0.9987
Iteration: 3
Correlation with previous iteration:  0.9995
Iteration: 4
Correlation with previous iteration:  0.9998
Iteration: 5
Correlation with previous iteration:  0.9999
Iteration: 6
Correlation with previous iteration:  0.9999
5 realignment iterations

Plotting Wishbone Results

Use the WBResults class object returned from the run_wishbone function to plot various graphs.

Plot Wishbone on tSNE maps

Wishbone trajectory and branch results can be visualized on tSNE maps using the plot_wishbone_on_tsne function.

Note: Please make sure to run Wishbone before attempting to plot Wishbone results.


In [24]:
wb.plot_wishbone_on_tsne(d)


Please make sure that the tSNE data entered corresponds to the Wishbone object you've entered.
        If yes, press enter to continue.
        If not, Ctrl-C to exit and retry with correct parameters.
Out[24]:
(<matplotlib.figure.Figure at 0x11cadbda0>,
 <matplotlib.axes._subplots.AxesSubplot at 0x11c45eda0>)

Plot Marker Trajectory

Gene expression trends along the Wishbone trajectory can be visualized using the plot_marker_trajectory function. This function also returns the smoothed trends along with the matplotlib fig, ax handler objects.

Note: Variance calculation is currently not supported for single-cell RNA-seq (sc-seq)


In [25]:
vals, fig, ax = wb.plot_marker_trajectory(data, ['CD34', 'GATA1', 'GATA2', 'MPO']);


Plot Marker Heatmap

The marker trends can be visualized as heatmaps in a given trajectory range using the following functions:


In [26]:
wb.plot_marker_heatmap(vals)


Out[26]:
(<matplotlib.figure.Figure at 0x11c4219b0>,
 <matplotlib.axes._subplots.AxesSubplot at 0x11e117668>)

In [27]:
wb.plot_marker_heatmap(vals, trajectory_range=[0.1, 0.6])


Out[27]:
(<matplotlib.figure.Figure at 0x11db14588>,
 <matplotlib.axes._subplots.AxesSubplot at 0x1284408d0>)

Plot Derivatives

The change in marker trends along the trajectory or derivatives can be visualized using these functions:


In [28]:
wb.plot_derivatives(vals)


Out[28]:
(<matplotlib.figure.Figure at 0x11c935208>,
 <matplotlib.axes._subplots.AxesSubplot at 0x11d7fc5f8>)

In [29]:
wb.plot_derivatives(vals, trajectory_range=[0.3, 0.6])


Out[29]:
(<matplotlib.figure.Figure at 0x11ba9ac88>,
 <matplotlib.axes._subplots.AxesSubplot at 0x11bf64cf8>)

Running MAGIC

For a visual representation of MAGIC results, see Plotting MAGIC Results

MAGIC can be run with the run_magic function.

Note: Data should be filtered and normalized before running MAGIC. Running PCA is not necessary, since the run_magic function automatically performs PCA.


In [30]:
new_data = scanalysis.tools.magic.run_magic(data)


Doing PCA
Successfully ran PCA, and returning:
pca_projections
pca.explained_variance_ratio_
Using pca_projections
Computing distances
Autotuning distances
Computing kernel
MAGIC: L_t = L^t
MAGIC: data_new = L_t * data

Let's try MAGIC with the data set used in the original MAGIC [notebook] as well.(http://nbviewer.jupyter.org/github/pkathail/magic/blob/develop/notebooks/Magic_single_cell_RNAseq.ipynb).


In [31]:
m_data = scanalysis.io.loadsave.load("~/sdata_nn_TGFb_day_8_10.csv")


Successfully loaded /Users/hjin/sdata_nn_TGFb_day_8_10.csv as a pd.DataFrame object

We have to filter the data, but we won't do it here because it's not necessary.


In [ ]:
# Minimum molecules/cell value
CELL_MIN = 0

# Maximum molecules/cell values
CELL_MAX = 1000000

# Minimum number of nonzero cells/gene 
# (None if no filtering desired)
GENE_NONZERO = None

# Minimum number of molecules/gene
# (None if no filtering desired)
GENE_MOLECULES = None

m_data = scanalysis.io.preprocess.filter_scseq_data(m_data, filter_cell_min=CELL_MIN, filter_cell_max=CELL_MAX, 
                         filter_gene_nonzero=GENE_NONZERO, filter_gene_mols=GENE_MOLECULES)
## ^but this takes forever...
### also Pooja doesn't actually filter the data in the example notebook 
## (there are just dummy parameters as an example of how to call the filtering function), so you should still be able to tes

Let's normalize the data though.


In [33]:
m_data = scanalysis.io.preprocess.normalize_scseq_data(m_data)


Successfully normalized data

Then, let's apply the run_magic function on m_data.


In [34]:
new_m_data = scanalysis.tools.magic.run_magic(m_data)


Doing PCA
Successfully ran PCA, and returning:
pca_projections
pca.explained_variance_ratio_
Using pca_projections
Computing distances
Autotuning distances
Computing kernel
MAGIC: L_t = L^t
MAGIC: data_new = L_t * data

Plotting MAGIC Results

Note: Please make sure to run MAGIC on normalized data before attempting to plot various MAGIC results.

Gene-gene scatter plots

2D scatter plot before MAGIC:


In [35]:
fig, ax = scanalysis.plots.plot.scatter_gene_expression(data, ['SRRM1', 'TAB2'], color = 'GPX4')
ax.set_xlabel('SRRM1')
ax.set_ylabel('TAB2')


Out[35]:
<matplotlib.text.Text at 0x11bd91668>

The second plot below is for the data set used in the original MAGIC notebook.


In [36]:
fig, ax = scanalysis.plots.plot.scatter_gene_expression(m_data, ['VIM', 'CDH1'], color='ZEB1')
ax.set_xlabel('Vimentin (VIM)')
ax.set_ylabel('E-cadherin (CDH1)')


Out[36]:
<matplotlib.text.Text at 0x11d44b4a8>

2D scatter plot after MAGIC:


In [37]:
fig, ax = scanalysis.plots.plot.scatter_gene_expression(new_data, ['MAGIC SRRM1', 'MAGIC TAB2'], color = 'MAGIC GPX4')
ax.set_xlabel('MAGIC SRRM1')
ax.set_ylabel('MAGIC TAB2')


Out[37]:
<matplotlib.text.Text at 0x11d6c4748>

The second plot below is for the data set used in the original MAGIC notebook.


In [38]:
fig, ax = scanalysis.plots.plot.scatter_gene_expression(new_m_data, ['MAGIC VIM', 'MAGIC CDH1'], color ='MAGIC ZEB1')
ax.set_xlabel('MAGIC Vimentin (VIM)')
ax.set_ylabel('MAGIC E-cadherin (CDH1)')


Out[38]:
<matplotlib.text.Text at 0x11dbb7fd0>

3D scatter plot before MAGIC:


In [39]:
fig, ax = scanalysis.plots.plot.scatter_gene_expression(data, ['SRRM1', 'TAB2', 'CBR1'], color='GPX4')
ax.set_xlabel('SRRM1')
ax.set_ylabel('TAB2')
ax.set_zlabel('CBR1')


Out[39]:
<matplotlib.text.Text at 0x11df88400>

The second plot below is for the data set used in the original MAGIC notebook.


In [40]:
fig, ax = scanalysis.plots.plot.scatter_gene_expression(m_data, ['VIM', 'CDH1', 'FN1'], color='ZEB1')
ax.set_xlabel('Vimentin (VIM)')
ax.set_ylabel('E-cadherin (CDH1)')
ax.set_zlabel('Fibronectin (FN1)')


Out[40]:
<matplotlib.text.Text at 0x11c418c18>

3D scatter plot after MAGIC:


In [41]:
fig, ax = scanalysis.plots.plot.scatter_gene_expression(new_data, ['MAGIC SRRM1', 'MAGIC TAB2', 'MAGIC CBR1'], color='MAGIC GPX4')
ax.set_xlabel('MAGIC SRRM1')
ax.set_ylabel('MAGIC TAB2')
ax.set_zlabel('MAGIC CBR1')


Out[41]:
<matplotlib.text.Text at 0x11ebebef0>

The second plot below is for the data set used in the original MAGIC notebook.


In [42]:
fig, ax = scanalysis.plots.plot.scatter_gene_expression(new_m_data, ['MAGIC VIM', 'MAGIC CDH1', 'MAGIC FN1'], color='MAGIC ZEB1')
ax.set_xlabel('MAGIC Vimentin (VIM)')
ax.set_ylabel('MAGIC E-cadherin (CDH1)')
ax.set_zlabel('MAGIC Fibronectin (FN1)')
ax.set_zlim(35, 150)


Out[42]:
(35, 150)

PCA scatter plots

PC2 vs PC3 colored by CDH1, VIM, FN1 and ZEB1 (before MAGIC):

potential PROBLEMS:

  • there's a problem with PCA scatter plot after MAGIC --> does not produce the correct results, need to look into it further
  • also tSNE scatter plots don't look the exact same as MAGIC notebook's??
  • didn't quite figure FigureGrid, ie how to add scatterplot info to the generated layout (can you?) --> for now, just focus on the original way to generate the figures (in magic notebook)

First, however, we should set up our data. Add to temp the column names of the various Principal Components.


In [43]:
temp.columns = ['PC1','PC2','PC3','PC4','PC5']

Then, combine data and temp into one combined dataset, which is assigned to variable x below.


In [44]:
x = pd.concat([data, temp], axis=1)

Finally, let's plot.


In [45]:
gs = gridspec.GridSpec(2,2)
fig = plt.figure(figsize=[15, 12])
genes = ['SRRM1', 'TAB2', 'CBR1', 'GPX4']
for i in range(len(genes)):
    ax = fig.add_subplot(gs[i//2, i%2])
    scanalysis.plots.plot.scatter_gene_expression(x, genes=['PC2', 'PC3'], color=genes[i], fig=fig, ax=ax)


The second plot below is for the data set used in the original MAGIC notebook.


In [46]:
pca1, pca2 = scanalysis.utils.pca.run_pca(m_data, 5)

pca1.columns = ['PC1','PC2','PC3','PC4','PC5']

x1 = pd.concat([m_data, pca1], axis=1)


Successfully ran PCA, and returning:
pca_projections
pca.explained_variance_ratio_

In [47]:
x1


Out[47]:
5_8S_rRNA A1BG A1BG-AS1 A2M A2M-AS1 A2ML1 A2ML1-AS1 A4GALT AAAS AACS ... snoU2-30 snoU2_19 snoZ196 uc_338 yR211F11.2 PC1 PC2 PC3 PC4 PC5
5S_rRNA
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 1.002377 ... 0.0 0.0 0.0 0.000000 0.0 5.268489 -7.326328 -10.902250 -21.332481 -7.759448
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 9.723591 30.954273 -52.138871 14.844967 -6.638429
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -2.636628 -24.459979 3.300242 0.261998 13.182163
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -61.924236 64.855218 -4.219311 9.354655 24.876486
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -1.933779 -14.034919 -33.710470 -23.797237 -21.602256
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 43.262347 -9.463780 -39.499641 -10.654658 21.827372
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.303152 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 27.722355 -49.030626 3.766531 4.538944 -18.324494
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -6.969313 -8.083622 -48.211538 -10.064245 -13.469753
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -65.470075 -17.458701 -29.769120 11.596196 -8.886055
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 1.182226 0.0 31.618308 -57.544313 -5.506573 -15.395313 5.716787
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 37.282532 -48.088288 -35.407980 -3.379317 3.044111
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -22.014042 -18.559749 -26.713549 28.344150 -5.900785
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 129.614122 33.861676 -34.204005 -17.137463 -11.180545
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 13.288417 32.542834 -68.918824 3.522467 1.844989
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.148420 1.148420 ... 0.0 0.0 0.0 0.000000 0.0 72.448225 -65.687480 -26.380419 -6.631345 9.684851
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.613918 ... 0.0 0.0 0.0 0.000000 0.0 -13.080983 -7.620847 12.202455 -1.406390 9.457061
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 5.332828 -50.684682 -24.524436 -18.740487 -0.198397
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 1.088820 ... 0.0 0.0 0.0 0.000000 0.0 54.219775 -14.290547 6.626765 -19.189480 -19.194530
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 1.515816 ... 0.0 0.0 0.0 0.000000 0.0 -53.779653 -19.572461 -37.961896 -13.173462 -6.572958
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -28.258746 35.284907 -76.988650 11.723466 10.204721
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 1.055041 ... 0.0 0.0 0.0 0.000000 0.0 -38.799659 -36.918959 -18.781573 0.538416 -12.048628
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.800982 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -19.936131 -22.021039 -20.092318 -0.046374 -4.926983
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.435595 ... 0.0 0.0 0.0 0.000000 0.0 176.334617 1.615435 40.817789 -35.768453 17.348594
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -65.256466 -73.754467 14.597707 -9.680502 -18.015941
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 12.249147 -26.680102 70.579518 0.998247 64.791072
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -81.861563 -40.134792 -47.339517 -2.817016 6.163513
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -48.207051 3.456303 -58.299460 2.436432 1.858663
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 2.471864 ... 0.0 0.0 0.0 0.000000 0.0 -22.077094 -35.681554 -19.450048 -20.940343 -5.765403
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 1.063556 ... 0.0 0.0 0.0 0.000000 0.0 -74.500247 -40.545101 4.969477 -20.099384 8.810580
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.944245 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 511.499053 -87.180696 98.475103 128.068970 -56.918816
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -15.115928 -29.197537 -1.075098 15.712224 -9.319003
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 66.982611 75.442707 15.710664 30.495681 17.508643
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -49.845202 -18.051825 22.862420 5.318756 -13.801937
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 1.089101 0.0 7.427699 -63.070808 21.927986 -28.047049 -18.453114
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -36.206380 -84.863729 56.669380 157.418954 36.508416
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -21.225527 37.477337 24.160792 -7.557950 2.916248
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -21.280816 15.268987 33.954124 5.587206 -11.573837
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -18.721926 1.505921 4.726854 -16.272760 17.389087
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -19.272302 -2.955892 -22.327368 25.582159 -2.210682
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 86.104412 76.517491 -72.376718 10.826177 8.806199
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.916341 ... 0.0 0.0 0.0 0.000000 0.0 -44.568784 36.477049 26.232177 16.220796 -11.223694
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.702014 ... 0.0 0.0 0.0 0.000000 0.0 -34.995797 -11.669021 58.648147 17.520154 -18.850449
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -0.106695 134.169609 17.754414 41.144718 -21.191051
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.854162 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -17.727680 -8.986490 -3.905240 0.633668 6.845743
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 1.272864 ... 0.0 0.0 0.0 0.000000 0.0 -2.842862 -6.216062 -10.028895 29.625628 3.914262
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 50.215616 53.356398 56.792168 31.928692 9.050539
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -8.584209 -34.994540 44.747456 -17.010822 2.402486
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -66.004018 22.208045 5.539712 29.725609 -10.258114
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.862725 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -64.468221 -44.896189 -32.484424 27.112561 -1.459941
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -20.013795 -1.048727 -16.826925 -6.793904 -7.645179
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.314526 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -30.846271 -24.124713 24.000714 -18.617051 -12.752303
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 1.159472 ... 0.0 0.0 0.0 0.000000 0.0 -70.047575 -71.775906 26.423747 112.309016 53.422713
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 1.503387 ... 0.0 0.0 0.0 0.000000 0.0 26.809455 177.421965 21.745513 5.867462 -29.000994
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -25.086318 63.144835 14.817744 -11.907078 4.389294
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -14.610205 -0.909161 -24.167663 -11.382486 6.600433
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -72.876490 -2.481705 5.192598 -7.107912 -0.654718
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -4.060181 -50.866229 33.022061 41.260449 -2.771602
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -19.337961 -53.443358 -8.218221 -4.400894 1.356182
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.686472 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 0.268278 37.733105 18.239846 13.940413 -15.903046
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 ... 0.0 0.0 0.0 0.000000 0.0 -38.401332 14.875271 -10.395433 48.360160 13.189225

7523 rows × 28914 columns


In [48]:
gs = gridspec.GridSpec(2,2)
fig = plt.figure(figsize=[15, 12])
genes = ['CDH1', 'VIM', 'EZH2', 'ZEB1']
for i in range(len(genes)):
    ax = fig.add_subplot(gs[i//2, i%2])
    scanalysis.plots.plot.scatter_gene_expression(x1, genes=['PC2', 'PC3'], color=genes[i], fig=fig, ax=ax)


PC2 vs PC3 colored by CDH1, VIM, FN1 and ZEB1 (after MAGIC):


In [49]:
x2 = pd.concat([new_data, temp], axis=1)
x2


Out[49]:
MAGIC SRRM1 MAGIC ZFP106 MAGIC TAB2 MAGIC TXNRD2 MAGIC GRINL1A MAGIC SSRP1 MAGIC EPDR1 MAGIC GPX4 MAGIC ALOX5AP MAGIC CDK5R1 ... MAGIC BC024571 MAGIC SCNN1A MAGIC CBR1 MAGIC GTF2I MAGIC AK153575 PC1 PC2 PC3 PC4 PC5
W29956 4.801985 3.530075 1.648740 0.992195 4.529602 5.014837 0.461926 2.491495 2.253145 0.149126 ... 1.688175 0.095502 2.086086 5.306369 2.136134 0.074972 -0.191587 -0.119149 -0.217170 0.113008
W30018 4.338214 3.208445 1.481532 0.809141 4.483518 5.080472 0.115917 2.199057 2.669890 0.155532 ... 1.239677 0.187815 1.393686 4.971366 1.195740 0.000558 -0.204520 -0.148149 -0.213746 0.118565
W30161 4.858542 3.670900 1.280465 1.242986 3.883307 4.051857 1.173168 3.127940 1.267661 0.096227 ... 2.153646 0.075997 3.374529 5.348307 3.242772 0.176868 -0.184069 -0.175023 -0.358310 0.148426
W30203 4.107018 2.877348 1.328850 0.814980 4.800919 4.568226 0.115948 2.389170 2.666896 0.158439 ... 1.223220 0.148050 1.477352 5.142973 1.263993 0.023297 -0.274966 -0.132949 -0.240905 0.108025
W30258 3.165111 2.172156 0.804392 0.829582 5.469828 3.111920 0.088105 2.884060 2.335797 0.204067 ... 0.945664 0.082772 1.329192 5.653724 0.912743 0.081680 -0.316567 -0.243547 -0.303318 -0.050524
W30296 4.125229 3.435906 1.162895 0.794324 3.900441 4.924124 0.092786 1.951360 2.347056 0.262198 ... 1.178331 0.320476 1.081428 4.726392 0.707014 -0.251958 -0.260204 -0.255429 -0.243747 0.176038
W30301 2.855687 1.905425 0.584090 0.714719 5.306994 2.772569 0.016138 3.116379 2.176219 0.222153 ... 0.763936 0.169240 1.379154 5.643254 0.613796 -0.078236 -0.393959 -0.366573 -0.222263 0.051706
W30306 3.055897 2.102612 0.746126 0.763285 5.412404 3.091041 0.027277 2.900770 2.336990 0.218176 ... 0.858503 0.121842 1.273520 5.594770 0.759332 -0.007170 -0.358824 -0.202952 -0.246437 -0.010374
W31106 4.385124 3.986690 1.262665 0.771134 3.514035 5.515064 0.114271 1.587346 2.156801 0.363485 ... 1.257062 0.370707 0.957675 4.566221 0.548253 -0.315401 -0.136304 -0.122165 -0.191190 0.099055
W31108 4.729937 4.561610 1.440850 0.869150 3.547243 6.039922 0.116604 1.614918 1.939964 0.374238 ... 1.187109 0.349102 0.981581 4.771396 0.535615 -0.315221 -0.066132 -0.091635 -0.129344 0.091457
W31110 4.493501 4.078750 1.382644 0.909863 3.659241 5.668125 0.110288 1.779980 2.046445 0.295433 ... 1.184108 0.337175 0.988405 4.714317 0.611846 -0.262880 -0.142433 -0.067186 -0.186542 0.139203
W31117 4.451791 3.600302 1.607837 0.866171 4.081092 5.322680 0.142837 2.068140 2.537083 0.170741 ... 1.328236 0.245698 1.376168 4.794000 1.158785 -0.079540 -0.162672 -0.098603 -0.233542 0.199879
W31118 4.660136 4.285859 1.488413 0.927503 3.680031 5.911555 0.105098 1.802424 1.996860 0.260456 ... 1.152836 0.317138 1.044968 4.734462 0.701793 -0.201986 -0.180735 -0.084839 -0.149947 0.112470
W31119 4.849783 3.621344 1.808124 0.868469 4.529530 5.907453 0.127602 2.217844 2.522330 0.163866 ... 1.297984 0.127403 1.555652 5.192125 1.302590 -0.008532 -0.167895 -0.030464 -0.138028 0.112988
W31129 5.114409 3.852391 1.763432 1.083224 4.413077 5.252056 0.619080 2.545346 2.006458 0.155604 ... 1.842792 0.077247 2.300699 5.379710 2.455053 0.062913 -0.076580 -0.040238 -0.187158 0.101694
W31130 4.418688 3.928348 1.208538 0.725245 3.493270 5.543225 0.110576 1.554438 2.085683 0.432769 ... 1.314767 0.391708 0.920702 4.588368 0.459259 -0.371833 -0.081909 -0.116348 -0.205981 0.100128
W31131 4.403229 4.057522 1.265929 0.768419 3.521924 5.578181 0.115343 1.577438 2.144267 0.370784 ... 1.262527 0.365640 0.985652 4.642111 0.561081 -0.308209 -0.139729 -0.185469 -0.178805 0.151881
W31141 4.566921 3.393187 1.631594 0.825730 4.473364 5.625495 0.100734 2.217028 2.569297 0.157191 ... 1.193561 0.168851 1.371646 5.019216 1.122500 -0.049650 -0.226463 -0.053255 -0.175789 0.076807
W31145 4.404794 3.920018 1.141819 0.695895 3.450630 5.510789 0.105470 1.579689 2.078168 0.464871 ... 1.321457 0.386406 0.970277 4.643074 0.501291 -0.398236 -0.117102 -0.149534 -0.208948 0.110857
W31148 4.481889 4.065547 1.366800 0.844638 3.556177 5.759322 0.109271 1.672189 2.128595 0.264067 ... 1.136576 0.331282 0.954236 4.512356 0.630488 -0.216362 -0.152339 -0.098606 -0.156877 0.073144
W31152 4.511299 4.029540 1.429865 0.892000 3.608188 5.755149 0.101455 1.743971 2.122922 0.246744 ... 1.104929 0.322952 0.932654 4.506942 0.648563 -0.192317 -0.116961 -0.067928 -0.192260 0.058923
W31157 4.761755 3.392871 1.703737 1.002217 4.571122 5.172586 0.241018 2.312268 2.633674 0.142865 ... 1.552364 0.080660 1.972486 5.460866 1.914718 0.074770 -0.198166 0.000690 -0.242112 0.039217
W31158 4.421860 4.082618 1.311472 0.809276 3.546770 5.621303 0.117902 1.608724 2.111374 0.348999 ... 1.239342 0.362508 0.985802 4.655338 0.581613 -0.309214 -0.122283 -0.129975 -0.160024 0.156441
W31160 4.899961 4.272915 1.716637 0.922476 3.928222 6.332259 0.094124 1.961171 2.051302 0.220637 ... 1.130669 0.231984 1.147279 4.865141 0.862335 -0.092839 -0.114620 -0.005318 -0.084954 0.024925
W31164 4.392396 3.991564 1.246239 0.747636 3.485607 5.542437 0.111939 1.550185 2.135962 0.379032 ... 1.267333 0.380947 0.939056 4.534051 0.517366 -0.327143 -0.102492 -0.128637 -0.195083 0.076230
W31166 4.538677 3.804297 1.523499 0.842478 3.903309 5.811562 0.101111 1.918311 2.303830 0.197327 ... 1.135936 0.257898 1.099105 4.699476 0.856689 -0.091803 -0.153907 -0.096720 -0.139918 0.077307
W31168 4.811920 4.332877 1.710362 0.955700 3.716028 6.262897 0.095379 1.874916 1.967109 0.232453 ... 1.066709 0.266939 1.008784 4.724316 0.775036 -0.151018 -0.118654 -0.034133 -0.113026 0.052029
W31169 4.783216 4.241201 1.638034 0.951855 3.790100 6.197728 0.075253 1.922319 1.987414 0.221272 ... 1.053420 0.264766 1.000990 4.737288 0.751206 -0.183225 -0.185913 -0.028330 -0.127292 0.013725
W31170 4.770470 4.575934 1.526887 0.919539 3.564452 6.096497 0.110739 1.669294 1.913331 0.310892 ... 1.129719 0.330388 0.974194 4.692079 0.590530 -0.258172 -0.089286 -0.087331 -0.152294 0.061346
W31174 4.904189 3.503653 1.824600 0.980638 4.569418 5.598143 0.215965 2.328584 2.551419 0.152869 ... 1.520343 0.072371 1.916268 5.477192 1.837209 0.079853 -0.183540 0.038536 -0.191599 0.016784
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
W75961 4.934462 3.733032 1.442882 1.278638 3.963676 4.065864 1.072697 2.997085 1.487420 0.102463 ... 2.338334 0.065187 3.220355 5.484690 3.453026 0.143518 -0.178122 -0.079127 -0.343875 0.053883
W75964 4.229072 3.359049 0.949617 0.780777 3.887025 4.783939 0.099301 2.032448 2.125858 0.376487 ... 1.280767 0.314092 1.032325 4.900530 0.463677 -0.383608 -0.232827 -0.245786 -0.286904 -0.049391
W75965 6.258612 3.963620 0.689623 2.582849 4.486363 5.542431 1.372133 3.762976 0.248378 0.065116 ... 0.570741 0.061619 3.099951 3.905245 0.747943 0.119254 -0.153970 -0.204631 -0.149539 -0.065836
W75966 4.250509 3.132517 0.847259 0.833025 2.717521 5.630481 0.124068 1.225029 1.778148 0.916365 ... 1.265370 1.132986 0.678204 3.083418 0.458368 -0.533693 0.001531 -0.079221 -0.412563 -0.047241
W75968 4.495009 3.901594 1.299712 0.865436 3.677418 5.460678 0.106316 1.785275 2.122724 0.315171 ... 1.187622 0.350623 0.939517 4.603794 0.537241 -0.265032 -0.108726 -0.136416 -0.220631 -0.042457
W75969 5.056263 3.889850 1.439033 1.269507 3.991414 4.179282 1.181452 3.039068 1.298436 0.105944 ... 2.273210 0.060334 3.223567 5.458214 3.334689 0.128785 -0.160435 -0.098864 -0.302925 0.062069
W75974 4.462342 3.614040 0.813314 0.716991 3.037232 5.366092 0.074158 1.565214 1.716255 0.856628 ... 1.351743 0.643195 0.991764 4.114110 0.528404 -0.545333 -0.093372 -0.145886 -0.354418 0.058514
W75977 4.495742 3.691720 0.989343 0.701837 3.365968 5.447854 0.109750 1.619244 1.954076 0.557472 ... 1.366452 0.475824 0.941374 4.519087 0.407475 -0.438285 -0.075081 -0.141206 -0.280684 0.044811
W75993 6.296532 3.886278 0.678496 2.765843 4.271711 5.570573 1.427973 4.008422 0.126688 0.059484 ... 0.486734 0.045967 3.130980 3.607552 0.588676 0.135986 -0.093014 -0.252953 -0.121510 -0.061485
W75996 3.021015 2.056308 0.749283 0.778685 5.491075 3.023122 0.034941 2.951414 2.341813 0.210610 ... 0.851902 0.092808 1.237879 5.681939 0.773270 0.077856 -0.399990 -0.238128 -0.302389 -0.037794
W76001 4.708018 3.389442 1.638670 0.976358 4.650206 5.185714 0.293462 2.450872 2.440093 0.147976 ... 1.478485 0.108062 1.828495 5.235240 1.642405 0.021207 -0.194734 -0.080043 -0.204582 -0.009732
W76042 4.471151 3.714314 1.124525 0.805755 3.677559 5.235223 0.119030 1.781709 2.118309 0.384949 ... 1.309863 0.339445 0.971017 4.739324 0.463510 -0.327376 -0.166252 -0.130432 -0.232220 -0.054687
W76054 4.316517 3.789437 1.462200 0.927097 3.721749 5.537386 0.090764 1.801097 2.201430 0.225351 ... 1.141002 0.340996 0.963776 4.566442 0.699363 -0.153970 -0.103869 -0.092999 -0.243854 0.128617
W76062 5.146877 3.890124 1.156050 1.402305 3.995903 4.225873 1.358219 3.293680 0.737882 0.086196 ... 1.809989 0.048084 3.286785 5.022312 2.611797 0.200385 -0.107001 -0.205234 -0.284903 0.118201
W76063 4.523411 3.669544 1.035487 0.737257 3.484359 5.320847 0.125215 1.675288 2.048886 0.484090 ... 1.380279 0.433403 0.939236 4.592402 0.415045 -0.378431 -0.149077 -0.164297 -0.324677 -0.090739
W76070 6.164820 4.283816 0.771836 2.404642 4.048335 5.340201 1.440033 3.919793 0.139993 0.047896 ... 0.701293 0.026671 3.129673 3.878473 0.924522 0.151230 -0.025981 -0.191692 -0.167314 0.047034
W76071 2.804352 1.778130 0.750726 0.754286 5.448479 2.767145 0.051504 3.404285 2.170132 0.198275 ... 0.731321 0.085861 1.316733 5.745535 0.613204 0.119067 -0.367058 -0.219214 -0.233148 -0.056782
W76089 3.424103 2.401314 0.735598 0.748589 4.847105 3.645902 0.027192 2.793183 2.308340 0.199769 ... 0.848505 0.237415 1.156091 5.226440 0.664002 -0.187871 -0.271531 -0.117919 -0.186741 -0.089855
W76149 6.094729 3.586827 0.678870 2.699334 3.932871 5.250521 1.508781 4.334744 0.107232 0.063789 ... 0.624280 0.016478 3.244647 3.295326 0.666452 0.161075 -0.171116 -0.305801 -0.208826 -0.112335
W76150 3.617510 2.599444 0.875290 0.762908 4.769036 3.920131 0.039096 2.543075 2.411327 0.197426 ... 0.932161 0.227440 1.106275 5.124185 0.746872 -0.142603 -0.193159 -0.135312 -0.205480 -0.111147
W76151 6.320898 4.014021 0.725441 2.669896 4.188429 5.491387 1.482429 3.992086 0.132817 0.057260 ... 0.575293 0.033632 3.119799 3.597222 0.691258 0.129532 -0.090461 -0.233146 -0.127430 -0.034884
W76159 3.176048 2.163950 0.807624 0.841932 5.587965 3.135776 0.062289 2.780673 2.415087 0.197148 ... 0.908638 0.070088 1.266798 5.592569 0.927407 0.117746 -0.378393 -0.212504 -0.368926 -0.108447
W76160 4.141298 3.371814 1.142808 0.830679 3.993572 4.855940 0.082882 2.058933 2.327528 0.242454 ... 1.150175 0.311241 1.066715 4.746729 0.673625 -0.215761 -0.188929 -0.187230 -0.250634 0.071493
W76170 2.994853 2.005870 0.581855 0.709328 5.294301 2.889371 0.011700 2.905963 2.249005 0.211237 ... 0.780924 0.171915 1.280328 5.586930 0.668142 -0.064978 -0.364881 -0.280952 -0.301063 -0.024388
W76185 4.394842 3.586530 0.994818 0.731065 3.645715 5.150421 0.106775 1.800767 2.071368 0.458838 ... 1.364507 0.353742 0.988804 4.789750 0.430579 -0.389787 -0.150857 -0.221838 -0.261820 0.005326
W76187 2.958585 2.008390 0.671557 0.751909 5.432503 2.897030 0.022008 2.951940 2.272618 0.220298 ... 0.812124 0.120393 1.284752 5.685136 0.711473 0.006214 -0.361512 -0.265602 -0.285895 -0.068786
W76226 3.253582 2.204377 0.578515 0.714423 4.872696 3.221210 0.026419 2.846029 2.251823 0.208434 ... 0.837645 0.255283 1.241677 5.268554 0.573973 -0.255452 -0.292642 -0.266366 -0.343037 -0.059360
W76255 3.214747 2.208159 0.793890 0.794504 5.463594 3.249851 0.049834 2.793501 2.425038 0.203476 ... 0.920120 0.095420 1.205288 5.594164 0.874356 0.029574 -0.325417 -0.168947 -0.255977 -0.071485
W76282 2.854438 1.885495 0.593446 0.721668 5.339084 2.729788 0.017152 3.093325 2.152539 0.224318 ... 0.759759 0.150962 1.381321 5.719003 0.609771 -0.054350 -0.366014 -0.288383 -0.200739 -0.019090
W76331 3.190292 2.177003 0.817208 0.828428 5.569050 3.192713 0.048199 2.767698 2.449908 0.198195 ... 0.911364 0.076885 1.216715 5.588662 0.892585 0.062850 -0.287189 -0.163459 -0.309412 -0.053321

4423 rows × 2317 columns


In [50]:
gs = gridspec.GridSpec(2,2)
fig = plt.figure(figsize=[15, 12])
genes = ['MAGIC SRRM1', 'MAGIC TAB2', 'MAGIC CBR1', 'MAGIC GPX4']
for i in range(len(genes)):
    ax = fig.add_subplot(gs[i//2, i%2])
    scanalysis.plots.plot.scatter_gene_expression(x2, genes=['PC2', 'PC3'], color=genes[i], fig=fig, ax=ax)


The second plot below is for the data set used in the original MAGIC notebook.


In [51]:
x3 = pd.concat([new_m_data, pca1], axis=1)

In [52]:
gs = gridspec.GridSpec(2,2)
fig = plt.figure(figsize=[15, 12])
genes = ['MAGIC CDH1', 'MAGIC VIM', 'MAGIC EZH2', 'MAGIC ZEB1']
for i in range(len(genes)):
    ax = fig.add_subplot(gs[i//2, i%2])
    scanalysis.plots.plot.scatter_gene_expression(x3, genes=['PC2', 'PC3'], color=genes[i], fig=fig, ax=ax)


tSNE scatter plots

tSNE maps colored by CDH1, VIM, FN1, and ZEB1 (before MAGIC):


In [53]:
fig, ax = scanalysis.plots.plot.plot_gene_expression(data=data, tsne=d, genes=['SRRM1', 'TAB2', 'CBR1', 'GPX4'])


<matplotlib.figure.Figure at 0x11f4dd2b0>

The second plot below is for the data set used in the original MAGIC notebook.


In [54]:
t1 = scanalysis.utils.tsne.TSNE()
d1 = t1.fit_transform(pca1)

In [55]:
fig, ax = scanalysis.plots.plot.plot_gene_expression(data=m_data, tsne=d1, genes=['CDH1', 'VIM', 'EZH2', 'ZEB1'])


<matplotlib.figure.Figure at 0x11f864cf8>

tSNE maps colored by CDH1, VIM, FN1, and ZEB1 (after MAGIC):


In [56]:
fig, ax = scanalysis.plots.plot.plot_gene_expression(data=new_data, tsne=d, genes=['MAGIC SRRM1', 'MAGIC TAB2', 'MAGIC CBR1', 'MAGIC GPX4'])


<matplotlib.figure.Figure at 0x11f935d30>

The second plot below is for the data set used in the original MAGIC notebook.


In [57]:
fig, ax = scanalysis.plots.plot.plot_gene_expression(data=new_m_data, tsne=d1, genes=['MAGIC CDH1', 'MAGIC VIM', 'MAGIC EZH2', 'MAGIC ZEB1'])


<matplotlib.figure.Figure at 0x120cefc88>

Saving figures

You can save a figure as a png file using "savefig" as shown below.


In [58]:
scanalysis.plots.plot.savefig(fig, 'h')

Running Palantir

First, load the pickle file with the data. The data is normalized and log transformed.


In [2]:
import scanalysis

In [3]:
mb_data = scanalysis.io.loadsave.load("~/mb_data.p")


Successfully loaded /Users/hjin/mb_data.p as a <class 'pandas.core.frame.DataFrame'> object

In [4]:
import pandas as pd
import numpy as np

We need the data to be in cells x genes format (index x columns), so in this case we will switch the rows and columns to achieve this.


In [5]:
mb_data = pd.DataFrame.transpose(mb_data)

In [5]:
mb_data


Out[5]:
KCTD15 STT3B NAT6 FHL2 SP140L DOCK9 CENPN NEDD9 HIST1H2AM TEK ... ZNF543 SGTB EEF1A1 TSPAN33 DNAJC4 SAG FARP1 EXTL2 ZDHHC17 GOLPH3
Run4_120703408880541 -3.321928 -3.321928 -3.321928 0.171306 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.448183 -3.321928 1.105781 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120703409056541 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.536806 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120703409580963 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 5.660550 -3.321928 1.840569 -3.321928 -3.321928 -3.321928 0.880299 0.880299
Run4_120703423990708 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.120207 -3.321928 0.574557 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120703424252854 -3.321928 -0.365265 -3.321928 -3.321928 -3.321928 -3.321928 -0.365265 -3.321928 -0.365265 -3.321928 ... -3.321928 -3.321928 6.740922 -3.321928 -3.321928 -3.321928 -3.321928 0.538690 -3.321928 -0.365265
Run4_120703436876077 -3.321928 -3.321928 0.363786 0.363786 0.363786 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.833304 -3.321928 1.306611 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120703455025387 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -0.270688 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.987921 -0.270688 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120726911638237 -3.321928 0.918170 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -0.521655 -3.321928 ... -3.321928 -3.321928 6.682439 -3.321928 -0.521655 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120726912355038 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.426178 -3.321928 -0.098613 -3.321928 -3.321928 -0.098613 -3.321928 -3.321928
Run4_120726924974443 -3.321928 -0.910988 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -0.910988 -3.321928 -3.321928 ... -3.321928 -3.321928 6.795428 -3.321928 -3.321928 -3.321928 -3.321928 -0.910988 -0.910988 -0.910988
Run4_120726924978030 -3.321928 -0.369327 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.432798 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120726943295348 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.077957 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120726943845302 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 0.293697 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 5.817339 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120772961130853 -3.321928 -3.321928 -3.321928 0.282395 -3.321928 0.282395 -3.321928 0.282395 -3.321928 -3.321928 ... -3.321928 -3.321928 6.729827 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120786758780660 -3.321928 -3.321928 0.047722 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.797041 0.047722 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 0.047722
Run4_120786786086116 -3.321928 0.245224 0.245224 -3.321928 0.245224 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.579004 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120786804205803 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -0.443817 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.465827 -3.321928 -3.321928 -3.321928 -3.321928 -0.443817 -3.321928 -3.321928
Run4_120786804401973 -3.321928 -3.321928 -0.212571 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.820481 -3.321928 0.701323 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120797898099934 -3.321928 -0.736818 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.162065 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120797925428019 -3.321928 0.810766 -0.109248 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -0.109248 -3.321928 6.681686 -3.321928 -0.109248 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120797944278244 -3.321928 -3.321928 -3.321928 0.319141 -3.321928 -3.321928 -0.569621 -3.321928 -3.321928 -3.321928 ... -0.569621 -3.321928 6.858059 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 0.319141 -3.321928
Run4_120797944309486 -3.321928 -0.597133 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.948771 -3.321928 -0.597133 -3.321928 -3.321928 -3.321928 -3.321928 -0.597133
Run4_120797944462237 -3.321928 1.583616 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 7.016901 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120797944538971 -3.321928 -3.321928 0.106350 1.037736 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 7.011207 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 0.106350
Run4_120797945084765 -3.321928 1.128506 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.734742 -3.321928 1.128506 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120864497952619 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 5.509805 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_121202296155437 -0.803194 -0.803194 -0.803194 0.065101 -0.803194 -3.321928 -0.803194 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.663044 -3.321928 -0.803194 -3.321928 -3.321928 -3.321928 -0.803194 0.065101
Run4_121202296712412 -3.321928 0.731223 -3.321928 -3.321928 -3.321928 -3.321928 0.731223 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.001394 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_121202296875939 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.988487 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 0.624661
Run4_121202311609131 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.575155 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
Run5_240634599983342 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.541875 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_240634599986987 0.702973 0.702973 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 7.022010 -3.321928 -3.321928 -3.321928 -3.321928 0.702973 -3.321928 -3.321928
Run5_240634613909861 -3.321928 0.388657 -3.321928 -0.505150 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.405009 -3.321928 -0.505150 -3.321928 -3.321928 -3.321928 -0.505150 -0.505150
Run5_240634614373595 -3.321928 -0.022172 -0.022172 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.566330 -3.321928 -3.321928 -3.321928 -3.321928 -0.022172 -3.321928 -3.321928
Run5_240634614729955 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.101873 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_240634626784550 -3.321928 -3.321928 -3.321928 1.289575 -3.321928 -3.321928 -3.321928 -3.321928 -0.181935 -3.321928 ... -3.321928 -3.321928 6.318588 -3.321928 -0.181935 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_240634645855022 -3.321928 -0.151090 -3.321928 -3.321928 -0.151090 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.735736 -3.321928 -0.151090 -3.321928 -3.321928 -0.151090 -3.321928 -0.151090
Run5_240634646116662 -3.321928 -3.321928 -3.321928 0.543496 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 7.071382 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 0.543496
Run5_241057653508843 -3.321928 -3.321928 0.102278 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.795394 -3.321928 0.102278 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241057653738918 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.066499 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241057654294885 -3.321928 0.719076 0.719076 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 7.039148 -3.321928 0.719076 -3.321928 -3.321928 -3.321928 0.719076 0.719076
Run5_241057668712349 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.792638 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 0.731223
Run5_241057680972510 -3.321928 -3.321928 0.131881 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.827974 -3.321928 0.131881 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241057681259245 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.907769 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241057700113179 -3.321928 0.200470 -3.321928 -3.321928 0.200470 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 0.200470 6.685227 -3.321928 1.136287 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241098858613659 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.523592 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241098858810213 -3.321928 0.910984 -0.014261 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.588530 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241098873552118 -3.321928 0.099779 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.451950 -3.321928 -3.321928 -3.321928 -3.321928 0.099779 -3.321928 0.099779
Run5_241098885647774 -3.321928 -3.321928 -3.321928 1.098178 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.364817 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241098904976174 -0.080268 -0.080268 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.939614 -0.080268 -0.080268 -3.321928 -3.321928 -3.321928 -3.321928 -0.080268
Run5_241098905205038 -3.321928 -3.321928 -3.321928 0.590031 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.375239 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241106375007076 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -0.487455 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.425585 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241106389756316 -3.321928 1.671793 -3.321928 -3.321928 -3.321928 -3.321928 -0.198384 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.593066 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241106389784372 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.666589 -3.321928 -3.321928 -3.321928 -3.321928 -0.212452 -3.321928 -3.321928
Run5_241106401770805 -3.321928 1.560339 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.747132 0.070037 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241114577000174 -3.321928 -0.230532 -1.070481 -3.321928 -1.070481 -3.321928 -1.070481 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.651551 -1.070481 -1.070481 -3.321928 -3.321928 -3.321928 -3.321928 -0.230532
Run5_241114577004764 -3.321928 -3.321928 -3.321928 -3.321928 -0.463470 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 0.433472 6.741683 -3.321928 -0.463470 -3.321928 -3.321928 -3.321928 -3.321928 0.433472
Run5_241114589051630 -0.840674 -3.321928 -3.321928 0.951237 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.610811 -3.321928 -3.321928 -3.321928 -3.321928 -0.840674 -3.321928 -3.321928
Run5_241114589051819 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 0.901317 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.656252 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241114589128940 -3.321928 -0.398169 -3.321928 -0.398169 -3.321928 -3.321928 0.503493 -3.321928 -3.321928 -3.321928 ... -3.321928 -3.321928 6.518473 -3.321928 0.503493 -3.321928 -3.321928 -3.321928 -3.321928 -0.398169

4714 rows × 16209 columns


In [6]:
DMEigVals = scanalysis.io.loadsave.load("~/palantir/dm_eig_vals.csv")


Successfully loaded /Users/hjin/palantir/dm_eig_vals.csv as a pd.DataFrame object

In [7]:
DMEigs = scanalysis.io.loadsave.load("~/palantir/dm_eigs.csv")


Successfully loaded /Users/hjin/palantir/dm_eigs.csv as a pd.DataFrame object

Note: the run_multibranch function takes ~10 minutes.

Use the following parameters when running run_multibranch for this particular data set:

  • start_cell: Run5_126835192163230
  • num_waypoints: 300
  • flock = 0

In [8]:
der = scanalysis.tools.pr.palantir.run_multibranch(data_ = mb_data, DMEigs = DMEigs, DMEigVals = DMEigVals, dm_eigs = [1,2,3], start_cell="Run5_126835192163230", num_waypoints = 300, flock = 0)


Sampling and flocking waypoints...
Time for determining waypoints: 0.0019352833429972331 minutes
Shortest path distances...
Time for shortest paths: 7.113125201066335 minutes
Determining perspectives, trajectory...
Correlation at iteration 1: 1.0000
Determining terminal states...
Entropy and branch probabilities...
Markov chain construction...
Computing fundamental matrix and absorption probabilities...
Project results to all cells...
/usr/local/lib/python3.6/site-packages/scanalysis/tools/pr/palantir.py:163: ClusterWarning: scipy.cluster: The symmetric non-negative hollow observation matrix looks suspiciously like an uncondensed distance matrix
  Z = hierarchy.linkage(pairwise_distances(data.loc[cells,:]))
/usr/local/lib/python3.6/site-packages/scipy/sparse/compressed.py:774: SparseEfficiencyWarning: Changing the sparsity structure of a csr_matrix is expensive. lil_matrix is more efficient.
  SparseEfficiencyWarning)

In [9]:
der.entropy


Out[9]:
Run4_120703408880541    0.000774
Run4_120703409056541    0.393889
Run4_120703409580963    0.042169
Run4_120703423990708    0.042173
Run4_120703424252854    0.008200
Run4_120703436876077    0.333471
Run4_120703455025387    0.039332
Run4_120726911638237    0.026509
Run4_120726912355038    0.101492
Run4_120726924974443    0.063163
Run4_120726924978030    0.188080
Run4_120726943295348    0.042169
Run4_120726943845302    0.042132
Run4_120772961130853    0.307581
Run4_120786758780660    0.322896
Run4_120786786086116    0.388644
Run4_120786804205803    0.024522
Run4_120786804401973    0.112543
Run4_120797898099934    0.029274
Run4_120797925428019    0.183669
Run4_120797944278244    0.000259
Run4_120797944309486    0.001234
Run4_120797944462237    0.222543
Run4_120797944538971    0.033698
Run4_120797945084765    0.329432
Run4_120864497952619    0.003331
Run4_121202296155437    0.000115
Run4_121202296712412    0.008246
Run4_121202296875939    0.395576
Run4_121202311609131    0.042183
                          ...   
Run5_240634599983342    0.043782
Run5_240634599986987    0.394045
Run5_240634613909861    0.000006
Run5_240634614373595    0.066328
Run5_240634614729955    0.042173
Run5_240634626784550    0.000170
Run5_240634645855022    0.000236
Run5_240634646116662    0.394514
Run5_241057653508843    0.192886
Run5_241057653738918    0.042204
Run5_241057654294885    0.393926
Run5_241057668712349    0.393729
Run5_241057680972510    0.114760
Run5_241057681259245    0.267546
Run5_241057700113179    0.208576
Run5_241098858613659    0.394126
Run5_241098858810213    0.369379
Run5_241098873552118    0.151911
Run5_241098885647774    0.000097
Run5_241098904976174    0.208672
Run5_241098905205038    0.042793
Run5_241106375007076    0.000033
Run5_241106389756316    0.010549
Run5_241106389784372    0.036193
Run5_241106401770805    0.013081
Run5_241114577000174    0.199644
Run5_241114577004764    0.031536
Run5_241114589051630    0.000007
Run5_241114589051819    0.053343
Run5_241114589128940    0.687691
Length: 4714, dtype: float64

In [18]:
der.branch_prob


Out[18]:
Run4_235626713532342 Run5_239477254471070
Run4_120703408880541 0.999863 0.000000
Run4_120703409056541 0.128067 0.871933
Run4_120703409580963 0.012602 0.987398
Run4_120703423990708 0.012603 0.987397
Run4_120703424252854 0.000000 0.999025
Run4_120703436876077 0.112057 0.887943
Run4_120703455025387 0.010688 0.989312
Run4_120726911638237 0.000000 0.993855
Run4_120726912355038 0.050348 0.949652
Run4_120726924974443 0.022975 0.977025
Run4_120726924978030 0.063607 0.936393
Run4_120726943295348 0.012602 0.987398
Run4_120726943845302 0.012620 0.987380
Run4_120772961130853 0.101962 0.898038
Run4_120786758780660 0.107130 0.892870
Run4_120786786086116 0.128038 0.871962
Run4_120786804205803 0.000000 0.994569
Run4_120786804401973 0.045300 0.954700
Run4_120797898099934 0.000000 0.991981
Run4_120797925428019 0.065013 0.934987
Run4_120797944278244 0.999958 0.000000
Run4_120797944309486 0.999802 0.000000
Run4_120797944462237 0.071747 0.928253
Run4_120797944538971 0.992283 0.000000
Run4_120797945084765 0.110174 0.889826
Run4_120864497952619 0.000000 0.999565
Run4_121202296155437 0.999985 0.000000
Run4_121202296712412 0.000000 0.999122
Run4_121202296875939 0.128183 0.871817
Run4_121202311609131 0.012606 0.987394
... ... ...
Run5_240634599983342 0.013192 0.986808
Run5_240634599986987 0.128076 0.871924
Run5_240634613909861 0.999999 0.000000
Run5_240634614373595 0.025380 0.974620
Run5_240634614729955 0.012603 0.987397
Run5_240634626784550 0.999977 0.000000
Run5_240634645855022 0.999963 0.000000
Run5_240634646116662 0.128181 0.871819
Run5_241057653508843 0.064838 0.935162
Run5_241057653738918 0.012612 0.987388
Run5_241057654294885 0.128069 0.871931
Run5_241057668712349 0.128055 0.871945
Run5_241057680972510 0.043250 0.956750
Run5_241057681259245 0.083386 0.916614
Run5_241057700113179 0.068107 0.931893
Run5_241098858613659 0.128133 0.871867
Run5_241098858810213 0.124479 0.875521
Run5_241098873552118 0.056441 0.943559
Run5_241098885647774 0.999987 0.000000
Run5_241098904976174 0.068359 0.931641
Run5_241098905205038 0.012756 0.987244
Run5_241106375007076 0.999995 0.000000
Run5_241106389756316 0.000000 0.998731
Run5_241106389784372 0.000000 0.990306
Run5_241106401770805 0.000000 0.998358
Run5_241114577000174 0.066504 0.933496
Run5_241114577004764 0.000000 0.991540
Run5_241114589051630 0.999999 0.000000
Run5_241114589051819 0.019835 0.980165
Run5_241114589128940 0.431048 0.568952

4714 rows × 2 columns

Compare trajectory results with the trajectory.csv file using a scatter plot...


In [10]:
atrajectory = scanalysis.io.loadsave.load("~/palantir/trajectory.csv")


Successfully loaded /Users/hjin/palantir/trajectory.csv as a pd.DataFrame object

In [16]:
import matplotlib.pyplot as plt
%matplotlib inline

In [11]:
plt.scatter(der.trajectory, atrajectory)


Out[11]:
<matplotlib.collections.PathCollection at 0x10ec32c88>

Plotting Palantir Results

Here, we will try the first five genes in the data matrix. You shouldn't plot all the markers because that will kill your computer.


In [12]:
mb_data_f5 = mb_data.iloc[:,0:5]

In [17]:
mb_data_f5


Out[17]:
KCTD15 STT3B NAT6 FHL2 SP140L
Run4_120703408880541 -3.321928 -3.321928 -3.321928 0.171306 -3.321928
Run4_120703409056541 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120703409580963 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120703423990708 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120703424252854 -3.321928 -0.365265 -3.321928 -3.321928 -3.321928
Run4_120703436876077 -3.321928 -3.321928 0.363786 0.363786 0.363786
Run4_120703455025387 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120726911638237 -3.321928 0.918170 -3.321928 -3.321928 -3.321928
Run4_120726912355038 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120726924974443 -3.321928 -0.910988 -3.321928 -3.321928 -3.321928
Run4_120726924978030 -3.321928 -0.369327 -3.321928 -3.321928 -3.321928
Run4_120726943295348 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120726943845302 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120772961130853 -3.321928 -3.321928 -3.321928 0.282395 -3.321928
Run4_120786758780660 -3.321928 -3.321928 0.047722 -3.321928 -3.321928
Run4_120786786086116 -3.321928 0.245224 0.245224 -3.321928 0.245224
Run4_120786804205803 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120786804401973 -3.321928 -3.321928 -0.212571 -3.321928 -3.321928
Run4_120797898099934 -3.321928 -0.736818 -3.321928 -3.321928 -3.321928
Run4_120797925428019 -3.321928 0.810766 -0.109248 -3.321928 -3.321928
Run4_120797944278244 -3.321928 -3.321928 -3.321928 0.319141 -3.321928
Run4_120797944309486 -3.321928 -0.597133 -3.321928 -3.321928 -3.321928
Run4_120797944462237 -3.321928 1.583616 -3.321928 -3.321928 -3.321928
Run4_120797944538971 -3.321928 -3.321928 0.106350 1.037736 -3.321928
Run4_120797945084765 -3.321928 1.128506 -3.321928 -3.321928 -3.321928
Run4_120864497952619 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_121202296155437 -0.803194 -0.803194 -0.803194 0.065101 -0.803194
Run4_121202296712412 -3.321928 0.731223 -3.321928 -3.321928 -3.321928
Run4_121202296875939 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run4_121202311609131 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
... ... ... ... ... ...
Run5_240634599983342 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_240634599986987 0.702973 0.702973 -3.321928 -3.321928 -3.321928
Run5_240634613909861 -3.321928 0.388657 -3.321928 -0.505150 -3.321928
Run5_240634614373595 -3.321928 -0.022172 -0.022172 -3.321928 -3.321928
Run5_240634614729955 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_240634626784550 -3.321928 -3.321928 -3.321928 1.289575 -3.321928
Run5_240634645855022 -3.321928 -0.151090 -3.321928 -3.321928 -0.151090
Run5_240634646116662 -3.321928 -3.321928 -3.321928 0.543496 -3.321928
Run5_241057653508843 -3.321928 -3.321928 0.102278 -3.321928 -3.321928
Run5_241057653738918 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241057654294885 -3.321928 0.719076 0.719076 -3.321928 -3.321928
Run5_241057668712349 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241057680972510 -3.321928 -3.321928 0.131881 -3.321928 -3.321928
Run5_241057681259245 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241057700113179 -3.321928 0.200470 -3.321928 -3.321928 0.200470
Run5_241098858613659 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241098858810213 -3.321928 0.910984 -0.014261 -3.321928 -3.321928
Run5_241098873552118 -3.321928 0.099779 -3.321928 -3.321928 -3.321928
Run5_241098885647774 -3.321928 -3.321928 -3.321928 1.098178 -3.321928
Run5_241098904976174 -0.080268 -0.080268 -3.321928 -3.321928 -3.321928
Run5_241098905205038 -3.321928 -3.321928 -3.321928 0.590031 -3.321928
Run5_241106375007076 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241106389756316 -3.321928 1.671793 -3.321928 -3.321928 -3.321928
Run5_241106389784372 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241106401770805 -3.321928 1.560339 -3.321928 -3.321928 -3.321928
Run5_241114577000174 -3.321928 -0.230532 -1.070481 -3.321928 -1.070481
Run5_241114577004764 -3.321928 -3.321928 -3.321928 -3.321928 -0.463470
Run5_241114589051630 -0.840674 -3.321928 -3.321928 0.951237 -3.321928
Run5_241114589051819 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_241114589128940 -3.321928 -0.398169 -3.321928 -0.398169 -3.321928

4714 rows × 5 columns

Run the plot_markers function to visualize results.

PROBLEM:

when compute_std parameter is set to True, results in ValueError, what seems to be happening is that the the program is trying to reshape the original array of 5 (which holds the trends) into array of dimensions 5x500, but it can't because there are only 5 elements in the original array. 500 is derived from the traj_bins instance variable, which was initialized according to the no_bins parameter. In reality, the trends array can only be reshaped into an array of 5x1 dimensions... so I was wondering, is the length of trends correct?


In [72]:
der.compute_marker_trends(mb_data_f5, der.branch_prob.columns, True, n_jobs=1)


Run4_235626713532342
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-72-02d7d3fccd10> in <module>()
----> 1 der.compute_marker_trends(mb_data_f5, der.branch_prob.columns, True, n_jobs=1)

/usr/local/lib/python3.6/site-packages/scanalysis/plots/pr_plot.py in compute_marker_trends(self, marker_data, branches, compute_std, n_jobs)
    180                                 trends = [res[i][0] for i in range(len(res))]
    181 				marker_trends[branch].loc[:, :] = np.ravel(trends).reshape([marker_data.shape[1], 
--> 182 					len(self.traj_bins)])
    183                                 stds = [res[i][1] for i in range(len(res))]
    184 				marker_std[branch].loc[:, :] = np.ravel(trends).reshape([marker_data.shape[1], 

ValueError: cannot reshape array of size 5 into shape (5,500)

It works when compute_std parameter is set to False, shown below:


In [47]:
der.compute_marker_trends(mb_data_f5, der.branch_prob.columns, False, n_jobs=1)


Run4_235626713532342
Time for processing Run4_235626713532342: 0.009019752343495687 minutes
Run5_161340154039083
Time for processing Run5_161340154039083: 0.0065639654795328775 minutes
Run5_239477254471070
Time for processing Run5_239477254471070: 0.006295533974965414 minutes
Out[47]:
OrderedDict([('Run4_235626713532342',
                      0.000000  0.002004  0.004008  0.006012  0.008016  0.010020  0.012024  \
              KCTD15 -3.223493 -3.223432 -3.223370 -3.223309 -3.223248 -3.223188 -3.223128   
              STT3B  -1.941112 -1.937000 -1.932889 -1.928778 -1.924667 -1.920558 -1.916452   
              NAT6   -3.048012 -3.042779 -3.037546 -3.032313 -3.027079 -3.021845 -3.016608   
              FHL2   -3.094041 -3.085326 -3.076610 -3.067895 -3.059179 -3.050464 -3.041749   
              SP140L -2.977317 -2.976396 -2.975475 -2.974555 -2.973635 -2.972714 -2.971794   
              
                      0.014028  0.016032  0.018036    ...     0.981964  0.983968  0.985972  \
              KCTD15 -3.223070 -3.223012 -3.222956    ...    -2.735273 -2.727841 -2.720397   
              STT3B  -1.912351 -1.908255 -1.904165    ...    -1.738432 -1.740201 -1.741968   
              NAT6   -3.011370 -3.006128 -3.000882    ...    -2.886075 -2.891965 -2.897853   
              FHL2   -3.033035 -3.024322 -3.015610    ...    -0.900182 -0.895109 -0.890022   
              SP140L -2.970873 -2.969953 -2.969033    ...    -2.739661 -2.739247 -2.738839   
              
                      0.987976  0.989980  0.991984  0.993988  0.995992  0.997996  1.000000  
              KCTD15 -2.712944 -2.705484 -2.698019 -2.690550 -2.683079 -2.675606 -2.668132  
              STT3B  -1.743732 -1.745491 -1.747247 -1.748998 -1.750747 -1.752495 -1.754242  
              NAT6   -2.903740 -2.909623 -2.915502 -2.921378 -2.927252 -2.933123 -2.938994  
              FHL2   -0.884924 -0.879817 -0.874702 -0.869582 -0.864459 -0.859333 -0.854206  
              SP140L -2.738435 -2.738033 -2.737632 -2.737232 -2.736832 -2.736433 -2.736034  
              
              [5 rows x 500 columns]),
             ('Run5_161340154039083',
                      0.000000  0.002004  0.004008  0.006012  0.008016  0.010020  0.012024  \
              KCTD15 -3.235354 -3.234418 -3.233483 -3.232550 -3.231622 -3.230702 -3.229798   
              STT3B  -2.180822 -2.161938 -2.143054 -2.124167 -2.105281 -2.086408 -2.067565   
              NAT6   -2.945049 -2.947338 -2.949624 -2.951906 -2.954184 -2.956450 -2.958697   
              FHL2   -3.015959 -3.011833 -3.007707 -3.003581 -2.999460 -2.995350 -2.991259   
              SP140L -3.025660 -3.022069 -3.018480 -3.014892 -3.011303 -3.007709 -3.004107   
              
                      0.014028  0.016032  0.018036    ...     0.981964  0.983968  0.985972  \
              KCTD15 -3.228913 -3.228050 -3.227208    ...    -3.334171 -3.334171 -3.334171   
              STT3B  -2.048760 -2.029996 -2.011275    ...    -3.200158 -3.200158 -3.200158   
              NAT6   -2.960915 -2.963096 -2.965229    ...    -3.169200 -3.169200 -3.169200   
              FHL2   -2.987199 -2.983187 -2.979237    ...    -3.373307 -3.373307 -3.373307   
              SP140L -3.000494 -2.996869 -2.993227    ...    -3.472706 -3.472706 -3.472706   
              
                      0.987976  0.989980  0.991984  0.993988  0.995992  0.997996  1.000000  
              KCTD15 -3.334171 -3.334171 -3.334171 -3.334171 -3.334171 -3.334171 -3.334171  
              STT3B  -3.200158 -3.200158 -3.200158 -3.200158 -3.200158 -3.200158 -3.200158  
              NAT6   -3.169200 -3.169200 -3.169200 -3.169200 -3.169200 -3.169200 -3.169200  
              FHL2   -3.373307 -3.373307 -3.373307 -3.373307 -3.373307 -3.373307 -3.373307  
              SP140L -3.472706 -3.472706 -3.472706 -3.472706 -3.472706 -3.472706 -3.472706  
              
              [5 rows x 500 columns]),
             ('Run5_239477254471070',
                      0.000000  0.002004  0.004008  0.006012  0.008016  0.010020  0.012024  \
              KCTD15 -3.235164 -3.234335 -3.233507 -3.232680 -3.231855 -3.231035 -3.230221   
              STT3B  -2.130488 -2.114559 -2.098631 -2.082701 -2.066774 -2.050855 -2.034954   
              NAT6   -2.958364 -2.959346 -2.960326 -2.961305 -2.962280 -2.963250 -2.964209   
              FHL2   -2.984522 -2.982699 -2.980875 -2.979052 -2.977233 -2.975420 -2.973618   
              SP140L -3.013294 -3.010466 -3.007638 -3.004812 -3.001985 -2.999156 -2.996324   
              
                      0.014028  0.016032  0.018036    ...     0.981964  0.983968  0.985972  \
              KCTD15 -3.229418 -3.228625 -3.227843    ...    -3.422076 -3.422076 -3.422076   
              STT3B  -2.019078 -2.003230 -1.987413    ...    -1.310172 -1.310172 -1.310172   
              NAT6   -2.965153 -2.966076 -2.966974    ...    -3.308897 -3.308897 -3.308897   
              FHL2   -2.971835 -2.970080 -2.968363    ...    -3.195147 -3.195147 -3.195147   
              SP140L -2.993488 -2.990648 -2.987803    ...    -3.165987 -3.165987 -3.165987   
              
                      0.987976  0.989980  0.991984  0.993988  0.995992  0.997996  1.000000  
              KCTD15 -3.422076 -3.422076 -3.422076 -3.422076 -3.422076 -3.422076 -3.422076  
              STT3B  -1.310172 -1.310172 -1.310172 -1.310172 -1.310172 -1.310172 -1.310172  
              NAT6   -3.308897 -3.308897 -3.308897 -3.308897 -3.308897 -3.308897 -3.308897  
              FHL2   -3.195147 -3.195147 -3.195147 -3.195147 -3.195147 -3.195147 -3.195147  
              SP140L -3.165987 -3.165987 -3.165987 -3.165987 -3.165987 -3.165987 -3.165987  
              
              [5 rows x 500 columns])])

Plot markers

But let's plot the markers onto a graph- the function plot_markers will automatically call compute_marker_trends by itself, so there is no need to explicitly call the function compute_markers_trends like we did above.


In [48]:
der.plot_markers(mb_data_f5, branches = der.branch_prob.columns)


Run4_235626713532342
Time for processing Run4_235626713532342: 0.010241564114888508 minutes
Run5_161340154039083
Time for processing Run5_161340154039083: 0.008515433470408122 minutes
Run5_239477254471070
Time for processing Run5_239477254471070: 0.008487796783447266 minutes

Palantir on tSNE maps

Let's see the tSNE maps of this particular dataset.


In [6]:
m, n = scanalysis.utils.pca.run_pca(mb_data)


Successfully ran PCA, and returning:
pca_projections
pca.explained_variance_ratio_

In [9]:
Eigvec, Eigval = scanalysis.utils.diffusionmap.run_diffusion_map(m)


Running Diffusion maps with the following parameters:
Normalization: smarkov
Number of nearest neighbors k: 10
Epsilon: 1.0000
(symmetric markov) ... 
3.45 seconds
Successfully ran diffusion map, and returning EigenVectors and EigenValues

In [10]:
Eigvec


Out[10]:
0 1 2 3 4 5 6 7 8 9
Run4_120703408880541 -0.025547 -0.003673 0.001963 -0.001296 -0.000899 0.000711 -0.000616 -0.000550 0.000396 0.000250
Run4_120703409056541 0.026098 0.003752 -0.002005 0.001323 0.000919 -0.000726 0.000630 0.000562 -0.000404 -0.000255
Run4_120703409580963 -0.024882 -0.003577 0.001912 -0.001262 -0.000876 0.000692 -0.000600 -0.000535 0.000385 0.000243
Run4_120703423990708 0.015744 0.002109 -0.001129 0.000745 0.000517 -0.000409 0.000354 0.000316 -0.000228 -0.000144
Run4_120703424252854 0.024166 0.003475 -0.001858 0.001226 0.000851 -0.000672 0.000583 0.000520 -0.000375 -0.000236
Run4_120703436876077 0.007877 0.001133 -0.000606 0.000400 0.000277 -0.000219 0.000190 0.000170 -0.000122 -0.000077
Run4_120703455025387 -0.012733 -0.001830 0.000978 -0.000645 -0.000448 0.000354 -0.000307 -0.000274 0.000197 0.000124
Run4_120726911638237 -0.013797 0.004074 -0.005003 0.003309 0.002297 -0.001814 0.001574 0.001401 -0.001011 -0.000637
Run4_120726912355038 0.019161 0.002751 -0.001468 0.000969 0.000672 -0.000531 0.000461 0.000411 -0.000296 -0.000187
Run4_120726924974443 -0.002755 0.001435 0.000235 -0.000124 -0.000077 0.000058 -0.000049 -0.000042 0.000030 0.000019
Run4_120726924978030 0.020019 -0.000750 0.000397 -0.000263 -0.000183 0.000144 -0.000125 -0.000111 0.000080 0.000050
Run4_120726943295348 -0.020148 -0.002898 0.001549 -0.001023 -0.000710 0.000561 -0.000486 -0.000434 0.000312 0.000197
Run4_120726943845302 0.021254 0.003057 -0.001634 0.001079 0.000749 -0.000592 0.000513 0.000458 -0.000330 -0.000208
Run4_120772961130853 -0.014724 -0.002117 0.001132 -0.000747 -0.000519 0.000410 -0.000355 -0.000317 0.000228 0.000144
Run4_120786758780660 0.025619 0.003684 -0.001968 0.001299 0.000902 -0.000713 0.000618 0.000551 -0.000397 -0.000250
Run4_120786786086116 -0.025476 -0.003663 0.001957 -0.001292 -0.000897 0.000708 -0.000614 -0.000548 0.000395 0.000249
Run4_120786804205803 -0.016768 -0.002288 0.001225 -0.000809 -0.000561 0.000443 -0.000385 -0.000343 0.000247 0.000156
Run4_120786804401973 0.015395 0.002158 -0.001138 0.000751 0.000521 -0.000411 0.000357 0.000318 -0.000229 -0.000145
Run4_120797898099934 -0.004188 0.001417 -0.001747 0.000848 0.000608 -0.000486 0.000424 0.000379 -0.000274 -0.000173
Run4_120797925428019 0.000156 0.000062 -0.000033 0.000022 0.000015 -0.000012 0.000010 0.000009 -0.000007 -0.000004
Run4_120797944278244 0.023713 -0.008058 0.004162 -0.002660 -0.001834 0.001444 -0.001251 -0.001112 0.000802 0.000505
Run4_120797944309486 -0.000736 0.016009 -0.005065 0.003162 0.002136 -0.001684 0.001451 0.001288 -0.000927 -0.000583
Run4_120797944462237 0.011292 0.001623 -0.000867 0.000572 0.000397 -0.000314 0.000272 0.000243 -0.000175 -0.000110
Run4_120797944538971 0.001997 0.000287 -0.000154 0.000101 0.000070 -0.000056 0.000048 0.000043 -0.000031 -0.000020
Run4_120797945084765 0.018873 0.002714 -0.001451 0.000958 0.000665 -0.000525 0.000456 0.000407 -0.000293 -0.000185
Run4_120864497952619 0.003507 0.000497 -0.000266 0.000175 0.000122 -0.000096 0.000083 0.000074 -0.000054 -0.000034
Run4_121202296155437 -0.001431 -0.008953 -0.016524 0.060172 0.037093 -0.020680 -0.016373 0.033539 -0.002001 -0.006501
Run4_121202296712412 0.018986 0.002731 -0.001460 0.000964 0.000669 -0.000529 0.000458 0.000409 -0.000294 -0.000186
Run4_121202296875939 0.024339 0.003501 -0.001871 0.001235 0.000857 -0.000677 0.000587 0.000524 -0.000377 -0.000238
Run4_121202311609131 0.009808 0.001380 -0.000738 0.000487 0.000338 -0.000267 0.000232 0.000207 -0.000149 -0.000094
... ... ... ... ... ... ... ... ... ... ...
Run5_240634599983342 -0.000158 -0.000023 0.000012 -0.000008 -0.000006 0.000004 -0.000004 -0.000003 0.000002 0.000002
Run5_240634599986987 0.010666 0.001534 -0.000820 0.000541 0.000376 -0.000297 0.000257 0.000230 -0.000165 -0.000104
Run5_240634613909861 -0.018553 0.035095 -0.020968 0.014728 0.009813 -0.007316 0.006411 0.005715 -0.004086 -0.002588
Run5_240634614373595 -0.003104 -0.000476 0.000258 -0.000170 -0.000118 0.000093 -0.000081 -0.000072 0.000052 0.000033
Run5_240634614729955 0.003337 0.000480 -0.000257 0.000169 0.000118 -0.000093 0.000081 0.000072 -0.000052 -0.000033
Run5_240634626784550 -0.011481 -0.001593 0.000854 -0.000564 -0.000391 0.000309 -0.000268 -0.000239 0.000172 0.000109
Run5_240634645855022 0.004263 0.000567 -0.000303 0.000200 0.000139 -0.000110 0.000095 0.000085 -0.000061 -0.000039
Run5_240634646116662 -0.000857 -0.000123 0.000066 -0.000043 -0.000030 0.000024 -0.000021 -0.000018 0.000013 0.000008
Run5_241057653508843 0.004424 0.000636 -0.000340 0.000224 0.000156 -0.000123 0.000107 0.000095 -0.000068 -0.000043
Run5_241057653738918 -0.002471 -0.000310 0.000167 -0.000110 -0.000076 0.000060 -0.000052 -0.000047 0.000034 0.000021
Run5_241057654294885 0.004818 0.000693 -0.000370 0.000245 0.000170 -0.000134 0.000116 0.000104 -0.000075 -0.000047
Run5_241057668712349 0.023630 0.003398 -0.001816 0.001199 0.000832 -0.000657 0.000570 0.000509 -0.000366 -0.000231
Run5_241057680972510 0.025270 0.003632 -0.001941 0.001281 0.000889 -0.000703 0.000609 0.000544 -0.000391 -0.000247
Run5_241057681259245 -0.006601 -0.000949 0.000507 -0.000335 -0.000232 0.000184 -0.000159 -0.000142 0.000102 0.000064
Run5_241057700113179 0.016791 0.002415 -0.001291 0.000852 0.000591 -0.000467 0.000405 0.000362 -0.000260 -0.000164
Run5_241098858613659 0.003597 0.000517 -0.000276 0.000182 0.000127 -0.000100 0.000087 0.000077 -0.000056 -0.000035
Run5_241098858810213 0.022731 0.003144 -0.001681 0.001109 0.000770 -0.000609 0.000528 0.000471 -0.000339 -0.000214
Run5_241098873552118 -0.008461 -0.001217 0.000650 -0.000429 -0.000298 0.000235 -0.000204 -0.000182 0.000131 0.000083
Run5_241098885647774 0.018749 0.001377 -0.000723 0.000468 0.000326 -0.000249 0.000224 0.000197 -0.000142 -0.000090
Run5_241098904976174 0.006218 0.000693 -0.000371 0.000245 0.000170 -0.000134 0.000117 0.000104 -0.000075 -0.000047
Run5_241098905205038 0.016364 0.002354 -0.001258 0.000831 0.000577 -0.000455 0.000395 0.000353 -0.000254 -0.000160
Run5_241106375007076 0.000218 -0.002754 0.000120 0.000408 0.000281 -0.000148 0.000182 0.000049 -0.000043 0.000006
Run5_241106389756316 0.004279 0.000615 -0.000329 0.000217 0.000151 -0.000119 0.000103 0.000092 -0.000066 -0.000042
Run5_241106389784372 -0.007988 -0.001149 0.000614 -0.000406 -0.000282 0.000222 -0.000193 -0.000172 0.000124 0.000078
Run5_241106401770805 -0.005746 -0.000826 0.000442 -0.000292 -0.000202 0.000160 -0.000139 -0.000124 0.000089 0.000056
Run5_241114577000174 -0.022341 0.005342 -0.002565 0.001672 0.001155 -0.000910 0.000789 0.000701 -0.000506 -0.000319
Run5_241114577004764 0.024071 -0.000699 0.000198 -0.000144 -0.000103 0.000082 -0.000072 -0.000063 0.000046 0.000029
Run5_241114589051630 0.000228 0.013532 -0.055582 -0.049411 0.195793 0.057720 -0.041972 -0.006625 0.015575 0.002678
Run5_241114589051819 -0.024240 -0.003486 0.001863 -0.001230 -0.000854 0.000674 -0.000585 -0.000522 0.000376 0.000237
Run5_241114589128940 0.018355 0.001499 -0.000958 0.000626 0.000433 -0.000342 0.000296 0.000265 -0.000190 -0.000120

4714 rows × 10 columns


In [11]:
Eigval


Out[11]:
0
0 1.0
1 1.0
2 1.0
3 1.0
4 1.0
5 1.0
6 1.0
7 1.0
8 1.0
9 1.0

In [12]:
t2 = scanalysis.utils.tsne.TSNE()
d2 = t2.fit_transform(Eigvec)

In [13]:
d2


Out[13]:
x y
Run4_120703408880541 19.493440 -42.238459
Run4_120703409056541 3.691569 -55.084756
Run4_120703409580963 14.213279 -42.630559
Run4_120703423990708 44.420442 -11.853079
Run4_120703424252854 -11.111397 -45.642286
Run4_120703436876077 25.624517 -5.474491
Run4_120703455025387 -37.303838 10.606120
Run4_120726911638237 -21.486878 3.502410
Run4_120726912355038 13.014772 -28.502148
Run4_120726924974443 -11.231616 14.220312
Run4_120726924978030 10.822952 -14.521204
Run4_120726943295348 -25.975386 -26.079071
Run4_120726943845302 -3.261728 -21.320777
Run4_120772961130853 -51.330259 4.237437
Run4_120786758780660 0.436507 -53.601006
Run4_120786786086116 18.954794 -42.349656
Run4_120786804205803 -46.413421 -8.518092
Run4_120786804401973 45.985634 -10.212774
Run4_120797898099934 -13.387704 11.994244
Run4_120797925428019 8.855971 26.263237
Run4_120797944278244 8.685462 -10.001652
Run4_120797944309486 -14.118796 2.119409
Run4_120797944462237 38.548808 17.353306
Run4_120797944538971 15.389363 39.505068
Run4_120797945084765 15.289740 -27.789873
Run4_120864497952619 26.947899 31.424185
Run4_121202296155437 -9.275298 7.196519
Run4_121202296712412 14.268926 -28.247830
Run4_121202296875939 -9.990822 -46.712526
Run4_121202311609131 35.225054 4.695856
... ... ...
Run5_240634599983342 8.547439 23.595018
Run5_240634599986987 35.040321 12.631399
Run5_240634613909861 -14.977659 -6.064951
Run5_240634614373595 -12.346470 21.203319
Run5_240634614729955 26.567883 32.893966
Run5_240634626784550 -6.602693 33.841078
Run5_240634645855022 25.853897 23.456315
Run5_240634646116662 4.739253 16.986460
Run5_241057653508843 25.013213 21.965883
Run5_241057653738918 -7.008858 21.912112
Run5_241057654294885 22.351999 19.178286
Run5_241057668712349 -14.583999 -38.000357
Run5_241057680972510 -2.304187 -52.102443
Run5_241057681259245 -29.806699 30.810778
Run5_241057700113179 34.811254 -17.296102
Run5_241098858613659 27.057890 30.648464
Run5_241098858810213 -12.967986 -29.759840
Run5_241098873552118 -18.271544 45.645404
Run5_241098885647774 16.783846 -21.628943
Run5_241098904976174 18.070776 5.421445
Run5_241098905205038 38.432537 -14.503203
Run5_241106375007076 4.721691 10.684564
Run5_241106389756316 25.876101 23.067676
Run5_241106389784372 -21.632312 42.170660
Run5_241106401770805 -31.995660 23.511466
Run5_241114577000174 -26.591280 -4.981108
Run5_241114577004764 7.815415 -14.122114
Run5_241114589051630 -9.386130 3.605965
Run5_241114589051819 9.691492 -43.126794
Run5_241114589128940 17.006639 -21.526422

4714 rows × 2 columns


In [17]:
fig, ax = scanalysis.plots.plot.plot_tsne(d2)



In [25]:
fig = plt.figure(figsize=[5, 4])
scanalysis.plots.plot.plot_tsne_by_cell_sizes(mb_data, d2, fig = fig)


Out[25]:
(<matplotlib.figure.Figure at 0x11727d5f8>,
 <matplotlib.axes._subplots.AxesSubplot at 0x11727d048>)

Use the tSNE data provided by Manu.


In [15]:
tsne = scanalysis.io.loadsave.load('~/tsne.csv')


Successfully loaded /Users/hjin/tsne.csv as a pd.DataFrame object

Filter out and only include the tSNE data that corresponds to the original mb_data dataset. In other words, filter out to take only the cell names in the index of mb_data from tSNE data.


In [16]:
tsne1 = tsne.loc[mb_data.index]

In [17]:
tsne1


Out[17]:
x y
Run4_120703408880541 -9.938553 -3.918489
Run4_120703409056541 -29.987230 5.025842
Run4_120703409580963 8.778947 -21.146475
Run4_120703423990708 8.304699 -20.570558
Run4_120703424252854 34.838399 -8.290442
Run4_120703436876077 -21.483573 12.986087
Run4_120703455025387 16.528668 12.909906
Run4_120726911638237 22.247869 7.292149
Run4_120726912355038 7.143360 9.374328
Run4_120726924974443 10.166742 6.552430
Run4_120726924978030 5.630279 18.002874
Run4_120726943295348 9.359823 -21.175617
Run4_120726943845302 11.177851 -4.365635
Run4_120772961130853 -14.602084 11.574279
Run4_120786758780660 -9.246595 19.675193
Run4_120786786086116 -14.483479 17.721635
Run4_120786804205803 25.178340 5.149995
Run4_120786804401973 3.927354 14.469976
Run4_120797898099934 19.476349 3.277522
Run4_120797925428019 -1.694995 20.516168
Run4_120797944278244 -8.974321 -15.999008
Run4_120797944309486 -8.965051 -9.449672
Run4_120797944462237 -15.140176 18.118078
Run4_120797944538971 -11.394474 0.309655
Run4_120797945084765 -19.016624 17.388215
Run4_120864497952619 34.515769 -13.917341
Run4_121202296155437 -9.864364 -24.259759
Run4_121202296712412 36.173311 -9.565256
Run4_121202296875939 -19.267720 8.421058
Run4_121202311609131 8.082084 -19.820283
... ... ...
Run5_240634599983342 5.136808 -9.148511
Run5_240634599986987 -28.974262 7.378295
Run5_240634613909861 -5.159132 -31.930537
Run5_240634614373595 10.514562 10.004391
Run5_240634614729955 8.816761 -20.767494
Run5_240634626784550 -8.871302 -14.613257
Run5_240634645855022 -8.954690 -10.596766
Run5_240634646116662 -30.567564 5.370154
Run5_241057653508843 2.043231 19.333152
Run5_241057653738918 5.541572 -15.140417
Run5_241057654294885 -31.955755 -5.796775
Run5_241057668712349 -28.491896 -11.229763
Run5_241057680972510 9.300760 18.155685
Run5_241057681259245 -7.245898 21.784444
Run5_241057700113179 -5.369934 20.275344
Run5_241098858613659 -25.969002 11.158525
Run5_241098858810213 -18.497675 15.121312
Run5_241098873552118 -0.729871 16.251062
Run5_241098885647774 -9.212466 -18.095847
Run5_241098904976174 -0.889530 22.003007
Run5_241098905205038 15.459690 14.305659
Run5_241106375007076 -9.704659 -25.556231
Run5_241106389756316 31.080121 -0.761071
Run5_241106389784372 11.306116 16.274098
Run5_241106401770805 23.359979 5.978699
Run5_241114577000174 -3.289491 20.831109
Run5_241114577004764 23.550028 5.632268
Run5_241114589051630 -5.482493 -31.566590
Run5_241114589051819 11.204909 15.904865
Run5_241114589128940 18.558962 15.452899

4714 rows × 2 columns


In [18]:
der.plot_palantir_on_tsne(tsne1)


Please make sure that the tSNE data entered corresponds to the DiffEntrResults object you've entered.
		If yes, press enter to continue.
		If not, Ctrl-C to exit and retry with correct parameters.
Out[18]:
(<matplotlib.figure.Figure at 0x1154355c0>,
 <matplotlib.axes._subplots.AxesSubplot at 0x114a10518>)

Specific example

which shows the marker trends of the following genes: ['HBB', 'CD34', 'MPO', 'LYZ', 'CST3']


In [11]:
data_part = mb_data.loc[:,['HBB', 'CD34', 'MPO', 'LYZ', 'CST3']]

In [32]:
data_part


Out[32]:
HBB CD34 MPO LYZ CST3
Run4_120703408880541 -3.321928 0.171306 -3.321928 0.171306 2.645347
Run4_120703409056541 -3.321928 0.837003 0.837003 -3.321928 -3.321928
Run4_120703409580963 -3.321928 -3.321928 4.974236 6.386403 0.880299
Run4_120703423990708 -3.321928 -3.321928 5.063559 3.296390 -3.321928
Run4_120703424252854 -3.321928 0.538690 -3.321928 -0.365265 -3.321928
Run4_120703436876077 -3.321928 -3.321928 0.363786 -3.321928 0.363786
Run4_120703455025387 -3.321928 -0.270688 -0.270688 -3.321928 -3.321928
Run4_120726911638237 -3.321928 0.370883 -3.321928 -3.321928 -0.521655
Run4_120726912355038 -0.098613 0.822005 4.912722 -3.321928 -0.098613
Run4_120726924974443 -3.321928 -3.321928 4.006959 -0.910988 -0.053432
Run4_120726924978030 -3.321928 1.795234 -3.321928 -0.369327 0.534347
Run4_120726943295348 -3.321928 -3.321928 4.910699 6.399458 0.980907
Run4_120726943845302 -3.321928 -3.321928 5.758552 5.531596 -3.321928
Run4_120772961130853 -3.321928 1.221830 -3.321928 -3.321928 0.282395
Run4_120786758780660 -3.321928 -3.321928 0.047722 -3.321928 -3.321928
Run4_120786786086116 -3.321928 -3.321928 0.245224 -3.321928 -3.321928
Run4_120786804205803 -3.321928 -0.443817 -3.321928 -3.321928 0.454569
Run4_120786804401973 -3.321928 1.256403 -3.321928 -3.321928 -3.321928
Run4_120797898099934 -3.321928 -0.736818 5.070566 2.608983 0.678238
Run4_120797925428019 -3.321928 0.810766 -3.321928 -3.321928 0.810766
Run4_120797944278244 -0.569621 0.319141 -3.321928 -3.321928 2.041438
Run4_120797944309486 -3.321928 -3.321928 -3.321928 -0.597133 0.289401
Run4_120797944462237 -3.321928 1.986570 -3.321928 -3.321928 -3.321928
Run4_120797944538971 -3.321928 1.037736 -3.321928 -3.321928 -3.321928
Run4_120797945084765 1.128506 -3.321928 -3.321928 -3.321928 -3.321928
Run4_120864497952619 -3.321928 -3.321928 3.539276 5.588708 2.836658
Run4_121202296155437 -3.321928 0.065101 -0.803194 -0.803194 1.770428
Run4_121202296712412 0.731223 -3.321928 0.731223 -3.321928 1.687102
Run4_121202296875939 -3.321928 1.577101 -3.321928 0.624661 -3.321928
Run4_121202311609131 0.335232 -3.321928 4.975569 5.742348 2.246810
... ... ... ... ... ...
Run5_240634599983342 -3.321928 -3.321928 4.334501 3.686505 2.478976
Run5_240634599986987 -3.321928 -3.321928 -3.321928 -3.321928 -3.321928
Run5_240634613909861 4.089875 -3.321928 -3.321928 -0.505150 1.332478
Run5_240634614373595 -3.321928 1.461658 0.902651 -3.321928 -3.321928
Run5_240634614729955 -3.321928 -3.321928 5.754522 6.201268 -3.321928
Run5_240634626784550 -0.181935 -3.321928 -3.321928 -3.321928 2.002738
Run5_240634645855022 -3.321928 -3.321928 -3.321928 -3.321928 0.766502
Run5_240634646116662 -3.321928 2.060912 -3.321928 -3.321928 -3.321928
Run5_241057653508843 -3.321928 -3.321928 -3.321928 -3.321928 0.102278
Run5_241057653738918 -3.321928 -3.321928 5.097710 2.069387 -3.321928
Run5_241057654294885 -3.321928 2.651800 -3.321928 -3.321928 -3.321928
Run5_241057668712349 -3.321928 1.687102 -3.321928 -3.321928 -3.321928
Run5_241057680972510 -3.321928 0.131881 0.131881 -3.321928 0.131881
Run5_241057681259245 -3.321928 -3.321928 0.644397 -3.321928 2.166477
Run5_241057700113179 -3.321928 1.136287 0.200470 -3.321928 1.136287
Run5_241098858613659 -3.321928 -3.321928 -3.321928 -3.321928 0.729147
Run5_241098858810213 -3.321928 -3.321928 4.011044 -3.321928 -0.014261
Run5_241098873552118 -3.321928 1.030843 -3.321928 -3.321928 -3.321928
Run5_241098885647774 -3.321928 -0.357935 -3.321928 -3.321928 1.496269
Run5_241098904976174 0.841381 -0.080268 -3.321928 -3.321928 -3.321928
Run5_241098905205038 -3.321928 0.590031 0.590031 -3.321928 0.590031
Run5_241106375007076 -3.321928 -0.487455 -3.321928 -3.321928 1.662848
Run5_241106389756316 -3.321928 1.271771 -0.198384 -3.321928 1.984637
Run5_241106389784372 -0.212452 -0.212452 -3.321928 -0.212452 -0.212452
Run5_241106401770805 -3.321928 1.560339 0.070037 -3.321928 -3.321928
Run5_241114577000174 -0.230532 -1.070481 2.423913 -1.070481 -1.070481
Run5_241114577004764 -3.321928 0.433472 2.926546 -0.463470 1.689836
Run5_241114589051630 2.362388 -3.321928 0.560859 -0.840674 1.258165
Run5_241114589051819 -3.321928 -0.023438 -3.321928 -3.321928 2.176139
Run5_241114589128940 -3.321928 -0.398169 0.503493 -3.321928 -0.398169

4714 rows × 5 columns


In [33]:
der.compute_marker_trends(data_part, None, False, n_jobs=1)


Run4_235626713532342
Time for processing Run4_235626713532342: 0.018091583251953126 minutes
Run5_239477254471070
Time for processing Run5_239477254471070: 0.005901432037353516 minutes
Out[33]:
OrderedDict([('Run4_235626713532342',
                    0.000000  0.002004  0.004008  0.006012  0.008016  0.010020  0.012024  \
              HBB  -2.877598 -2.875372 -2.873146 -2.870921 -2.868695 -2.866469 -2.864242   
              CD34 -1.126912 -1.122667 -1.118422 -1.114177 -1.109935 -1.105695 -1.101458   
              MPO  -2.641946 -2.623113 -2.604279 -2.585444 -2.566609 -2.547773 -2.528935   
              LYZ  -2.797144 -2.791235 -2.785326 -2.779417 -2.773507 -2.767598 -2.761688   
              CST3 -1.038528 -1.039312 -1.040095 -1.040878 -1.041659 -1.042437 -1.043210   
              
                    0.014028  0.016032  0.018036    ...     0.981964  0.983968  0.985972  \
              HBB  -2.862014 -2.859783 -2.857550    ...     2.619686  2.702827  2.786069   
              CD34 -1.097225 -1.092997 -1.088777    ...    -2.553407 -2.574056 -2.594718   
              MPO  -2.510096 -2.491255 -2.472412    ...    -1.746521 -1.740373 -1.734224   
              LYZ  -2.755777 -2.749864 -2.743948    ...    -2.733164 -2.739379 -2.745599   
              CST3 -1.043976 -1.044735 -1.045484    ...     1.597440  1.601482  1.605516   
              
                    0.987976  0.989980  0.991984  0.993988  0.995992  0.997996  1.000000  
              HBB   2.869388  2.952762  3.036172  3.119603  3.203048  3.286501  3.369957  
              CD34 -2.615391 -2.636073 -2.656760 -2.677450 -2.698142 -2.718836 -2.739530  
              MPO  -1.728076 -1.721927 -1.715778 -1.709628 -1.703479 -1.697329 -1.691179  
              LYZ  -2.751822 -2.758047 -2.764273 -2.770500 -2.776727 -2.782955 -2.789183  
              CST3  1.609542  1.613564  1.617582  1.621598  1.625612  1.629626  1.633639  
              
              [5 rows x 500 columns]),
             ('Run5_239477254471070',
                    0.000000  0.002004  0.004008  0.006012  0.008016  0.010020  0.012024  \
              HBB  -2.853380 -2.854855 -2.856332 -2.857810 -2.859285 -2.860748 -2.862192   
              CD34 -1.453088 -1.429931 -1.406779 -1.383641 -1.360530 -1.337458 -1.314431   
              MPO  -2.617134 -2.611562 -2.605986 -2.600400 -2.594797 -2.589168 -2.583508   
              LYZ  -2.590957 -2.597913 -2.604870 -2.611829 -2.618794 -2.625763 -2.632735   
              CST3 -0.657507 -0.677218 -0.696926 -0.716619 -0.736281 -0.755889 -0.775426   
              
                    0.014028  0.016032  0.018036    ...     0.981964  0.983968  0.985972  \
              HBB  -2.863610 -2.864986 -2.866301    ...    -2.795084 -2.795084 -2.795084   
              CD34 -1.291457 -1.268547 -1.245715    ...    -3.190252 -3.190252 -3.190252   
              MPO  -2.577812 -2.572072 -2.566275    ...    -7.487341 -7.487341 -7.487341   
              LYZ  -2.639710 -2.646682 -2.653649    ...    -5.059789 -5.059789 -5.059789   
              CST3 -0.794869 -0.814202 -0.833403    ...     6.546765  6.546765  6.546765   
              
                    0.987976  0.989980  0.991984  0.993988  0.995992  0.997996  1.000000  
              HBB  -2.795084 -2.795084 -2.795084 -2.795084 -2.795084 -2.795084 -2.795084  
              CD34 -3.190252 -3.190252 -3.190252 -3.190252 -3.190252 -3.190252 -3.190252  
              MPO  -7.487341 -7.487341 -7.487341 -7.487341 -7.487341 -7.487341 -7.487341  
              LYZ  -5.059789 -5.059789 -5.059789 -5.059789 -5.059789 -5.059789 -5.059789  
              CST3  6.546765  6.546765  6.546765  6.546765  6.546765  6.546765  6.546765  
              
              [5 rows x 500 columns])])

In [54]:
der.plot_markers(data_part)


Run4_235626713532342
Time for processing Run4_235626713532342: 0.02019548018773397 minutes
Run5_161340154039083
Time for processing Run5_161340154039083: 0.008869433403015136 minutes
Run5_239477254471070
Time for processing Run5_239477254471070: 0.008534518877665202 minutes

Comparison with trends.p...


In [18]:
trends = scanalysis.io.loadsave.load("~/trends.p")


Successfully loaded /Users/hjin/trends.p as a <class 'collections.OrderedDict'> object

In [19]:
trends


Out[19]:
OrderedDict([('Run4_235626713532342',
                      0.000000  0.002004  0.004008  0.006012  0.008016  0.010020  0.012024  \
              KCTD15 -3.232311 -3.232019 -3.231727 -3.231436 -3.231144 -3.230853 -3.230562   
              STT3B  -2.121511 -2.114979 -2.108448 -2.101917 -2.095387 -2.088857 -2.082327   
              NAT6   -3.008021 -3.007220 -3.006418 -3.005616 -3.004814 -3.004011 -3.003208   
              FHL2   -3.080830 -3.077146 -3.073462 -3.069778 -3.066094 -3.062410 -3.058725   
              SP140L -3.010032 -3.008821 -3.007610 -3.006399 -3.005188 -3.003978 -3.002768   
              
                      0.014028  0.016032  0.018036    ...     0.981964  0.983968  0.985972  \
              KCTD15 -3.230271 -3.229980 -3.229691    ...    -2.702542 -2.702542 -2.702542   
              STT3B  -2.075798 -2.069270 -2.062743    ...    -1.747917 -1.747917 -1.747917   
              NAT6   -3.002405 -3.001601 -3.000795    ...    -2.920024 -2.920024 -2.920024   
              FHL2   -3.055040 -3.051356 -3.047672    ...    -0.862405 -0.862405 -0.862405   
              SP140L -3.001558 -3.000349 -2.999140    ...    -2.736467 -2.736467 -2.736467   
              
                      0.987976  0.989980  0.991984  0.993988  0.995992  0.997996  1.000000  
              KCTD15 -2.702542 -2.702542 -2.702542 -2.702542 -2.702542 -2.702542 -2.702542  
              STT3B  -1.747917 -1.747917 -1.747917 -1.747917 -1.747917 -1.747917 -1.747917  
              NAT6   -2.920024 -2.920024 -2.920024 -2.920024 -2.920024 -2.920024 -2.920024  
              FHL2   -0.862405 -0.862405 -0.862405 -0.862405 -0.862405 -0.862405 -0.862405  
              SP140L -2.736467 -2.736467 -2.736467 -2.736467 -2.736467 -2.736467 -2.736467  
              
              [5 rows x 500 columns]),
             ('Run5_161340154039083',
                      0.000000  0.002004  0.004008  0.006012  0.008016  0.010020  0.012024  \
              KCTD15 -3.232700 -3.232356 -3.232011 -3.231667 -3.231323 -3.230978 -3.230635   
              STT3B  -2.176860 -2.168530 -2.160200 -2.151871 -2.143543 -2.135215 -2.126887   
              NAT6   -2.952421 -2.953131 -2.953841 -2.954550 -2.955259 -2.955968 -2.956676   
              FHL2   -3.009247 -3.007339 -3.005431 -3.003522 -3.001614 -2.999705 -2.997796   
              SP140L -3.021628 -3.020101 -3.018575 -3.017048 -3.015522 -3.013996 -3.012471   
              
                      0.014028  0.016032  0.018036    ...     0.981964  0.983968  0.985972  \
              KCTD15 -3.230291 -3.229949 -3.229607    ...    -3.235839 -3.235839 -3.235839   
              STT3B  -2.118560 -2.110234 -2.101910    ...    -2.323412 -2.323412 -2.323412   
              NAT6   -2.957383 -2.958090 -2.958796    ...    -3.107218 -3.107218 -3.107218   
              FHL2   -2.995888 -2.993980 -2.992074    ...    -3.336250 -3.336250 -3.336250   
              SP140L -3.010947 -3.009423 -3.007899    ...    -3.225934 -3.225934 -3.225934   
              
                      0.987976  0.989980  0.991984  0.993988  0.995992  0.997996  1.000000  
              KCTD15 -3.235839 -3.235839 -3.235839 -3.235839 -3.235839 -3.235839 -3.235839  
              STT3B  -2.323412 -2.323412 -2.323412 -2.323412 -2.323412 -2.323412 -2.323412  
              NAT6   -3.107218 -3.107218 -3.107218 -3.107218 -3.107218 -3.107218 -3.107218  
              FHL2   -3.336250 -3.336250 -3.336250 -3.336250 -3.336250 -3.336250 -3.336250  
              SP140L -3.225934 -3.225934 -3.225934 -3.225934 -3.225934 -3.225934 -3.225934  
              
              [5 rows x 500 columns]),
             ('Run5_239477254471070',
                      0.000000  0.002004  0.004008  0.006012  0.008016  0.010020  0.012024  \
              KCTD15 -3.233172 -3.232856 -3.232539 -3.232223 -3.231906 -3.231590 -3.231274   
              STT3B  -2.128690 -2.121639 -2.114589 -2.107538 -2.100488 -2.093439 -2.086389   
              NAT6   -2.963221 -2.963410 -2.963599 -2.963788 -2.963976 -2.964165 -2.964353   
              FHL2   -2.979977 -2.979003 -2.978028 -2.977053 -2.976078 -2.975103 -2.974128   
              SP140L -3.010570 -3.009361 -3.008153 -3.006944 -3.005736 -3.004528 -3.003321   
              
                      0.014028  0.016032  0.018036    ...     0.981964  0.983968  0.985972  \
              KCTD15 -3.230958 -3.230642 -3.230328    ...    -3.338049 -3.339260 -3.340470   
              STT3B  -2.079341 -2.072292 -2.065245    ...    -1.320993 -1.320590 -1.320187   
              NAT6   -2.964541 -2.964728 -2.964915    ...    -3.208254 -3.209815 -3.211377   
              FHL2   -2.973154 -2.972180 -2.971207    ...    -3.207388 -3.207292 -3.207196   
              SP140L -3.002114 -3.000907 -2.999700    ...    -3.011832 -3.014224 -3.016615   
              
                      0.987976  0.989980  0.991984  0.993988  0.995992  0.997996  1.000000  
              KCTD15 -3.341680 -3.342890 -3.344099 -3.345309 -3.346519 -3.347729 -3.348939  
              STT3B  -1.319783 -1.319379 -1.318975 -1.318571 -1.318168 -1.317766 -1.317365  
              NAT6   -3.212939 -3.214500 -3.216063 -3.217625 -3.219188 -3.220751 -3.222314  
              FHL2   -3.207099 -3.207002 -3.206906 -3.206809 -3.206713 -3.206616 -3.206521  
              SP140L -3.019007 -3.021399 -3.023791 -3.026184 -3.028576 -3.030969 -3.033362  
              
              [5 rows x 500 columns])])

Gene expression trend clusters plot


In [9]:
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
The blue line is the mean, and the dotted skyblue lines are +/- 1 standard deviation.

In [10]:
magic_mb_data = scanalysis.tools.magic.run_magic(mb_data)


Doing PCA
Successfully ran PCA, and returning:
pca_projections
pca.explained_variance_ratio_
Using pca_projections
Computing distances
Autotuning distances
Computing kernel
MAGIC: L_t = L^t
MAGIC: data_new = L_t * data
Rescaling should not be performed on log-transformed (or other negative) values. Imputed data returned unscaled.

In [14]:
magic_mb_data


Out[14]:
MAGIC KCTD15 MAGIC STT3B MAGIC NAT6 MAGIC FHL2 MAGIC SP140L MAGIC DOCK9 MAGIC CENPN MAGIC NEDD9 MAGIC HIST1H2AM MAGIC TEK ... MAGIC ZNF543 MAGIC SGTB MAGIC EEF1A1 MAGIC TSPAN33 MAGIC DNAJC4 MAGIC SAG MAGIC FARP1 MAGIC EXTL2 MAGIC ZDHHC17 MAGIC GOLPH3
Run4_120703408880541 -3.081890 -1.569109 -2.521323 -1.554796 -2.795134 -3.317158 -2.975426 -3.245054 -3.176520 -3.267717 ... -3.239820 -3.238034 6.630811 -3.277199 -2.297714 -3.263423 -3.278235 -2.346597 -3.132810 -2.348929
Run4_120703409056541 -3.223699 -1.930572 -2.988096 -2.962721 -2.986637 -3.311284 -3.234645 -3.124792 -3.293640 -3.314926 ... -3.277682 -3.222976 6.780579 -3.143666 -1.900879 -3.297389 -3.248498 -2.986265 -3.143435 -2.465603
Run4_120703409580963 -3.223181 -2.076255 -3.085813 -3.292070 -3.135195 -3.316689 -2.821887 -3.265570 -3.246728 -3.321864 ... -3.307121 -3.208709 6.003144 -3.213007 -2.636761 -3.295449 -3.299821 -3.019693 -3.120315 -2.418979
Run4_120703423990708 -3.215980 -1.981249 -3.048919 -3.287169 -3.094142 -3.310708 -2.845531 -3.264872 -3.262614 -3.321886 ... -3.302719 -3.236065 6.090235 -3.215611 -2.627050 -3.299187 -3.294404 -2.950676 -3.115017 -2.438089
Run4_120703424252854 -3.203108 -1.272880 -3.082375 -3.178140 -2.784867 -3.302792 -1.893781 -3.090756 -2.973497 -3.321923 ... -3.248457 -3.209358 6.538290 -3.048899 -2.087339 -3.293808 -3.258687 -2.810710 -3.005967 -2.138928
Run4_120703436876077 -3.219536 -1.484021 -2.895867 -2.998829 -2.912177 -3.312076 -3.101283 -3.167702 -3.262815 -3.315371 ... -3.261060 -3.216538 6.723866 -3.091167 -1.840114 -3.273854 -3.274768 -2.854313 -3.096797 -2.344273
Run4_120703455025387 -3.123461 -1.451660 -2.976502 -2.990115 -2.801327 -3.309934 -2.468890 -3.133177 -3.128368 -3.321208 ... -3.219220 -3.237013 6.736430 -3.057646 -2.123279 -3.305402 -3.238856 -2.672721 -3.154654 -2.291091
Run4_120726911638237 -3.108019 -1.335022 -2.931123 -3.073056 -2.767325 -3.309279 -2.286662 -3.173869 -3.048676 -3.321011 ... -3.232952 -3.219958 6.617090 -3.054272 -2.163475 -3.290079 -3.252878 -2.633768 -3.107675 -2.238018
Run4_120726912355038 -3.135072 -1.420292 -2.817047 -3.232200 -2.963895 -3.316875 -2.935137 -3.189686 -3.257561 -3.321626 ... -3.271841 -3.223040 6.569613 -3.108898 -2.125303 -3.275122 -3.281910 -2.748630 -2.975976 -2.268182
Run4_120726924974443 -3.106525 -1.431902 -3.020832 -3.241469 -2.949221 -3.306524 -2.648301 -3.171256 -3.225755 -3.321836 ... -3.259293 -3.216339 6.460272 -3.049665 -2.266480 -3.282715 -3.275805 -2.745735 -2.992193 -2.234002
Run4_120726924978030 -3.111809 -1.381074 -2.971232 -3.215453 -2.844776 -3.316541 -2.946111 -3.132166 -3.266658 -3.321636 ... -3.252419 -3.194913 6.659178 -3.048285 -2.040427 -3.281300 -3.271629 -2.743699 -3.087167 -2.143520
Run4_120726943295348 -3.222513 -2.052294 -3.081354 -3.292987 -3.132859 -3.316915 -2.794967 -3.263317 -3.237254 -3.321840 ... -3.305816 -3.210262 6.003949 -3.208484 -2.644415 -3.296485 -3.301333 -3.019402 -3.121816 -2.402200
Run4_120726943845302 -3.185125 -1.631010 -3.073897 -3.283206 -3.072048 -3.311298 -2.571473 -3.232467 -3.214463 -3.321814 ... -3.276259 -3.249041 6.164309 -3.145800 -2.585373 -3.306391 -3.292252 -2.920001 -3.085188 -2.314808
Run4_120772961130853 -3.198832 -1.462469 -2.797474 -2.865596 -2.919680 -3.310225 -3.061590 -3.174690 -3.244186 -3.314440 ... -3.263273 -3.226258 6.720166 -3.109366 -1.860006 -3.275235 -3.278661 -2.768194 -3.097013 -2.313170
Run4_120786758780660 -3.212533 -1.506512 -2.933464 -2.946274 -2.919001 -3.312265 -3.129977 -3.158011 -3.278951 -3.308242 ... -3.245103 -3.222478 6.761568 -3.095647 -1.856859 -3.269118 -3.275074 -2.806352 -3.125063 -2.331296
Run4_120786786086116 -3.228851 -1.499693 -2.913895 -2.995114 -2.905127 -3.312224 -3.116965 -3.162477 -3.272904 -3.312062 ... -3.261602 -3.213634 6.733228 -3.093470 -1.829419 -3.272986 -3.270801 -2.860025 -3.105258 -2.355472
Run4_120786804205803 -3.109662 -1.337881 -2.946268 -3.129458 -2.731585 -3.308828 -2.253090 -3.144044 -3.017530 -3.321819 ... -3.225701 -3.225533 6.631412 -3.021372 -2.137293 -3.290409 -3.245870 -2.626662 -3.119560 -2.208451
Run4_120786804401973 -3.129057 -1.418882 -2.895197 -3.098356 -2.868439 -3.313517 -2.856331 -3.187184 -3.247419 -3.319896 ... -3.251707 -3.226428 6.652359 -3.106263 -2.100579 -3.291496 -3.282131 -2.698161 -3.095678 -2.289722
Run4_120797898099934 -3.127313 -1.437418 -3.016064 -3.240199 -2.936889 -3.303462 -2.384316 -3.160513 -3.119537 -3.321879 ... -3.263733 -3.218166 6.402816 -3.023367 -2.246675 -3.286147 -3.262752 -2.746950 -2.969903 -2.206292
Run4_120797925428019 -3.126208 -1.400603 -2.964870 -3.161403 -2.880492 -3.317628 -3.016500 -3.135063 -3.271054 -3.320707 ... -3.244077 -3.202069 6.706034 -3.057365 -2.015492 -3.283324 -3.272680 -2.747855 -3.102708 -2.171762
Run4_120797944278244 -3.084598 -1.647712 -2.440577 -1.122333 -2.811441 -3.312656 -2.960105 -3.226602 -3.118022 -3.238368 ... -3.217570 -3.233360 6.610854 -3.260488 -2.204504 -3.237739 -3.278549 -2.363241 -2.978049 -2.438002
Run4_120797944309486 -3.068198 -1.585711 -2.537787 -1.306138 -2.796412 -3.309592 -2.925184 -3.257008 -3.129367 -3.269304 ... -3.210045 -3.231683 6.619987 -3.263567 -2.263951 -3.248874 -3.261364 -2.383984 -3.048991 -2.335558
Run4_120797944462237 -3.156165 -1.468789 -2.935629 -3.081238 -2.912973 -3.315312 -3.032005 -3.164107 -3.260213 -3.319141 ... -3.247902 -3.227985 6.718737 -3.099084 -1.995776 -3.283048 -3.278852 -2.755695 -3.097460 -2.255863
Run4_120797944538971 -3.146210 -1.670437 -2.451420 -1.872663 -2.877264 -3.316205 -3.050350 -3.208972 -3.189754 -3.283646 ... -3.284429 -3.251705 6.687447 -3.212800 -2.028054 -3.277423 -3.276504 -2.439015 -3.147949 -2.464378
Run4_120797945084765 -3.225207 -1.818980 -3.220545 -3.224216 -2.819439 -3.320565 -3.113755 -3.068048 -3.302235 -3.321562 ... -3.244668 -3.251410 6.524010 -3.162408 -1.816038 -3.309672 -3.205707 -2.920333 -2.985415 -2.492861
Run4_120864497952619 -3.205950 -1.567981 -3.098010 -3.253015 -3.068130 -3.304848 -2.167806 -3.131862 -3.084733 -3.321922 ... -3.282597 -3.224331 6.160203 -2.959386 -2.200208 -3.292022 -3.239187 -2.960366 -2.832748 -2.184525
Run4_121202296155437 -2.992803 -1.615893 -2.684153 -1.137275 -2.749521 -3.299228 -2.731205 -3.268543 -3.060227 -3.285965 ... -3.192415 -3.220071 6.588875 -3.247963 -2.309537 -3.257175 -3.222502 -2.384197 -3.020119 -2.373971
Run4_121202296712412 -3.262692 -1.383821 -3.228454 -3.244587 -3.061170 -3.318550 -2.402348 -3.062022 -3.131201 -3.321924 ... -3.256075 -3.220500 6.325052 -3.137648 -1.973579 -3.280431 -3.266923 -3.057817 -2.463228 -2.337073
Run4_121202296875939 -3.229370 -1.758347 -2.954337 -2.907607 -2.940981 -3.311679 -3.201069 -3.158394 -3.289960 -3.306505 ... -3.262877 -3.210581 6.780498 -3.130101 -1.858649 -3.286352 -3.256590 -2.925826 -3.143536 -2.443435
Run4_121202311609131 -3.217603 -2.004872 -3.088401 -3.285846 -3.113990 -3.314767 -2.853082 -3.253039 -3.259150 -3.321869 ... -3.302387 -3.221436 6.060135 -3.207274 -2.604633 -3.293555 -3.289395 -3.011834 -3.102583 -2.417170
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
Run5_240634599983342 -3.204246 -1.792009 -3.089810 -3.242897 -2.978325 -3.312901 -2.971268 -3.166223 -3.276583 -3.321741 ... -3.283821 -3.246306 6.385648 -3.148276 -2.274235 -3.290368 -3.248989 -2.913401 -3.021336 -2.360227
Run5_240634599986987 -3.214779 -1.896751 -2.980674 -2.962574 -2.979256 -3.313315 -3.228867 -3.135747 -3.286806 -3.316949 ... -3.273714 -3.232705 6.756045 -3.146554 -1.929529 -3.297572 -3.258924 -2.967227 -3.143967 -2.456150
Run5_240634613909861 -2.859645 -1.783996 -2.805858 -0.968392 -2.795156 -3.296171 -2.653197 -3.224540 -2.984903 -3.284657 ... -3.244883 -3.207747 6.507601 -3.228436 -2.271170 -3.282914 -3.230381 -2.212925 -3.041256 -2.438850
Run5_240634614373595 -3.108294 -1.367273 -2.914471 -3.182012 -2.869839 -3.314081 -2.777858 -3.195277 -3.251214 -3.320765 ... -3.254673 -3.210597 6.560887 -3.115374 -2.225251 -3.285759 -3.285453 -2.683968 -3.070424 -2.280421
Run5_240634614729955 -3.220708 -1.986232 -3.076670 -3.291911 -3.126981 -3.315832 -2.753849 -3.257442 -3.227901 -3.321831 ... -3.303227 -3.217135 6.025292 -3.200161 -2.641468 -3.297821 -3.299111 -3.015192 -3.121054 -2.381709
Run5_240634626784550 -3.071257 -1.672867 -2.523299 -1.315098 -2.812962 -3.309508 -2.959912 -3.237661 -3.140976 -3.248771 ... -3.224941 -3.242929 6.595661 -3.259977 -2.258888 -3.254805 -3.271302 -2.342674 -3.034775 -2.412881
Run5_240634645855022 -3.096544 -1.671122 -2.434980 -1.237599 -2.832529 -3.314873 -3.006384 -3.222268 -3.148650 -3.222419 ... -3.230924 -3.244573 6.613869 -3.265129 -2.238226 -3.247293 -3.288358 -2.317639 -3.002487 -2.448946
Run5_240634646116662 -3.214985 -1.723710 -2.999413 -2.961188 -2.943235 -3.313745 -3.195997 -3.155884 -3.287020 -3.313846 ... -3.261648 -3.227281 6.755146 -3.123701 -1.910426 -3.291430 -3.266668 -2.904643 -3.145618 -2.423927
Run5_241057653508843 -3.131765 -1.470249 -3.009714 -3.150645 -2.879017 -3.316344 -2.992224 -3.141257 -3.266289 -3.320720 ... -3.239080 -3.224314 6.715484 -3.079334 -2.062277 -3.286197 -3.272701 -2.754143 -3.107597 -2.206956
Run5_241057653738918 -3.206009 -1.748883 -3.009993 -3.285835 -3.047671 -3.308838 -2.783817 -3.250304 -3.261938 -3.321765 ... -3.289759 -3.281842 6.191388 -3.199579 -2.620474 -3.310623 -3.294687 -2.843020 -3.071052 -2.420670
Run5_241057654294885 -3.218547 -1.931872 -2.941039 -2.919790 -2.990507 -3.312869 -3.232581 -3.137328 -3.284534 -3.313615 ... -3.267702 -3.220275 6.787180 -3.158191 -1.898689 -3.296052 -3.249541 -2.983549 -3.138883 -2.465398
Run5_241057668712349 -3.222011 -1.999752 -2.973683 -2.989801 -3.001002 -3.312437 -3.241935 -3.109851 -3.293589 -3.316340 ... -3.282284 -3.229025 6.772567 -3.154540 -1.922701 -3.298497 -3.248979 -3.000260 -3.137186 -2.448262
Run5_241057680972510 -3.140344 -1.494514 -3.044892 -3.094119 -2.861558 -3.313335 -2.862833 -3.123606 -3.238792 -3.320290 ... -3.217683 -3.241389 6.755012 -3.075304 -2.057132 -3.294334 -3.264303 -2.723860 -3.140005 -2.242671
Run5_241057681259245 -3.193832 -1.708359 -3.139337 -3.191103 -2.847580 -3.319246 -3.111503 -3.085577 -3.277826 -3.320917 ... -3.260521 -3.214783 6.666602 -3.098783 -1.985176 -3.283537 -3.213169 -2.840964 -3.050382 -2.231027
Run5_241057700113179 -3.159231 -1.461948 -2.972689 -3.158126 -2.914574 -3.316587 -3.062622 -3.142723 -3.263929 -3.319829 ... -3.256771 -3.207907 6.697169 -3.079022 -1.972894 -3.276248 -3.265674 -2.783967 -3.065442 -2.190339
Run5_241098858613659 -3.220162 -1.721533 -3.002838 -2.998812 -2.934196 -3.314088 -3.195992 -3.153672 -3.288375 -3.317105 ... -3.269058 -3.223339 6.740140 -3.111879 -1.888025 -3.289889 -3.265763 -2.929230 -3.129458 -2.443454
Run5_241098858810213 -3.185490 -1.498575 -2.861062 -3.138341 -2.954799 -3.313471 -3.034042 -3.185314 -3.251497 -3.320340 ... -3.278451 -3.229068 6.641273 -3.109784 -1.989495 -3.277527 -3.277994 -2.801917 -3.031900 -2.274487
Run5_241098873552118 -3.134463 -1.422929 -2.941147 -3.229845 -2.895447 -3.319049 -2.962541 -3.140419 -3.245506 -3.321468 ... -3.267859 -3.189547 6.656239 -3.076380 -2.085147 -3.278712 -3.261052 -2.726930 -3.073514 -2.130171
Run5_241098885647774 -3.029672 -1.707027 -2.561668 -1.108453 -2.796227 -3.302153 -2.892200 -3.238205 -3.097059 -3.252572 ... -3.217481 -3.237405 6.580580 -3.242798 -2.227968 -3.249543 -3.255394 -2.351237 -2.981197 -2.442039
Run5_241098904976174 -3.138503 -1.566602 -3.101759 -3.214470 -2.856883 -3.316849 -3.019188 -3.107945 -3.264846 -3.321554 ... -3.255565 -3.217595 6.684905 -3.082371 -2.094782 -3.280940 -3.250955 -2.790244 -3.060238 -2.150540
Run5_241098905205038 -3.138945 -1.493684 -2.981848 -2.966873 -2.844952 -3.312899 -2.698291 -3.145697 -3.197010 -3.319788 ... -3.213354 -3.243712 6.752877 -3.078947 -2.096419 -3.300151 -3.255906 -2.700804 -3.156759 -2.309089
Run5_241106375007076 -2.923881 -1.729871 -2.777274 -1.143981 -2.774147 -3.290595 -2.678590 -3.260127 -3.051016 -3.280753 ... -3.201482 -3.227900 6.537399 -3.241787 -2.331590 -3.272132 -3.216028 -2.325152 -3.036873 -2.411070
Run5_241106389756316 -3.194947 -1.289885 -3.068332 -3.151757 -2.775695 -3.305311 -1.973350 -3.110251 -2.992648 -3.321917 ... -3.251323 -3.209429 6.575693 -3.056624 -2.107170 -3.297740 -3.257921 -2.793294 -3.037845 -2.141973
Run5_241106389784372 -3.130010 -1.447876 -3.018643 -3.057054 -2.801635 -3.309102 -2.506153 -3.118257 -3.141229 -3.321594 ... -3.219318 -3.238605 6.734734 -3.056775 -2.108032 -3.304986 -3.243763 -2.681796 -3.152927 -2.254555
Run5_241106401770805 -3.132524 -1.356941 -3.006591 -3.253577 -2.783091 -3.319502 -2.570887 -3.078659 -3.183241 -3.321746 ... -3.256177 -3.172294 6.574304 -3.066900 -2.270817 -3.275082 -3.250769 -2.676230 -3.101180 -2.082148
Run5_241114577000174 -3.124879 -1.351343 -2.909282 -3.206047 -2.862171 -3.318179 -2.971534 -3.126657 -3.269699 -3.321471 ... -3.257846 -3.172518 6.644058 -3.005273 -1.959542 -3.280071 -3.271637 -2.737031 -3.075583 -2.111363
Run5_241114577004764 -3.139255 -1.445386 -3.073601 -3.221897 -2.848247 -3.305571 -2.500155 -3.134047 -3.148407 -3.321868 ... -3.249785 -3.215601 6.519693 -3.043005 -2.180765 -3.283983 -3.264422 -2.773278 -2.960356 -2.198471
Run5_241114589051630 -2.788986 -1.795620 -2.880063 -0.917752 -2.776454 -3.290136 -2.538701 -3.223378 -2.940625 -3.289864 ... -3.253349 -3.200817 6.491914 -3.206056 -2.296105 -3.294451 -3.233995 -2.160525 -3.053154 -2.436158
Run5_241114589051819 -3.140459 -1.470544 -3.026568 -3.080186 -2.818859 -3.308172 -2.630256 -3.131064 -3.176867 -3.321192 ... -3.226190 -3.237047 6.719744 -3.072656 -2.101145 -3.302088 -3.256258 -2.708915 -3.141650 -2.253366
Run5_241114589128940 -3.101402 -1.385691 -2.897740 -2.809494 -2.796280 -3.308600 -2.532806 -3.196049 -3.145657 -3.315582 ... -3.228901 -3.225371 6.639267 -3.111345 -2.189421 -3.287887 -3.260175 -2.616543 -3.105371 -2.265993

4714 rows × 16209 columns


In [13]:
der.plot_clusters_of_gene_trends(marker_data= magic_mb_data, genes = ['MAGIC HBB', 'MAGIC CD34', 'MAGIC MPO', 'MAGIC LYZ', 'MAGIC CST3'], branch= "Run4_235626713532342")


Run4_235626713532342
Time for processing Run4_235626713532342: 0.027271580696105958 minutes
Run5_239477254471070
Time for processing Run5_239477254471070: 0.02018060286839803 minutes
Finding 30 nearest neighbors using minkowski metric and 'auto' algorithm
Neighbors computed in 0.10970187187194824 seconds
Jaccard graph constructed in 0.13449382781982422 seconds
Wrote graph to binary file in 0.021192073822021484 seconds
Running Louvain modularity optimization
After 1 runs, maximum modularity is Q = 0.789828
Louvain completed 21 runs in 0.27453112602233887 seconds
PhenoGraph complete in 0.5834717750549316 seconds
Out[13]:
(<matplotlib.figure.Figure at 0x109cb0588>,
 <matplotlib.axes._subplots.AxesSubplot at 0x114e8d0b8>)

In [10]:
der.plot_clusters_of_gene_trends(marker_data =mb_data, genes = ['HBB', 'CD34', 'MPO', 'LYZ', 'CST3'], branch= 'Run5_161340154039083'


Run4_235626713532342
Time for processing Run4_235626713532342: 0.03389538526535034 minutes
Run5_161340154039083
Time for processing Run5_161340154039083: 0.026498699188232423 minutes
Run5_239477254471070
Time for processing Run5_239477254471070: 0.024944814046223958 minutes
Finding 30 nearest neighbors using minkowski metric and 'auto' algorithm
Neighbors computed in 0.10907316207885742 seconds
Jaccard graph constructed in 0.13175702095031738 seconds
Wrote graph to binary file in 0.03805804252624512 seconds
Running Louvain modularity optimization
After 1 runs, maximum modularity is Q = 0.512576
Louvain completed 21 runs in 0.3971428871154785 seconds
PhenoGraph complete in 0.694284200668335 seconds
Out[10]:
(<matplotlib.figure.Figure at 0x116ebc080>,
 <matplotlib.axes._subplots.AxesSubplot at 0x116e474e0>)

In [ ]:
trends

In [11]:
der.plot_clusters_of_gene_trends(marker_data= mb_data, genes = ['HBB', 'CD34', 'MPO', 'LYZ', 'CST3'], branch= 'Run5_239477254471070')


Run4_235626713532342
Time for processing Run4_235626713532342: 0.030156850814819336 minutes
Run5_161340154039083
Time for processing Run5_161340154039083: 0.02466394901275635 minutes
Run5_239477254471070
Time for processing Run5_239477254471070: 0.02221071720123291 minutes
Finding 30 nearest neighbors using minkowski metric and 'auto' algorithm
Neighbors computed in 0.10754823684692383 seconds
Jaccard graph constructed in 0.1486520767211914 seconds
Wrote graph to binary file in 0.05315995216369629 seconds
Running Louvain modularity optimization
After 1 runs, maximum modularity is Q = 0.564012
After 2 runs, maximum modularity is Q = 0.567554
Louvain completed 22 runs in 0.43536376953125 seconds
PhenoGraph complete in 0.7614130973815918 seconds
Out[11]:
(<matplotlib.figure.Figure at 0x115e65f98>,
 <matplotlib.axes._subplots.AxesSubplot at 0x1188116a0>)

References

Setty M, Tadmor MD, Reich-Zeliger S, Angel O, Salame TM, Kathail P, Choi K, Bendall S, Friedman N, Pe’er D. "Wishbone identifies bifurcating developmental trajectories from single-cell data." Nat. Biotech. 2016 April 12. http://dx.doi.org/10.1038/nbt.3569

van Dijk, David, et al. "MAGIC: A diffusion-based imputation method reveals gene-gene interactions in single-cell RNA-sequencing data." BioRxiv (2017): 111591. http://www.biorxiv.org/content/early/2017/02/25/111591

Go back to the top.