---
# System prepended metadata

title: Running LRP pipeline for SMC with Docker
tags: [UVA]

---

# Running LRP pipeline for SMC with Docker


Alternative procedire using  Singularity [source](https://github.com/biocorecrg/C4LWG-2018)

## Software installation procedure on Mac

An option to run the [LRP](https://github.com/sheynkman-lab/Long-Read-Proteogenomics) pipeline is using [Singularity](https://docs.sylabs.io/guides/3.5/user-guide/introduction.html)(a Linux container). Singularity runs on Linux natively. To run it on Windows or Mac, a virtual machine(VM) is required.

Here are the instructions to run it on Mac device using just your terminal.

### Homebrew installation

Install [Homebrew](https://brew.sh/) if does not exist already. 
```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

### Vagrant installation 

Vagrant is a VM from [Hashicorp](https://www.hashicorp.com/#open-source-tools). 
```
brew install virtualbox 
brew install vagrant 
brew install vagrant-manager
```

### VM (pre-instaled with Singularity) installation  

Create a folder on your desktop (or wherever you like) to install the Vagrant VM pre-installed with Singularity
```
mkdir vm_SMC_LRP && cd vm_SMC_LRP
```
To bring up the VM in this directory, run the following.
```
export VM=sylabs/singularity-3.0-ubuntu-bionic64 && \
    vagrant init $VM && \
    vagrant up && \
    vagrant ssh
```
Once installation is complete, you'd the see this on your terminal
```
vagrant@vagrant:~
```
You can check if the installation of Singularity is successfull by checking its version
```
singularity version
```

### Nextflow installation

```
sudo apt-get update
sudo apt install curl
sudo apt install default-jre
curl -s https://get.nextflow.io | bash
```
Common problme with Nextflow instalation -> The Path.
Make sure the $PATH is under `/bin`, else nextflow does not get recognized (`nextflow: command not found`). 
For this, you can either specify the `export PATH=/../` during it's installation or just move nextflow from wherever it's installed to `/bin`
```
sudo mv nextflow bin/
```
### Docker installation

```
sudo apt install docker.io
```
Just another docker hurdle if `permission denied while trying to connect to the Docker daemon socket` [source](http://cmr.miccai.cloud/docker-submission-tutorial/)
```
sudo chmod 666 /var/run/docker.sock
```

### LRP GitHub pipeline clone

```
git clone https://github.com/sheynkman-lab/Long-Read-Proteogenomics
```

### Running LRP pipeline 

The nextflow pipeline is `main.nf` and with configurations.  The `.config` holds directory to data and ...
```
nextflow run main.nf --config conf/test_without_sqanti.config 
```
Error: ![](https://i.imgur.com/IMNNAYP.png)
Solution [here](https://ostechnix.com/how-to-increase-memory-and-cpu-on-vagrant-machine/)


### Downloading CPAT Docker image

```
docker pull gsheynkmanlab/cpat:addr

nextflow run cpat.nf --config nextflow.config 

nextflow cpat.nf --name SMC_CPAT --hexamer Human_Hexamer.tsv --logit_model Human_logitModel.RData --sample_fasta SMC_corrected.fasta --min_orf 50 --outdir SMC_CPAT_output

nextflow cpat.nf --name SMC_CPAT --hexamer Human_Hexamer.tsv --logit_model Human_logitModel.RData --sample_fasta SMC_filtered_track.fasta --min_orf 50 --outdir SMC_filtered_CPAT_output
```

![](https://i.imgur.com/QGszQxp.png)


### Download orf_calling Docker image

```
docker pull gsheynkmanlab/orf_calling

nextflow orf_calling.nf --pb_gene pb_gene.tsv --classification SMC_classification.txt --gencode_gtf gencode.v38.annotation.gtf --sample_gtf ./../cpat/SMC_filtered_track_updated.gtf --sample_fasta ./../cpat/SMC_filtered_track.fasta --orf_coord ./../cpat/SMC_filtered_CPAT_output/cpat/SMC_CPAT.ORF_prob.tsv --output SMC_ORF

```

Error with run 1:
![](https://i.imgur.com/ojmc1QQ.png)

Error with run 2: (Looks like the container does not have enough memoey)
![](https://i.imgur.com/VTFUYpI.png)

Increased VM CPU and memory
![](https://i.imgur.com/HQi6dIr.png)


Error with run 3:
![](https://i.imgur.com/Sggepxq.png)

Running orf_caller on a subset i.e. toy file with 10 PacBio genes

Running CPAT on 'SMC.corrected.fasta' from 4 sample cells

```
 nextflow cpat.nf --name SMC_corrected_CPAT --hexamer Human_Hexamer.tsv --logit_model Human_logitModel.RData --sample_fasta SMC_corrected.fasta --min_orf 50 --outdir SMC_corrected_CPAT_output
```


### Download generate_reference_table Docker image

```
docker pull gsheynkmanlab/generate-reference-tables

nextflow ref_table_generation.nf --config nextflow.config --gencode_gtf gencode.v38.annotation.gtf --gencode_fasta gencode.v38.pc_transcripts.fa

nextflow run ref_table_generation.nf --config nextflow.config --gencode_gtf gencode.v38.annotation.gtf --gencode_fasta gencode.v38.pc_transcripts.fa --with-docker --without-singularity
```
Error1:
![](https://i.imgur.com/7RXtiTa.png)


Error in code: 

![](https://i.imgur.com/5STewK9.png)

Solved by changing the script to have `--gene_lens` instead of `--gen_lens`.


### Download transcriptome_summary Docker image

```
docker pull gsheynkmanlab/transcriptome-summary
```
Ran `pb_gene.py` on local because python dependencies.

```
python3 biosurfer/analysis/pb_gene.py --sq_out ./SMC_classification.txt --ensg_to_gene ./ensg_gene.tsv --enst_to_isoname ./enst_isoname.tsv --odir ./SMC/
```
![](https://i.imgur.com/t6KeT8D.png)

### Download orf_calling Docker image
```
docker pull gsheynkmanlab/orf_calling:latest

nextflow orf_calling.nf --config nextflow.config --orf_coord ./../cpat/SMC_corrected_CPAT_output/cpat/SMC_corrected_CPAT.ORF_prob.tsv --gencode_gtf gencode.v38.annotation.gtf --sample_gtf SMC_corrected.gtf --pb_gene ./../transcriptome_summary/results/pb_gene.tsv --classification SMC_classification.txt --sample_fasta SMC_corrected.fasta --output results/
```

Running python script
```
python3 src/orf_calling.py --orf_coord ./../cpat/SMC_corrected_CPAT_output/cpat/SMC_corrected_CPAT.ORF_prob.tsv --gencode gencode.v38.annotation.gtf --sample_gtf SMC_corrected.gtf --pb_gene ./../transcriptome_summary/results/pb_gene.tsv --classification SMC_classification.txt --sample_fasta SMC_corrected.fasta --orf_fasta ./../cpat/SMC_corrected_CPAT_output/cpat/SMC_corrected_CPAT.ORF_seqs.fa  --output SMC_corrected_best_orf.tsv

```
