README.md 9.01 KB
Newer Older
1
2
# RADSex

3
4
5
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 !
6

Romain Feron's avatar
Romain Feron committed
7
## Overview
8

9
10
11
12
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.
13

14
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
15

16
## Documentation
Romain Feron's avatar
Romain Feron committed
17

18
19
20
This README file contains a simple documentation, including a basic installation guide as well as a quick start section. 

The full documentation for RADSex (still under construction) is available [there](https://radsex.readthedocs.io/en/docs).
Romain Feron's avatar
Romain Feron committed
21
22
23
It contains a complete Getting Started section, a detailed usage for all functions, and real-life datasets examples covering many situations.


Romain Feron's avatar
Romain Feron committed
24
## Requirements
25

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

## Installation
30

31
- Clone: `git clone https://github.com/RomainFeron/RadSex.git`
32
- *Alternative: download the archive and unzip it*
33
34
- Go to the RadSex directory (`cd RadSex`)
- Run `make`
Romain Feron's avatar
Romain Feron committed
35
- The compiled `radsex` binary is located in `RadSex/bin/`
36

37
38
39
40
41
## Quick start

#### Before starting

Before running the pipeline, you should prepare the following elements:
42
43
44
45
46
47
48
49
50
51
- 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 [popmap section](#population-map) for details).
- 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](#chromosomes-names) for details)
52
53
54
55
56

#### Computing the coverage table

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

57
`radsex process --input-dir ./samples --output-file coverage_table.tsv --threads 16 --min-coverage 1`
58

59
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 `--threads` specifies the number of threads to use.
60

61
62
63
The parameter `--min-coverage` 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.
64
65
66
67
68

#### 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:

69
`radsex distrib --input-file coverage_table.tsv --output-file distribution.tsv --popmap-file popmap.tsv --min-coverage 5`
70

71
72
73
In this example, the input file `--input-file` 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](#population-map) 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.
74
75
76
77
78
79
80
81
82
83
84
85
86

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:

87
`radsex signif --input-file coverage_table.tsv --output-file sequences.tsv --popmap-file popmap.tsv --min-coverage 5 [ --output-format fasta ]`
88

89
90
91
92
In this example, the input file `--input-file` 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](#population-map) 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 `--output-format` parameter.
93
94
95
96
97
98
99

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:

100
`radsex map --input-file coverage_table.tsv --output-file mapping.tsv --popmap-file popmap.tsv --genome-file genome.fasta --min-quality 20 --min-frequency 0.1 --min-coverage 5`
101

102
103
104
105
106
In this example, the input file `--input-file` 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 `--genome-file`. The sex of each individual in the population is given by `popmap.tsv` (see the [popmap section](#population-map) 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 `--min-quality` specifies the minimum mapping quality (as defined in [BWA](http://bio-bwa.sourceforge.net/bwa.shtml)) to consider a sequence mapped (`--min-quality`), 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.
107
108
109
110
111
112
113
114

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

115
116
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).
117

Romain Feron's avatar
Romain Feron committed
118
## LICENSE
119

120
121
Copyright (C) 2018 Romain Feron and INRA LPGP

122
123
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.
124

125
126
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.
127
128

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