Part I · Module 07 · PHYLUCE 1.7.3

Extracting UCE loci

Convert the probe-to-contig matches identified in the previous module into a monolithic FASTA dataset containing the recovered UCE loci across all samples.

Objective

Define the samples to include, summarize the UCE loci present in the match database, and extract the corresponding sequences from the assembled contigs.

Strategy used in this tutorial

We will generate an incomplete matrix. This retains loci that are present in only a subset of samples. Matrix completeness will be evaluated and filtered later, after alignment.

1. Activate PHYLUCE 1.7.3

conda activate phyluce-1.7.3

On Apple Silicon:

conda activate phyluce-1.7.3-x86

Confirm that both programs are available:

phyluce_assembly_get_match_counts --help

phyluce_assembly_get_fastas_from_match_counts --help

2. Define the project paths

PROJECT="/path/to/my_UCE_project"

CONTIGS="$PROJECT/spades-assemblies/contigs"
LOCUS_DB="$PROJECT/uce-search-results/probe.matches.sqlite"

TAXON_SETS="$PROJECT/taxon-sets"
DATASET="$TAXON_SETS/all"

LOGS="$DATASET/log"

mkdir -p "$DATASET" "$LOGS"
CONTIGS
Standardized SPAdes contigs generated in Module 05.
LOCUS_DB
SQLite database produced by phyluce_assembly_match_contigs_to_probes.
DATASET
Directory containing the taxon-set configuration and extracted UCE sequences.

3. Create the sample-set configuration

PHYLUCE uses a simple configuration file to define which samples should be included in a dataset. Create:

TAXON_CONF="$PROJECT/taxon-set.conf"

Example:

[all]
sample01
sample02
sample03
sample04
sample05

The identifiers must match the sample names stored in probe.matches.sqlite.

Inspect the file:

cat "$TAXON_CONF"

4. Generate the UCE match-count configuration

Use phyluce_assembly_get_match_counts to determine which UCE loci are available for the selected samples.

phyluce_assembly_get_match_counts \
  --locus-db "$LOCUS_DB" \
  --taxon-list-config "$TAXON_CONF" \
  --taxon-group all \
  --output "$DATASET/all-taxa-incomplete.conf" \
  --incomplete-matrix \
  --log-path "$LOGS"
--locus-db
UCE match database created in Module 06.
--taxon-list-config
Configuration containing the samples to include.
--taxon-group
Section of the configuration file to use; here, [all].
--output
Data-matrix configuration containing the selected samples and UCE loci.
--incomplete-matrix
Retains loci even when some samples lack data for that locus.
Why use an incomplete matrix here?

Requiring a complete matrix at this stage can discard many informative loci. PHYLUCE recommends retaining the broader set first and deciding the desired occupancy threshold after alignment.

5. Inspect the match-count configuration

The generated file contains two sections: the samples included in the dataset and the UCE loci retained for extraction.

head -40 "$DATASET/all-taxa-incomplete.conf"

A simplified example looks like:

[Organisms]
sample01
sample02
sample03
sample04
sample05

[Loci]
uce-12
uce-31
uce-45
uce-108
uce-142
...

6. Extract the UCE sequences

Now extract the corresponding UCE sequences from the SPAdes contigs:

phyluce_assembly_get_fastas_from_match_counts \
  --contigs "$CONTIGS" \
  --locus-db "$LOCUS_DB" \
  --match-count-output "$DATASET/all-taxa-incomplete.conf" \
  --output "$DATASET/all-taxa-incomplete.fasta" \
  --incomplete-matrix "$DATASET/all-taxa-incomplete.incomplete" \
  --log-path "$LOGS"
--contigs
Directory containing the assembled contigs.
--locus-db
Database connecting samples, contigs and UCE loci.
--match-count-output
Configuration created by phyluce_assembly_get_match_counts.
--output
Monolithic FASTA containing all extracted UCE sequences.
--incomplete-matrix
File in which PHYLUCE records loci missing from individual samples.

7. Expected output

taxon-sets/
└── all/
    ├── all-taxa-incomplete.conf
    ├── all-taxa-incomplete.fasta
    ├── all-taxa-incomplete.incomplete
    └── log/
        ├── phyluce_assembly_get_match_counts.log
        └── phyluce_assembly_get_fastas_from_match_counts.log
*.conf
Samples and loci selected from the match database.
*.fasta
Monolithic FASTA containing the recovered UCE sequences.
*.incomplete
Record of loci missing from particular samples.

8. Basic quality checks

Confirm that the FASTA contains sequences:

grep -c "^>" "$DATASET/all-taxa-incomplete.fasta"

Inspect the first few sequence headers:

grep "^>" "$DATASET/all-taxa-incomplete.fasta" | head

Inspect the missing-data record:

head "$DATASET/all-taxa-incomplete.incomplete"
Do not filter occupancy yet

At this stage we retain the broad UCE dataset. The next module aligns each locus, after which occupancy thresholds such as 50%, 75%, 90% or other project-specific values can be evaluated properly.

9. Why one monolithic FASTA?

The output FASTA contains sequences from many loci and samples in a single file. PHYLUCE uses the locus information encoded in the sequence headers to separate these records during the alignment step.

This file therefore serves as the bridge between UCE recovery and locus-by-locus multiple sequence alignment.

10. Pre-flight check

✓ The sample-set configuration contains all intended samples.
✓ Sample identifiers match those in probe.matches.sqlite.
✓ all-taxa-incomplete.conf was generated successfully.
✓ all-taxa-incomplete.fasta contains extracted UCE sequences.
✓ all-taxa-incomplete.incomplete records missing loci by sample.
✓ Logs from both extraction commands were retained.
✓ No occupancy filtering was applied prematurely.

References and official documentation

PHYLUCE 1.7.3 — UCE processing for phylogenomics

PHYLUCE 1.7.3 — Tutorial I: match counts and FASTA extraction

PHYLUCE 1.7.3 — Program list

Version policy

The syntax in this module follows PHYLUCE 1.7.3. In particular, --incomplete-matrix is intentionally used during match counting so occupancy can be filtered later, after locus alignment.

← Identifying UCE loci Next: UCE alignments →