Package: kb-python
kb-pythonkb-pythonis a python package for processing single-cell RNA-sequencing. It wraps thekallisto|bustoolssingle-cell RNA-seq command line tools in order to unify multiple processing workflows.kb-pythonwas developed byKyung Hoi (Joseph) MinandA. Sina Booeshaghiwhile inLior Pachter's lab at Caltech. If you usekb-pythonin a publication pleasecite*:Melsted, P., Booeshaghi, A.S., et al. 
Modular, efficient and constant-memory single-cell RNA-seq preprocessing. 
Nat Biotechnol  39, 813–818 (2021). 
https://doi.org/10.1038/s41587-021-00870-2InstallationThe latest release can be installed withpipinstallkb-pythonThe development version can be installed withpipinstallgit+https://github.com/pachterlab/kb_pythonThere are no prerequisite packages to install. Thekallistoandbustoolsbinaries are included with the package.Usagekbconsists of four subcommands$kb
usage:kb[-h][--list]<CMD>...
positionalarguments:<CMD>infoDisplaypackageandcitationinformationcompileCompile`kallisto`and`bustools`binariesfromsourcerefBuildakallistoindexandtranscript-to-genemappingcountGeneratecountmatricesfromasetofsingle-cellFASTQfileskb ref: generate a pseudoalignment indexThekb refcommand takes in a species annotation file (GTF) and associated genome (FASTA) and builds a species-specific index for pseudoalignment of reads. This must be run beforekb count. Internally,kb refextracts the coding regions from the GTF and builds a transcriptome FASTA that is then indexed withkallisto index.kbref-iindex.idx-gt2g.txt-f1transcriptome.fa<GENOME><GENOME_ANNOTATION><GENOME>refers to a genome file (FASTA).For example, the zebrafish genome is hosted byensembland can be downloadedhere<GENOME_ANNOTATION>refers to a genome annotation file (GTF)For example, the zebrafish genome annotation file is hosted byensembland can be downloadedhereNote:The latest genome annotation and genome file for every species on ensembl can be found with theggetcommand-line tool.Prebuilt indices are available athttps://github.com/pachterlab/kallisto-transcriptome-indicesExamples# Index the transcriptome from genome FASTA (genome.fa.gz) and GTF (annotation.gtf.gz)$kbref-iindex.idx-gt2g.txt-f1transcriptome.fagenome.fa.gzannotation.gtf.gz# An example for downloading a prebuilt reference for mouse$kbref-dmouse-iindex.idx-gt2g.txtkb count: pseudoalign and count readsThekb countcommand takes in the pseudoalignment index (built withkb ref) and sequencing reads generated by a sequencing machine to generate a count matrix. Internally,kb countruns numerouskallistoandbustoolscommands comprising a single-cell workflow for the specified technology that generated the sequencing reads.kbcount-iindex.idx-gt2g.txt-oout/-x<TECHNOLOGY><FASTQFILE[s]><TECHNOLOGY>refers to the assay that generated the sequencing reads.For a list of supported assays runkb --list<FASTQ FILE[s]>refers to the a list of FASTQ files generatedDifferent assays will have a different number of FASTQ filesDifferent assays will place the different features in different FASTQ filesFor example, sequencing a 10xv3 library on a NextSeq Illumina sequencer usually results in two FASTQ files.TheR1.fastq.gzfile (colloquially called "read 1") contains a 16 basepair cell barcode and a 12 basepair unique molecular identifier (UMI).TheR2.fastq.gzfile (colloquially called "read 2") contains the cDNA associated with the cell barcode-UMI pair in read 1.Examples# Quantify 10xv3 reads read1.fastq.gz and read2.fastq.gz$kbcount-iindex.idx-gt2g.txt-oout/-x10xv3read1.fastq.gzread2.fastq.gzkb info: display package and citation informationThekb infocommand prints out package information including the version ofkb-python,kallisto, andbustoolsalong with their installation location.$kbinfo
kb_python0.28.0...
kallisto:0.50.1...
bustools:0.43.1...
...kb compile: compilekallistoandbustoolsbinaries from sourceThekb compilecommand grabs the latestkallistoandbustoolssource and compiles the binaries.Note: this is not required to runkb-python.Use caseskb-pythonfacilitates fast and uniform pre-processing of single-cell sequencing data to answer relevant research questions.$pipinstallkb-pythonggetffq# Goal: quantify publicly available scRNAseq data$kbref-iindex.idx-gt2g.txt-f1transcriptome.fa$(ggetref--ftp-wdna,gtfhomo_sapiens)$kbcount-iindex.idx-gt2g.txt-x10xv3-oout$(ffq--ftpSRR10668798|jq-r'.[] | .url'|tr'\n'' ')# -> count matrix in out/ folder# Goal: quantify 10xv2 feature barcode data, feature_barcodes.txt is a tab-delimited file# containing barcode_sequence<tab>barcode_name$kbref-iindex.idx-gf2g.txt-f1features.fa--workflowkitefeature_barcodes.txt
$kbcount-iindex.idx-gf2b.txt-x10xv2-oout/--workflowkite--h5adR1.fastq.gzR2.fastq.gz# -> count matrix in out/ folderSubmitted by@sbooeshaghi.Do you have a cool use case forkb-python? Submit a PR (including the goal, code snippet, and your username) so that we can feature it here.TutorialsFor a list of tutorials that usekb-pythonplease seehttps://www.kallistobus.tools/.DocumentationDeveloper documentation is hosted onRead the Docs.ContributingThank you for wanting to improvekb-python! If you have believe you've found a bug, please submit an issue.If you have a new feature you'd like to add tokb-pythonplease create a pull request. Pull requests should contain a message detailing the exact changes made, the reasons for the change, and tests that check for the correctness of those changes.CiteIf you usekb-pythonin a publication, please cite the following papers:kb-python&bustools@article{melsted2021modular,
  title={\href{https://doi.org/10.1038/s41587-021-00870-2}{Modular, efficient and constant-memory single-cell RNA-seq preprocessing}},
  author={Melsted, P{\'a}ll and Booeshaghi, A. Sina and Liu, Lauren and Gao, Fan and Lu, Lambda and Min, Kyung Hoi Joseph and da Veiga Beltrame, Eduardo and Hj{\"o}rleifsson, Kristj{\'a}n Eldj{\'a}rn and Gehring, Jase and Pachter, Lior},
  author+an={1=first;2=first,highlight},
  journal={Nature biotechnology},
  year={2021},
  month={4},
  day={1},
  doi={https://doi.org/10.1038/s41587-021-00870-2}}kallisto@article{bray2016near,
  title={Near-optimal probabilistic RNA-seq quantification},
  author={Bray, Nicolas L and Pimentel, Harold and Melsted, P{\'a}ll and Pachter, Lior},
  journal={Nature biotechnology},
  volume={34},
  number={5},
  pages={525--527},
  year={2016},
  publisher={Nature Publishing Group}}BUSformat@article{melsted2019barcode,
  title={The barcode, UMI, set format and BUStools},
  author={Melsted, P{\'a}ll and Ntranos, Vasilis and Pachter, Lior},
  journal={Bioinformatics},
  volume={35},
  number={21},
  pages={4472--4473},
  year={2019},
  publisher={Oxford University Press}}kb-pythonwas inspired by Sten Linnarsson’sloompy fromfqcommand (http://linnarssonlab.org/loompy/kallisto/index.html)