Skip to main content

HiScanner (HIgh-resolution Single-Cell Allelic copy Number callER)

PyPI version License: MIT

HiScanner is a python package for high-resolution single-cell copy number analysis. It supports two modes of operation:

  1. Standard Pipeline (RDR + BAF): Full analysis using both read depth ratios (RDR) and B-allele frequencies (BAF)
  2. RDR-only Pipeline: Simplified analysis using only read depth ratios

We provide a demo dataset and tutorial to help you get started. After installation, see https://github.com/parklab/hiscanner_demo for instructions. The typical run time for the demo without (--use-cluster option) is less than 30 minutes.

Table of Contents

Installation

# Create new conda environment with all dependencies
conda create -n hiscanner_test \
    -c conda-forge -c bioconda -c defaults \
    python=3.8 samtools=1.15.1 bcftools=1.13 r-base "r-mgcv>=1.8"
conda activate hiscanner_test
pip install hiscanner --no-cache-dir

HiScanner (version 1.3) has been tested with Linux distributions:

  • CentOS Linux release 7.9.2009
  • Ubuntu 20.04.6 LTS (GNU/Linux 5.4.0-204-generic x86_64)

The typical installation time is less than 5 minutes.

Required External Files:

1) Mappability Track

hg19/GRCh37 (100mer)
wget https://www.math.pku.edu.cn/teachers/xirb/downloads/software/BICseq2/Mappability/hg19CRG.100bp.tar.gz --no-check-certificate
tar -xvzf hg19CRG.100bp.tar.gz
hg38/GRCh38 (150mer)

Download from: https://doi.org/10.6084/m9.figshare.28370357.v1

Other reference genomes: instructions on custom track generation

For other genomes/read length configurations, follow instructions at CGAP Annotations to generate mappability tracks.

IMPORTANT: Guidelines when choosing mappability tracks
  • Shorter mappability track (e.g., 100bp) with longer reads (e.g., 150bp): Valid but conservative (some uniquely mappable regions may be missed)
  • Longer mappability track (e.g., 150bp) with shorter reads (e.g., 100bp): Not valid, will cause false positives

2) Reference Genome

We require the reference genome fasta to be split into chromosomes, to allow for parallel processing. You can use the following command to split the reference genome:

samtools faidx /path/to/reference.fasta
mkdir /path/to/reference/split
awk '{print $1}' /path/to/reference.fasta.fai | xargs -I {} sh -c 'samtools faidx /path/to/reference.fasta {} > /path/to/reference/split/{}.fasta'

Pipeline Options

HiScanner offers two pipeline options:

1. Standard Pipeline (RDR + BAF)

Uses both read depth ratios and B-allele frequencies for comprehensive CNV analysis.

Steps:

  1. SNP Calling (via SCAN2)
  2. Phasing & BAF Computation
  3. ADO Analysis
  4. Segmentation
  5. CNV Calling

Requirements:

  • SCAN2 output files
  • Bulk and single cell BAM files
  • Reference genome
  • Mappability tracks

2. RDR-only Pipeline

Uses only read depth ratios for simplified CNV analysis.

Steps:

  1. Segmentation
  2. CNV Calling

Requirements:

  • Single cell BAM files
  • Reference genome
  • Mappability tracks

Running the Pipeline

Option 1: Standard Pipeline (RDR + BAF)

Step 1: SCAN2 (Prerequisites)

SCAN2 needs to be run separately before using HiScanner.

Note: If you only need SCAN2 output for HiScanner (and are not interested in SNV calls), you can save time by running SCAN2 with:

scan2 run --joblimit 5000 --snakemake-args ' --until shapeit/phased_hets.vcf.gz --latency-wait 120'

This will stop at the phasing step, which is sufficient for HiScanner's requirements.

If you have already run SCAN2, ensure you have:

  • VCF file with raw variants (gatk/hc_raw.mmq60.vcf.gz)

  • Phased heterozygous variants (shapeit/phased_hets.vcf)

  • Additionally, we note that the phased genotype field in phased_hets.vcf should be named as phasedgt. This is the expected output from the SCAN2 pipeline that we have tested with. If your VCF file has a different field name, please manually rename it to phasedgt in the VCF.

The expected location is scan2_out/ in your project directory.

Steps 2-5: HiScanner Pipeline

1. Initialize HiScanner project
hiscanner init --output ./my_project
cd my_project
2. Edit config.yaml

Edit with your paths and parameters

3. Prepare metadata file

Must contain the following columns:

bamID    bam    singlecell
bulk1    /path/to/bulk.bam    N
cell1    /path/to/cell1.bam   Y 
cell2    /path/to/cell2.bam   Y
4. Validate configuration
hiscanner validate
5. Run the pipeline
hiscanner run --step snp      # Check SCAN2 results
hiscanner run --step phase    # Process SCAN2 results
hiscanner run --step ado      # ADO analysis to identify optimal bin size
hiscanner run --step normalize # Normalize read depth ratios
hiscanner run --step segment  # Segmentation
hiscanner run --step cnv      # CNV calling

# Or run all steps at once:
hiscanner run --step all

For normalize (the most time-consuming step), we provide an option to run with cluster, e.g.,

hiscanner --config config.yaml run --step normalize --use-cluster

Option 2: RDR-only Pipeline

1. Initialize project
hiscanner init --output ./my_project
cd my_project
2. Edit config.yaml
  • Set rdr_only: true
  • Configure paths and parameters
3. Prepare metadata file

Must contain the following columns (bulk samples are not required):

bamID    bam    singlecell
cell1    /path/to/cell1.bam   Y 
cell2    /path/to/cell2.bam   Y
4. Validate configuration
hiscanner validate
5. Run the pipeline
hiscanner run --step normalize # Normalize read depth ratios
hiscanner run --step segment  # Segmentation
hiscanner run --step cnv      # CNV calling

Output Structure

hiscanner_output/
├── phased_hets/       # Processed heterozygous SNPs (Standard pipeline only)
├── ado/               # ADO analysis results (Standard pipeline only)
├── bins/             # Binned read depth
├── segs/             # Segmentation results
└── final_calls/      # Final CNV calls

Cleaning Up

HiScanner creates several temporary directories during analysis. You can clean these up using the clean command:

hiscanner clean

Troubleshooting

Common issues:

  1. SCAN2 output formatting issues (hg38 users): Newer SCAN2 versions using Eagle phasing (instead of SHAPEIT) may produce incompatible genotype formatting. Solution: Clean the GT field in phased_hets.vcf.gz to keep only the phase information (e.g., "0|1", instead of "0|1:5,6:7,8").
  2. Missing SCAN2 results: Ensure scan2_output directory is correctly specified. If the vcf is not zip-compressed, you can use bgzip to compress it (in scan2 environment).
bgzip scan2_out/gatk/hc_raw.mmq60.vcf
tabix -p vcf scan2_out/gatk/hc_raw.mmq60.vcf.gz
  1. File permissions: Check access to BAM files and reference data
  2. Memory issues: Adjust batch_size in config.yaml

Support

HiScanner is currently under active development. For support or questions, please open an issue on our GitHub repository.

Citation

If you use HiScanner in your research, please cite:

Zhao, Y., Luquette, L. J., Veit, A. D., Wang, X., Xi, R., Viswanadham, V. V., ... & Park, P. J. (2025). High-resolution detection of copy number alterations in single cells with HiScanner. Nature Communications, 16(1), 5477.

License

HiScanner is freely available for non-commercial use.

Metadata

Release files for hiscanner 1.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hiscanner 1.6.1
File Size Uploaded
hiscanner-1.6.1.tar.gz 4.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for hiscanner 1.6.1
File Interpreter ABI Platform
hiscanner-1.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 MB

Release files / hiscanner-1.6.1.tar.gz

Download URL hiscanner-1.6.1.tar.gz
Size 4.8 MB
Tags Source
SHA-256 checksum
How to use checksums
644f083e9a52379ae4d8e95287ffa59256f63675a7d3388a3f32754f56d147c5
BLAKE2b-256 checksum
How to use checksums
438ec1e820b9e57dc52ec1c00617f3324fa3d1879137614fd14f3d264ed38c04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.8.19 Linux/5.14.0-570.32.1.el9_6.x86_64

Release files / hiscanner-1.6.1-py3-none-any.whl

Download URL hiscanner-1.6.1-py3-none-any.whl
Size 4.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
beecb5dd0e6d9ad69e0fa309c0164abffcb4b772a49c2315ac58a7d60ec90654
BLAKE2b-256 checksum
How to use checksums
36f677bfb75fb7bebaa7546bc11beccdc1211bf281ddff2ac8afd1f9aeb9c42d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.8.19 Linux/5.14.0-570.32.1.el9_6.x86_64
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page