Introduction

Single-cell RNA sequencing has become a common approach to trace developmental processes of cells, however, using exogenous barcodes is more direct than predicting from expression profiles recently, based on that, as gene-editing technology matures, combining this technological method with exogenous barcodes can generate more complex dynamic information for single-cell. In this application note, we introduce an R package: LinTInd for reconstructing a tree from alleles generated by the genome-editing tool known as CRISPR for a moderate time period based on the order in which editing occurs, and for sc-RNA seq, ScarLin can also quantify the similarity between each cluster in three ways.

Installation

Via GitHub

devtools::install_github("mana-W/LinTInd")

Via Bioconductor

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("LinTInd")
library(LinTInd)

Import data

The input for LinTInd consists three required files:

and an optional file:

data<-paste0(system.file("extdata",package = 'LinTInd'),"/CB_UMI")
fafile<-paste0(system.file("extdata",package = 'LinTInd'),"/V3.fasta")
cutsite<-paste0(system.file("extdata",package = 'LinTInd'),"/V3.cutSites")
celltype<-paste0(system.file("extdata",package = 'LinTInd'),"/celltype.tsv")
data<-read.table(data,sep="\t",header=TRUE)
ref<-ReadFasta(fafile)
cutsite<-read.table(cutsite,col.names = c("indx","start","end"))
celltype<-read.table(celltype,header=TRUE,stringsAsFactors=FALSE)

For the sequence file, only the column contain reads’ strings is requeired, the cell barcodes and UMIs are both optional.

head(data,3)
##                                   Read.ID
## 1  @A01045:289:HM7K3DRXX:2:2101:9896:1031
## 2 @A01045:289:HM7K3DRXX:2:2101:13367:1031
## 3  @A01045:289:HM7K3DRXX:2:2101:9959:1047
##                                                                                                                                                                                                                                                     Read.Seq
## 1 GAACGCGTAGGATAACATGGCCATCATCAAGGAGTTCTCATGCGCTTCAAGGTGCACATGGTTTATTGGAGCCGTACATGAACTGAGGTTAAGGACAGGATGTCCCAGGCGTAGGTAATTGGCCCCCTGCCCTTCGCCTGGGTTATAAGCTTCGGGTTTAAACGGGCCCTGGGGGTGGCATCCCTGTGACCCCTCCCCAGTGCCTCTCCTGGCCCTGGAAGTTGCCACTCCAGTGCCCACCAGCCTTGTC
## 2 GAACGCGTAGGATAACATGGCCATCATCAAGGAGTTCTCATGCGCTTCAAGGTGCACATGGTTTATTGGAGCCGTACATGAACTGAGGTTAAGGACAGGATGTCCCAGGCGTAGGTAATTGGCCCCCTGCCCTTCGCCTGGGTTATAAGCTTCGGGTTTAAACGGGCCCTGGGGGTGGCATCCCTGTGACCCCTCCCCAGTGCCTCTCCTGGCCCTGGAAGTTGCCACTCCAGTGCCCACCAGCCTTGTC
## 3 GAACGCGTAGGATAACATGGCCATCATCAAGGAGTTCTCATGCGCTTCAAGGTGCACATGGTTTATTGGAGCCGTACATGAACTGAGGTTAAGGACAGGATGTCCCAGGCGTAGGTAATTGGCCCCCTGCCCTTCGCCTGGGTTATAAGCTTCGGGTTTAAACGGGCCCTGGGGGTGGCATCCCTGTGACCCCTCCCCAGTGCCTCTCCTGGCCCTGGAAGTTGCCACTCCAGTGCCCACCAGCCTTGTC
##            Cell.BC        UMI
## 1 GAAGGGTAGCCTCAGC CTTCTCCCGA
## 2 ACCCTCACAAGACTGG TGTAATTTTT
## 3 GAAGGGTAGCCTCAGC CTTCTCCCGA
ref
## $scarfull
## 333-letter DNAString object
## seq: GAACGCGTAGGATAACATGGCCATCATCAAGGAGTT...GGAAGTTGCCACTCCAGTGCCCACCAGCCTTGTCCT
cutsite
##   indx start end
## 1    0    39 267
## 2    1     1  23
## 3    2    28  50
## 4    3    55  77
## 5    4    82 104
## 6    5   109 131
## 7    6   136 158
## 8    7   163 185
head(celltype,3)
##            Cell.BC Cell.type
## 1 AAGCGAGTCTTCTGTA         A
## 2 AATCGACTCGTAGTGT         A
## 3 ACATGCAGTCCACACG         A

Array identify and indel visualization

In the first step, we shold use FindIndel() to alignment and find indels, and the function IndelForm() will help us to generate an array-form string for each read.

scarinfo<-FindIndel(data=data,scarfull=ref,scar=cutsite,indel.coverage="All",type="test",cln=1)
scarinfo<-IndelForm(scarinfo,cln=1)

Then for single-cell sequencing, we shold define a final-version of array-form string for each cell use IndelIdents(), there are three method are provided :

For bulk sequencing, in this step, we will generate a “cell barcode” for each read.

cellsinfo<-IndelIdents(scarinfo,method.use="umi.num",cln=1)

After define the indels for each cell, we can use IndelPlot() to visualise them.

IndelPlot(cellsinfo = cellsinfo)

Indel extract and similarity calculate

We can use the function TagProcess() to extract indels for cells/reads. The parameter Cells is optional.

tag<-TagProcess(cellsinfo$info,Cells=celltype)

And if the annotation of each cells are provided, we can also use TagDist() to calculate the relationship between each group in three way:

The heatmap of this result will be saved as a pdf file.

tag_dist=TagDist(tag,method = "Jaccard")
## Using Cell.type as value column: use value.var to override.
## Aggregation function missing: defaulting to length
tag_dist
##           A         B         C         D         E
## A 1.0000000 0.4925373 0.2794118 0.2985075 0.2058824
## B 0.4925373 1.0000000 0.5588235 0.6060606 0.4117647
## C 0.2794118 0.5588235 1.0000000 0.9047619 0.7500000
## D 0.2985075 0.6060606 0.9047619 1.0000000 0.6666667
## E 0.2058824 0.4117647 0.7500000 0.6666667 1.0000000

Tree reconstruct

In the laste part, we can use BuildTree() to Generate an array generant tree.

treeinfo<-BuildTree(tag)
## Using Cell.num as value column: use value.var to override.

Finally, we can use the function PlotTree() to visualise the tree created before.

plotinfo<-PlotTree(treeinfo = treeinfo,data.extract = "TRUE",annotation = "TRUE")
## Using tags as id variables
plotinfo$p

Session Info

sessionInfo()
## R version 4.2.0 RC (2022-04-19 r82224)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.4 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.15-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.15-bioc/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_GB              LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats4    parallel  stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
## [1] LinTInd_1.0.0       S4Vectors_0.34.0    BiocGenerics_0.42.0
## [4] ggplot2_3.3.5      
## 
## loaded via a namespace (and not attached):
##  [1] sass_0.4.1             tidyr_1.2.0            jsonlite_1.8.0        
##  [4] bslib_0.3.1            assertthat_0.2.1       highr_0.9             
##  [7] yulab.utils_0.0.4      GenomeInfoDbData_1.2.8 yaml_2.3.5            
## [10] pillar_1.7.0           lattice_0.20-45        glue_1.6.2            
## [13] rlist_0.4.6.2          digest_0.6.29          RColorBrewer_1.1-3    
## [16] XVector_0.36.0         colorspace_2.0-3       ggfun_0.0.6           
## [19] cowplot_1.1.1          htmltools_0.5.2        plyr_1.8.7            
## [22] ggnewscale_0.4.7       pkgconfig_2.0.3        pheatmap_1.0.12       
## [25] zlibbioc_1.42.0        purrr_0.3.4            patchwork_1.1.1       
## [28] tidytree_0.3.9         scales_1.2.0           ggplotify_0.1.0       
## [31] stringdist_0.9.8       tibble_3.1.6           farver_2.1.0          
## [34] generics_0.1.2         IRanges_2.30.0         ellipsis_0.3.2        
## [37] withr_2.5.0            lazyeval_0.2.2         cli_3.3.0             
## [40] magrittr_2.0.3         crayon_1.5.1           evaluate_0.15         
## [43] data.tree_1.0.0        fansi_1.0.3            nlme_3.1-157          
## [46] tools_4.2.0            data.table_1.14.2      lifecycle_1.0.1       
## [49] stringr_1.4.0          aplot_0.1.3            ggtree_3.4.0          
## [52] munsell_0.5.0          Biostrings_2.64.0      networkD3_0.4         
## [55] compiler_4.2.0         jquerylib_0.1.4        GenomeInfoDb_1.32.0   
## [58] gridGraphics_0.5-1     rlang_1.0.2            grid_4.2.0            
## [61] RCurl_1.98-1.6         htmlwidgets_1.5.4      igraph_1.3.1          
## [64] bitops_1.0-7           labeling_0.4.2         rmarkdown_2.14        
## [67] gtable_0.3.0           DBI_1.1.2              reshape2_1.4.4        
## [70] R6_2.5.1               knitr_1.38             dplyr_1.0.8           
## [73] fastmap_1.1.0          utf8_1.2.2             treeio_1.20.0         
## [76] ape_5.6-2              stringi_1.7.6          Rcpp_1.0.8.3          
## [79] vctrs_0.4.1            tidyselect_1.1.2       xfun_0.30