scTE: Quantifying transposable element (TEs) expression from single-cell sequencing data
scTE takes as input:
- Aligned sequence reads (BAM/SAM format)
- The genomic location of TEs (BED format)
- The genomic location of genes (GTF format)
Note
This repository is a fork from https://github.com/JiekaiLab/scTE
Installation
From PyPI
$ pip install scte-quant
From conda
It is recommended to use conda for installation, since it enhanced reproducibility and easier to manage dependencies.
$ conda create -n scte --channel-priority 0 --override-channels -c bioconda -c conda-forge -c billsfriend scte
From source
$ git clone https://gitee.com/billsfriend/scTE
$ cd scTE
$ pip install .
Usage
Building genome indices
scTE builds genome indices for the fast alignment of reads to genes and TEs. These indices can be automatically generated using the commands:
$ scTE_build -g mm10 # Mouse
$ scTE_build -g hg38 # Human
$ scTE_build -g panTro6 # Chimpanzee
$ scTE_build -g macFas5 # Macaca fascicularis
$ scTE_build -g dm6 # Drosophila melanogaster
$ scTE_build -g danRer11 # Zebrafish
$ scTE_build -g xenTro9 # Xenopus tropicalis
These scripts will automatically download the genome annotations, for mouse:
$ ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_mouse/release_M21/gencode.vM21.annotation.gtf.gz
$ http://hgdownload.soe.ucsc.edu/goldenPath/mm10/database/rmsk.txt.gz
Or for human:
$ ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/release_30/gencode.v30.annotation.gtf.gz
$ http://hgdownload.soe.ucsc.edu/goldenPath/hg38/database/rmsk.txt.gz
Or for Chimpanzee:
$ http://ftp.ensembl.org/pub/release-103/gtf/pan_troglodytes/Pan_troglodytes.Pan_tro_3.0.103.gtf.gz
$ https://hgdownload.soe.ucsc.edu/goldenPath/panTro6/database/rmsk.txt.gz
Or for Macaca fascicularis:
$ http://ftp.ensembl.org/pub/release-102/gtf/macaca_fascicularis/Macaca_fascicularis.Macaca_fascicularis_5.0.102.gtf.gz
$ http://hgdownload.soe.ucsc.edu/goldenPath/macFas5/database/rmsk.txt.gz
Or for Drosophila melanogaster:
$ http://ftp.ensembl.org/pub/release-103/gtf/drosophila_melanogaster/Drosophila_melanogaster.BDGP6.32.103.gtf.gz
$ http://hgdownload.soe.ucsc.edu/goldenPath/dm6/database/rmsk.txt.gz
Or for Zebrafish:
$ http://ftp.ensembl.org/pub/release-103/gtf/danio_rerio/Danio_rerio.GRCz11.103.gtf.gz
$ https://hgdownload.soe.ucsc.edu/goldenPath/danRer11/database/rmsk.txt.gz
Or for Xenopus tropicalis:
$ http://ftp.ensembl.org/pub/release-103/gtf/xenopus_tropicalis/Xenopus_tropicalis.Xenopus_tropicalis_v9.1.103.gtf.gz
$ https://hgdownload.soe.ucsc.edu/goldenPath/xenTro9/database/rmsk.txt.gz
mm10, hg38, panTro6, macFas5, dm6, danRer11, xenTro9 is the genome
assembly version. If you want to use your customs reference, you can use
the -gene -te options:
scTE_build -te TEs.bed -gene Genes.gtf -o costum
-te
Bed file for transposable elements annotation with at least 4 columns of chr, start, end & name of TE. Support .gz format.
-gene
Gtf file for genes annotation. Support .gz format.
For TEs.bed and Genes.gtf of other versions and species, TEs.bed derived from (rmsk.txt.gz)
on UCSC goldenPath and Genes.gtf (<species>.gtf.gz) from
Ensembl are well-tested and recommended.
For pre-set genomes (-g), rmsk.txt.gz is downloaded from UCSC and parsed
directly — no manual conversion needed. TEs are filtered to include only DNA,
LINE, LTR, SINE, Satellite and Retroposon. Satellite DNA is not classified as
TE by convention. If you want to customize your genome indices of TE, please
filter TEs.bed as you will before running scTE_build.
Building a custom index also writes an .annotations.txt file listing every annotation name
tagged with its source type (gene or TE), useful for downstream filtering.
For more information about BED and GTF format, see from
UCSC. These annotations are
then processed and converted into genome indices. The scTE algorithm
will allocate reads first to gene exons, and then to TEs by default.
Hence TEs inside exon/UTR regions of genes annotated in GENCODE will
only contribute to the gene, and not to the TE score. This feature can
be changed by setting –mode/-m inclusive in scTE, which will instruct
scTE to assign the reads to both TEs and genes if a read comes from a TE
inside exon/UTR regions of genes. If you want to remove the TEs inside
the intron of genes, you can sete –mode/-m nointron in scTE
Analysis of 10x style scRNA-seq data
scTE makes BAM/SAM file as input, highly recommend to use unfiltered alignment file as input.
For bam file generated by
STARsolo etc, the cell barcodes and
UMI need to be integrated into the read 'CR:Z' or 'UR:Z' tage as bellow:
$ scTE -i inp.bam -o out -x mm10.exclusive.idx --hdf5 True -CB CR -UMI UR
$ samtools view test.bam
A00269:12:H7YF2DMXX:2 0 chr10 55902580 255 50M * 0 0 GTTCTCTCCGTATGTGAGCATGGGAGATACATCCCAGAAAGGCAGAAGGG FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF NH:i:1 HI:i:1 AS:i:49 nM:i:0 CR:Z:CTAGAGTGTTTCGCTC CY:Z:FFFFFFFFFFFFFFFF UR:Z:TACATGACGC UY:Z:FFFFFFFFFF
A00269:13:H7YF2DMXX:2 0 chr10 55902784 255 50M * 0 0 ATAATCTTTGAGATCTCTGGTGAAAATAAGTAGCATAAAGGACAGAATCA FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF NH:i:1 HI:i:1 AS:i:49 nM:i:0 CR:Z:CTAGAGTGTTTCGCTC CY:Z:FFFFFFFFFFFFFFFF UR:Z:TACATGACGC UY:Z:FFFFFFFFFF
A00269:14:H7YF2DMXX:2 0 chr13 67837311 255 50M * 0 0 CTGTTCATTATTTGAGGAAATCAGGACAGGAAATCAAACATGGCAGAATC FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF NH:i:1 HI:i:1 AS:i:49 nM:i:0 CR:Z:ATCGAGTGTTTCGCTC CY:Z:FFFFFFFFFFFFFFFF UR:Z:TACATGACGC UY:Z:FFFFFFFFFF
A00269:15:H7YF2DMXX:2 0 chr14 114380523 255 50M * 0 0 GATCCAGATTAATTGAGACTGTTGATCCTCCTACAGGGTCGCCCTTCTCC FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF NH:i:1 HI:i:1 AS:i:49 nM:i:0 CR:Z:CTAGAGTGTTTCGCTC CY:Z:FFFFFFFFFFFFFFFF UR:Z:TACATGACGC UY:Z:FFFFFFFFFF
For bam file generated by Cell
Ranger
etc, the cell barcodes and UMI need to be integrated into the read
'CB:Z' or 'UB:Z' tage as bellow:
$ scTE -i inp.bam -o out -x mm10.exclusive.idx --hdf5 True -CB CB -UMI UB
$ samtools view test.bam
A00519:758:HTCCHDSXY:3:2535:21296:19774 16 chr1 14021 0 90M * 0 0 TGGATTTCTATCTCCCTGGCTTGGTGCCAGTTCCTCCAAGTCGATGGCACCTCCCTCCCTCTCAACCACTTGAGCAAACTCCAAGACATC ,FFFFFFFFFFFFFFFFFFFFFFFFFFFFF:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:F:FFFFFFFFFFFFFFFFFFF:FFFFF NH:i:5 HI:i:1 AS:i:88 nM:i:0 RG:Z:SC3_v3_NextGem_DI_CellPlex_Human_PBMC_10K:0:1:HTCCHDSXY:3 RE:A:I xf:i:0 CR:Z:CTCCCTCCACTGCGAC CY:Z:FFFFFFFFFFFFFFFF CB:Z:CTCCCTCCACTGCGAC-1 UR:Z:AAGGCGTAGTAG UY:Z:FFFFFFFFFFFF UB:Z:AAGGCGTAGTAG
A00519:758:HTCCHDSXY:1:1355:17237:31720 0 chr1 14260 0 90M * 0 0 CTCCCTCTCATCCCAGAGAAACAGGTCAGCTGGGAGCTTCTGCCCCCACTGCCTAGGGACCAACAGGGGCAGGAGGCAGTCACTGACCCC FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF NH:i:5 HI:i:1 AS:i:88 nM:i:0 RG:Z:SC3_v3_NextGem_DI_CellPlex_Human_PBMC_10K:0:1:HTCCHDSXY:1 RE:A:I xf:i:0 CR:Z:TCGTCCACAGTATGAA CY:Z:FFFFFFFFFFFFFFFF CB:Z:TCGTCCACAGTATGAA-1 UR:Z:GACTTATTTTTT UY:Z:FFFFFFFFFFFF UB:Z:GACTTATTTTTT
A00519:758:HTCCHDSXY:3:2227:16703:32080 16 chr1 14411 1 90M * 0 0 TCAGTTCTTTATTGATTGGTGTGCCGTTTTCTCTGGAAGCCTCTTAAGAACACAGTGGCGCAGGCTGGGTGGAGCCGTCCCCCCATGGAG FFFFFFFFFFFFFFFFFFFFFFFFFFF:FFFF:FFFFFFFF:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF NH:i:3 HI:i:1 AS:i:88 nM:i:0 RG:Z:SC3_v3_NextGem_DI_CellPlex_Human_PBMC_10K:0:1:HTCCHDSXY:3 RE:A:I xf:i:0 CR:Z:TTGAGTGGTTGTGGCC CY:Z:FFFFFFFFFFFFFFFF CB:Z:TTGAGTGGTTGTGGCC-1 UR:Z:TATAATGCTCAG UY:Z:FFFFFFFFFFFF UB:Z:TATAATGCTCAG
A00519:758:HTCCHDSXY:3:2563:23665:33802 16 chr1 14411 1 90M * 0 0 TCAGTTCTTTATTGATTGGTGTGCCGTTTTCTCTGGAAGCCTCTTAAGAACACAGTGGCGCAGGCTGGGTGGAGCCGTCCCCCCATGGAG FFFFF:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:FFFFFFFF:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF NH:i:3 HI:i:1 AS:i:88 nM:i:0 RG:Z:SC3_v3_NextGem_DI_CellPlex_Human_PBMC_10K:0:1:HTCCHDSXY:3 RE:A:I xf:i:0 CR:Z:TGTTGAGAGGCAATGC CY:Z:FFFFFFFFFFFFFFFF CB:Z:TGTTGAGAGGCAATGC-1 UR:Z:ACGGGTGTGGAG UY:Z:FFFFFFFFFFFF UB:Z:ACGGGTGTGGAG
-i
Input file: BAM/SAM file from CellRanger or STARsolo
-o
Output file prefix
-x
The filename of the index for the reference genome annotation generated by scTE_build
-p
Number of threads to use, Default: 1. scTE takes ~10Gb memory each thread for human and mouse genome.
--hdf5
Save the output as .h5ad formatted file instead of csv file. Default: False
--max-chunk-lines
Maximum lines per chunk when splitting large chromosome BEDs during alignment.
0 = adaptive (targets 2x thread count tasks). Useful for balancing load across workers.
Default: 0
--intermediate-compression
Compression for intermediate BED files: zstd (default, faster), gzip, or none.
Auto-detects zstd CLI and falls back to gzip if unavailable.
scTE is most tuned to STARsolo or
the Cell
Ranger
pipeline outputs, and can accept BAM files produced by either of these
two programs. For other aligners, the barcode should be stored in the
CR:Z or CB:Z tag, and the UMI in the UR:Z or UB:Z tag in the BAM
file
Analysis of C1 style scRNA-seq data
If the UMI is missing or not
used in the scRNA-seq technology (for example on the Fluidigm C1
platform), it can be disabled with –UMI False (the default is True)
switch in scTE. If the barcode is missing it can be disabled with the
–CB False (the default is True), and instead the cell barcodes will be
taken from the names of the BAM files.
$ scTE -i inp.bam -o out -x mm10.exclusive.idx -CB False -UMI False
multiple BAM files can be provided to scTE with the –i option
$ scTE -i *.bam -o out -x mm10.exclusive.idx -CB False -UMI False
or
$ scTE -i input1.bam,input2.bam,... -o out -x mm10.exclusive.idx -CB False -UMI False
Accelerated backend: polars-bio
scTE can optionally use polars-bio as the BAM parsing and interval-overlap engine. When installed, it is auto-detected and used by default — no manual flag needed.
$ pip install scte-quant[bio] # install with polars-bio support
Control with the --use-polars-bio flag:
$ scTE -i inp.bam -o out -x mm10.exclusive.idx --use-polars-bio yes # force on
$ scTE -i inp.bam -o out -x mm10.exclusive.idx --use-polars-bio no # force off
$ scTE -i inp.bam -o out -x mm10.exclusive.idx --use-polars-bio auto # default
Tradeoffs vs the original samtools/pysam backend:
| Factor | polars-bio | Original (samtools/pysam) |
|---|---|---|
| Speed | ~3-6× faster | baseline |
| Memory | ~4× more RAM | baseline (0.72 GB) |
| CPU utilization | Auto-parallelizes at ~2 cores | Scales with -p via multiprocessing + samtools threads |
-p flag effect |
Ignored — internal auto-parallel only | Controls pool size + samtools threads |
Benchmark (single bulk BAM, 892 MB, hg38, 0.1× sample):
| Mode | -p |
Wall time | CPU% | Peak RAM |
|---|---|---|---|---|
| polars-bio | 1 | 14.7 s | 187% | 2.95 GB |
| polars-bio | 12 | 13.9 s | 182% | 2.97 GB |
| Original | 1 | 87.2 s | 126% | 0.72 GB |
| Original | 12 | 46.8 s | 433% | 0.72 GB |
Consistency with original backend (same 892 MB hg38 bulk BAM):
| Metric | Value |
|---|---|
| Pearson r (all genes) | 0.957 |
| Spearman r | 0.954 |
| PB total assignments | 9.37 M |
| NP total assignments | 6.45 M |
| PB TE assignments | 1.58 M |
| NP TE assignments | 0.69 M |
Polars-bio assigns 45% more reads overall and 2.3× more to TEs. The difference
is concentrated in repeat families (MLT1*, THE1B, MSTA) and stems from polars-bio
reading all alignments in the BAM via its native DataFusion parser, whereas the
original samtools view | awk | sed pipeline drops some (multi-mapping or
secondary/supplementary) alignments. For most use cases polars-bio provides
more complete read counting; if bit-for-bit reproducibility with the original
backend is required, use --use-polars-bio no.
polars-bio is substantially faster per-file but uses more memory and does not yet distribute work across multiple BAM files in parallel. For single-file runs and memory-sufficient environments it provides the best throughput.
Development roadmap
v1.5.x — Current (polars-bio integration)
- polars-bio accelerated BAM scanning and interval overlap
- Auto-detection with
--use-polars-bio {auto,yes,no} - UMI deduplication and cell-barcode whitelist filtering
- Unified verbose logging (per-chromosome breakdown) with original backend
- Bulk mode (
-CB False) with multi-sample support
v1.6.x — Near-term
- EM multi-mapping resolution — Expectation-Maximization algorithm
to probabilistically resolve multi-mapping reads across candidate TE
features, with per-cell independent EM and configurable iterations
(branch:
feat/em-multiresolution-analysis) - Multi-resolution quantification — TE taxonomy hierarchy
(class / family / subfamily / locus) with
--resolutionflag, enabling aggregation from repeat-level to repeat-family counts - scTE_analyze — standalone CLI for downstream analysis: TE-aware normalization (CPM, log1p-CPM), differential expression (Wilcoxon rank-sum), TE-gene correlation (genome-wide and cis), and publication-ready plots (volcano, heatmap, correlation network)
- scTEATAC optimization — BAM→BED via pysam fallback (no bedtools
required),
--emflag for ATAC multi-mapping resolution, dedicated ATAC test data and CI integration tests - Multi-sample parallelism for polars-bio: distribute BAM files across
worker processes using the
-pthread count, matching the original backend's multiprocessing behaviour - Controlled polars-bio parallelism: expose DataFusion thread count via
-p(or a dedicated flag) so users can tune CPU/memory tradeoffs
v1.7.x — Future
- Pluggable plugin system for custom quantification workflows (post-alignment filtering, per-repeat-family aggregation, etc.)
- Native
.h5ad/.zarrchunked output support for large datasets - CI/CD with automated PyPI and conda releases on version tags
Analysis of scATAC-seq data
The genome indices were prebuilt using:
$ wget -c http://hgdownload.soe.ucsc.edu/goldenPath/mm10/database/rmsk.txt.gz -O mm10.te.txt.gz
$ zcat mm10.te.txt.gz | grep -E 'LINE|SINE|LTR|Retroposon' | cut -f6-8,11 >mm10.te.bed
$ scTEATAC_build -g mm10.te.bed -o mm10.te.atac
Then the bam file can processe using scTE with the command:
scTEATAC -i input.bam -x mm10.te.atac.idx
Citation
If scTE is useful for your research, consider citing Nature Communications (2021)
Metadata
Release files for scte-quant 1.5.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| scte_quant-1.5.4.tar.gz | 228.7 kB | Without provenance | Details for scte_quant-1.5.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| scte_quant-1.5.4-py3-none-any.whl | Python 3 | none | any | Details for scte_quant-1.5.4-py3-none-any.whl |
Total release size: 300.0 kB
Release files / scte_quant-1.5.4.tar.gz
| Download URL | scte_quant-1.5.4.tar.gz |
|---|---|
| Size | 228.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d93fe82edba21667ba0640264fbfa47bfdd36cc058cfc7f842989efc2399cc8
|
|
BLAKE2b-256 checksum How to use checksums |
5de66ba695e65ef575f7347ba8ebbd2062c2293e538c53314e3c41e8c83f6c57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / scte_quant-1.5.4-py3-none-any.whl
| Download URL | scte_quant-1.5.4-py3-none-any.whl |
|---|---|
| Size | 71.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3e0107f60892a5b7002c126e3daddf9b511e73b12854052b835ce2a6954a1ce
|
|
BLAKE2b-256 checksum How to use checksums |
54431ad4c0f0936389b1d6d40108b725c20d0b346a3a66bbd01aab9907c174d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for scte-quant 1.5.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.