README.md 13.9 KB
Newer Older
1
2
3
# RADSex

The RADSex pipeline is **currently under development** and has not been officially released yet. Missing features are been implemented, and some bugs are to be expected in this current development version. Please contact me by email or on Github, or open an issue if you encounter bugs or would like to discuss a feature !
4

Romain Feron's avatar
Romain Feron committed
5
## Overview
6

7
RADSex is a software package for the analysis of sex-determination using RAD-Sequencing data. The `process` function generates a data structure summarizing a set of demultiplexed RAD reads, and other functions use this data structure to infer information about the type of sex-determination system, identify sex-biased sequences, and map the RAD sequences to a reference genome. The results of RADSex are meant to be visualized with the `radsex-vis` R package, available here: https://github.com/INRA-LPGP/radsex-vis.
8

9
This pipeline was developed for the PhyloSex project, which investigates sex determining factors in a wide range of fish species.
Romain Feron's avatar
Romain Feron committed
10
11

## Requirements
12

13
- A C++11 compliant compiler (GCC >= 4.8.1, Clang >= 3.3)
Romain Feron's avatar
Romain Feron committed
14
15
16
- The zlib library (which should be installed on linux by default)

## Installation
17

18
- Clone: `git clone git@github.com:INRA-LPGP/RadSex.git`
19
- *Alternative: download the archive and unzip it*
20
21
- Go to the RadSex directory (`cd RadSex`)
- Run `make`
Romain Feron's avatar
Romain Feron committed
22
- The compiled `radsex` binary is located in `RadSex/bin/`
23

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
## Quick start

#### Before starting

Before running the pipeline, you should prepare the following elements:
- A **set of demultiplexed reads**. The current version of RADSex does not implement demultiplexing; raw sequencing reads can be demultiplexed using [Stacks](http://catchenlab.life.illinois.edu/stacks/comp/process_radtags.php) or [pyRAD](http://nbviewer.jupyter.org/gist/dereneaton/af9548ea0e94bff99aa0/pyRAD_v.3.0.ipynb#The-seven-steps-described). 
- A **population map** (popmap): a tabulated file with individual ID as the first column and sex as the second column. It is important that the individual IDs in the popmap are the same as the names of the demultiplexed reads files (see the population map section).
- If you want to map the sequences to a reference genome: a **reference genome** in fasta format. Note that when visualizing `mapping` results with `radsex-vis`, linkage groups / chromosomes are automatically inferred from scaffold names in the reference sequence if their name starts with *LG*, *chr*, or *chromosome* (case unsensitive). If chromosomes are named differently in the reference genome, you should prepare a tabulated file with reference scaffold ID in the first column and corresponding chromosome name in the second column (see the chromosomes names section)

#### Computing the coverage table

The first step of RADSex is to create a table of coverage for the dataset using the `process` command:

`radsex process -d ./samples -o coverage_table.tsv -t 16 -c 1`

In this example, demultiplexed reads are stored in `./samples` and the coverage table generated by `process` will be stored in `coverage_table.tsv`. The parameter `-t` specifies the number of threads to use.

The parameter `-c` specifies the minimum coverage value to consider a sequence present in an individual: sequences which are not present with coverage higher than this value in at least one individual will not be retained in the coverage table. It is advised to keep the minimum coverage to 1 for this step, as it can be adjusted for each analysis later.

#### Computing the distribution of sequences between sexes

After generating the coverage table, the `distrib` command is used to compute the distribution of sequences between sexes:

`radsex distrib -f coverage_table.tsv -o distribution.tsv -p popmap.tsv -c 5`

In this example, the input file `-f` is the coverage table generated in the [previous step](#computing-the-coverage-table), and the distribution of sequences between sexes will be stored in `distribution.tsv`. The sex of each individual in the population is given by `popmap.tsv` (see the popmap section for details). The minimum coverage to consider a sequence present in an individual is set to 5, meaning that sequences present with coverage (depth) lower than 5 in one individual will not be counted in this individual.

The resulting file `distribution.tsv` is a table with four columns:
- **Males** : number of males in which a sequence was present.
- **Females** : number of females in which a sequence was present.
- **Sequences** : number of sequences present in the corresponding number of males and females.
- **P** : p-value of a chi-squared test for association with sex.

This distribution can be visualized with the `plot_sex_distribution()` function of `radsex-vis`, which generates a [distribution heatmap](./examples/figures/sex_distribution.png).

#### Extracting sequences significantly associated with sex

Sequences significantly associated with sex can be obtained with the `signif` command:

`radsex signif -f coverage_table.tsv -o sequences.tsv -p popmap.tsv -c 5`

In this example, the input file `-f` is the coverage table generated in the [first step](#computing-the-coverage-table), and the sequences significantly associated with sex will be stored in `sequences.tsv`. The sex of each individual in the population is given by `popmap.tsv` (see the popmap section for details), and the minimum coverage to consider a sequence present in an individual is set to 5 (see the [previous section](#computing-the-distribution-of-sequences-between-sexes)). By default, the `signif` function exports a small coverage table; sequences can be exported to fasta using the `--fasta` parameter.

The coverage table generated by `signif` can be visualized with the `plot_coverage()` function of `radsex-vis`, which generates a [coverage heatmap](./examples/figures/coverage.png)

#### Mapping sequences to a reference genome

Sequences can be mapped to a reference genome using the `map` command:

`radsex map -f coverage_table.tsv -o mapping.tsv -p popmap.tsv -g genome.fasta -q 20 --min-frequency 0.1 -c 5`

In this example, the input file `-f` is the coverage table generated in the [first step](#computing-the-coverage-table), the mapping results will be stored in `sequences.tsv`, and the path to the reference genome file is given by `-g`. The sex of each individual in the population is given by `popmap.tsv` (see the popmap section for details), and the minimum coverage to consider a sequence present in an individual is set to 5 (see the [previous section](#computing-the-distribution-of-sequences-between-sexes)). The parameter `-q` specifies the minimum mapping quality (as defined in [BWA](http://bio-bwa.sourceforge.net/bwa.shtml)) to consider a sequence mapped (`-q`), here set to 20. The parameter `--min-frequency` specifies the minimum frequency of a sequence in at least one sex; it is set to 0.1 here, meaning that only sequences present in at least 10% of individuals of one sex are retained for mapping.

The resulting file `mapping.tsv` is a table with five columns:
- **Sequence :** ID of the mapped sequence
- **Contig :** ID of the contig where the sequence mapped
- **Position :** position of the mapped sequence on the contig
- **SexBias :** sex-bias of the mapped sequence, defined as (Males / Total males ) - (Females / Total females)
- **P :** p-value of a chi-squared test for association with sex

The mapping results generated by `map` can be visualized with the `plot_genome()` function of `radsex-vis`, which generates a [circular plot](./examples/figures/genome.png). Mapping results for a specific scaffold can be visualized with the `plot_scaffold()` function to generate a [linear plot](./examples/figures/scaffold.png).

Romain Feron's avatar
Romain Feron committed
86
## Usage
87

Romain Feron's avatar
Romain Feron committed
88
### General
89

90
`radsex <command> [options]`
91
92
93

**Available commands** :

94
95
Command            | Description
------------------ | ------------
96
`process`    | Compute a table of coverage from a set of demultiplexed reads
Romain Feron's avatar
Romain Feron committed
97
`distrib` | Compute the distribution of sequences between sexes
98
`subset` | Extract a subset of the coverage table
Romain Feron's avatar
Romain Feron committed
99
`signif` | Extract sequences significantly associated with sex
100
`loci` | Recreate polymorphic loci from a subset of coverage table
Romain Feron's avatar
Romain Feron committed
101
102
`mapping` | Map a subset of sequences (coverage table or fasta) to a reference genome and output sex-association metrics for each mapped sequence
`freq` | Compute sequence frequencies for the population
103

Romain Feron's avatar
Romain Feron committed
104
### process
105

Romain Feron's avatar
Romain Feron committed
106
`radsex process -d input_dir_path -o output_file_path [ -t n_threads -c min_cov ]`
107

108
*Generates a table of coverage for all individuals and all sequences. The output is a tabulated file, where each line contains the ID, sequence and coverage for each individual of a sequence.*
109
110
111
112
113

**Options** :

Option | Full name | Description
--- | --- | ---
114
115
116
`-d` | `input_dir_path` | Path to a folder containing demultiplexed reads |
`-o``output_file_path` | Path to the output file |
`-t``n_threads` | Number of threads to use (default: 1) |
117
`-c``min_cov` | Minimum coverage to consider a sequence in an individual (default: 1) |
118

Romain Feron's avatar
Romain Feron committed
119
### distrib
120

Romain Feron's avatar
Romain Feron committed
121
`radsex distrib -f input_file_path -o output_file_path -p popmap_file_path [ -c min_cov --output-matrix ]`
122

Romain Feron's avatar
Romain Feron committed
123
*Generates a table which contains the number of sequences present with coverage higher than min_cov and the probability of association with sex for every combination of number of males and number of females.*
124
125
126
127

**Options** :

Option | Full name | Description
128
129
------ | --------- | -------------
`-f` | `input_file_path` | Path to an coverage table obtained with `process` |
130
`-o``output_file_path` | Path to the output file |
Romain Feron's avatar
Romain Feron committed
131
132
`-p``popmap_file_path` | Path to a popmap file indicating the sex of each individual |
`-c``min_cov` | Minimum coverage to consider a sequence present in an individual (default: 1) |
133
`--output-matrix``output_matrix` | If true, outputs the resutls as a matrix with males in columns and females in rows instead of a table (default: false) |
134

135
### subset
136

Romain Feron's avatar
Romain Feron committed
137
`radsex subset -f input_file_path -o output_file_path -p popmap_file_path [ -c min_cov --min-males min_males --min-females min_females --max-males max_males --max-females max_females --min-individuals min_individuals --max-individuals max_individuals]`
138

139
*Filters the coverage table to only export sequences present in any combination of M males and F females, with min_males ≤ M ≤ max_males, min_females ≤ F ≤ max_females, and min_individuals ≤ M + F ≤ max_individuals*
140
141
142
143
144

**Options** :

Option | Full name | Description
--- | --- | ---
145
`-f` | `input_file_path` | Path to an coverage table obtained with `process` |
146
`-o``output_file_path` | Path to the output file |
Romain Feron's avatar
Romain Feron committed
147
`-p``popmap_file_path` | Path to a popmap file indicating the sex of each individual |
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
`-c``min_cov` | Minimum coverage to consider a sequence present in an individual (default: 1) |
`--min-males``min_males` | Minimum number of males with a retained sequence |
`--min-females``min_females` | Minimum number of females with a retained sequence |
`--max-males``max_males` | Maximum number of males with a retained sequence |
`--max-females``max_females` | Maximum number of females with a retained sequence |
`--max-individuals``max_individuals` | Maximum number of individuals with a retained sequence |
`--max-individuals``max_individuals` | Maximum number of individuals with a retained sequence |

### signif

`radsex signif -f input_file_path -o output_file_path -p popmap_file_path [ -c min_cov ]`

*Filters the coverage table to only export sequences significantly associated with sex, defined as sequences for which p < 0.05 (after Bonferroni correction), with p being the p-value of a chi-squared test on the numbers of males and females.*

**Options** :

Option | Full name | Description
--- | --- | ---
`-f` | `input_file_path` | Path to an coverage table obtained with `process` |
`-o``output_file_path` | Path to the output file |
`-p``popmap_file_path` | Path to a popmap file indicating the sex of each individual |
`-c``min_cov` | Minimum coverage to consider a sequence present in an individual (default: 1) |

### map

`radsex map -f input_file_path -o output_file_path -p popmap_file_path -g genome_file_path [ -c min_cov -q min_quality --min-frequency min_frequency ]`

*Maps the sequences from the coverage table to a reference genome and outputs mapping position, sex bias, and p-value of association with sex for each mapped sequence.*

**Options** :

Option | Full name | Description
--- | --- | ---
`-f` | `input_file_path` | Path to an coverage table obtained with `process` |
`-o``output_file_path` | Path to the output file |
`-p``popmap_file_path` | Path to a popmap file indicating the sex of each individual |
`-g``genome_file_path` | Path to a reference genome file in fasta format |
`-c``min_cov` | Minimum coverage to consider a sequence present in an individual (default: 1) |
`-q``min_quality` | Minimum mapping quality, as defined in BWA, to consider a sequence properly mapped (default: 20) |
`--min-frequency``min_frequency` | Minimum frequency in at least one sex for a sequence to be retained (default: 0.25) |

### freq

`radsex freq -f input_file_path -o output_file_path [ -c min_cov ]`

*Computes the sequences frequencies for the entire population*

**Options** :

Option | Full name | Description
--- | --- | ---
`-f` | `input_file_path` | Path to an coverage table obtained with `process` |
`-o``output_file_path` | Path to the output file |
`-c``min_cov` | Minimum coverage to consider a sequence present in an individual (default: 1) |
202
203
204

### LICENSE

205
206
207
208
209
210
211
Copyright (C) 2018 Romain Feron and INRA LPGP

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/