Skip to content

Commit f908aad

Browse files
author
Stephan Schiffels
committed
updated README and help documentation.
Tested with sample data.
1 parent 54921d7 commit f908aad

2 files changed

Lines changed: 31 additions & 25 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ The main tool in this repository is the program `pileupCaller` to sample alleles
1616

1717
Important Note: You should definitely use the `-B` flag, which disables base alignment quality recalibration. This mechanism is turned on by default and causes huge reference bias with low coverage ancient DNA data. This flag disables the mechanism.
1818

19-
To input the SNP positions you can either use a Text file with all positions or a bed file (see samtools manual). The output is a simple text file with all positions that could be genotyped in the three samples.
19+
In the above command line, the file "list_of_positions.txt" should either contain positions (0-based) or a bed file (see samtools manual for details). The output is a simple text file with all positions that could be genotyped in the three samples.
2020

2121
Next, you need to run my tool pileupCaller, which you run like this:
2222

23-
pileupCaller --sampleNames Sample1,Sample2,Sample3 \
23+
pileupCaller --randomHaploid --sampleNames Sample1,Sample2,Sample3 \
2424
--samplePopName MyPop -f <Eigenstrat.snp> \
25-
-o EigenStrat -e <My_output_prefix> < pileup.txt
25+
-e <My_output_prefix> < pileup.txt
2626

27-
Here, options –sampleNames gives the names of the samples that is output in the Eigenstrat `*.ind` file, and and `–samplePopName` is optional to also give the population names in that file (defaults to `Unknown`, you can also change it later in the output). Then, option `-f` gives an Eigenstrat positions file. This is important because the pileup file only contains sites which could be called in at least one of your samples. In order to later merge your dataset with another Eigenstrat file, pileupCaller will check every position in the other Eigenstrat file to make sure every position is output with the correct alleles and missing genotypes if appropriate. Finally, the -o option gives the output format (here Eigenstrat) and the `-e` option gives the prefix for the `*.ind`, `*.pos` and `*.geno` files. Note that this is specific for Eigenstrat output. For FreqSum output, the results will simply be written out to standard out.
27+
Here, options `--sampleNames` gives the names of the samples that is output in the Eigenstrat `*.ind` file, and and `-–samplePopName` is optional to also give the population names in that file (defaults to `Unknown`, you can also change it later in the output). Then, option `-f` gives an Eigenstrat positions file. This is important because the pileup file only contains sites which could be called in at least one of your samples. In order to later merge your dataset with another Eigenstrat file, pileupCaller will check every position in the other Eigenstrat file to make sure every position is output with the correct alleles and missing genotypes if appropriate. Finally, the -o option gives the output format (here Eigenstrat) and the `-e` option gives the prefix for the `*.ind`, `*.pos` and `*.geno` files. Note that this is specific for Eigenstrat output. For FreqSum output, the results will simply be written out to standard out. Note that without specifying `-e`, the output format will be freqSum format, described [here](https://rarecoal-docs.readthedocs.io/en/latest/rarecoal-tools.html#vcf2freqsum), which is useful for debugging your pipeline, since it's just a single file that is output into the terminal and can therefore easily be inspected.
2828

2929
You can also get some help by typing `pileupCaller -h`, which shows a lot more option, for example the sampling method, minimal coverage and other important options.
3030

@@ -33,9 +33,9 @@ Note that you can also fuse the two steps above into one unix pipe:
3333
samtools mpileup -R -B -q30 -Q30 -l <list_of_positions.txt> \
3434
-f <reference_genome.fasta> \
3535
Sample1.bam Sample2.bam Sample3.bam | \
36-
pileupCaller --sampleNames Sample1,Sample2,Sample3 \
36+
pileupCaller --randomHaploid --sampleNames Sample1,Sample2,Sample3 \
3737
--samplePopName MyPop -f <Eigenstrat.snp> \
38-
-o EigenStrat -e <My_output_prefix>
38+
-e <My_output_prefix>
3939

4040
There is however an issue here: If you have aligned your read data to a version of the reference genome that uses `chr1`, `chr2` and so on as chromosome names, the resulting Eigenstrat file will be valid, but won't merge with other Eigenstrat datasets that use chromosome names `1`, `2` and so on. I would therefore recommend to strip the `chr` from your chromosome names if necessary. You can do that easily using a little UNIX filter using the `sed` tool. In the full pipeline, it looks like this:
4141

src-executables/pileupCaller.hs

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,30 +78,30 @@ argParser = ProgOpt <$> parseCallingMode <*> parseKeepIncongruentReads <*> parse
7878
OP.help "Sample two reads at random (without replacement) at each site and represent the \
7979
\individual by a diploid genotype constructed from those two random \
8080
\picks. This will always assign missing data to positions where only \
81-
\one read is present, even if minDepth=1.")
81+
\one read is present, even if minDepth=1. The main use case for this \
82+
\option is for estimating mean heterozygosity across sites.")
8283
parseMajorityCalling = MajorityCalling <$> (parseMajorityCallingFlag *> parseDownsamplingFlag)
8384
parseMajorityCallingFlag = OP.flag' True (OP.long "majorityCall" <> OP.help
8485
"Pick the allele supported by the \
8586
\most reads at a site. If an equal numbers of alleles fulfil this, pick one at \
86-
\random. This results in a haploid call.")
87+
\random. This results in a haploid call. See --downSampling for best practices \
88+
\for calling rare variants")
8789
parseDownsamplingFlag = OP.switch (OP.long "downSampling" <> OP.help "When this switch is given, \
8890
\the MajorityCalling mode will downsample \
8991
\from the total number of reads a number of reads \
9092
\(without replacement) equal to the --minDepth given. This mitigates \
9193
\reference bias in the MajorityCalling model, which increases with higher coverage. \
9294
\The recommendation for rare-allele calling is --majorityCall --downsampling --minDepth 3")
9395
parseKeepIncongruentReads = OP.switch (OP.long "keepIncongruentReads" <> OP.help "By default, \
94-
\pileupCaller removes reads with alleles that are neither of the two alleles specified in the SNP file. \
95-
\Any sampling (depending on the calling mode) is therefore by default constrained to reads \
96-
\supporting the reference an alternative allele, and any other alleles (for example at triallelic sites or \
97-
\due to damage) are removed. With this flag given, sampling is performed unconstrained on all reads. If \
98-
\a read is sampled with an allele that is neither of the two given alleles, a missing genotype is generated. \
99-
\IMPORTANT NOTE: The default behaviour has changed in pileupCaller. If you want to emulate the previous \
96+
\pileupCaller now removes reads with tri-allelic alleles that are neither of the two alleles specified in the SNP file. \
97+
\To keep those reads for sampling, set this flag. With this option given, if \
98+
\the sampled read has a tri-allelic allele that is neither of the two given alleles in the SNP file, a missing genotype is generated. \
99+
\IMPORTANT NOTE: The default behaviour has changed in pileupCaller version 1.4.0. If you want to emulate the previous \
100100
\behaviour, use this flag. I recommend now to NOT set this flag and use the new behaviour.")
101101
parseSeed = OP.option (Just <$> OP.auto) (OP.long "seed" <>
102102
OP.value Nothing <> OP.metavar "<RANDOM_SEED>" <>
103103
OP.help "random seed used for the random number generator. If not given, use \
104-
\system clock to seed the random number generator")
104+
\system clock to seed the random number generator.")
105105
parseMinDepth = OP.option OP.auto (OP.long "minDepth" <> OP.short 'd' <>
106106
OP.value 1 <> OP.showDefault <> OP.metavar "<DEPTH>" <>
107107
OP.help "specify the minimum depth for a call. For sites with fewer \
@@ -114,7 +114,7 @@ argParser = ProgOpt <$> parseCallingMode <*> parseKeepIncongruentReads <*> parse
114114
parseSingleStrandMode = OP.flag' SingleStrandMode (OP.long "singleStrandMode" <>
115115
OP.help "At C/T polymorphisms, ignore reads aligning to the forward strand. \
116116
\At G/A polymorphisms, ignore reads aligning to the reverse strand. This should \
117-
\remove ancient-DNA damage in ancient DNA libraries prepared with the single-stranded protocoll.")
117+
\remove post-mortem damage in ancient DNA libraries prepared with the non-UDG single-stranded protocol.")
118118
parseSnpFile = OP.strOption (OP.long "snpFile" <> OP.short 'f' <>
119119
OP.metavar "<FILE>" <> OP.help "an Eigenstrat-formatted SNP list file for \
120120
\the positions and alleles to call. All \
@@ -128,14 +128,18 @@ argParser = ProgOpt <$> parseCallingMode <*> parseKeepIncongruentReads <*> parse
128128
\ordered by chromosome and position, and this is checked. The chromosome order in humans is 1-22,X,Y,MT. \
129129
\Chromosome can generally begin with \"chr\". In case of non-human data with different chromosome \
130130
\names, you should convert all names to numbers. They will always considered to \
131-
\be numerically ordered, even beyond 22.")
131+
\be numerically ordered, even beyond 22. Finally, I note that for internally, \
132+
\X is converted to 23, Y to 24 and MT to 90. This is the most widely used encoding in Eigenstrat \
133+
\databases for human data, so using a SNP file with that encoding will automatically be correctly aligned \
134+
\to pileup data with actual chromosome names X, Y and MT (or chrX, chrY and chrMT, respectively).")
132135
parseFormat = (EigenstratFormat <$> parseEigenstratPrefix <*> parseSamplePopName) <|> pure FreqSumFormat
133136
parseEigenstratPrefix = OP.strOption (OP.long "eigenstratOut" <> OP.short 'e' <>
134137
OP.metavar "<FILE_PREFIX>" <>
135138
OP.help "Set Eigenstrat as output format. Specify the filenames for the EigenStrat \
136139
\SNP and IND file outputs: <FILE_PREFIX>.snp.txt and <FILE_PREFIX>.ind.txt \
137-
\If not set, output will be FreqSum (Default). Note that freqSum format, described at\
138-
\... is useful for testing your pipeline, since it's output to standard out")
140+
\If not set, output will be FreqSum (Default). Note that freqSum format, described at \
141+
\https://rarecoal-docs.readthedocs.io/en/latest/rarecoal-tools.html#vcf2freqsum, \
142+
\is useful for testing your pipeline, since it's output to standard out")
139143
parseSampleNames = parseSampleNameList <|> parseSampleNameFile
140144
parseSampleNameList = OP.option (Left . splitOn "," <$> OP.str)
141145
(OP.long "sampleNames" <> OP.metavar "NAME1,NAME2,..." <>
@@ -153,19 +157,21 @@ programHelpDoc :: PP.Doc
153157
programHelpDoc =
154158
part1 PP.<$>
155159
PP.enclose PP.line PP.line (PP.indent 4 samtoolsExample) PP.<$>
156-
part2
160+
part2 PP.<$> PP.line PP.<$>
161+
PP.string versionInfoText
157162
where
158163
part1 = PP.fillSep . map PP.text . words $
159-
"PileupCaller is a simple tool to create genotype calls from bam files. \
160-
\You need to convert bam files into the mpileup-format, specified at \
164+
"PileupCaller is a tool to create genotype calls from bam files using read-sampling methods. \
165+
\To use this tool, you need to convert bam files into the mpileup-format, specified at \
161166
\http://www.htslib.org/doc/samtools.html (under \"mpileup\"). The recommended command line \
162167
\to create a multi-sample mpileup file to be processed with pileupCaller is"
163168
samtoolsExample = PP.hang 4 . PP.fillSep . map PP.text . words $
164-
"samtools mpileup -B -q30 -Q30 -l <BED_FILE> -f <FASTA_REFERENCE_FILE> \
169+
"samtools mpileup -B -q30 -Q30 -l <BED_FILE> -R -f <FASTA_REFERENCE_FILE> \
165170
\Sample1.bam Sample2.bam Sample3.bam | pileupCaller ..."
166171
part2 = PP.fillSep . map PP.text . words $
167-
"Note that flag -B in samtools is very important to reduce reference \
168-
\bias in low coverage data. " ++ versionInfoText
172+
"You can lookup what these options do in the samtools documentation. \
173+
\Note that flag -B in samtools is very important to reduce reference \
174+
\bias in low coverage data."
169175

170176
initialiseEnvironment :: ProgOpt -> IO Env
171177
initialiseEnvironment args = do

0 commit comments

Comments
 (0)