Q1: does THREADS assume that you start with a phased input VCF file?
R1: it's not stated explicitly. This example works with phased data
Here's the directory content:
filter_convert.shgenerate_demo.shrun_threads.sh
Since paths are defined in configuration file, you can run these scripts from the project root folder or from the threads subfolder. In the examples below, we
will show example in threads subfolder.
We are supposing to have a data subfolder in the base folder (not tracked with
git), where the input VCF file is located.
All scripts (code here) take a configuration file with some basic operational parameters:
basefolder: path to the main project folder, where input data are to be found and intermediate and final results are stored (these can be different subfolders)- paths to software packages, e.g.
plink,bcftoolsetc.
Here's an example configuration file, change basefolder accordingly:
#! /bin/bash
set -euo pipefail
basefolder=/home/paolo/Projects/SheepTreeSeq
bcftools=$(which bcftools)
plink2=$(which plink2)This script will keep only biallelic SNP variants and will convert the input VCF file to
the required input interface for threads (the .pgen, .map, .pvar files).
Input VCF file is located in $basefolder/data/ts2kPhased.vcf.gz and is hard-coded in the script for the moment. Call the script as:
bash filter_convert.sh <your_config_file.sh>In your threads subfolder: the project $basefolder is specified in the config file.
From threads documentation, a demography file is needed:
- two columns: n. of generations in the past, effective population size at that moment (Ne)
- this file must start with 0 generations in the past
- multiple lines with increasing generation numbers and corresponding Ne values can be added
Example:
0 1000
10 100
20 50You can create a demography file like the one above with the following script:
bash generate_demo.sh <your_config_file.sh>NOTE this is very basic for the moment and is hard-coded in
generate_demo.shscript.
This script will run threads with default configuration, e.g.:
threads infer --pgen threads/example/ts2kPhased_filtered.pgen \
--map threads/example/ts2kPhased_filtered.map \
--demography threads/example/ne.demo \
--out threads/example/ts2kPhased_filtered.threadsAn then will convert the output ARG object to a tree sequence object, e.g.:
threads convert --threads threads/example/ts2kPhased_filtered.threads \
--tsz threads/example/ts2kPhased_filtered.tszAll these steps can be run with the following script:
bash run_threads.sh <your_config_file.sh>After contacting Pier Palamara, he uploaded an example dataset, available here: https://palamaralab.github.io/software/threads/data/
As of March 2025, threads does not work out of the box on ARM Macs. But there is a hack: "Edit the file /Users/hbecher/miniconda3/envs/threadsarg/lib/python3.11/site-packages/threads_arg/main.py directly and replace the two calls to os.sched_getaffinity with, for instance, a fixed number equal to the number of cores on your Mac. That is the only project file that uses it." (You will have to adjust the file location to your system setup.)
Threads throws a seg fault if there are multiallelic sites.