Tutorial 3: Imputation scATAC-seq analysis

Here we will use scATAC-seq dataset `Forebrain’ as an example to illustrate how scAGDE performs imputation task in scATAC-seq analysis.

1. Read and preprocess data

We first read ‘.h5ad’ data file using Scanpy package

[4]:
import scanpy as sc
adata = sc.read_h5ad("data/Forebrain.h5ad")

We can use Scanpy to further filter data. In our case, we pass this step because the loaded dataset has been preprocessed. Some codes for filtering are copied below for easy reference:

[5]:
sc.pp.filter_cells(adata, min_genes=100)
min_cells = int(adata.shape[0] * 0.01)
sc.pp.filter_genes(adata, min_cells=min_cells)
[6]:
adata
[6]:
AnnData object with n_obs × n_vars = 2088 × 11285
    obs: 'celltype', 'n_genes'
    var: 'n_cells'
    uns: 'neighbors', 'pca', 'tsne', 'umap'
    obsm: 'X_pca', 'X_tsne', 'X_umap'
    varm: 'PCs'
    obsp: 'connectivities', 'distances'

2. Setup and train scAGDE model

Now we can initialize the trainer with the AnnData object, which will ensure settings for model are in place for training.

We can specify the outdir to the dir path where we want to save the output file (mainly the model weights file).

n_centroids represents the cluster number of dataset. If this information is unknown, we can set n_centroids=None and in this case, scAGDE will apply the estimation strategy to estimate the optimal cluster number for the initialization of its cluster layer. Here, we set n_centroids=8.

We can train scAGDE on specified device by setting gpu. For example, train scAGDE on CPUs by gpu=None and trian it on GPU #0 by gpu="0"

If you are merely interested in learning cell embeddings without consiering any optimization about cell clustering, you can specify cluster_opt=False here. In this case, scAGDE will be run withour any clustering-related module and optimization.

[7]:
import scAGDE
trainer = scAGDE.Trainer(adata,outdir="output",n_centroids=8,gpu="3")
device used: cuda:3

Now we can train scAGDE model in end-to-end style. The whole pipeline behind the function of fit() mainly consists of three stages, as below:

  1. scAGDE first trained an chromatin accessibility-based autoencoder to measure the importance of the peaks and select the key peaks. The number of selected peaks is set to 10,000 in default, or you can change it by setting top_n. In the meanwhile, the initial cell representations for cell graph construction are stored in adata.obs[embed_init_key], which is "latent_init" in default.

  2. scAGDE then constructed cell graph and trains the GCN-based embedded model to extract essential structural information from both count and cell graph data.

  3. scAGDE finally yiels robust and discriminative cell embeddings which are stored in adata.obsm[embed_key], which is "latent" in default. Also, scAGDE enables imputation task if impute_key is not None and the imputed data will be stored in adata.obsm[impute_key], which is "impute" in default.

scAGDE performs clustering on final embeddings if cluster_key is not None, and the cluster assignments will be in adata.obs[cluster_key], which is "cluster" in default. The cluster number is the value of n_centroids and if estimation is used, the cluster number is the value of estimated cluster number.

You can also explore each step as you wish by following a step-by-step tutorial in Tutorial 2: Step-by-Step scATAC-seq analysis.

[8]:
adata = trainer.fit(topn=10000,impute_key="impute")
print(adata)
Cell number: 2088
Peak number: 11285
n_centroids: 8


## Training CountModel ##
CountModel: 100%|██████████| 5000/5000 [00:31<00:00, 157.84it/s, loss=1687.1017]

## Constructing Cell Graph ##
Cell number: 2088
Peak number: 10000
n_centroids: 8


## Training GraphModel ##
GraphModel-preTrain: 100%|██████████| 1500/1500 [00:14<00:00, 100.03it/s, loss=1804.3624]
GraphModel: 100%|██████████| 4000/4000 [00:50<00:00, 78.97it/s, loss=4249.9907]
R[write to console]:                    __           __
   ____ ___  _____/ /_  _______/ /_
  / __ `__ \/ ___/ / / / / ___/ __/
 / / / / / / /__/ / /_/ (__  ) /_
/_/ /_/ /_/\___/_/\__,_/____/\__/   version 6.0.0
Type 'citation("mclust")' for citing this R package in publications.

AnnData object with n_obs × n_vars = 2088 × 11285
    obs: 'celltype', 'n_genes', 'cluster'
    var: 'n_cells', 'is_selected'
    uns: 'neighbors', 'pca', 'tsne', 'umap'
    obsm: 'X_pca', 'X_tsne', 'X_umap', 'latent_init', 'impute', 'latent'
    varm: 'PCs'
    obsp: 'connectivities', 'distances'

3. The imputation visualization

In our study of scAGDE, we evaluated the effectiveness of imputation in multiple ways, like cell clustering and visualization, and explored the impact in downstream analysis. Here we list some key steps for these analysis.

It is worth noting that the main figures presented in our work were produced by R code, and the general idea is shown here.

3.1 Fetch imputed data

We can fetch impued data matrix from adata.obsm[impute_key]. Also we prepare the original data matrix for comparison.

[9]:
# subset the adata with selected features
raw = adata[:,adata.var["is_selected"] == 1].X
imputed = adata.obsm["impute"]
print(imputed.shape)
assert imputed.shape == raw.shape, "shape not identical"
(2088, 10000)

Next let’s binary the imputed data.

[10]:
binary = scAGDE.utils.binarization(imputed,raw)
print(binary.shape)
(2088, 10000)

3.2 t-SNE/UMAP comparison

We can observe the t-SNE or UMAP visualization on raw, imputed and binary imputed data with cell type labels to evaluate the effect of imputation. Besides, we perform Leiden clustering algorithm for further evaluation.

[11]:
import warnings
warnings.filterwarnings('ignore')
[12]:
import anndata
data_raw = anndata.AnnData(raw,obs=adata.obs,var=adata[:,adata.var["is_selected"] == 1].var)
sc.tl.pca(data_raw, svd_solver="arpack")
sc.pp.neighbors(data_raw)
sc.tl.umap(data_raw)
sc.tl.tsne(data_raw)
sc.tl.leiden(
    data_raw,
    resolution=0.5,
    random_state=0,
    n_iterations=2,
    directed=False,
)
sc.pl.umap(data_raw,color=["celltype","leiden"],title="Raw")
sc.pl.tsne(data_raw,color=["celltype","leiden"],title="Raw")
WARNING: The title list is shorter than the number of panels. Using 'color' value instead for some plots.
../_images/notebooks_tutorial3_25_1.png
WARNING: The title list is shorter than the number of panels. Using 'color' value instead for some plots.
../_images/notebooks_tutorial3_25_3.png
[13]:
data_imputed = anndata.AnnData(imputed,obs=adata.obs,var=adata[:,adata.var["is_selected"] == 1].var)
sc.tl.pca(data_imputed, svd_solver="arpack")
sc.pp.neighbors(data_imputed)
sc.tl.umap(data_imputed)
sc.tl.tsne(data_imputed)
sc.tl.leiden(
    data_imputed,
    resolution=0.5,
    random_state=0,
    n_iterations=2,
    directed=False,
)
sc.pl.umap(data_imputed,color=["celltype","leiden"],title="Imputed")
sc.pl.tsne(data_imputed,color=["celltype","leiden"],title="Imputed")
WARNING: The title list is shorter than the number of panels. Using 'color' value instead for some plots.
../_images/notebooks_tutorial3_26_1.png
WARNING: The title list is shorter than the number of panels. Using 'color' value instead for some plots.
../_images/notebooks_tutorial3_26_3.png
[14]:
data_binary = anndata.AnnData(binary.A,obs=adata.obs,var=adata[:,adata.var["is_selected"] == 1].var)
sc.tl.pca(data_binary, svd_solver="arpack")
sc.pp.neighbors(data_binary)
sc.tl.tsne(data_binary)
sc.tl.umap(data_binary)
sc.tl.leiden(
    data_binary,
    resolution=0.5,
    random_state=0,
    n_iterations=2,
    directed=False,
)
sc.pl.umap(data_binary,color=["celltype","leiden"],title="Imputed")
sc.pl.tsne(data_binary,color=["celltype","leiden"],title="Imputed")
WARNING: The title list is shorter than the number of panels. Using 'color' value instead for some plots.
../_images/notebooks_tutorial3_27_1.png
WARNING: The title list is shorter than the number of panels. Using 'color' value instead for some plots.
../_images/notebooks_tutorial3_27_3.png

Finally, we save the AnnData object in .h5ad format, including the binarized imputed data for future use.

[ ]:
#
import os
# Generate Seurat object
outdir = "imputation"
if not os.path.exists(outdir): os.makedirs(outdir)
# We save the binary imputed data into the AnnData object for future use.
adata.obsm["binary"] = binary.A
adata[:,adata.var["is_selected"] == 1].write(os.path.join(outdir,"brain.h5ad"),compression="gzip")

3. Downstream analysis

3.1 Set up the enviornment and data

  • How to use R code in this notebook?

We have developed several R scripts to perform downstream analyses, and the essential code for key analyses is provided below. To interactively execute the analysis within this notebook, we utilize the rpy2 package, which allows running R code directly. Thus, please ensure that rpy2 is installed. Alternatively, you may extract these R scripts and execute them externally as standalone R scripts.

The code below initializes rpy2. After this setup, you can write and execute R code directly within notebook cells by starting with %%R.

[2]:
import logging
import rpy2.rinterface_lib.callbacks
from rpy2.robjects import pandas2ri
rpy2.rinterface_lib.callbacks.logger.setLevel(logging.ERROR)
pandas2ri.activate()
%load_ext rpy2.ipython

To completely finish the following analysis, you need requires specific R packages listed below (pkgs), and you can verify and install using the code provided below.

The following code will help you install all the required packages:
% Installing with conda solves most of the dependency package installation problems:
conda install r-signac
conda install r-seurat
conda install r-sceasy
conda install bioconductor-tfbstools
% The other packages can be installed just in R:
install.packages(“reticulate”)
install.packages(“dplyr”)
if (!requireNamespace(“BiocManager”, quietly = TRUE)) install.packages(“BiocManager”)
BiocManager::install(“ComplexHeatmap”)
BiocManager::install(“JASPAR2020”)
BiocManager::install(“EnsDb.Mmusculus.v79”)
BiocManager::install(“BSgenome.Mmusculus.UCSC.mm10”)
BiocManager::install(“biovizBase”)
BiocManager::install(“motifmatchr”)
BiocManager::install(“chromVAR”)
[3]:
%%R
pkgs <- c(
    "reticulate",
    "sceasy",
    "Signac",
    "Seurat",
    "dplyr",
    "ComplexHeatmap",
    "ggplot2",
    "circlize",
    "TFBSTools",
    "JASPAR2020",
    "EnsDb.Mmusculus.v79",
    "BSgenome.Mmusculus.UCSC.mm10"
)
######## Install all packages using codes below ########
# if (!requireNamespace("BiocManager", quietly = TRUE))
#     install.packages("BiocManager")
# BiocManager::install(pkgs)
suppressWarnings(suppressPackageStartupMessages(lapply(pkgs,library,character.only=TRUE)))

    WARNING: The R package "reticulate" only fixed recently
    an issue that caused a segfault when used with rpy2:
    https://github.com/rstudio/reticulate/pull/1188
    Make sure that you use a version of that package that includes
    the fix.
    [[1]]
[1] "reticulate" "tools"      "stats"      "graphics"   "grDevices"
[6] "utils"      "datasets"   "methods"    "base"

[[2]]
 [1] "sceasy"     "reticulate" "tools"      "stats"      "graphics"
 [6] "grDevices"  "utils"      "datasets"   "methods"    "base"

[[3]]
 [1] "Signac"     "sceasy"     "reticulate" "tools"      "stats"
 [6] "graphics"   "grDevices"  "utils"      "datasets"   "methods"
[11] "base"

[[4]]
 [1] "SeuratObject" "Seurat"       "Signac"       "sceasy"       "reticulate"
 [6] "tools"        "stats"        "graphics"     "grDevices"    "utils"
[11] "datasets"     "methods"      "base"

[[5]]
 [1] "dplyr"        "SeuratObject" "Seurat"       "Signac"       "sceasy"
 [6] "reticulate"   "tools"        "stats"        "graphics"     "grDevices"
[11] "utils"        "datasets"     "methods"      "base"

[[6]]
 [1] "ComplexHeatmap" "grid"           "dplyr"          "SeuratObject"
 [5] "Seurat"         "Signac"         "sceasy"         "reticulate"
 [9] "tools"          "stats"          "graphics"       "grDevices"
[13] "utils"          "datasets"       "methods"        "base"

[[7]]
 [1] "ggplot2"        "ComplexHeatmap" "grid"           "dplyr"
 [5] "SeuratObject"   "Seurat"         "Signac"         "sceasy"
 [9] "reticulate"     "tools"          "stats"          "graphics"
[13] "grDevices"      "utils"          "datasets"       "methods"
[17] "base"

[[8]]
 [1] "circlize"       "ggplot2"        "ComplexHeatmap" "grid"
 [5] "dplyr"          "SeuratObject"   "Seurat"         "Signac"
 [9] "sceasy"         "reticulate"     "tools"          "stats"
[13] "graphics"       "grDevices"      "utils"          "datasets"
[17] "methods"        "base"

[[9]]
 [1] "TFBSTools"      "circlize"       "ggplot2"        "ComplexHeatmap"
 [5] "grid"           "dplyr"          "SeuratObject"   "Seurat"
 [9] "Signac"         "sceasy"         "reticulate"     "tools"
[13] "stats"          "graphics"       "grDevices"      "utils"
[17] "datasets"       "methods"        "base"

[[10]]
 [1] "JASPAR2020"     "TFBSTools"      "circlize"       "ggplot2"
 [5] "ComplexHeatmap" "grid"           "dplyr"          "SeuratObject"
 [9] "Seurat"         "Signac"         "sceasy"         "reticulate"
[13] "tools"          "stats"          "graphics"       "grDevices"
[17] "utils"          "datasets"       "methods"        "base"

[[11]]
 [1] "EnsDb.Mmusculus.v79" "ensembldb"           "AnnotationFilter"
 [4] "GenomicFeatures"     "AnnotationDbi"       "Biobase"
 [7] "GenomicRanges"       "GenomeInfoDb"        "IRanges"
[10] "S4Vectors"           "stats4"              "BiocGenerics"
[13] "JASPAR2020"          "TFBSTools"           "circlize"
[16] "ggplot2"             "ComplexHeatmap"      "grid"
[19] "dplyr"               "SeuratObject"        "Seurat"
[22] "Signac"              "sceasy"              "reticulate"
[25] "tools"               "stats"               "graphics"
[28] "grDevices"           "utils"               "datasets"
[31] "methods"             "base"

[[12]]
 [1] "BSgenome.Mmusculus.UCSC.mm10" "BSgenome"
 [3] "rtracklayer"                  "BiocIO"
 [5] "Biostrings"                   "XVector"
 [7] "EnsDb.Mmusculus.v79"          "ensembldb"
 [9] "AnnotationFilter"             "GenomicFeatures"
[11] "AnnotationDbi"                "Biobase"
[13] "GenomicRanges"                "GenomeInfoDb"
[15] "IRanges"                      "S4Vectors"
[17] "stats4"                       "BiocGenerics"
[19] "JASPAR2020"                   "TFBSTools"
[21] "circlize"                     "ggplot2"
[23] "ComplexHeatmap"               "grid"
[25] "dplyr"                        "SeuratObject"
[27] "Seurat"                       "Signac"
[29] "sceasy"                       "reticulate"
[31] "tools"                        "stats"
[33] "graphics"                     "grDevices"
[35] "utils"                        "datasets"
[37] "methods"                      "base"

  • How to read AnnData data object in R?

First, we will convert Python objects into data formats required by R. Specifically, we will convert an AnnData object to a Seurat object and save it as an .rds file. Here, we use the sceasy package to perform this task; however, you may opt for any other method you are comfortable with.

[24]:
%%R
sceasy::convertFormat("imputation/brain.h5ad", from = "anndata", to = "seurat", outFile = "imputation/brain.rds", assay="peaks")
An object of class Seurat
10000 features across 2088 samples within 1 assay
Active assay: peaks (10000 features, 0 variable features)
 2 layers present: counts, data
 7 dimensional reductions calculated: pca, tsne, umap, binary, impute, latent, latent_init
Warning: Feature names cannot have underscores ('_'), replacing with dashes ('-')
Warning: Feature names cannot have underscores ('_'), replacing with dashes ('-')
X -> counts

Next, let we example the correct data object in R.

[34]:
%%R
brain <- readRDS("imputation/brain.rds")
brain
An object of class Seurat
10000 features across 2088 samples within 1 assay
Active assay: peaks (10000 features, 0 variable features)
 2 layers present: counts, data
 7 dimensional reductions calculated: pca, tsne, umap, binary, impute, latent, latent_init

3.2 Differential accessibility regions (DARs) identification

Next, let’s identify Differential Accessibility Regions following the standard Signac workflow. First, we need to convert the data to the appropriate format. During this process, we will integrate both the imputed and binary imputed data as two ChromatinAssay objects within the same SeuratObject, storing them as different assay.

  • Prepare data object

[35]:
%%R
library(Signac)
library(EnsDb.Mmusculus.v79)
# Convert our Seurat object to Signac object, saving meta information and cell embeddings.
metadata <- brain@meta.data
latent <- brain@reductions$latent
latent@assay.used <- "peaks"
counts_ <- brain@assays$peaks@counts
impute_ <- t(brain@reductions$impute@cell.embeddings)
rownames(impute_) <- rownames(brain)
binary_ <- t(brain@reductions$binary@cell.embeddings)
rownames(binary_) <- rownames(brain)
chrom_assay <-  CreateChromatinAssay(
  counts = counts_,
  sep = c(":", "-")
)
brain <- CreateSeuratObject(
  counts = chrom_assay,
  assay = 'peaks',
  meta.data = metadata
)
brain[["latent"]] <- latent
brain[["impute"]] <-  CreateChromatinAssay(
  counts = impute_,
  sep = c("-", "-")
)
brain[["binary"]] <-  CreateChromatinAssay(
  counts = binary_,
  sep = c("-", "-")
)
Idents(brain) <- brain$celltype
# Annotation
annotations <- GetGRangesFromEnsDb(ensdb = EnsDb.Mmusculus.v79)
seqlevels(annotations) <- paste0('chr', seqlevels(annotations))
genome(annotations) <- "mm10"
# saveRDS("imputation/annotation.rds",annotations)
# annotations <- readRDS("imputation/annotation.rds")
Annotation(brain[["peaks"]]) <- annotations
Annotation(brain[["impute"]]) <- annotations
Annotation(brain[["binary"]]) <- annotations
rm(counts_,impute_,binary_,annotations,chrom_assay,latent,metadata)
  • DARs identification

At this stage, we use the FindAllMarkers function to identify differential accessible regions for the raw, imputed, and binary imputed data separately.

[36]:
%%R
markersPeaks.Raw <- FindAllMarkers(brain, only.pos = TRUE, min.pct = 0.15, logfc.threshold = 0.15,assay = "peaks")
markersPeaks.Impute <- FindAllMarkers(brain, only.pos = TRUE, min.pct = 0.15, logfc.threshold = 0.15,assay = "impute")
markersPeaks.Binary <- FindAllMarkers(brain, only.pos = TRUE, min.pct = 0.15, logfc.threshold = 0.15,assay = "binary")
  |                                                  | 0 % ~calculating   |+                                                 | 1 % ~17s           |++                                                | 2 % ~17s           |++                                                | 3 % ~17s           |+++                                               | 4 % ~17s           |+++                                               | 5 % ~17s           |++++                                              | 6 % ~16s           |++++                                              | 7 % ~16s           |+++++                                             | 8 % ~16s           |+++++                                             | 9 % ~16s           |++++++                                            | 10% ~16s           |++++++                                            | 11% ~16s           |+++++++                                           | 12% ~15s           |+++++++                                           | 13% ~15s           |++++++++                                          | 14% ~15s           |++++++++                                          | 15% ~15s           |+++++++++                                         | 16% ~15s           |+++++++++                                         | 17% ~15s           |++++++++++                                        | 18% ~14s           |++++++++++                                        | 19% ~14s           |+++++++++++                                       | 20% ~14s           |+++++++++++                                       | 21% ~14s           |++++++++++++                                      | 22% ~14s           |++++++++++++                                      | 23% ~14s           |+++++++++++++                                     | 24% ~13s           |+++++++++++++                                     | 26% ~13s           |++++++++++++++                                    | 27% ~13s           |++++++++++++++                                    | 28% ~13s           |+++++++++++++++                                   | 29% ~13s           |+++++++++++++++                                   | 30% ~12s           |++++++++++++++++                                  | 31% ~12s           |++++++++++++++++                                  | 32% ~12s           |+++++++++++++++++                                 | 33% ~12s           |+++++++++++++++++                                 | 34% ~12s           |++++++++++++++++++                                | 35% ~11s           |++++++++++++++++++                                | 36% ~11s           |+++++++++++++++++++                               | 37% ~11s           |+++++++++++++++++++                               | 38% ~11s           |++++++++++++++++++++                              | 39% ~11s           |++++++++++++++++++++                              | 40% ~11s           |+++++++++++++++++++++                             | 41% ~10s           |+++++++++++++++++++++                             | 42% ~10s           |++++++++++++++++++++++                            | 43% ~10s           |++++++++++++++++++++++                            | 44% ~10s           |+++++++++++++++++++++++                           | 45% ~10s           |+++++++++++++++++++++++                           | 46% ~09s           |++++++++++++++++++++++++                          | 47% ~09s           |++++++++++++++++++++++++                          | 48% ~09s           |+++++++++++++++++++++++++                         | 49% ~09s           |+++++++++++++++++++++++++                         | 50% ~09s           |++++++++++++++++++++++++++                        | 51% ~09s           |+++++++++++++++++++++++++++                       | 52% ~08s           |+++++++++++++++++++++++++++                       | 53% ~08s           |++++++++++++++++++++++++++++                      | 54% ~08s           |++++++++++++++++++++++++++++                      | 55% ~08s           |+++++++++++++++++++++++++++++                     | 56% ~08s           |+++++++++++++++++++++++++++++                     | 57% ~07s           |++++++++++++++++++++++++++++++                    | 58% ~07s           |++++++++++++++++++++++++++++++                    | 59% ~07s           |+++++++++++++++++++++++++++++++                   | 60% ~07s           |+++++++++++++++++++++++++++++++                   | 61% ~07s           |++++++++++++++++++++++++++++++++                  | 62% ~07s           |++++++++++++++++++++++++++++++++                  | 63% ~06s           |+++++++++++++++++++++++++++++++++                 | 64% ~06s           |+++++++++++++++++++++++++++++++++                 | 65% ~06s           |++++++++++++++++++++++++++++++++++                | 66% ~06s           |++++++++++++++++++++++++++++++++++                | 67% ~06s           |+++++++++++++++++++++++++++++++++++               | 68% ~06s           |+++++++++++++++++++++++++++++++++++               | 69% ~05s           |++++++++++++++++++++++++++++++++++++              | 70% ~05s           |++++++++++++++++++++++++++++++++++++              | 71% ~05s           |+++++++++++++++++++++++++++++++++++++             | 72% ~05s           |+++++++++++++++++++++++++++++++++++++             | 73% ~05s           |++++++++++++++++++++++++++++++++++++++            | 74% ~04s           |++++++++++++++++++++++++++++++++++++++            | 76% ~04s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~04s           |+++++++++++++++++++++++++++++++++++++++           | 78% ~04s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~04s           |++++++++++++++++++++++++++++++++++++++++          | 80% ~04s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~03s           |+++++++++++++++++++++++++++++++++++++++++         | 82% ~03s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~03s           |++++++++++++++++++++++++++++++++++++++++++        | 84% ~03s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~03s           |+++++++++++++++++++++++++++++++++++++++++++       | 86% ~03s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~02s           |++++++++++++++++++++++++++++++++++++++++++++      | 88% ~02s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~02s           |+++++++++++++++++++++++++++++++++++++++++++++     | 90% ~02s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~02s           |++++++++++++++++++++++++++++++++++++++++++++++    | 92% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 93% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 94% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 95% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 96% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 97% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 99% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=17s
  |                                                  | 0 % ~calculating   |+                                                 | 1 % ~43s           |+                                                 | 2 % ~42s           |++                                                | 3 % ~43s           |++                                                | 4 % ~42s           |+++                                               | 5 % ~42s           |+++                                               | 6 % ~41s           |++++                                              | 7 % ~40s           |++++                                              | 8 % ~40s           |+++++                                             | 9 % ~40s           |+++++                                             | 10% ~39s           |++++++                                            | 11% ~39s           |++++++                                            | 12% ~38s           |+++++++                                           | 13% ~38s           |+++++++                                           | 14% ~37s           |++++++++                                          | 15% ~37s           |++++++++                                          | 16% ~36s           |+++++++++                                         | 17% ~36s           |+++++++++                                         | 18% ~36s           |++++++++++                                        | 19% ~35s           |++++++++++                                        | 20% ~35s           |+++++++++++                                       | 21% ~34s           |+++++++++++                                       | 22% ~34s           |++++++++++++                                      | 23% ~33s           |++++++++++++                                      | 24% ~33s           |+++++++++++++                                     | 25% ~32s           |+++++++++++++                                     | 26% ~32s           |++++++++++++++                                    | 27% ~32s           |++++++++++++++                                    | 28% ~31s           |+++++++++++++++                                   | 29% ~31s           |+++++++++++++++                                   | 30% ~30s           |++++++++++++++++                                  | 31% ~30s           |++++++++++++++++                                  | 32% ~29s           |+++++++++++++++++                                 | 33% ~29s           |+++++++++++++++++                                 | 34% ~29s           |++++++++++++++++++                                | 35% ~28s           |++++++++++++++++++                                | 36% ~28s           |+++++++++++++++++++                               | 37% ~27s           |+++++++++++++++++++                               | 38% ~27s           |++++++++++++++++++++                              | 39% ~26s           |++++++++++++++++++++                              | 40% ~26s           |+++++++++++++++++++++                             | 41% ~26s           |+++++++++++++++++++++                             | 42% ~25s           |++++++++++++++++++++++                            | 43% ~25s           |++++++++++++++++++++++                            | 44% ~24s           |+++++++++++++++++++++++                           | 45% ~24s           |+++++++++++++++++++++++                           | 46% ~23s           |++++++++++++++++++++++++                          | 47% ~23s           |++++++++++++++++++++++++                          | 48% ~22s           |+++++++++++++++++++++++++                         | 49% ~22s           |+++++++++++++++++++++++++                         | 50% ~22s           |++++++++++++++++++++++++++                        | 51% ~21s           |++++++++++++++++++++++++++                        | 52% ~21s           |+++++++++++++++++++++++++++                       | 53% ~20s           |+++++++++++++++++++++++++++                       | 54% ~20s           |++++++++++++++++++++++++++++                      | 55% ~19s           |++++++++++++++++++++++++++++                      | 56% ~19s           |+++++++++++++++++++++++++++++                     | 57% ~19s           |+++++++++++++++++++++++++++++                     | 58% ~18s           |++++++++++++++++++++++++++++++                    | 59% ~18s           |++++++++++++++++++++++++++++++                    | 60% ~17s           |+++++++++++++++++++++++++++++++                   | 61% ~17s           |+++++++++++++++++++++++++++++++                   | 62% ~16s           |++++++++++++++++++++++++++++++++                  | 63% ~16s           |++++++++++++++++++++++++++++++++                  | 64% ~16s           |+++++++++++++++++++++++++++++++++                 | 65% ~15s           |+++++++++++++++++++++++++++++++++                 | 66% ~15s           |++++++++++++++++++++++++++++++++++                | 67% ~14s           |++++++++++++++++++++++++++++++++++                | 68% ~14s           |+++++++++++++++++++++++++++++++++++               | 69% ~13s           |+++++++++++++++++++++++++++++++++++               | 70% ~13s           |++++++++++++++++++++++++++++++++++++              | 71% ~13s           |++++++++++++++++++++++++++++++++++++              | 72% ~12s           |+++++++++++++++++++++++++++++++++++++             | 73% ~12s           |+++++++++++++++++++++++++++++++++++++             | 74% ~11s           |++++++++++++++++++++++++++++++++++++++            | 75% ~11s           |++++++++++++++++++++++++++++++++++++++            | 76% ~10s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~10s           |+++++++++++++++++++++++++++++++++++++++           | 78% ~10s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~09s           |++++++++++++++++++++++++++++++++++++++++          | 80% ~09s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~08s           |+++++++++++++++++++++++++++++++++++++++++         | 82% ~08s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~07s           |++++++++++++++++++++++++++++++++++++++++++        | 84% ~07s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~07s           |+++++++++++++++++++++++++++++++++++++++++++       | 86% ~06s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~06s           |++++++++++++++++++++++++++++++++++++++++++++      | 88% ~05s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~05s           |+++++++++++++++++++++++++++++++++++++++++++++     | 90% ~04s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~04s           |++++++++++++++++++++++++++++++++++++++++++++++    | 92% ~03s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 93% ~03s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 94% ~03s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 95% ~02s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 96% ~02s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 97% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 98% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 99% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=43s
  |                                                  | 0 % ~calculating   |+                                                 | 1 % ~37s           |++                                                | 2 % ~37s           |++                                                | 3 % ~37s           |+++                                               | 4 % ~36s           |+++                                               | 5 % ~36s           |++++                                              | 6 % ~36s           |++++                                              | 7 % ~35s           |+++++                                             | 8 % ~35s           |+++++                                             | 9 % ~34s           |++++++                                            | 10% ~34s           |++++++                                            | 11% ~34s           |+++++++                                           | 12% ~33s           |+++++++                                           | 13% ~33s           |++++++++                                          | 14% ~32s           |++++++++                                          | 15% ~32s           |+++++++++                                         | 16% ~32s           |+++++++++                                         | 17% ~31s           |++++++++++                                        | 18% ~31s           |++++++++++                                        | 19% ~31s           |+++++++++++                                       | 20% ~30s           |+++++++++++                                       | 21% ~30s           |++++++++++++                                      | 22% ~29s           |++++++++++++                                      | 23% ~29s           |+++++++++++++                                     | 24% ~29s           |+++++++++++++                                     | 25% ~28s           |++++++++++++++                                    | 26% ~28s           |++++++++++++++                                    | 27% ~28s           |+++++++++++++++                                   | 28% ~27s           |+++++++++++++++                                   | 29% ~27s           |++++++++++++++++                                  | 30% ~26s           |++++++++++++++++                                  | 31% ~26s           |+++++++++++++++++                                 | 32% ~26s           |+++++++++++++++++                                 | 33% ~25s           |++++++++++++++++++                                | 34% ~25s           |++++++++++++++++++                                | 35% ~24s           |+++++++++++++++++++                               | 36% ~24s           |+++++++++++++++++++                               | 37% ~24s           |++++++++++++++++++++                              | 38% ~23s           |++++++++++++++++++++                              | 39% ~23s           |+++++++++++++++++++++                             | 40% ~23s           |+++++++++++++++++++++                             | 41% ~22s           |++++++++++++++++++++++                            | 42% ~22s           |++++++++++++++++++++++                            | 43% ~21s           |+++++++++++++++++++++++                           | 44% ~21s           |+++++++++++++++++++++++                           | 45% ~21s           |++++++++++++++++++++++++                          | 46% ~20s           |++++++++++++++++++++++++                          | 47% ~20s           |+++++++++++++++++++++++++                         | 48% ~19s           |+++++++++++++++++++++++++                         | 49% ~19s           |++++++++++++++++++++++++++                        | 51% ~19s           |++++++++++++++++++++++++++                        | 52% ~18s           |+++++++++++++++++++++++++++                       | 53% ~18s           |+++++++++++++++++++++++++++                       | 54% ~18s           |++++++++++++++++++++++++++++                      | 55% ~17s           |++++++++++++++++++++++++++++                      | 56% ~17s           |+++++++++++++++++++++++++++++                     | 57% ~16s           |+++++++++++++++++++++++++++++                     | 58% ~16s           |++++++++++++++++++++++++++++++                    | 59% ~16s           |++++++++++++++++++++++++++++++                    | 60% ~15s           |+++++++++++++++++++++++++++++++                   | 61% ~15s           |+++++++++++++++++++++++++++++++                   | 62% ~15s           |++++++++++++++++++++++++++++++++                  | 63% ~14s           |++++++++++++++++++++++++++++++++                  | 64% ~14s           |+++++++++++++++++++++++++++++++++                 | 65% ~13s           |+++++++++++++++++++++++++++++++++                 | 66% ~13s           |++++++++++++++++++++++++++++++++++                | 67% ~13s           |++++++++++++++++++++++++++++++++++                | 68% ~12s           |+++++++++++++++++++++++++++++++++++               | 69% ~12s           |+++++++++++++++++++++++++++++++++++               | 70% ~11s           |++++++++++++++++++++++++++++++++++++              | 71% ~11s           |++++++++++++++++++++++++++++++++++++              | 72% ~11s           |+++++++++++++++++++++++++++++++++++++             | 73% ~10s           |+++++++++++++++++++++++++++++++++++++             | 74% ~10s           |++++++++++++++++++++++++++++++++++++++            | 75% ~10s           |++++++++++++++++++++++++++++++++++++++            | 76% ~09s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~09s           |+++++++++++++++++++++++++++++++++++++++           | 78% ~08s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~08s           |++++++++++++++++++++++++++++++++++++++++          | 80% ~08s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~07s           |+++++++++++++++++++++++++++++++++++++++++         | 82% ~07s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~06s           |++++++++++++++++++++++++++++++++++++++++++        | 84% ~06s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~06s           |+++++++++++++++++++++++++++++++++++++++++++       | 86% ~05s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~05s           |++++++++++++++++++++++++++++++++++++++++++++      | 88% ~05s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~04s           |+++++++++++++++++++++++++++++++++++++++++++++     | 90% ~04s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~03s           |++++++++++++++++++++++++++++++++++++++++++++++    | 92% ~03s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 93% ~03s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 94% ~02s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 95% ~02s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 96% ~02s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 97% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 98% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 99% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=38s
  |                                                  | 0 % ~calculating   |+                                                 | 1 % ~50s           |++                                                | 2 % ~49s           |++                                                | 3 % ~48s           |+++                                               | 4 % ~48s           |+++                                               | 5 % ~47s           |++++                                              | 6 % ~46s           |++++                                              | 7 % ~46s           |+++++                                             | 8 % ~45s           |+++++                                             | 9 % ~45s           |++++++                                            | 10% ~44s           |++++++                                            | 11% ~44s           |+++++++                                           | 12% ~43s           |+++++++                                           | 13% ~43s           |++++++++                                          | 14% ~42s           |++++++++                                          | 15% ~42s           |+++++++++                                         | 16% ~41s           |+++++++++                                         | 17% ~41s           |++++++++++                                        | 18% ~40s           |++++++++++                                        | 19% ~40s           |+++++++++++                                       | 20% ~39s           |+++++++++++                                       | 21% ~39s           |++++++++++++                                      | 22% ~38s           |++++++++++++                                      | 23% ~38s           |+++++++++++++                                     | 24% ~37s           |+++++++++++++                                     | 25% ~37s           |++++++++++++++                                    | 26% ~36s           |++++++++++++++                                    | 27% ~36s           |+++++++++++++++                                   | 28% ~35s           |+++++++++++++++                                   | 29% ~35s           |++++++++++++++++                                  | 30% ~34s           |++++++++++++++++                                  | 31% ~34s           |+++++++++++++++++                                 | 32% ~33s           |+++++++++++++++++                                 | 33% ~33s           |++++++++++++++++++                                | 34% ~32s           |++++++++++++++++++                                | 35% ~32s           |+++++++++++++++++++                               | 36% ~31s           |+++++++++++++++++++                               | 37% ~31s           |++++++++++++++++++++                              | 38% ~30s           |++++++++++++++++++++                              | 39% ~30s           |+++++++++++++++++++++                             | 40% ~29s           |+++++++++++++++++++++                             | 41% ~29s           |++++++++++++++++++++++                            | 42% ~28s           |++++++++++++++++++++++                            | 43% ~28s           |+++++++++++++++++++++++                           | 44% ~27s           |+++++++++++++++++++++++                           | 45% ~27s           |++++++++++++++++++++++++                          | 46% ~26s           |++++++++++++++++++++++++                          | 47% ~26s           |+++++++++++++++++++++++++                         | 48% ~25s           |+++++++++++++++++++++++++                         | 49% ~25s           |++++++++++++++++++++++++++                        | 51% ~24s           |++++++++++++++++++++++++++                        | 52% ~24s           |+++++++++++++++++++++++++++                       | 53% ~23s           |+++++++++++++++++++++++++++                       | 54% ~23s           |++++++++++++++++++++++++++++                      | 55% ~22s           |++++++++++++++++++++++++++++                      | 56% ~22s           |+++++++++++++++++++++++++++++                     | 57% ~21s           |+++++++++++++++++++++++++++++                     | 58% ~21s           |++++++++++++++++++++++++++++++                    | 59% ~20s           |++++++++++++++++++++++++++++++                    | 60% ~20s           |+++++++++++++++++++++++++++++++                   | 61% ~19s           |+++++++++++++++++++++++++++++++                   | 62% ~19s           |++++++++++++++++++++++++++++++++                  | 63% ~18s           |++++++++++++++++++++++++++++++++                  | 64% ~18s           |+++++++++++++++++++++++++++++++++                 | 65% ~17s           |+++++++++++++++++++++++++++++++++                 | 66% ~17s           |++++++++++++++++++++++++++++++++++                | 67% ~16s           |++++++++++++++++++++++++++++++++++                | 68% ~16s           |+++++++++++++++++++++++++++++++++++               | 69% ~15s           |+++++++++++++++++++++++++++++++++++               | 70% ~15s           |++++++++++++++++++++++++++++++++++++              | 71% ~14s           |++++++++++++++++++++++++++++++++++++              | 72% ~14s           |+++++++++++++++++++++++++++++++++++++             | 73% ~13s           |+++++++++++++++++++++++++++++++++++++             | 74% ~13s           |++++++++++++++++++++++++++++++++++++++            | 75% ~12s           |++++++++++++++++++++++++++++++++++++++            | 76% ~12s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~11s           |+++++++++++++++++++++++++++++++++++++++           | 78% ~11s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~10s           |++++++++++++++++++++++++++++++++++++++++          | 80% ~10s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~09s           |+++++++++++++++++++++++++++++++++++++++++         | 82% ~09s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~08s           |++++++++++++++++++++++++++++++++++++++++++        | 84% ~08s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~07s           |+++++++++++++++++++++++++++++++++++++++++++       | 86% ~07s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~06s           |++++++++++++++++++++++++++++++++++++++++++++      | 88% ~06s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~05s           |+++++++++++++++++++++++++++++++++++++++++++++     | 90% ~05s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~04s           |++++++++++++++++++++++++++++++++++++++++++++++    | 92% ~04s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 93% ~03s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 94% ~03s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 95% ~02s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 96% ~02s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 97% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 98% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 99% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=49s
  |                                                  | 0 % ~calculating   |+                                                 | 1 % ~22s           |++                                                | 2 % ~22s           |++                                                | 3 % ~22s           |+++                                               | 4 % ~22s           |+++                                               | 5 % ~21s           |++++                                              | 6 % ~21s           |++++                                              | 7 % ~21s           |+++++                                             | 8 % ~21s           |+++++                                             | 9 % ~20s           |++++++                                            | 10% ~20s           |++++++                                            | 11% ~20s           |+++++++                                           | 12% ~20s           |+++++++                                           | 13% ~20s           |++++++++                                          | 14% ~19s           |++++++++                                          | 15% ~19s           |+++++++++                                         | 16% ~19s           |+++++++++                                         | 17% ~19s           |++++++++++                                        | 18% ~18s           |++++++++++                                        | 19% ~18s           |+++++++++++                                       | 20% ~18s           |+++++++++++                                       | 21% ~18s           |++++++++++++                                      | 22% ~18s           |++++++++++++                                      | 23% ~17s           |+++++++++++++                                     | 24% ~17s           |+++++++++++++                                     | 26% ~17s           |++++++++++++++                                    | 27% ~17s           |++++++++++++++                                    | 28% ~16s           |+++++++++++++++                                   | 29% ~16s           |+++++++++++++++                                   | 30% ~16s           |++++++++++++++++                                  | 31% ~16s           |++++++++++++++++                                  | 32% ~15s           |+++++++++++++++++                                 | 33% ~15s           |+++++++++++++++++                                 | 34% ~15s           |++++++++++++++++++                                | 35% ~15s           |++++++++++++++++++                                | 36% ~14s           |+++++++++++++++++++                               | 37% ~14s           |+++++++++++++++++++                               | 38% ~14s           |++++++++++++++++++++                              | 39% ~14s           |++++++++++++++++++++                              | 40% ~14s           |+++++++++++++++++++++                             | 41% ~13s           |+++++++++++++++++++++                             | 42% ~13s           |++++++++++++++++++++++                            | 43% ~13s           |++++++++++++++++++++++                            | 44% ~13s           |+++++++++++++++++++++++                           | 45% ~12s           |+++++++++++++++++++++++                           | 46% ~12s           |++++++++++++++++++++++++                          | 47% ~12s           |++++++++++++++++++++++++                          | 48% ~12s           |+++++++++++++++++++++++++                         | 49% ~12s           |+++++++++++++++++++++++++                         | 50% ~11s           |++++++++++++++++++++++++++                        | 51% ~11s           |+++++++++++++++++++++++++++                       | 52% ~11s           |+++++++++++++++++++++++++++                       | 53% ~11s           |++++++++++++++++++++++++++++                      | 54% ~10s           |++++++++++++++++++++++++++++                      | 55% ~10s           |+++++++++++++++++++++++++++++                     | 56% ~10s           |+++++++++++++++++++++++++++++                     | 57% ~10s           |++++++++++++++++++++++++++++++                    | 58% ~09s           |++++++++++++++++++++++++++++++                    | 59% ~09s           |+++++++++++++++++++++++++++++++                   | 60% ~09s           |+++++++++++++++++++++++++++++++                   | 61% ~09s           |++++++++++++++++++++++++++++++++                  | 62% ~09s           |++++++++++++++++++++++++++++++++                  | 63% ~08s           |+++++++++++++++++++++++++++++++++                 | 64% ~08s           |+++++++++++++++++++++++++++++++++                 | 65% ~08s           |++++++++++++++++++++++++++++++++++                | 66% ~08s           |++++++++++++++++++++++++++++++++++                | 67% ~07s           |+++++++++++++++++++++++++++++++++++               | 68% ~07s           |+++++++++++++++++++++++++++++++++++               | 69% ~07s           |++++++++++++++++++++++++++++++++++++              | 70% ~07s           |++++++++++++++++++++++++++++++++++++              | 71% ~06s           |+++++++++++++++++++++++++++++++++++++             | 72% ~06s           |+++++++++++++++++++++++++++++++++++++             | 73% ~06s           |++++++++++++++++++++++++++++++++++++++            | 74% ~06s           |++++++++++++++++++++++++++++++++++++++            | 76% ~06s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~05s           |+++++++++++++++++++++++++++++++++++++++           | 78% ~05s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~05s           |++++++++++++++++++++++++++++++++++++++++          | 80% ~05s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~04s           |+++++++++++++++++++++++++++++++++++++++++         | 82% ~04s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~04s           |++++++++++++++++++++++++++++++++++++++++++        | 84% ~04s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~03s           |+++++++++++++++++++++++++++++++++++++++++++       | 86% ~03s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~03s           |++++++++++++++++++++++++++++++++++++++++++++      | 88% ~03s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~03s           |+++++++++++++++++++++++++++++++++++++++++++++     | 90% ~02s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~02s           |++++++++++++++++++++++++++++++++++++++++++++++    | 92% ~02s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 93% ~02s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 94% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 95% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 96% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 97% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 99% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=23s
  |                                                  | 0 % ~calculating   |+                                                 | 1 % ~18s           |++                                                | 2 % ~18s           |++                                                | 3 % ~18s           |+++                                               | 4 % ~17s           |+++                                               | 5 % ~17s           |++++                                              | 6 % ~17s           |++++                                              | 7 % ~17s           |+++++                                             | 8 % ~17s           |+++++                                             | 9 % ~16s           |++++++                                            | 10% ~16s           |++++++                                            | 11% ~16s           |+++++++                                           | 12% ~16s           |+++++++                                           | 13% ~16s           |++++++++                                          | 14% ~16s           |++++++++                                          | 15% ~15s           |+++++++++                                         | 16% ~15s           |+++++++++                                         | 17% ~15s           |++++++++++                                        | 18% ~15s           |++++++++++                                        | 19% ~15s           |+++++++++++                                       | 20% ~14s           |+++++++++++                                       | 21% ~14s           |++++++++++++                                      | 22% ~14s           |++++++++++++                                      | 23% ~14s           |+++++++++++++                                     | 24% ~14s           |+++++++++++++                                     | 25% ~14s           |++++++++++++++                                    | 26% ~13s           |++++++++++++++                                    | 27% ~13s           |+++++++++++++++                                   | 28% ~13s           |+++++++++++++++                                   | 29% ~13s           |++++++++++++++++                                  | 30% ~13s           |++++++++++++++++                                  | 31% ~12s           |+++++++++++++++++                                 | 32% ~12s           |+++++++++++++++++                                 | 33% ~12s           |++++++++++++++++++                                | 34% ~12s           |++++++++++++++++++                                | 35% ~12s           |+++++++++++++++++++                               | 36% ~12s           |+++++++++++++++++++                               | 37% ~11s           |++++++++++++++++++++                              | 38% ~11s           |++++++++++++++++++++                              | 39% ~11s           |+++++++++++++++++++++                             | 40% ~11s           |+++++++++++++++++++++                             | 41% ~11s           |++++++++++++++++++++++                            | 42% ~10s           |++++++++++++++++++++++                            | 43% ~10s           |+++++++++++++++++++++++                           | 44% ~10s           |+++++++++++++++++++++++                           | 45% ~10s           |++++++++++++++++++++++++                          | 46% ~10s           |++++++++++++++++++++++++                          | 47% ~10s           |+++++++++++++++++++++++++                         | 48% ~09s           |+++++++++++++++++++++++++                         | 49% ~09s           |++++++++++++++++++++++++++                        | 51% ~09s           |++++++++++++++++++++++++++                        | 52% ~09s           |+++++++++++++++++++++++++++                       | 53% ~09s           |+++++++++++++++++++++++++++                       | 54% ~08s           |++++++++++++++++++++++++++++                      | 55% ~08s           |++++++++++++++++++++++++++++                      | 56% ~08s           |+++++++++++++++++++++++++++++                     | 57% ~08s           |+++++++++++++++++++++++++++++                     | 58% ~08s           |++++++++++++++++++++++++++++++                    | 59% ~08s           |++++++++++++++++++++++++++++++                    | 60% ~07s           |+++++++++++++++++++++++++++++++                   | 61% ~07s           |+++++++++++++++++++++++++++++++                   | 62% ~07s           |++++++++++++++++++++++++++++++++                  | 63% ~07s           |++++++++++++++++++++++++++++++++                  | 64% ~07s           |+++++++++++++++++++++++++++++++++                 | 65% ~06s           |+++++++++++++++++++++++++++++++++                 | 66% ~06s           |++++++++++++++++++++++++++++++++++                | 67% ~06s           |++++++++++++++++++++++++++++++++++                | 68% ~06s           |+++++++++++++++++++++++++++++++++++               | 69% ~06s           |+++++++++++++++++++++++++++++++++++               | 70% ~06s           |++++++++++++++++++++++++++++++++++++              | 71% ~05s           |++++++++++++++++++++++++++++++++++++              | 72% ~05s           |+++++++++++++++++++++++++++++++++++++             | 73% ~05s           |+++++++++++++++++++++++++++++++++++++             | 74% ~05s           |++++++++++++++++++++++++++++++++++++++            | 75% ~05s           |++++++++++++++++++++++++++++++++++++++            | 76% ~04s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~04s           |+++++++++++++++++++++++++++++++++++++++           | 78% ~04s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~04s           |++++++++++++++++++++++++++++++++++++++++          | 80% ~04s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~03s           |+++++++++++++++++++++++++++++++++++++++++         | 82% ~03s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~03s           |++++++++++++++++++++++++++++++++++++++++++        | 84% ~03s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~03s           |+++++++++++++++++++++++++++++++++++++++++++       | 86% ~03s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~02s           |++++++++++++++++++++++++++++++++++++++++++++      | 88% ~02s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~02s           |+++++++++++++++++++++++++++++++++++++++++++++     | 90% ~02s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~02s           |++++++++++++++++++++++++++++++++++++++++++++++    | 92% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 93% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 94% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 95% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 96% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 97% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 99% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=18s
  |                                                  | 0 % ~calculating   |+                                                 | 1 % ~09s           |++                                                | 2 % ~08s           |++                                                | 3 % ~08s           |+++                                               | 4 % ~08s           |+++                                               | 5 % ~08s           |++++                                              | 6 % ~08s           |++++                                              | 7 % ~08s           |+++++                                             | 8 % ~08s           |+++++                                             | 9 % ~08s           |++++++                                            | 10% ~08s           |++++++                                            | 11% ~08s           |+++++++                                           | 12% ~08s           |+++++++                                           | 13% ~07s           |++++++++                                          | 14% ~07s           |++++++++                                          | 15% ~07s           |+++++++++                                         | 16% ~07s           |+++++++++                                         | 17% ~07s           |++++++++++                                        | 18% ~07s           |++++++++++                                        | 19% ~07s           |+++++++++++                                       | 20% ~07s           |+++++++++++                                       | 21% ~07s           |++++++++++++                                      | 22% ~07s           |++++++++++++                                      | 23% ~07s           |+++++++++++++                                     | 24% ~06s           |+++++++++++++                                     | 25% ~06s           |++++++++++++++                                    | 26% ~06s           |++++++++++++++                                    | 27% ~06s           |+++++++++++++++                                   | 28% ~06s           |+++++++++++++++                                   | 29% ~06s           |++++++++++++++++                                  | 30% ~06s           |++++++++++++++++                                  | 31% ~06s           |+++++++++++++++++                                 | 32% ~06s           |+++++++++++++++++                                 | 33% ~06s           |++++++++++++++++++                                | 34% ~06s           |++++++++++++++++++                                | 35% ~06s           |+++++++++++++++++++                               | 36% ~05s           |+++++++++++++++++++                               | 37% ~05s           |++++++++++++++++++++                              | 38% ~05s           |++++++++++++++++++++                              | 39% ~05s           |+++++++++++++++++++++                             | 40% ~05s           |+++++++++++++++++++++                             | 41% ~05s           |++++++++++++++++++++++                            | 42% ~05s           |++++++++++++++++++++++                            | 43% ~05s           |+++++++++++++++++++++++                           | 44% ~05s           |+++++++++++++++++++++++                           | 45% ~05s           |++++++++++++++++++++++++                          | 46% ~05s           |++++++++++++++++++++++++                          | 47% ~05s           |+++++++++++++++++++++++++                         | 48% ~04s           |+++++++++++++++++++++++++                         | 49% ~04s           |++++++++++++++++++++++++++                        | 51% ~04s           |++++++++++++++++++++++++++                        | 52% ~04s           |+++++++++++++++++++++++++++                       | 53% ~04s           |+++++++++++++++++++++++++++                       | 54% ~04s           |++++++++++++++++++++++++++++                      | 55% ~04s           |++++++++++++++++++++++++++++                      | 56% ~04s           |+++++++++++++++++++++++++++++                     | 57% ~04s           |+++++++++++++++++++++++++++++                     | 58% ~04s           |++++++++++++++++++++++++++++++                    | 59% ~04s           |++++++++++++++++++++++++++++++                    | 60% ~03s           |+++++++++++++++++++++++++++++++                   | 61% ~03s           |+++++++++++++++++++++++++++++++                   | 62% ~03s           |++++++++++++++++++++++++++++++++                  | 63% ~03s           |++++++++++++++++++++++++++++++++                  | 64% ~03s           |+++++++++++++++++++++++++++++++++                 | 65% ~03s           |+++++++++++++++++++++++++++++++++                 | 66% ~03s           |++++++++++++++++++++++++++++++++++                | 67% ~03s           |++++++++++++++++++++++++++++++++++                | 68% ~03s           |+++++++++++++++++++++++++++++++++++               | 69% ~03s           |+++++++++++++++++++++++++++++++++++               | 70% ~03s           |++++++++++++++++++++++++++++++++++++              | 71% ~03s           |++++++++++++++++++++++++++++++++++++              | 72% ~02s           |+++++++++++++++++++++++++++++++++++++             | 73% ~02s           |+++++++++++++++++++++++++++++++++++++             | 74% ~02s           |++++++++++++++++++++++++++++++++++++++            | 75% ~02s           |++++++++++++++++++++++++++++++++++++++            | 76% ~02s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~02s           |+++++++++++++++++++++++++++++++++++++++           | 78% ~02s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~02s           |++++++++++++++++++++++++++++++++++++++++          | 80% ~02s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~02s           |+++++++++++++++++++++++++++++++++++++++++         | 82% ~02s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~01s           |++++++++++++++++++++++++++++++++++++++++++        | 84% ~01s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~01s           |+++++++++++++++++++++++++++++++++++++++++++       | 86% ~01s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~01s           |++++++++++++++++++++++++++++++++++++++++++++      | 88% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++     | 90% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++    | 92% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 93% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 94% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 95% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 96% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 97% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 99% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=08s
  |                                                  | 0 % ~calculating   |+                                                 | 1 % ~14s           |++                                                | 2 % ~14s           |++                                                | 3 % ~14s           |+++                                               | 4 % ~14s           |+++                                               | 5 % ~14s           |++++                                              | 6 % ~14s           |++++                                              | 7 % ~13s           |+++++                                             | 8 % ~13s           |+++++                                             | 9 % ~13s           |++++++                                            | 10% ~13s           |++++++                                            | 11% ~13s           |+++++++                                           | 12% ~13s           |+++++++                                           | 13% ~12s           |++++++++                                          | 14% ~12s           |++++++++                                          | 15% ~12s           |+++++++++                                         | 16% ~12s           |+++++++++                                         | 17% ~12s           |++++++++++                                        | 18% ~12s           |++++++++++                                        | 19% ~12s           |+++++++++++                                       | 20% ~11s           |+++++++++++                                       | 21% ~11s           |++++++++++++                                      | 22% ~11s           |++++++++++++                                      | 23% ~11s           |+++++++++++++                                     | 24% ~11s           |+++++++++++++                                     | 26% ~11s           |++++++++++++++                                    | 27% ~11s           |++++++++++++++                                    | 28% ~10s           |+++++++++++++++                                   | 29% ~10s           |+++++++++++++++                                   | 30% ~10s           |++++++++++++++++                                  | 31% ~10s           |++++++++++++++++                                  | 32% ~10s           |+++++++++++++++++                                 | 33% ~10s           |+++++++++++++++++                                 | 34% ~10s           |++++++++++++++++++                                | 35% ~09s           |++++++++++++++++++                                | 36% ~09s           |+++++++++++++++++++                               | 37% ~09s           |+++++++++++++++++++                               | 38% ~09s           |++++++++++++++++++++                              | 39% ~09s           |++++++++++++++++++++                              | 40% ~09s           |+++++++++++++++++++++                             | 41% ~09s           |+++++++++++++++++++++                             | 42% ~08s           |++++++++++++++++++++++                            | 43% ~08s           |++++++++++++++++++++++                            | 44% ~08s           |+++++++++++++++++++++++                           | 45% ~08s           |+++++++++++++++++++++++                           | 46% ~08s           |++++++++++++++++++++++++                          | 47% ~08s           |++++++++++++++++++++++++                          | 48% ~08s           |+++++++++++++++++++++++++                         | 49% ~07s           |+++++++++++++++++++++++++                         | 50% ~07s           |++++++++++++++++++++++++++                        | 51% ~07s           |+++++++++++++++++++++++++++                       | 52% ~07s           |+++++++++++++++++++++++++++                       | 53% ~07s           |++++++++++++++++++++++++++++                      | 54% ~07s           |++++++++++++++++++++++++++++                      | 55% ~06s           |+++++++++++++++++++++++++++++                     | 56% ~06s           |+++++++++++++++++++++++++++++                     | 57% ~06s           |++++++++++++++++++++++++++++++                    | 58% ~06s           |++++++++++++++++++++++++++++++                    | 59% ~06s           |+++++++++++++++++++++++++++++++                   | 60% ~06s           |+++++++++++++++++++++++++++++++                   | 61% ~06s           |++++++++++++++++++++++++++++++++                  | 62% ~05s           |++++++++++++++++++++++++++++++++                  | 63% ~05s           |+++++++++++++++++++++++++++++++++                 | 64% ~05s           |+++++++++++++++++++++++++++++++++                 | 65% ~05s           |++++++++++++++++++++++++++++++++++                | 66% ~05s           |++++++++++++++++++++++++++++++++++                | 67% ~05s           |+++++++++++++++++++++++++++++++++++               | 68% ~05s           |+++++++++++++++++++++++++++++++++++               | 69% ~04s           |++++++++++++++++++++++++++++++++++++              | 70% ~04s           |++++++++++++++++++++++++++++++++++++              | 71% ~04s           |+++++++++++++++++++++++++++++++++++++             | 72% ~04s           |+++++++++++++++++++++++++++++++++++++             | 73% ~04s           |++++++++++++++++++++++++++++++++++++++            | 74% ~04s           |++++++++++++++++++++++++++++++++++++++            | 76% ~04s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~03s           |+++++++++++++++++++++++++++++++++++++++           | 78% ~03s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~03s           |++++++++++++++++++++++++++++++++++++++++          | 80% ~03s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~03s           |+++++++++++++++++++++++++++++++++++++++++         | 82% ~03s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~03s           |++++++++++++++++++++++++++++++++++++++++++        | 84% ~02s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~02s           |+++++++++++++++++++++++++++++++++++++++++++       | 86% ~02s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~02s           |++++++++++++++++++++++++++++++++++++++++++++      | 88% ~02s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~02s           |+++++++++++++++++++++++++++++++++++++++++++++     | 90% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++    | 92% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 93% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 94% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 95% ~01s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 96% ~01s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 97% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 99% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=14s
Calculating cluster AC
Calculating cluster EX1
Calculating cluster EX2
Calculating cluster EX3
Calculating cluster IN1
Calculating cluster IN2
Calculating cluster MG
Calculating cluster OC

[4]:
%%R
# saveRDS(object = markersPeaks.Raw,file = "imputation/markersPeaks.Raw.rds")
# saveRDS(object = markersPeaks.Impute,file = "imputation/markersPeaks.Impute.rds")
# saveRDS(object = markersPeaks.Binary,file = "imputation/markersPeaks.Binary.rds")
# markersPeaks.Raw <- readRDS("imputation/markersPeaks.Raw.rds")
# markersPeaks.Impute <- readRDS("imputation/markersPeaks.Impute.rds")
# markersPeaks.Binary <- readRDS("imputation/markersPeaks.Binary.rds")

Select the top 15 most prominent differentially accessible regions for each cluster.

[36]:
%%R
markersPeaks.topn.Raw <- markersPeaks.Raw %>%
  group_by(cluster) %>%
  top_n(n = 15, wt = avg_log2FC)
markersPeaks.topn.Impute <- markersPeaks.Impute %>%
  group_by(cluster) %>%
  top_n(n = 15, wt = avg_log2FC)
markersPeaks.topn.Binary <- markersPeaks.Binary %>%
  group_by(cluster) %>%
  top_n(n = 15, wt = avg_log2FC)

  • Heatmap visualization

The following code uses the ComplexHeatmap package to plot accessibility heatmaps for the three data matrices across these top DARs.

[49]:
%%R
library(dplyr)
library(ComplexHeatmap)
library(circlize)
solarExtra = c("5"='#3361A5', "7"='#248AF3', "1"='#14B3FF', "8"='#88CEEF', "9"='#C1D5DC', "4"='#EAD397', "3"='#FDB31A',"2"= '#E42A2A', "6"='#A31D1D')
paletteContinuous <- function(
    pal,
    n = 256,
    reverse = FALSE
){
  palOut <- colorRampPalette(pal)(n)
  return(palOut)

}
.rowZscores <- function(m = NULL, min = -2, max = 2, limit = FALSE){
  z <- sweep(m - rowMeans(m), 1, matrixStats::rowSds(m),`/`)
  if(limit){
    z[z > max] <- max
    z[z < min] <- min
  }
  return(z)
}
hm <- function(mat,sp){
  mat <- .rowZscores(mat, limit = FALSE)
  limits = c(min(mat), max(mat))
  color = paletteContinuous(solarExtra, n = 100)
  breaks <- seq(-2,2, length.out = length(color))
  color <- circlize::colorRamp2(breaks, color)
  top_anno <- HeatmapAnnotation(
    cluster = anno_block(gp = gpar(fill = NA,col=NA), # set color
                         labels = levels(cluster_info),
                         labels_gp = gpar(cex = 0.5, col ="black",fontsize=25, fontface="bold"))) # set font
  Heatmap(
    mat,
    name = "Z-score",
    cluster_rows = FALSE,
    cluster_columns = FALSE,
    show_column_names = FALSE,
    show_row_names = FALSE,
    column_split = cluster_info,
    row_split = sp,
    border = T,
    border_gp = gpar(lwd=1,col="#555555"),
    # row_split = cluster_info,
    top_annotation =  top_anno,
    # left_annotation =  top_anno,
    column_title= NULL,
    row_title = NULL,
    col = color,
    heatmap_legend_param = list(
      color_bar = "continuous",
      legend_direction = "horizontal"
    )
  )
}

# Fetching data for heatmap plots
cluster_info <- sort(brain$celltype)
mat.raw <- GetAssayData(brain, slot = "data", assay = "peaks")
mat.raw <- as.matrix(mat.raw[markersPeaks.topn.Raw$gene, names(cluster_info)])
mat.impute <- GetAssayData(brain, slot = "data", assay = "impute")
mat.impute <- as.matrix(mat.impute[markersPeaks.topn.Impute$gene, names(cluster_info)])
mat.binary <- GetAssayData(brain, slot = "data", assay = "binary")
mat.binary <- as.matrix(mat.binary[markersPeaks.topn.Binary$gene, names(cluster_info)])

Let’s show the heatmaps for raw, imputed and binary imputed data in that order:

[93]:
%%R
ht_opt$message = FALSE
# pdf("imputation/heatmap_DARs_raw.pdf", width = 8, height = 4.5)
draw(hm(mat.raw,markersPeaks.topn.Raw$cluster),heatmap_legend_side = "bot",)
# dev.off()
../_images/notebooks_tutorial3_58_0.png
[94]:
%%R
# pdf("imputation/heatmap_DARs_impute.pdf", width = 8, height = 4.5)
draw(hm(mat.impute,markersPeaks.topn.Impute$cluster),heatmap_legend_side = "bot")
# dev.off()
../_images/notebooks_tutorial3_59_0.png
[95]:
%%R
# pdf("imputation/heatmap_DARs_binary.pdf", width = 8, height = 4.5)
draw(hm(mat.binary,markersPeaks.topn.Binary$cluster),heatmap_legend_side = "bot")
# dev.off()
../_images/notebooks_tutorial3_60_0.png
  • Difference sets of DARs

Next, we investigate how imputation enhances the results of DARs analysis, focusing on the set of differential DARs as the starting point.

[98]:
%%R
a <- markersPeaks.Impute %>%
  dplyr::filter(avg_log2FC > 1) %>%
  arrange(cluster)
b <- markersPeaks.Raw %>%
  dplyr::filter(avg_log2FC > 1) %>%
  arrange(cluster)
diff.more <- as.data.frame(setdiff(a,b))
diff.more.topn <- diff.more %>%
  group_by(cluster) %>%
  dplyr::filter(avg_log2FC > 1)
mat.diff <- GetAssayData(brain, slot = "data", assay = "impute")
mat.diff <- as.matrix(mat.diff[diff.more.topn$gene, names(cluster_info)])
mat <- mat.diff
.rowZscores(mat, limit = FALSE)-> mat

Let’s visualize the heatmap on these difference sets of DARs.

[105]:
%%R
color.count = paletteContinuous(solarExtra, n = 100)
breaks <- seq(-2, 2, length.out = length(color.count))
color.count <- circlize::colorRamp2(breaks, color.count)
top_anno <- HeatmapAnnotation(
  cluster = anno_block(gp = gpar(fill = c("#E64B35FF","#4DBBD5FF","#00A087FF","#3C5488FF","#F39B7FFF","#8491B4FF","#91D1C2FF","#DC0000FF")), # 设置填充色
                       labels = levels(cluster_info),
                       labels_gp = gpar(cex = 0.5, col = "white",fontsize=17,fontface="bold"))) # set font
sp <- subset(diff.more.topn,select=c("gene","cluster"))
sp$gene <- NULL


hm.count <- Heatmap(
  mat,
  name = "Z-score",
  cluster_rows = FALSE,
  cluster_columns = FALSE,
  show_column_names = FALSE,
  show_row_names = FALSE,
  column_split = cluster_info,
  top_annotation =  top_anno,
  column_title= NULL,
  col = color.count,
  split = sp,
  row_title = NULL,
  row_gap = unit(0, "mm"),
  column_gap = unit(0, "mm"),
  border = TRUE,
  border_gp = gpar(lwd=1),
  heatmap_legend_param = list(
    color_bar = "continuous",
    legend_direction = "horizontal"
  )
)
draw(hm.count,gap=unit(0, "points"),heatmap_legend_side = "bot",show_heatmap_legend=F)
../_images/notebooks_tutorial3_65_0.png

3.3 Motif deviation score

To further understand the biological significance behind this increase in cell type-specific peaks post-imputation, we proceeded with enrichment analysis. The analysis revealed that the enhanced cell type-specific peaks after imputation are significantly associated with cell identity, rather than being arbitrary occurrences.

Specifically, we use Signac which has incorporated chromVAR algorithm to calculate the motif activity score for each cell. For a detailed explanation of the method, refer to the Signac or chromVAR paper.

  • Calculate motif deviation score

[37]:
%%R
library(TFBSTools)
library(JASPAR2020)
library(BSgenome.Mmusculus.UCSC.mm10)
genome <- BSgenome.Mmusculus.UCSC.mm10
pfm <- getMatrixSet(
  x = JASPAR2020,
  opts = list(species=10090,collection = "CORE", tax_group = 'vertebrates', all_versions = FALSE)
)
brain <- AddMotifs(object = brain,genome = genome,pfm = pfm)
motif.id2name <- lapply(pfm,function(x){x@name})
motif.name2id <- setNames(as.list(names(motif.id2name)), unlist(motif.id2name))

Beyond motif deviation score, we also computed T-SNE embedding based on this score for futher visualization.

[38]:
%%R
brain <- RunChromVAR(
  object = brain,
  genome = genome,
  assay = "peaks",
  new.assay.name = "chromvar.peaks",
)
DefaultAssay(brain) <- "chromvar.peaks"
brain <- ScaleData(brain, features = rownames(brain),do.scale=F)
brain <- RunPCA(brain,slot="data", features = rownames(brain),reduction.name = "pca.chromvar.peaks",reduction.key = "pca.chromvar.peaks")
brain <- RunTSNE(brain,slot="data", reduction = "pca.chromvar.peaks", reduction.name = "tsne.chromvar.peaks",reduction.key = "tsne.chromvar.peaks",check_duplicates=F)
[39]:
%%R
brain <- AddMotifs(object = brain,genome = genome,pfm = pfm, assay = "impute")
brain <- RunChromVAR(
  object = brain,
  genome = genome,
  assay = "impute",
  new.assay.name = "chromvar.impute",
)
DefaultAssay(brain) <- "chromvar.impute"
brain <- ScaleData(brain, features = rownames(brain),do.scale=F)
brain <- RunPCA(brain,slot="data", features = rownames(brain),reduction.name = "pca.chromvar.impute",reduction.key = "pca.chromvar.impute")
brain <- RunTSNE(brain,slot="data", reduction = "pca.chromvar.impute", reduction.name = "tsne.chromvar.impute",reduction.key = "tsne.chromvar.impute",check_duplicates=F)

  • Visualize motif deviation scor before and after imputation

[ ]:
%%R
# Ensure the existence of interested motif.
grep("Dlx2",names(motif.name2id),ignore.case=T,value=T)
[1] "Dlx2"
[ ]:
%%R
library(ggplot2)
plotfunction <- function(tf,noTitle=F){
  g <- FeaturePlot(
    object = brain,
    features = as.character(motif.name2id[tf]), # query the corresponding id by motif name.
    min.cutoff = 'q5',
    max.cutoff = 'q95',
    pt.size = 1,
    label = T,
    reduction = "tsne.chromvar.impute",
    # ncol = length(chosen),
    col = paletteContinuous(colorRampPalette(
      c("1"="#8499cb","2"="white","3"="#ff0000")
    )(10), n = 50),
    slot = "data"
  )+
    ggtitle(NULL)+
    labs(x = "TSNE1", y = "TSNE2")+
    theme(
      axis.line = element_line(linewidth=.25,arrow = arrow(type = "closed",length = unit(0.04, "inches"))),
      panel.border = element_blank(),
      axis.text = element_blank(),
      axis.ticks = element_blank(),
      axis.title = element_text(hjust = 0, face = "italic"),
      plot.margin = margin(0,0,0,0)
    )+
    NULL
  g
}
tf <- "Dlx2"
DefaultAssay(brain) <- "chromvar.impute"
p1 <- plotfunction(tf)
DefaultAssay(brain) <- "chromvar.peaks"
p2 <- plotfunction(tf)

[ ]:
%%R
# `p1` represents the interest feature's expression of imputed data, while 'p2' represents the result of raw data.
p1/p2
../_images/notebooks_tutorial3_76_0.png
  • Differential testing on motif score

To identify cell type-specific regulatory elements, we can search for differentially-active motifs by performing differential testing on motif score.

[40]:
%%R
markers.dev.peaks <- FindAllMarkers(
  object = brain,
  only.pos = T,
  mean.fxn = rowMeans,
  fc.name = "avg_diff",
  min.pct = .25, logfc.threshold = .25,
  assay = "chromvar.peaks",
  slot = "scale.data"
)
markers.dev.peaks$motif.name <- brain[["peaks"]]@motifs@motif.names[markers.dev.peaks$gene]
markers.dev.impute <- FindAllMarkers(
  object = brain,
  only.pos = T,
  mean.fxn = rowMeans,
  fc.name = "avg_diff",
  min.pct = .25, logfc.threshold = .25,
  assay = "chromvar.impute",
  slot = "scale.data"
)
markers.dev.impute$motif.name <- brain[["peaks"]]@motifs@motif.names[markers.dev.impute$gene]
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~00s           |++++++++                                          | 15% ~00s           |+++++++++                                         | 17% ~00s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~00s           |++++++++                                          | 15% ~00s           |+++++++++                                         | 17% ~00s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~01s           |++++++++                                          | 15% ~01s           |+++++++++                                         | 17% ~01s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~00s           |++++++++                                          | 15% ~00s           |+++++++++                                         | 17% ~00s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~00s           |++++++++                                          | 15% ~00s           |+++++++++                                         | 17% ~00s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~00s           |++++++++                                          | 15% ~00s           |+++++++++                                         | 17% ~00s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~00s           |++++++++                                          | 15% ~00s           |+++++++++                                         | 17% ~00s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~00s           |++++++++                                          | 15% ~00s           |+++++++++                                         | 17% ~00s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~00s           |++++++++                                          | 15% ~00s           |+++++++++                                         | 17% ~00s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~00s           |++++++++                                          | 15% ~00s           |+++++++++                                         | 17% ~00s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~00s           |++++++++                                          | 15% ~00s           |+++++++++                                         | 17% ~00s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~00s           |++++++++                                          | 15% ~00s           |+++++++++                                         | 17% ~00s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~00s           |++++++++                                          | 15% ~00s           |+++++++++                                         | 17% ~00s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~00s           |++++++++                                          | 15% ~00s           |+++++++++                                         | 17% ~00s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~00s           |++++++++                                          | 15% ~00s           |+++++++++                                         | 17% ~00s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
  |                                                  | 0 % ~calculating   |+                                                 | 2 % ~00s           |++                                                | 4 % ~00s           |+++                                               | 6 % ~00s           |++++                                              | 8 % ~00s           |+++++                                             | 9 % ~00s           |++++++                                            | 11% ~00s           |+++++++                                           | 13% ~00s           |++++++++                                          | 15% ~00s           |+++++++++                                         | 17% ~00s           |++++++++++                                        | 19% ~00s           |+++++++++++                                       | 21% ~00s           |++++++++++++                                      | 23% ~00s           |+++++++++++++                                     | 25% ~00s           |++++++++++++++                                    | 26% ~00s           |+++++++++++++++                                   | 28% ~00s           |++++++++++++++++                                  | 30% ~00s           |+++++++++++++++++                                 | 32% ~00s           |+++++++++++++++++                                 | 34% ~00s           |++++++++++++++++++                                | 36% ~00s           |+++++++++++++++++++                               | 38% ~00s           |++++++++++++++++++++                              | 40% ~00s           |+++++++++++++++++++++                             | 42% ~00s           |++++++++++++++++++++++                            | 43% ~00s           |+++++++++++++++++++++++                           | 45% ~00s           |++++++++++++++++++++++++                          | 47% ~00s           |+++++++++++++++++++++++++                         | 49% ~00s           |++++++++++++++++++++++++++                        | 51% ~00s           |+++++++++++++++++++++++++++                       | 53% ~00s           |++++++++++++++++++++++++++++                      | 55% ~00s           |+++++++++++++++++++++++++++++                     | 57% ~00s           |++++++++++++++++++++++++++++++                    | 58% ~00s           |+++++++++++++++++++++++++++++++                   | 60% ~00s           |++++++++++++++++++++++++++++++++                  | 62% ~00s           |+++++++++++++++++++++++++++++++++                 | 64% ~00s           |++++++++++++++++++++++++++++++++++                | 66% ~00s           |++++++++++++++++++++++++++++++++++                | 68% ~00s           |+++++++++++++++++++++++++++++++++++               | 70% ~00s           |++++++++++++++++++++++++++++++++++++              | 72% ~00s           |+++++++++++++++++++++++++++++++++++++             | 74% ~00s           |++++++++++++++++++++++++++++++++++++++            | 75% ~00s           |+++++++++++++++++++++++++++++++++++++++           | 77% ~00s           |++++++++++++++++++++++++++++++++++++++++          | 79% ~00s           |+++++++++++++++++++++++++++++++++++++++++         | 81% ~00s           |++++++++++++++++++++++++++++++++++++++++++        | 83% ~00s           |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s           |++++++++++++++++++++++++++++++++++++++++++++      | 87% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++     | 89% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++    | 91% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++   | 92% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++  | 94% ~00s           |+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s           |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s

Select the top 7 most prominent differentially-active motifs for each cluster.

[44]:
%%R
markers.motif.sig.impute <- markers.dev.impute[which(markers.dev.impute$avg_diff>1),]
markers.motif.sig.peaks <- markers.dev.peaks[which(markers.dev.peaks$avg_diff>1),]

markers.motif.sig.impute.topn <- markers.motif.sig.impute%>%
  group_by(cluster)%>%
  top_n(7,wt = avg_diff)
markers.motif.sig.peaks.topn <- markers.motif.sig.peaks%>%
  group_by(cluster)%>%
  top_n(7,wt = avg_diff)

The following code uses the ComplexHeatmap package to plot accessibility heatmaps for the three data matrices across these top DARs.

[52]:
%%R
# Fetching data for heatmap plots
mat.dev.impute <- GetAssayData(brain, slot = "data", assay = "chromvar.impute")
mat.dev.impute <- as.matrix(mat.dev.impute[markers.motif.sig.impute.topn$gene, names(cluster_info)])
mat.dev.peaks <- GetAssayData(brain, slot = "data", assay = "chromvar.peaks")
mat.dev.peaks <- as.matrix(mat.dev.peaks[markers.motif.sig.peaks.topn$gene, names(cluster_info)])


top_anno <- HeatmapAnnotation(
  cluster = anno_block(gp = gpar(fill = NA,col=NA),
                       labels = levels(cluster_info),
                       labels_gp = gpar(cex = 0.5, col = c("#E64B35FF","#4DBBD5FF","#00A087FF","#3C5488FF","#F39B7FFF","#8491B4FF","#91D1C2FF","#DC0000FF"),fontsize=25, fontface="bold"))) # 设置字体
hm.impute <- Heatmap(
  mat.dev.impute,
  name = "chromVAR deviations of imputed",
  cluster_rows = FALSE,
  cluster_columns = FALSE,
  show_column_names = FALSE,
  column_split = cluster_info,
  top_annotation =  top_anno,
  column_title= NULL,
  col = paletteContinuous(colorRampPalette(
    c("1"="#8499cb","2"="white","3"="#ff0000")
  )(10), n = 100),

  row_names_rot = 0,
  row_names_side = "left",
  row_labels = motif.id2name[rownames(mat.dev.impute)],
  row_title = NULL,
  row_gap = unit(0, "mm"),
  column_gap = unit(0, "mm"),
  border = F,
  border_gp = gpar(lwd=1),
  heatmap_legend_param = list(
    color_bar = "continuous",
    legend_direction = "horizon"
  )
)
hm.raw <- Heatmap(
  mat.dev.peaks,
  name = "chromVAR deviations of raw",
  cluster_rows = FALSE,
  cluster_columns = FALSE,
  show_column_names = FALSE,
  column_split = cluster_info,
  top_annotation =  top_anno,
  column_title= NULL,
  col = paletteContinuous(colorRampPalette(
    c("1"="#8499cb","2"="white","3"="#ff0000")
  )(10), n = 100),

  row_names_rot = 0,
  row_names_side = "left",
  row_labels = motif.id2name[rownames(mat.dev.peaks)],
  row_title = NULL,
  row_gap = unit(0, "mm"),
  column_gap = unit(0, "mm"),
  border = F,
  border_gp = gpar(lwd=1),
  heatmap_legend_param = list(
    color_bar = "continuous",
    legend_direction = "horizon"
  )
)

Let’s show the heatmaps for raw, imputed and binary imputed data in that order:

[53]:
%%R
draw(hm.raw,gap=unit(0, "points"),heatmap_legend_side = "left",show_heatmap_legend=F)
../_images/notebooks_tutorial3_85_0.png
[54]:
%%R
draw(hm.impute,gap=unit(0, "points"),heatmap_legend_side = "left",show_heatmap_legend=F)
../_images/notebooks_tutorial3_86_0.png

Obviously, the heatmap of top differentially-active motifs based on imputed data provides clearer cell group distribution.