In this notebook, we demonstrate the utility of CRank, an automatic method for prioritizing network communities and identifying the most promising ones for further experimentation, for the analysis of single-cell RNA-sequencing data.
This notebook reproduces Figure 4 in the CRank paper on Prioritizing network communities.
Single-cell RNA sequencing has transformed our understanding of complex cell populations (Trapnell, et al., Genome Research 2015). While many types of questions can be answered using single-cell RNA-sequencing, a central focus is the ability to survey the diversity of cell types within a sample.
To demonstrate that CRank scales to large networks, we used the single-cell RNA-seq dataset containing 1,306,127 embroyonic mouse brain cells (Zheng et al., Nature Communications 2017 and 10x Genomics) for which no cell types are known. Dataset was preprocessed using standard procedures to select and filter the cells based on quality-control metrics, normalize and scale the data, detect highly variable genes, and remove unwanted sources of variation (Satija et al., Nature Biotechnology 2015).
The dataset was represented as a weighted graph of nearest neighbor relations (edges) among cells (nodes), where relations indicated cells with similar gene expression patterns calculated using diffusion pseudotime analysis (Haghverdi et al., Nature Methods 2016). To partition this graph into highly interconnected communities we apply a community detection method proposed for single-cell data (Levine et al., Cell 2015).
Community detection analysis segregates the cells into 141 fine-grained communities, the largest containing 18,788 (1.8% of) and the smallest only 203 (0.02% of) cells. After detecting the communities, CRank takes the cell-cell interaction network and the detected communities, and generates a rank-ordered list of communities, assigning a priority to each community. CRank's prioritization of communities derived from the cell-cell interaction network takes less than 2 minutes.
(Last compiled and run on: 11/08/2017)
from operator import itemgetter
import numpy as np
import scanpy.api as sc
import pandas as pd
from matplotlib import pyplot as plt
sc.settings.verbosity = 3
sc.settings.set_figure_params(dpi=70)
sc.logging.print_version_and_date()
%matplotlib inline
ANALYSIS_DATA = '1M_neurons_corrected'
LOG_EXPRESSION_MATRIX = '1M_neurons_filtered_raw_log'
PRIORITIZATION = '1M_neurons_prioritization.txt'
Load the single-cell RNA-seq dataset.
We preprocessed (normalized, filtered) the dataset, constructed cell-cell interaction network, calculated diffusion map, computed t-SNE and PCA projections, and detected communities. These computations take several hours and need substantial amounts of memory. For convenience, adata_corrected
object contains all results of these computations. Note that these computations represent the standard pipeline in the analysis of single-cell RNA-seq data; they are not in any way specific to CRank and are not required by CRank.
Also, load the log-normalized expression matrix (UMI count matrix).
adata_corrected = sc.read(ANALYSIS_DATA)
adata_raw = sc.read(LOG_EXPRESSION_MATRIX)
Print variables in adata_corrected
object containing results of additional analyses run on the cell-cell interaction network.
print(adata_corrected.add.keys())
print()
print(adata_corrected.smp.keys())
print()
print(adata_corrected.var.keys())
Plot 1 million cells in the cell-cell interacton network using t-SNE. Color cells according to clustering of cells into clusters/communities; cells assigned to each community are distinguished by color.
N = len(set(adata_corrected.smp['louvain_groups']))
c = plt.cm.get_cmap('hsv', N+1)
colors = [c(i) for i in range(N)]
fig, ax = plt.subplots(figsize=(12, 10))
sc.pl.scatter(adata_corrected, basis='tsne', color='louvain_groups', palette=colors, ax=ax, legend_loc='none');