$ singularity pull --name scShapes.sif shub://Malindrie/scShapes $ singularity shell scShapes.sif Singularity scShapes.sif:~ >
$ docker pull maldharm/scshapes $ docker run -it maldharm/scshapes root@516e456b0762:/#
To use containerized
scShapes package, need to launch
R or execute an R script through
This is a basic example which shows how you can use scShapes for identifying differential distributions in single-cell RNA-seq data. For this example data we use the toy example data
scData included in the package.
We first filter the genes to keep only genes expressed in at least 10% of cells:
In order to normalize for differences in sequencing depth, the log of the total UMI counts assigned per cell will be used as an offset in the GLM. This function is inbuilt in the algorithm; however the user is required to input the library sizes. In our example data this information together with the covariates is given under the lists
Perform Kolmogorov-Smirnov test to select genes belonging to the family of ZINB distributions.
scData_KS <- ks_test(counts=scData$counts, cexpr=scData$covariates, lib.size=scData$lib_size, BPPARAM=SnowParam(workers=8,type="SOCK")) # Select genes significant from the KS test. # By default the 'ks_sig' function performs Benjamini-Hochberg correction for multiple hypothese testing # and selects genes significant at p-value of 0.01 scData_KS_sig <- ks_sig(scData_KS) # Subset UMI counts corresponding to the genes significant from the KS test scData.sig.genes <- scData$counts[rownames(scData$counts) %in% names(scData_KS_sig$genes),]
Fit the 4 distributions P,NB,ZIP,ZINB for genes that belong to the ZINB family of distributions by fitting GLM with log of the library sizes as an offset and cell types as a covariate in the GLM.
Once the 4 distributions are fitted, we next calculate the BIC value for each model and select the model with the least BIC value.
To ensure the fit of the models selected based on the least BIC value, additionally we perform LRT to test for model adequacy and presence of zero-inflation.
Finally based on the results of the model adequacy tests, we can identify the distribution of best fit for each gene.
Once the distribution of best fit is identified for genes of interest, it is also possible to extract parameters of interest for the models.
If our dataset consists of multiple conditions we can follow the above approach to identify the best fir distribution shape for each gene under each treatment condition (selecting the subset of genes common between conditions). Then using the dataframe of genes and distribution followed under each condition, now we can identify genes changing distribution between conditions.
For example suppose we follow above pipeline for scRNA-seq data on two treatment conditions ‘CTRL’ and ‘STIM’ and have identified the best distribution fit for each gene under each condition independently. Suppose the dataframe
ifnb.distr; with genes as rows and columns as ‘CTRL’ and ‘STIM’ with the corresponding distribution name a particular gene follows, then we can identify genes changing distribution shape between ‘CTRL’ and ‘STIM’ as;
This will give a list of two lists with genes changing distribution between condition and genes changing distribution from unimodal in one condition to zero-inflated in the other condition.
Here is the output of sessionInfo() on the system on which this document was compiled:
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: #>  LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C #>  LC_TIME=en_GB LC_COLLATE=C #>  LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 #>  LC_PAPER=en_US.UTF-8 LC_NAME=C #>  LC_ADDRESS=C LC_TELEPHONE=C #>  LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C #> #> attached base packages: #>  stats graphics grDevices utils datasets methods base #> #> other attached packages: #>  BiocParallel_1.30.0 scShapes_1.2.0 #> #> loaded via a namespace (and not attached): #>  Rcpp_22.214.171.124 bslib_0.3.1 compiler_4.2.0 #>  jquerylib_0.1.4 plyr_1.8.7 tools_4.2.0 #>  digest_0.6.29 jsonlite_1.8.0 evaluate_0.15 #>  lattice_0.20-45 rlang_1.0.2 Matrix_1.4-1 #>  cli_3.3.0 yaml_2.3.5 parallel_4.2.0 #>  mvtnorm_1.1-3 xfun_0.30 fastmap_1.1.0 #>  coda_0.19-4 stringr_1.4.0 knitr_1.38 #>  sass_0.4.1 stats4_4.2.0 grid_4.2.0 #>  R6_2.5.1 snow_0.4-4 bdsmatrix_1.3-4 #>  emdbook_1.3.12 VGAM_1.1-6 rmarkdown_2.14 #>  magrittr_2.0.3 codetools_0.2-18 htmltools_0.5.2 #>  MASS_7.3-57 splines_4.2.0 bbmle_1.0.24 #>  numDeriv_2016.8-1.1 dgof_1.2 stringi_1.7.6 #>  pscl_1.5.5