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>