# SMTrackR

## Visualizing protein-DNA binding on individual sequenced DNA molecules.

Single-molecule assays like NOMe-seq, and dSMF are superior to DNase-seq and
ATAC-seq as they do not nibble down DNA. Thus, they enable quantification of
all three i.e., protein-free, Transcription Factor-bound and
histone-complex-bound states. But a user-friendly tool to visualize and
quantify such states is lacking. Here, we present, SMTrackR, a Bioconductor
package to visualize protein-DNA binding states on individual sequenced DNA
molecules. SMTrackR queries the single-molecule footprint database we built and
hosted at Galaxy Server. It comprises of BigBed files generated from NOMe-seq
and dSMF datasets. SMTrackR exploits UCSC REST API to query a BigBed file and
plot footprint heatmap categorized in different binding states as well as
report their occupancies.

List of tracks are available [here](https://docs.google.com/spreadsheets/d/1eu2Y2S0lyAUqxlvtnPBCO55OrxidYV7SwVRkqelPcKk/edit?gid=0#gid=0).

## Installation

Please use the following command to install this package in `R`

```
library(devtools)
devtools::install_github("satyanarayan-rao/SMTrackR", build_vignettes=TRUE, force=TRUE)
```

## Generating Protein-DNA binding Visualization


### Using data from mouse 8Cell stage

Pseudo-bulk signal is generated by merging all 8Cell scNOMe-seq data available from [Wang et al., Nat Commun., 2021](https://pubmed.ncbi.nlm.nih.gov/33623021/). 

```
library(SMTrackR)
SMTrackR::plotFootprints(organism = "mmusculus", model = "8cell", condition = "WT", 
               genome_assembly = "mm10", type = "SMF", chromosome = "chr5", 
               start = 113847750,  end  = 113847780, tr = "8cell", label = "remove_dup_true", 
               fp_cap = 50, remove_dup = T, target_dir = "smf")
```
NOTE: The heatmap will be saved in `smf/plots/remove_dup_true.heatmap.pdf`.

The `png` version of the plot is shown here. 


<img src="./plots/remove_dup_true.heatmap.png" alt="remove_dup" width="400">


### Using data from Drosophila Melanogaster S2 cells

Please use the command below to generate a heatmap centered at `chr2L:480290-480320` in _Drosophila Melanogaster_ S2 cells. Here dSMF data is sourced from [Krebs et al., Mol. Cell., 2017](https://pubmed.ncbi.nlm.nih.gov/28735898/).

```
library(SMTrackR)
SMTrackR::plotFootprints(target_dir = "dsmf")
```

The above command will generate `dsmf/plots/peak229.heatmap.pdf`. The `png` version is shown below. 

<img src="./plots/peak229.heatmap.png" alt="peak229" width="400">


### Using SMAC-seq data from Yeast

```
library(SMTrackR)
SMTrackR::plotMethylationCallsNanopore(target_dir = "nanopore")
```

The png version of the plot is shown below. 

<img src="./plots/smac_seq.heatmap.png" alt="nanopore" width="600">

## Visualizing on gene tracks

Because `Gviz` is a heavy package, we have not made ours to depend on this, but we generate a code that renders the heatmap below the gene track. Users are of course free to change the zoom level and add other tracks of their need. The generated code renders ideogram, axis, gene tracks and the heatmap highlight the center. It requires that you run the **`plotFootprints` function first**, so that it can use the heatmap data. Please look at the code below.

```
SMTrackR::plotFootprints(organism = "mmusculus", model = "16cell", condition = "WT",
                         genome_assembly = "mm10", type = "SMF", chromosome = "chr1",
                         start = 191718250,  end = 191718280, tr = "16cell",
                         label = "tss", fp_cap = 50, remove_dup = F, target_dir = "smf")
SMTrackR::generateGvizCodeforSMF(organism = "mmusculus", model = "16cell", condition = "WT",
                         genome_assembly = "mm10", type = "SMF", chromosome = "chr1",
                         start = 191718250,  end = 191718280, tr = "16cell",
                         label = "tss", fp_cap = 50, remove_dup = F, gviz_left = 500, 
                         gviz_right = 500, target_dir = "smf")
```

The png version of `smf/plots/tss.gviz.pdf` is shown below. 

NOTE: `R` script written by `generateGvizCodeforSMF` code uses Nov 2020 Ensembl Archive, which is currently not available (at least from last two weeks). Our bigBed tracks are built on mm9 and mm10 assemblies, so we can't use the latest (may2025) archive which maps `mm39`. The plot below was generated with functional [nov2020.archive.ensembl.org](nov2020.archive.ensembl.org).

<img src="./plots/tss.gviz.png" alt="nanopore" width="600">

