SkillAgentSearch skills...

ScHumanNet

Analysis cell-type-specific functional gene network, with SCINET and HumanNetv3

Install / Use

/learn @netbiolab/ScHumanNet
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

scHumanNet

Construction and analysis of cell-type-specific functional gene network with SCINET and HumanNetv3

License Python R

A unified mono-repository providing both R and Python implementations for constructing and analyzing cell-type-specific functional gene networks using single-cell RNA-seq data.

Framework Introduction

scHumanNet enables cell-type specific networks with scRNA-seq data. The SCINET framework (Mohammade et al. Cell Syst. 2019) takes a single cell gene expression profile and the “reference interactome” HumanNet v3, to construct a list of cell-type specific network. With the modified version of SCINET source code and the detailed tutorial described below, researchers could take any single-cell RNA sequencing (scRNA-seq) data of any biological context (e.g., disease) and construct their own cell-type specific network for downstream analysis.

For a given scRNA-seq data set, the SCINET framework utilize imputation, transformation, and normalization from the ACTIONet package(Mohammadi et al. Nat. Commun. 2018) to robustly capture cell-level gene interactions. HumanNet v3 with 1.1 million weighted edges are used as a scaffold information to infer the likelihood of each gene interactions. A subsampling scheme for each cell-type clusters (cell groups) ensures retaining of accurate gene interaction strength despite the incompleteness of single cell dataset at high resolution. Overall, we show that HumanNet v3 not only allow gene prioritization in broad spectrum of diseases, but through construction of context specific cell-type networks, also allow an in-depth study of disease heterogeneity and its underlying mechanism at a cellular level.

Installation

Conda Environment

For a complete environment with both R and Python we first set up conda environment:

# Clone the repository
git clone https://github.com/netbiolab/scHumanNet.git
cd scHumanNet

conda config --add channels conda-forge
conda config --add channels bioconda
conda env create -n scHumanNet -f packages/scHumanNet_env.yml
conda activate scHumanNet

Python Package

Install the Python package from the repository:

# Install Python package
pip install -e .

# Or install with development dependencies
pip install -e ".[dev]"

R Package

Install the R package:

  1. in command line terminal:
R CMD INSTALL ./packages/ACTIONet_2.0.18_HNv3
  1. in R:
# Install from the r-package directory
devtools::install("./r-package")

# Or install required dependencies first
install.packages(c("igraph", "dplyr", "data.table"))
devtools::install_github("shmohammadi86/SCINET")

Quick Start

Python

import schumannet as schn
import pandas as pd

# Load your networks and metadata
networks = schn.load_networks("path/to/networks/")
metadata = pd.read_csv("metadata.csv")

# Sort networks and add LLS weights
sorted_networks = schn.sort_add_lls(networks)

# Find hub genes
hub_results = schn.find_all_hub(sorted_networks, centrality='degree')

# Differential analysis
centralities = schn.get_centrality('degree', sorted_networks)
rank_df = schn.combine_perc_rank(centralities)
diff_results = schn.find_diff_hub(
    rank_df, metadata, 'celltype', 'condition', 'Control', sorted_networks
)

R

library(scHumanNet)
library(igraph)
library(dplyr)

# Load your data
data('HNv3_XC_LLS')
sorted.net.list <- SortAddLLS(Celltype.specific.networks, graph.hn3)

# Find hub genes
sig.hub.df <- FindAllHub(sorted.net.list, centrality="degree")

# Differential analysis
strength.list <- GetCentrality(method='degree', net.list = sorted.net.list)
rank.df.final <- CombinePercRank(strength.list)
diffPR.df.sig <- FindDiffHub(rank.df.final, meta, 'celltype', 'condition', 
                             'Control', sorted.net.list)

Command Line Interface

The Python package includes a CLI for common tasks:

# Find hub genes
schumannet find-hubs --networks ./networks/ --output hub_results.csv

# Differential analysis
schumannet diff-analysis --networks ./networks/ --metadata meta.csv \
  --celltype-col celltype --condition-col condition --control Control \
  --output diff_results.csv

# Calculate network statistics
schumannet network-stats --networks ./networks/ --output network_stats.csv

Repository Structure

scHumanNet/
├── python/schumannet/          # Python package
│   ├── __init__.py
│   ├── core.py                 # Core analysis functions
│   ├── utils.py                # Utility functions
│   └── cli.py                  # Command-line interface
├── r-package/                  # R package
│   ├── R/                      # R source code
│   ├── man/                    # R documentation
│   ├── DESCRIPTION
│   └── NAMESPACE
├── data/                       # Shared data files
├── examples/                   # Example scripts
│   ├── python_example.py
│   └── r_example.R
├── docs/                       # Documentation
├── figures/                    # Analysis scripts for figures
├── scripts/                    # Additional scripts
├── setup.py                    # Python package setup
├── pyproject.toml             # Python package configuration
└── README.md

Key Features

  • Dual Language Support: Both R and Python implementations with identical functionality
  • Statistical Framework: Non-parametric testing for hub gene significance
  • Differential Analysis: Compare networks between conditions/cell types
  • Network Connectivity: Assess functional connectivity of gene sets
  • Command Line Tools: Easy-to-use CLI for common workflows
  • Comprehensive Documentation: API reference and examples

Documentation

Construction of scHumanNet (Example 1)

For the first example case, we showcase the construction of scHumanNet using publically accessible pan-cancer dataset from Qian et al. Cell Research 2020. The 10X count folder and the metadata can be downloaded from http://blueprint.lambrechtslab.org.

load libraries

library(ACTIONet)
library(scHumanNet)
library(Seurat)
library(igraph)
counts <- Read10X('/your/path/to/BC_counts/')
meta <- read.table('/your/path/to/BC_metadata.csv', header = T, sep = ',')

Create sce object

This tutorial converts count data and metadata to sce obeject from SingleCellExperiment, to be used as intput for network construction.

data <- SingleCellExperiment(assays = list(logcounts = counts), colData = meta)

For seurat objects, manually insert count data and metadata within the SingleCellExperiment(), or use the as.SingleCellExperiment() provided in the Seurat package.

data <- SingleCellExperiment(assays = list(logcounts = seurat_object@assays$RNA@counts), colData = seurat_object@meta.data)
data <- Seurat::as.SingleCellExperiment(seurat.object)

Prior to scHumanNet construction, reduce data and use the ace class from the ACTIONet package. run.ACTIONet() is optional, this wrapper function performs matrix transformation via revese-rank normalization and imputation. For more information, refer to Mohammadi et al. Nat Communication

ace <- reduce.ace(data)
#ace = run.ACTIONet(ace = ace, thread_no = 8)

The column CellType of the metadata here indicates the column where each barcode is annotated from the user’s preferred choice of methods.

ace[['Labels']] <- meta$CellType

Load HumanNetv3 interactome and retrieve cell-type specific interactions. Command data('HNv3_XC_LLS') loads the interactome as an igraph object named graph.hn3.

data('HNv3_XC_LLS')
ace <- compute.cluster.feature.specificity(ace, ace$Labels, "celltype_specificity_scores")
Celltype.specific.networks = run.SCINET.clusters(ace, specificity.slot.name = "celltype_specificity_scores_feature_specificity")

Sort each genepair alphabetically and add LLS weight from HumanNetv3. Elements of sorted.net.list are stored as edgelist. This is later useful for assessing edge overlap between scHumanNets.

sorted.net.list <- SortAddLLS(Celltype.specific.networks, reference.network = graph.hn3)

Check each element of list and save scHumanNets, with both SCINET and LLS weights included in the edgelist for downstream analysis. R code used to analyze pan-cancer scHumanNet is included in the figures folder.

lapply(sorted.net.list, head)
saveRDS(sorted.net.list, './sorted_el_list.rds')

scHumanNet package provides a statistical framework to threshold functional hub genes from each cell-type specific networks via FindAllHub(). Briefly, it creates a null model of random networks by swapping edges with equal probability, thus creating a distribution of centrality values. Each hub's centrality is measured against this null distribution and a p-value is calculated. Default correction method is Benjamini-Hochberg method and the default threshold cut value is FDR < 0.05. To filter for genes, use the gene column and not the rownames.

sig.hub.df <- FindAllHub(sorted.net.list, centrality="degree")
sig.hub.df

| Centrality | gene | pvalue | qvalue | celltype | |-------------|------|----------|--------|----------| | 1 | CD19 | 0.0000891981090000892 | 0.00428745577260429 | B_cell | | 0.9995374 | CD40 | 0.000089198

Related Skills

View on GitHub
GitHub Stars45
CategoryProduct
Updated2mo ago
Forks10

Languages

C++

Security Score

90/100

Audited on Jan 22, 2026

No findings