Skip to content

CAPTUS Pipeline

anadhifah edited this page Oct 26, 2026 · 2 revisions

This wiki assumed Captus and all dependencies are installed

Input preparation

cd <username>
mkdir captus_<genus_name>
mkdir 00_raw

Put all raw reads (fastq.gz) and outgroups in 00_raw (R1 & R2). Make sure the filename is accepted by captus. Examples in this study:

  • Genus_speciesDNA#_R1.fastq & Genus_speciesDNA#_R2.fastq
  • Genus_speciesSRR#_R1.fastq & Genus_speciesSRR#_R2.fastq Put reference file <probe_set_name>clean_fixed in the directory captus<genus_name>

Activate captus

conda activate captus

Clean the reads

captus clean -r 00_raw 

De Novo Assembly

captus assembly -r 01_clean_reads

Loci extraction

captus extract -a 02_assemblies -n <probe_set_name>_clean_fixed.fasta --threads 12

Alignment and Paralog Filtering

captus align -e 03_extractions

TrimAL Make directory output

mkdir -p 04_alignments/03_trimmed/06_informed/01_coding_NUC/03_genes_trimAL 

Trim using automated1 setting

 for f in 04_alignments/03_trimmed/06_informed/01_coding_NUC/03_genes/*; do
  base=$(basename "$f")
  trimal -in "$f" \
         -out "04_alignments/03_trimmed/06_informed/01_coding_NUC/03_genes_trimAL/$base" \
         -automated1
done

Build gene trees without parallel make directory output

mkdir -p 04_alignments/03_trimmed/06_informed/01_coding_NUC/iqtree_gene_output

Run iqtree

for file in 04_alignments/03_trimmed/06_informed/01_coding_NUC/03_genes_trimAL/*.fna
do
    base=$(basename "$file" .fna)

    iqtree \
        -s "$file" \
        -m MFP \
        -bb 1000 \
        -nt 4 \
        -pre "04_alignments/03_trimmed/06_informed/01_coding_NUC/iqtree_gene_output/$base"
done

Concatanate gene tree files into a single file

cat 04_alignments/03_trimmed/06_informed/01_coding_NUC/iqtree_gene_output/*.treefile > 04_alignments/03_trimmed/06_informed/01_coding_NUC/all_gene_trees.tre

PhyloPickMe Install Julia

winget install --name Julia --id 9NJNWW8PVKMN -e -s msstore

Add PhyloPickMe package

using Pkg
Pkg.add("PhyloPickMe")

Change environments to a julia environment

conda deactivate
julia

Run PickMe

julia -e 'using PhyloPickMe; PickMe("all_gene_trees.tre", "pickme_results")'

Create list of samples to keep (>Bad)

awk -F',' 'NR>1 && $3 ~ /bad|good|very good|exceptional/ {print $1}' pickme_results > keep_bad_samples.txt

Prune taxa based on PickMe in R

install.packages("ape")
library(ape)

Set working directory C:<username>\analysis copy "all_gene_trees.tre" and paste to folder analysis

tree <- read.tree("all_gene_trees.tre")

Read taxa to keep from file

keep_taxa <- readLines("keep_samples.txt")

Prune trees

tree_filt <- lapply(tree, function(tr) {
  keep <- intersect(tr$tip.label, keep_taxa)
  drop.tip(tr, setdiff(tr$tip.label, keep))
})

class(tree_filt) <- "multiPhylo"

Keep only trees with > 4 taxa

tree_filt <- tree_filt[sapply(tree_filt, Ntip) >= 4]

Summarize

summary(sapply(tree_filt, Ntip))
length(tree_filt)

Write filtered trees

write.tree(tree_filt, file = "gene_trees_filtered.newick")

Weighted astral Copy "gene_trees_filtered.newick" and paste to folder captus_<genus_name> Download aster

wastral \
  -i gene_trees_filtered.newick \
  -o wastral_gene_trees_filtered.tre \
  -t 12 \
  -R

##and for the bad included

wastral \
  -i gene_trees_filtered.newick \
  -o wastral_gene_trees_bad_filtered.tre \
  -t 12 \
  -R

Clone this wiki locally