Skip to content

marlaux/Metabarcoding-script-by-script

Repository files navigation

Hello fellow metabarcoders!     Olá colegas metabarcoders!    Texto em português abaixo!

THE UPDATED PIPELINE CAN BE FOUND HERE: https://github.com/marlaux/METAPIPE_METAbarcoding_PIPEline
NEW WORKFLOW STRUCTURE!

The scripts/jobs/directories structure was planned to help you to not waste your precious researcher time with technical issues.

For each step, take a time to study what is been done, along with the tools and respective options. Your project question may be easily answered using some script optional argument/parameter, remember that!

Besides reading lots and lots of scientific papers, do not forget that Google can help you a lot! Pages like https://www.biostars.org/ and http://seqanswers.com/ can solve your errors and doubts most of the times.

JOB/QUEUE SYSTEM IN HPC ENVIRONMENT (high-performance computing environment)
The HPC clusters are resources that are shared between many users, and to ensure fair use everyone must do their computations by submitting jobs through a queue system (batch system) that will execute the applications on the available resources. 

RUNNING JOBS\RODANDO OS JOBS
The "job", is a script to run on HPC using a "queue" system. The jobs run on the compute nodes, with the computatiohnal resources required.
There are different queue systems, as SLURM, PBS and OpenPBS
You can find a template for the jobs in the METAPIPE'S main page: slurm_job_template.slurm, OpenPBS_job_template.pbs, download/copy and use it!

This pipeline was originally built/configured to run through SLURM Workload Manager, but all the scripts run without a job, directly on command prompt

In METAPIPE, the modules, applications and script's commands are set up in bash scripts ".sh". Example: 
merge_pear.sh <-- the script, type ./merge_pear.sh -h 
run_merge_pear.slurm --> this is the job: slurm will place your script on a queue, waiting for the resources you asked and running on the compute nodes.
Example 1: scripts with parameters (options)
			./merge_pear.sh -f Lib1_R1_subsampled.fastq -r Lib1_R2_subsampled.fastq -o output -p 0.001 -s 20 -t 4
Example 2: scripts with positional arguments
			./clustering_swarm_with_chim_filter.sh my_project_prefix /cluster/work/users/my_user/my_work/METAPIPE/3_read_cleaning/dereplicated

GENERAL WORKLOW
For each step:
1. read the README.step, placed in each directory
2. study the basics of the tool(s) involved and take a look in the help (-h or --help)
3. identify your input files and make sure you know how to complete sentences like this:
In this step, the 'tool' will take my 'input' and 'do something' in order to 'something', by 'doing this' and 'doing that' to each sequence, generating the 'output file'.
Real example:
The 'Barcodes_LA.fa files' are required as input to 'cutadapt' tool in the 'demultiplexing step' for 'parsing the amplicons to the samples fasta files'.
The 'clustering step' inputs are the 'dereplicated by sample fasta files', which consist of 'unique sequences', also called 'seeds', and respective 'abundance by sample'.
To run in command prompt instead of jobs, you can ask the queue system to allocate compute resources for you, and once assigned you can run the commands.
Example 1: ask for 1 cpu running with 8GB RAM for 2 hours. Good for basic scripts, editing files, practicing and so on
srun --ntasks=1 --mem-per-cpu=8G --time=02:00:00 --qos=devel --account=nn9XXXk --pty bash -i
Example 2: ask for 4 cpus, 8GB RAM each, running for 1 hour. The amount of resources and the time requested should be balanced. 
srun --ntasks=4 --mem-per-cpu=8G --time=01:00:00 --qos=devel --account=nn9XXXk --pty bash -i
Read more here: https://documentation.sigma2.no/jobs/interactive_jobs.html
**By default the tools which allow multithreading are set to 4 tasks running in one node with 8GB RAM each.The remaining tools are set to 1 task and 8GB RAM. 
**Read each tool documentation to not waste queue time, because you can ask (and wait) for 16GB RAM for a tool which needs at most 2GB.
**If you know that your job is really heavy and demanding, you should use the slurm SCRATCH system. Read about it here: https://documentation.sigma2.no/jobs/running-scientific-software.html?highlight=scratch#slurm
4. if you get an error:
	a. read the log files
	b. copy and paste the error or warning on Google, most of the time someone have already asked it
	c. permission denied: run a global permission in your directory: chmod 776 *
5. do not be stuck!	Write to me if you need help: marlaux@outlook.com


Olá colegas metabarcoders!

A PIPELINE ATUALIZADA PODE SER ACESSADA AQUI: https://github.com/marlaux/METAPIPE

A estrutura de scripts/jobs/diretórios foi planejada para ajudar você a não perder seu precioso tempo de pesquisador com detalhes técnicos.

Para cada etapa, tome um tempo para estudar o que está sendo feito, assim como estudar as ferramentas utilizadas e respectivas opções/parâmetros. Sua hipótese, ou questão a ser respondida, pode ser facilmente resolvida usando um parâmetro opcional, não esqueça disso!!!

Além de ler muitos artigos científicos, não se esqueça que o Google pode te ajudar muito! Páginas como https://www.biostars.org/ e http://seqanswers.com/ podem solucionar seus erros e dúvidas na maioria das vezes. 


Sistema de filas no Ambiente HPC (high-performance computing environment)
Os clusters HPC são recursos compartilhados entre vários usuários, os quais devem enviar seus scripts para rodar no sistema de fila, que executará os aplicativos utilizando os recursos solicitados e disponíveis. 
O "job" é um script a ser executado em HPC usando um controlador de filas. Os jobs são executados nos nós de computação, com os recursos computacionais necessários.
Existem diferentes controladores de filas, como SLURM, PBS e OpenPBS
Você pode encontrar um modelo para os jobs na página principal da METAPIPE: slurm_job_template.slurm, arquivos OpenPBS_job_template.pbs, baixe/copie e use! 
Esta pipeline foi originalmente construída/configurada para rodar em job usando SLURM, mas todos os scripts rodam sem job, diretamente no prompt de comando.

Na METAPIPE pipeline, os aplicativos, ferramentas e scripts são montados em scripts bash ".sh" e Perl ".pl". 
Exemplo 1: scripts com parâmetros (opções)
./merge_pear.sh -f Lib1_R1_subsampled.fastq -r Lib1_R2_subsampled.fastq -o output -p 0,001 -s 20 -t 4
Exemplo 2: scripts com argumentos posicionais
./clustering_swarm_with_chim_filter.sh my_project_prefix /cluster/work/users/my_user/my_work/METAPIPE/3_read_cleaning/dereplicated

FLUXO GERAL DE TRABALHO
** Por padrão, as ferramentas que permitem multithreading são definidas para 4 cpus rodando em um nó com 8 GB de RAM cada. As ferramentas restantes são definidas para 1 tarefa e 8 GB de RAM.
** Leia a documentação de cada ferramenta para não perder tempo na fila, pois você pode pedir (e esperar) 16 GB de RAM para uma ferramenta que precisa de no máximo 2 GB.

Para cada etapa:
1. leia o README localizado em cada diretório

2. estude o básico da(s) ferramenta(s) envolvida(s) e dê uma olhada na ajuda (-h ou --help)

3. identifique seus arquivos de entrada e certifique-se de saber como completar frases como esta:
Nesta etapa, a 'ferramenta' usará o 'arquivo fasta' como input para 'fazer algo', gerando o 'output.txt' que contém 'métricas de tal coisa'.
Exemplo real:
Os 'arquivos fasta Barcodes_LA.fa', gerados pelo script 'preparing_tags_LCPI.pl', são necessários como entrada para a ferramenta 'cutadapt' na 'etapa de demultiplexação' para 'parsear os amplicons por amostra'.
Os inputs da 'etapa de clusterização' são os 'arquivos fasta desreplicados por amostra', que consistem em 'sequências únicas', e a respectiva 'abundância por amostra'.

4. se acontecer um erro:
		a. leia os arquivos de log
		b. copie e cole o erro ou aviso no Google, na maioria das vezes alguém já perguntou
		c. permissão negada: execute uma permissão global em seu diretório: chmod 776 *
		
5. não fique travado! Escreva para mim se precisar de ajuda: marlaux@outlook.com