计算机科学中flipingmanually zeroingg testing表示什么?

关注51Testing
Fliptest—iOS 的应用A/B测试框架
发表于: 11:06 &作者:未知 & 来源:51Testing软件测试网采编
推荐标签:
  FlipTest是专为设计的应用A/B测试框架,通过它,开发者可以无需重新向App Store提交应用或重构代码,只需添加一行代码,即可直接在iOS应用上进行A/B测试。对移动应用做 A/B 是非常难的,而 FlipTest 可以帮你简化这个过程。  对于想要追求UI极致的开发者而言,FlipTest绝对是最合适的。FlipTest会为应用选择最恰当的用户界面,还会基于外观、可用性等众多因素返还测试结果,从而帮助开发者彻底解决UI问题。
搜索风云榜
51Testing官方微信
51Testing官方微博
测试知识全知道PLINK: Whole genome data analysis toolset
Last original PLINK release is v1.07
(10-Oct-2009); PLINK 1.9 is now
for beta-testing
Whole genome association analysis toolset
Data management tools
PLINK provides a simple interface for recoding, reordering, merging,
flipping DNA-strand and extracting subsets of data.
A basic, but often useful feature, is to output a dataset:
with the PED file markers reordered for physical position,
with excluded SNPs (negative values in the MAP file) excluded from the new PED file
possibly excluding other SNPs based on filters such as genotyping rate
possibly recoding the SNPs to a 1/2 coding
possibly recoding the SNPs between letters and numbers (A,C,G,T / 1,2,3,4)
possibly transposing the genotype file (SNPs as rows)
possibly recoding the SNP to an additive and dominant pair of components
possibly listing the data with each specific genotype as a distinct row
possibly listing the data one genotype per row
possibly listing only minor alleles
The basic option to generate a new dataset is the --recode option:
plink --file data --recode
which will output the allele labels as they ap
also, the missing genotype code is preserved if this is different
from 0. Also, if --output-missing-genotype is specified (which can be as well as --missing-genotype)
then this value will be used instead (i.e. so that input and output files can have dif this also applies to
the phenotype with --output-missing-phenotype and --missing-phenotype).
option does the
same as --recode but
these can also be
filtered, etc, as described below.
In contrast,
plink --file data --recode12
will recode the alleles as 1 and 2 (and the missing genotype will always be
Both these commands will create two new files
(where, as usual, "plink" would be replaced by any specified --out
{filename} ).
Unless manually specified, for all these options, the usual filters
for missingness and allele frequency will be set so as not to exclude
any SNPs or individuals. By explicitly including an option,
e.g. --maf 0.05 on the command line, this behaviour is
overriden (see ).
By default, any --recode option, and also --make-bed
will preserve all genotypes exactly as they are.
To set to missing
Mendel errors or heterozygous haploid calls, use the
options --set-me-missing and --set-hh-missing
respectively. For the former, you will also need to specify --me 1
1 (i.e. to invole an evalation of Mendel errors, which does not
occur by default, by not excluding any individuals or SNPs based on
the results, i.e. if you only want to zero-out certain genotypes).
To recode SNP alleles from A,C,G,T to 1,2,3,4 or vice versa,
use --allele1234 (to go from letters to numbers)
and --alleleACGT (to go from numbers to letters). These flags
should be used in conjunction with a data generation command
(e.g. --make-bed), or any other analysis or summary statistic
Alleles other than A,C,G,T or 1,2,3,4 will be left unchanged.
It is sometimes useful to have a PED file that is tab-delimited,
except that between alleles of the same genotype a space instead of a
tab is used. A file formatted in this way can load into Excel, for
example, as a tab-delimited file, but with one genotype per column
instead of one allele per column. Use the option --tab as
well as --recode or --recode12 to achieve this
To make a new file in which non-founders without both parents also in
the same fileset are recoded as founders (i.e. pat and mat codes set
both to 0), add the --make-founders flag.
Transposed genotype files
When using either --recode or --recode12, you can obtain a transposed text genotype
file by adding the --transpose option. This generates two files:
plink.tped
The first contains the genotype data, with SNPs as rows and individuals as columns, for example: if
the original file was
then this would generate
1 snp1 0 1
1 snp2 0 20001
The first four columns are from the MAP file (chromosome, SNP ID,
genetic position, physical position), followed by the genotype
data. The plink.fam gives the ID, sex and phenotype
information for each individual.
The order of individuals in this
file is the same as the order across the columns of the TPED file. The
FAM file is just the first six columns of the PED file (or literally
the same FAM file if the input where a binary fileset).
Additive and dominance components
The following format is often useful if one wants to use a standard, non-genetic statistical package
to analyse the data, as here genotypes are coded as a single allele dosage number.
To create a file with SNP genotypes recoded in terms of additive and dominant components, use the
plink --file data --recodeAD
which, assuming C is the minor allele, will recode genotypes as
In otherwords, the default for the additive recoding is to count the
number of minor alleles per person. The --recodeAD option
produces both an additive and dominance coding: use --recodeA
instead to skip the SNP_HET coding.
The --recodeAD option saves the data to a single file
which has a header row indicating the SNP names (with _A
and _HET appended to the SNP names to represent additive and
dominant components, respectively).
For example, consider the following PED file, which has two SNPs:
Using the --recodeAD option generates the file
plink-recode.raw:
FID IID PAT MAT SEX PHENOTYPE snp1_2 snp1_HET snp2_G snp2_HET
1 1 0 0 1 1
1 2 0 0 2 1
1 3 0 0 1 1
1 4 0 0 2 1
The column labels reflect the snp name (e.g. snp1) with the
name of the minor allele appended (i.e. snp1_2 in the first instance, as
2 is the minor allele) for the additive component. The
dominant component ( a dummy variable reflecting heterozygote state)
is coded with the _HET suffix.
This file can be easily loaded into R: for example:
d <- read.table("plink.raw",header=T)
For example, for the first SNP, the individuals are coded
The additive count of the number of common (1) alleles is
therefore: 2, NA, 2 and 1, which
is reflected in the field snp1_2. The field snp1_HET
is coded 1 for the fourth individual who is heterozygous --
this field can be used to model dominance effect of the allele.
The behavior of the --recodeA and --recodeAD
commands can be changed with the --recode-allele
command. This allows for the 0, 1, 2 count to reflect the number of a
pre-specified allele type per SNP, rather than the number of the minor
allele. This command takes as a single argument the name of a file
that lists SNP name and allele to report, e.g. if the
file recode.txt contained
plink --file data --recodeAD --recode-allele recode.txt
would now report in the LOG file
Reading allele coding list from [ recode.txt ]
Read allele codes for 2 SNPs
and the plink.raw file would read
FID IID PAT MAT SEX PHENOTYPE snp1_1 snp1_HET snp2_A snp2_HET
1 1 0 0 1 1
1 2 0 0 2 1
1 3 0 0 1 1
1 4 0 0 2 1
If the SNP is monomorphic, by default the allele code out will
be 0 and all individuals will have a count of 0
(or NA). If an allele is specified
in --recode-allele that is not seen in the data, similarly
all individuals will receive a 0 count (i.e. rather than an error
being given).
NOTE For alleles that have exactly 0.50 minor
allele frequency, as for the second SNP in the example above, then
which allele is labelled as minor will depend on which was first
encountered in the PED file.
Listing by minor allele count
The command
--recode-rlist
will generate a files
plink.rlist
where the plink.rlist file format is
GENOTYPE (BOTH ALLELES)
FID/IID PAIRS ...
For example, consider a particular SNP, rs2379981 has a minor
allele (G) seen twice (in two heterozygotes) and two individuals with a
all other individuals are homozygous for the major allele. In
this case, we would see two rows in the pink.rlist file:
rs2379981 HET G A CH18612 NA18612
JA18998 NA18998
rs2379981 NIL 0 0 JA18999 NA18999
JA19003 NA19003
indicating, for example, that individual FID/IID CH18612/NA18612 has a
rare heterozygote.
This command could be used in conjunction with the
--reference command and --freq to list all instances
of rare non-reference alleles, e.g. from resequencing study data.
Listing by long-format (LGEN)
To output a file in the LGEN format, use the command
--recode-lgen
which generates files
plink.lgen
that can be read with the --lfile command.
--with-reference
with generate a fourth file
that can be read back in with the --reference command when using --lfile.
Listing by genotype
Another format that might sometimes be useful is the --list option which genetes a file
plink.list
that is ordered one genotype per row, listing all family and individual IDs of people with that genotype. For
example, if we have a file with two SNPs rs1001 and rs2002 (both on chromosome 1):
then then option
plink --file mydata --list
will generate the file plink.list
1 rs1001 AA A 1
1 rs1001 AC B 2 C 3
1 rs1001 CC D 4
1 rs1001 00
1 rs2002 22
1 rs2002 21 C 3 D 4
1 rs2002 11 A 1
1 rs2002 00 B 2
which has columns
Chromosome
SNP identifier
Family ID, Individual ID for 1st person
Family ID, Individual ID for 2nd person
Family ID, Individual ID for final person
Obviously, different rows will have a different number of columns.
Here, we see that individual A 1 has the A/A genotype for rs1001, etc.
This option is often useful in conjunction with --snp, if you want an easy breakdown of which individuals
have which genotypes.
To output just the list of SNPs that remain after all filtering, etc, use the
--write-snplist command, e.g. to get a list of all high frequency,
high genotyping-rate SNPs:
plink --bfile mydata --maf 0.05 --geno 0.05 --write-snplist
which generates a file
plink.snplist
This file is simply a list of included SNP names, i.e. the same SNPs that a --recode or --make-bed statement
would have produced in the corresponding MAP or BIM files.
To automatically update either the genetic or physical positions for some or all SNPs in a dataset, use the
--update-map command, which takes a single parameter of a filename, e.g.
plink --bfile mydata --update-map build36.txt --make-bed --out mydata2
where, for example, the file build36.txt contains
new physical positions for SNPs, based on dbSNP126/build 36, in the simple format of SNP/position per line, e.g.
To change genetic position (3rd column in map file) add the
flag --update-cm as well
as --update-map. There is no way to change chromosome
codes using this command.
Normally, one would want to save the new file with the changed
positions, as in the example above, although one could combine other
commands instead (e.g. association testing, etc) although the updated
positions would then be lost (i.e. the changes are not automatically
The file with new SNP information does not need to feature all of the SNPs
in the current dataset: SNPs not in this file will be left unchanged. If a SNP
is listed more than once in the file, an error will be reported.
NOTE When updating the map positions, it is possible that the
implied ordering of SNPs in the dataset might change. If this is the case, a
message will be written to the LOG file. Although the positions are updated,
the order is not changed internally: as SNPs might be out of order, it is
important to correct this by saving and reloading the file.
For example, the if the original
but we update rs10002 to position 580000, the data will be
Only after saving and reloading (e.g. --make-bed / --bfile ) will the file be
in the correct order
This will only be an issue for commands which rely on relative SNP
positions (e.g. --hap-window, --homozyg, etc).
If the LOG file does
not show a message that the order of SNPs has changed after using --update-map,
one need not worry.
The name and chromosome code of a SNP can also be changed, by adding the modifiers
--update-name or --update-chr, e.g.
./plink --bfile mydata --update-map rsID.lst --update-name --make-bed --out mydata2
./plink --bfile mydata --update-map chr-codes.txt --update-chr --make-bed --out mydata2
In both case, the format of the input file should be two columns per line, e.g.
SNP_A-1919191
or, for chromosome codes (use numeric values and codes X, Y, etc)
You cannot update more than one attribute at a time for SNPs.
To recode alleles, for example from A,B allele coding to A,C,G,T
coding, use the command --update-alleles, for example
./plink --bfile mydata --update-alleles mylist.txt --make-bed --out newfile
where the file mylist.txt contains five columns per row listing,
SNP identifier
Old allele code for one allele
Old allele code for other allele
New allele code for first allele
New allele code for other allele
For example,
will change allele A to G and allele B to T for rs10001, etc.
It is possible to manually specify which allele is the A1
allele and which is A2.
By default, the minor allele is
assigned to be A1.
All odds ratios, etc, are calculated
with respect to the A1 allele (i.e. an odds ratio greater
than 1 implies that the A1 allele increases risk).
To set a particular allele as A1, which might not be the minor allele,
use the command --reference-allele, which can be used with
any other analysis or data generation command, e.g.
./plink --bfile mydata --reference-allele mylist.txt --assoc
where the file mylist.txt contains a list of SNP IDs and
the allele to be set as A1, e.g.
This command can make comparing results across studies easier,
so that odds ratios
reported can be made to be in the same direction as the other study, for example.
Rather than try to manually edit PED or FAM files (which is not advised), use these functions
to change ID codes, sex and parental information for individuals in a fileset. The command
plink --bfile mydata --update-ids recoded.txt --make-bed --out mydata2
changes ID codes for individuals specified in recoded.txt, which should be
in the format of four columnds per row: old FID, old IID, new FID, new IID, e.g.
FA 1002.dup
will, for example find the person FA/1001 and change their FID/IID
values to F.
Not all people need be listed in the file (they
the order of the file need not match the original dataset.
Two simular commands (but that cannot be run at the same time as --update-ids) are
--update-sex myfile1.txt
that expects 3 columns per row:
Coded 1/2/0 for M/F/missing
--update-parents myfile2.txt
that expects 4 columns per row:
New paternal IID code
New maternal IID code
PLINK does not check see whether the new parents actually exist in the current file.
With all of these commands, you need to issue a data output command (--make-bed, --recode, etc) for the changes to be
preserved.
If a covariate file is specified along with any of the above --recode options or
with --make-bed, then that covariate file will also be written, as plink.cov
by default.
This option is useful if the covariate file has a different number of individuals,
or is ordered differently, to produce a set of covariate values that line up more easily
with the newly-created genotype and phenotype files.
plink --file data --covar myfile.txt --recode
creates also plink.cov.
If you want just to create a revised
version of the covariate file, but without creating a new set of
genotype files, then use the --write-covar option. This can
be used in conjunction with filters, etc, to output, for example, only
covariates for high-genotyping (99%) cases, as in this example:
plink --file data --write-covar myfile.txt
--filter-cases --mind 0.01
will output just the relevant lines of myfile.txt to
plink.cov, sorted to match the order of
To also include phenotype information in the plink.cov file
add the flag --with-phenotype.
This can be useful, for
example, when used in conjunction with --recodeA to generate
the files needed to replicate an analysis in R (e.g. extracting the
appropriate genotype data, and applying filters, etc).
To recode a categorical variable to a set of binary dummy variables, add
the command
--dummy-coding
for example
./plink --bfile mydate --covar cdata.raw --write-covar --dummy-coding
If the original covariate had two fields, a categorical variable with 8 levels (coded 0 to 7,
although it could have any numeric coding, e.g. 100, 150, 200, 250, etc), and a second variable
that was continuous, e.g.
-9 0.713952
then the command above will create mynewfile.cov, with added header row, with the fields:
Individual ID
Dummy variable for first covariate, coded
1/0 for 2/other
Dummy variable for first covariate, coded
1/0 for 3/other
Unchanged continuous covariate
Thus mynewfile.cov is as follows (spaces added for clarity):
COV1_2 COV1_3 COV1_4 COV1_5 COV1_6 COV1_7 COV1_0 COV2
0 0 0 1 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 1 0
1 0 0 0 0 0 0
0 1 0 0 0 0 0
0 0 1 0 0 0 0
-9 -9 -9 -9 -9 -9 -9
0 0 0 0 0 0 1
0 0 0 0 0 0 0
That is, for a variable with K categories, K-1 new
dummy variables are created. This new file can be used
with --linear and --logistic, and a coefficient for
each level would now be estimated for the first covariate (otherwise
PLINK would have incorrectly treated the first covariate as an
ordinal/ratio measure).
For covariate Y, each new dummy
variable for level X is named Y_X,
e.g. COV1_2, etc.
Note that one level is automatically excluded (1 in this case,
i.e. there is no COV1_1), which implicitly makes 1 the
reference category in subsequent analysis.
If PLINK detects more than
50 levels, it assumes the variable is not categorical
(i.e. like COV2) and so leaves it unchanged.
The command can
operate on multiple covariates in a single file at the same time. Note
that missing values are correctly handled (i.e. left as missing).
Note that, unlike cluster files (see below) PLINK
cannot handle any string information in covariate files.
Similar to --write-covar, the --write-cluster will
output the single selected cluster from the file specified
by --within. Unlike covariate files, this allows string labels
to be used.
plink --bfile mydata --within clst.dat --write-cluster --out mynewfile
which writes a file
mynewfile.clst
Use --mwithin to select which of multiple clusters is selected. The
--dummy-coding can not currently be used with --write-cluster
This command will read the list of SNPs in the file list.txt
and flip the strand for these SNPs, then save a new PED or BED fileset
(i.e. by using either the --recode or --make-bed
commands):
plink --file data --flip list.txt --recode
The list.txt should just be a simple list of SNP IDs, one SNP
Flipping strand means changing alleles
so, for example, a A/C SNP will become a T/G;
alternatively, a A/T SNP will become a
T/A SNP (i.e. in this case, the labels remain the same, but
whether the minor allele is A or
T will still depend on strand).
To flip strand for just a subset of the sample (e.g. if two samples have already been merged, and subsequently
a strand issue has been identified for one of those samples) use the option --flip-subset, for example
plink --file data --flip list.txt --flip-subset mylist.txt --recode
where mylist.txt is a text file containing the individuals (family ID, individual ID) to be flipped.
HINT When merging two datasets, it is clearly
very important that the two sets of SNPs are concordant in terms of
positive or negative strand. Whereas some mismatches will be easy to
spot as more than two alleles will be observed in the merged dataset,
other instances will not be so easy to spot, i.e. for A/T
and C/G SNPs.
If cases and controls have been genotyped separately and then the data
merged, it is always possible that strand has been incorrectly or incompletely
assigned to each SNP, meaning that the merged data may contain a number of SNPs
for which the allele coding differs between cases and controls (or between any other
grouping, such as collection site, etc).
If the two mis-matched groups correspond to cases and controls
exactly, then rare SNPs will show a very strong association with
disease (e.g. 5% MAF in cases, 95% in controls) and be easy to spot as
potential problems. More common SNPs could show intermediate levels of
association that might be easier to confuse with a real signal.
A simple approach to detect some proportion of such SNPs uses
differential patterns of LD in cases versus controls: the command
--flip-scan will query each SNP, and calculate the signed
correlation between it and a set of nearby SNPs in cases and controls
separately (of course, with the --pheno
command, case and control status can be set to
represent any binary split of the sample).
For each index SNP, PLINK identifies other SNPs in which the absolute
value of the genotypic correlation is above some threshold. For these
SNP pairs, it counts the number of times the signed correlation is
different in sign between cases and controls (a negative LD
pair) versus the same (a positive LD pair). For example, the
plink --bfile mydata --flip-scan
produces the output file
plink.flipscan
with the fields
Chromosome
SNP identifier for index SNP
Base-pair position
Minor allele code
Major allele code
Allele frequency (A1 allele)
Number of positive LD matches
Average correlation of these
Number of negative LD matches
Average correlation of these
NEGSNPS The SNPs showing negative correlation
For example, the majority of this file should show SNPs have
a NEG value of 0; the value of POS will be zero or
greater, depending on the extent of LD. For example:
However, occasionally one might observe different patterns of results.
Of particular interest is when
one SNP shows a large number of NEG SNPs. For example, here we show rs2240344 and nearby
SNPs, all of which have at least one NEG SNP (lines truncated)
rs|rs4899437|...
This pattern of results quite clearly points to rs2240344 as
being the odd man out: for 7 other SNPs, there is strong LD
(r above 0.5) in either cases or controls, but with
a SNP-SNP correlation in the other phenotype class that has the opposite
direction. In contrast, there is not a single SNP for which both cases
and controls have a consistent pattern of LD. For the nearby SNPs, all
of which have only 1 NEG SNP, it is with rs2240344. So, in this particular
case, it would suggest that stand is flipped in either cases or controls.
To display the specific sets of correlations in cases and controls for
each SNP, add the option
--flip-scan-verbose
which generates a file
plink.flipscan.verbose
which lists for any SNP with at least one NEG pair of LD values, the correlations
between the index SNP and the other flanking SNPs, showing the correlation in cases (R_A)
and controls (R_U):
Here we see a clear pattern in which the correlation is similar between cases and controls in magnitude
but has the opposite direction, strongly suggestive of a strand flip problem for this C/G SNP. In this case,
the allele frequency turns out to be quite different between cases and controls (60% versus 40%) but the LD approach
would have clearly detected this particular SNP being flipped in either cases or controls even if the true
allele frequency were exactly 50%. This latter class of SNP would not cause problems of spurious association
in single SNP analysis, but it could cause severe problems in haplotype and imputation analysis.
Naturally, if a SNP does not show strong LD with nearby SNPs, then
this approach will not be able to resolve strand issues. Also, if more
than one SNP in a region shows strand flips, or if there is a higher
level of mis-coding alleles in general, then this approach may
indicate that there are problems (many NEG scores above 0)
but it might be less clear how to remedy them.
To know which to resolve (cases or controls) one would need to look at
the frequency in other panels, or even the correlations, e.g. in
HapMap. Ideally, one would only need to do this for a small number of
SNPs if any. The --flip and --flip-subset commands
can then be used to flip the
appropriate genotypes.
Finally, the default threshold for counting can be changed by the
following command:
--flip-scan-threshold 0.8
The default is set at 0.5 (i.e. the pair needs to have a correlation
of 0.5 or greater in either cases or controls). The number of flanking
SNPs with are considered for each index SNP can be modified with the
--ld-window 10
to set the number of SNPs considered ups the
maximum physical distance away from the index SNP (1Mb by default) is
specified in kb with the command:
--ld-window-kb 500
To merge two PED/MAP files:
plink --file data1 --merge data2.ped data2.map --recode --out merge
The --merge option must be followed by 2 arguments: the name
of the second PED file and the name of the second MAP file. A
--recode (or --make-bed, etc) option is necessary to
output t in this case, --out option will
create the files merge-recode.ped
and merge-recode.map.
The --merge option can also be used with binary PED files,
either as input or output, but not as the second file: i.e.
plink --bfile data1 --merge data2.ped data2.map --make-bed --out merge
will create merge.bed, merge.fam
and merge.bim, as the --make-bed option was used
instead of the --recode option. Likewise,
the data1.* files point to a binary PED file set.
If the second fileset (data2.*) were in binary format, then
you must use --bmerge instead of --merge
plink --bfile data1 --bmerge data2.bed data2.bim data2.fam --make-bed --out merge
which takes 3 parameters (the names of the BED, BIM and FAM files, in that order).
The two filesets can either overlap completely, partially, or not at
all both in terms of markers and individuals. Imputed genotypes will
be set to missing (i.e. if SNP_B is not measured in the first
file, but it is in the second, then any individuals in the first file
who are not also present in the second file will be set to missing for
By default, any existing genotype data (i.e. in data1.ped)
will not be over-written by data in the second file (data2.ped).
By specifying a --merge-mode this default behavior can be
changed. The modes are:
Consensus call (default)
Only overwrite calls which are missing in original PED file
Only overwrite calls which are not missing in new PED file
Never overwrite
Always overwrite mode
Report all mismatching calls (diff mode -- do not merge)
Report mismatching non-missing calls (diff mode -- do not merge)
The default (mode 1) behaviour is to call the merged genotype as missing
if the original and new files contain different, non-
otherwise: i.e.
Merge mode
data1.ped ,
-----------------------
Modes 6 and 7 effectively provide a means for comparing two PED
files -- no merging is perf rather, a list of
mismatching SNPs is written to the file
plink.diff
They should also report the concordance rate in the LOG file, based on all SNPs
that feature in both sets.
A warning will be given if the chromosome and/or physical position
differ between the two MAP files.
Alleles must be exactly coded to match: that is,
PLINK will not assume that a {1,2,3,4} SNP coding maps onto
a {A,C,G,T} coding. You can use the --allele1234
and --alleleACGT commands prior to merging to convert
datasets and then merge these consistently coded files (you cannot
convert and merge on the fly, i.e. simply do putting --allele1234
on the command line along with --merge will not work: you
need to use --allele1234 and --make-bed first).
To merge more than two standard and/or binary filesets, it is often
more convenient to specify a single file that contains a list of
PED/MAP and/or BED/BIM/FAM files and use the --merge-list
option. Consider, for an extreme example, the case where each fileset
contains only a single SNP, and that there are thousands of these
files -- this option would help build a single fileset, in this case.
For example, consider we had 4 PED/MAP filesets
(labelled fA.* through fD.*) and 4 binary filesets,
labelled fE.* through fH.*).
Then using the command
plink --file fA --merge-list allfiles.txt --make-bed --out mynewdata
would create the binary fileset
mynewdata.bed
mynewdata.bim
mynewdata.fam
(alternatively, the --recode option could have been used instead of --make-bed
to generate a standard ASCII PED/MAP fileset). In this case, the file allfiles.txt
was a list of the to-be-merged files, one set per row:
fB.ped fB.map
fC.ped fC.map
fD.ped fD.map
fE.bed fE.bim fE.fam
fF.bed fF.bim fF.fam
fG.bed fG.bim fG.fam
fH.bed fH.bim fH.fam
Important Each fileset must be on a line by
itself: lines with two files are interpreted as PED/MAP
lines with three files are interpreted as binary BED/BIM/FAM
filesets. The files on a line must always be in this order (PED then
MAP; BED then BIM then FAM)
Note In this case the first of the 8 files must
be the starting file, i.e.
associated with --file on the
this file only contains the 8-1 remaining files
therefore. The final mynewdata.* files will contain
information from all 8 files.
The --merge-mode option can also be used with the --merge-list option,
as described above: however,
it is not possible to specify the "diff" features (i.e. modes 6 and 7).
There are multiple ways to extract just specific SNPs for
this section describes options that use the command-line
the next section describes other methods that read a file
containing the information.
Based on a single chromosome (--chr)
To analyse only a specific chromosome use
plink --file data --chr 6
Based on a range of SNPs (--from and --to)
To select a specific range of markers (that must all fall on the same chromosome) use, for example:
plink --bfile mydata --from rs273744 --to rs89883
Based on single SNP (and window) (--snp and --window)
Alternatively, you can specify a single SNP and, optionally, also ask
for all SNPs in the surrounding region, with the --window
plink --bfile mydata --snp rs652423 --window 20
which extracts only SNPs within +/- 20kb of rs652423.
Based on multiple SNPs and ranges (--snps)
Alternatively, the newer --snps command is more flexible but
slower than the previously described --snp
and --from/--to commands. The --snps
command will accept a comma-delimited list of SNPs, including ranges
based on physical position. For example,
plink --bfile mydata --snps rs273744-rs89883,rs12345-rs67890,rs999,rs222
selects the same range as above (rs273744 to rs89883) but also
the separate range rs273744 to rs89883 as well as the two
individual SNPs rs999 and rs222.
Note that SNPs need not be on the
also, a range can span multiple chromosomes (the range is defined based
on chromosome code order in that case, as well as physical position, i.e. a range from a SNP
on chromosome 4 to one on chromosome 6 includes all SNPs on chromosome 5). No spaces are
allowed between SNP names or ranges, i.e. it is
--snps rs1111-rs2222,rs3333,rs4444
--snps rs1111 - rs2222, rs3333 ,rs4444
Hint As mentioned above, unlike other methods mentioned above,
--snps will load in all the data before extracting what it needs,
whereas --snp only loads in what it needs, as so is a much
faster way to extract a region from a very large dataset: as a result,
if you really do want only a single SNP or a single range,
use --snp (with --window) or some variant of the
from/--to commands.
Based on physical position (--from-kb, etc)
One can also select regions based on a window defined in terms of physical distance
rather than SNP ID, using the command: e.g.
plink --bfile mydata --chr 2 --from-kb 5000 --to-kb 10000
to select all SNPs within this 5000kb region on chromosome 2 (when using --from-kb
and --to-kb you always need to specify the chromosome
with the --chr option).
HINT Two alternate forms of the --from-kb command are
--from-bp and --from-mb that take a parameter in terms of
base-pair position or megabase position, instead of kilobase (to be used with the
corresponding --to-bp and --to-mb options).
Based on a random sampling (--thin)
To keep only a random 20% of SNPs, for example, add the flag
--thin 0.2
All the above options can be used either with standard pedigree files
(i.e. using
--ped or --file) or with binary format pedigree (BED)
files (i.e. using --bfile). One must combine this option with the
desired analytic (e.g. --assoc), summary statistic (e.g.
--freq) or data-generation (e.g. --make-bed) option.
To extract only a subset of SNPs, it is possible to specify a
list of required SNPs and make a new file, or perform an analysis on
this subset, by using the command
plink --file data --extract mysnps.txt
where the file is just a list of SNPs, one per line, e.g.
Alternatively, you can use the command --range to modify the
behavior of --extract and --exclude. If the
--range flag is added, then instead of a list of SNPs, PLINK
will expect a list of chromosomal ranges to be given instead, one per
plink --file data --extract myrange.txt --range
All SNPs within that range will then be excluded or extracted. The
format of myrange.txt should be, one range per line,
whitespace-separated:
Chromosome code (1-22, X, Y, XY, MT, 0)
Start of range, physical position in base units
End of range, as above
Name of range/gene
For example,
would extract/exclude all SNPs in these three regions (5Mb and 2Mb on
chromosome 2 and 10Mb on chromosome X).
Based on an attribute file (--attrib)
Based on a set file (--gene)
Finally, if a SET file is also specified, you can use the --gene
option to extract all SNPs in that gene/region. For example, if the SET file
genes.set contains two genes:
plink --file mydata --set genes.set --gene GENE2 --recode
would, for example, create a new dataset with only the 3 SNPs in
One must combine these options with the desired analytic
(e.g. --assoc), summary statistic (e.g. --freq) or
data-generation (e.g. --make-bed) option.
To re-write the PED/MAP files, but with certain SNPs excluded, use the
plink --file data --exclude mysnps.txt
where the file mysnps.txt is, as for the --extract
command, just a list of SNPs, one per line.
As described above,
the --range command can modify the behaviour
of --exclude in the same manner as for --extract.
One must combine this option with the desired analytic
(e.g. --assoc), summary statistic (e.g. --freq) or
data-generation (e.g. --make-bed) option.
NOTE Another way of removing SNPs is to make the
physical position negative in the MAP file (this can not be done for
binary filesets (e.g. the *.bim file).
To blank out a specific set of genotypes, use the following commands,
--zero-cluster test.zero
--within test.clst
in conjunction with other data analysis, file generation or summary
statistic commands, where the file test.zero is a list of
SNPs and clusters, and test.clust is a
standard .
If the original PED file is
1b 1 0 0 1 1
2b 1 0 0 1 1
3b 1 0 0 1 1
4b 1 0 0 1 1
5b 1 0 0 1 1
6b 1 0 0 1 1
and the MAP file is
1 snp1 0 1000
1 snp2 0 2000
1 snp3 0 3000
and the list of SNPs/clusters to zero out in test.zero is
and the cluster file test.clst is
then the command
plink --file test --zero-cluster test.zero --within test.clst --recode
results in a new PED file, plink.ped,
A A C C A A
0 0 A A C C
0 0 A A A C
A A C C A A
C C A A C C
A C A A A C
1b 1 0 0 1
A A 0 0 0 0
2b 1 0 0 1
C C 0 0 0 0
3b 1 0 0 1
A C 0 0 0 0
4b 1 0 0 1
A A 0 0 0 0
5b 1 0 0 1
C C 0 0 0 0
6b 1 0 0 1
A C 0 0 0 0
i.e. with the appropriate genotypes zeroed out.
HINT See the section on
genotype data, which can often be useful in this context.
To keep only certain individuals in a file, use the option:
plink --file data --keep mylist.txt
where the file mylist.txt is, as for the --remove
command, just a list of Family ID / Individual ID pairs, one set per
line, i.e. one person per line. (fields can occur after the 2nd column but
they will be ignored -- i.e. you could use a FAM file as the parameter of the
--keep command, or have comments in the file. For example
Drop this individual because of consent issues
would be fine.
One must combine this option with the desired analytic (e.g. --assoc), summary
statistic (e.g. --freq) or data-generation (e.g. --make-bed) option.
To remove certain individuals from a file
plink --file data --remove mylist.txt
where the file mylist.txt is, as for the --keep
command, just a list of Family ID / Individual ID pairs, one set per
line, i.e. one person per line (although, as for --keep, fields
after the 2nd column are allowed but they will be ignored).
One must combine this option with the desired analytic
(e.g. --assoc), summary statistic (e.g. --freq) or
data-generation (e.g. --make-bed) option.
Whereas the options to
individuals are based
on files containing lists, it is also possible to specify a filter to include only certain
individuals based on phenotype, sex or some other variable.
The basic form of the command is --filter which takes two arguments, a filename and a value to
filter on, for example:
plink --file data --filter myfile.raw 1 --freq
implies a file myfile.raw exists which has a
similar format to phenotype and cluster files: that is, the first two
columns are family and individual IDs; the third column is expected to
be a numeric value (although the file can have more than 3 columns),
and only individuals who have a value of
1 for this would be included in any subsequent analysis or file generation procedure.
myfile.raw were
then only two individuals (F3 I1 and F3 I2) would be included based on this filter for
the calculation of allele frequencies. The filter can be any integer numeric value.
As with --pheno and --within, you can specify an
offset to read the filter from a column other than the first after the
obligatory ID columns.
Use the --mfilter option for
this. For example, if you have a binary fileset, and so the FAM file
contains phenotype as the sixth column, then you could specify
plink --bfile data --filter data.fam 2 --mfilter 4
i.e. cases have the value 2, and this
is the 4th variable in the file (i.e.
the first two columns are
ignored, as these are the ID columns).
Because filtering on cases or controls, or on sex, or on position
within the family, will be common operations, there are some shortcut
options that can be used instead of --filter. These are
--filter-cases
--filter-controls
--filter-males
--filter-females
--filter-founders
--filter-nonfounders
These flags can be used in any circumstances, e.g. to make a file of control founders,
plink --bfile data --filter-controls --filter-founders --make-bed --out newfile
or to analyse only males
plink --bfile data --assoc --filter-males
IMPORTANT Take care when using these with options to
merge filesets: the merging occurs before these filters.
One can define an attribute file for SNPs (or for individuals, see
below) that is simply a list of user-defined attributes for SNPs. For
example, this might be a file
which contains
failed exonic
These codes can be whatever you like, as is appropriate for your
a SNP can have multiple, white-space delimited attributes. Not
all SNPs need SNPs not in the dataset are allowed
to appear (they are just ignored); the order does not need to be the
same. Each SNP should only be listed once however. A SNP can be listed by itself
without any attributes (for example, to ensure it is not excluded when filtering
to exclude SNPs with a certain attribute, see below).
To filter SNPs on these, use the command (combined with some other
data generation or analysis option)
--attrib snps.txt exonic
for example, to extract only exonic SNPs (rs0001 and rs0010
in this example, assuming they've been coded this way).
To exclude SNPs that match the attribute, preface the
attribute with a minus sign on the command line, e.g.
--attrib snps.txt -failed
to extract only non-failed SNPs.
Finally, multiple filters can be
combined in a comma-delimited list
--attrib snps.txt exonic,-failed
would select exonic SNPs that did not fail. If a SNP does not feature
in the attribute file, it will always be excluded.
NOTE Within match type, multiple matches are treated
as logical ORs; between positive and negative matches as AND. For
example, matching on A,B,-C,-D implies individuals with (
A or B ) and not ( C or D )
This approach works similarly for individuals, except the command is
now --attrib-indiv, e.g.
--attrib-indiv inddat.txt
sample1,fullinfo
and the attribute file starts with family ID and individual ID before
listing any attributes, e.g.
sample2 fullinfo
Given a list of ranges in the following format (4 no
header file)
Chromosome
Start base-pair position
End base-pair position
Set/range/gene name
then the command
plink --file mydata --make-set gene.list --write-set
will generate the file
in the standard
format. The
command --make-set-border takes a single integer argument, allowing for a
certain kb window before and after the gene to be included, e.g. for 20kb upstream
and downstream:
plink --file mydata --make-set gene.list
--make-set-border 20 --write-set
HINT The --make-set command doesn't
necessarily have to be used with --write-set. Rather, it can
be used anywhere that --set can be used, to make sets on the
Similar, --set and --write-set can be
combined, e.g. to create a new, filtered set file.
Options for --make-set
To collapse all ranges into a single set (i.e. to generate one set
that corresponds to all SNPs in a gene, from a list of gene
co-ordinates, for example), use
--make-set-collapse-all SETNAME
along with --make-set, where SETNAME is any single
word that you use to name to newly created set. To make a set file of
all SNPs not in the specified ranges, add
--make-set-complement-all SETNAME
Optionally, the range file can contain a fifth column, to specify
groups of ranges. Sets can be constructed which collapse over these
groups. That is, the input for --make-set is now
Chromosome
Start base-pair position
End base-pair position
Set/range/gene name
Group label
Normally, the fifth column will just be ignored, unless the command
--make-set-collapse-group
is added, which creates sets of SNPs that correspond to each group
(i.e. PWAY-A, PWAY-B, etc, in this example) rather
than each gene/region (i.e. GENE1, etc). The command
--make-set-complement-group
works in a similar manner, except now forming sets of all
SNPs not in the given group of ranges.
HINT See the
for pre-compiled RefSeq gene-lists that can be used here.
It is possible to create a table that maps SNPs to sets, given a --set file has been specified,
with the --set-table command, e.g.
./plink --bfile mydata --set mydata.set --set-table
which generates a file
plink.set.table
which contains the fields
SNP identifier
Chromosome code
Base-pair physical position
First set name
Membership of first set
Second set name
Membership of second set
For each row, a series of 0s and 1s indicate whether or not each SNP
in the dataset is in a given SET.
This format can be useful for
subsequent analyses (i.e. it can be easily lined up with other result
files, e.g. from --assoc).
PLINK supports quality scores for SNPs and, described in the next
section, genotypes.
These can be used to filter on user-defined
thresholds. The command
--qual-scores indicates the file containing the scores.
Scores are assumed to
be numbers between 0 and 1, a higher number representing better quality. The threshold
at which SNPs are selected can be set with the command --qual-threshold. For example,
./plink --bfile mydata --qual-scores myscores.txt --qual-threshold 0.8 --make-bed --out qc-data
where myscores.txt is a text file of SNPs and scores, e.g.
will remove SNPs with scores less than 0.8.
The additional
flag --qual-max-threshold can be used to specify a maximum
threshold also (i.e. to select low-quality SNPs only).
Not all SNPs
need be in the file (the SNP is left in, the order can
be different, it can contain SNPs not in the data).
Quality scores for each genotype, rather than each SNP, can also be applied to PLINK datasets,
using the --qual-geno-scores command, e.g.
./plink --bfile mydata --qual-geno-scores gqual.txt --qual-geno-threshold 0.99 --assoc
(with a similar --qual-geno-max-threshold command as well).
The file containing the genotype quality scores should have the following format:
Q FID IID SNPID score
Q fam1 ind1 rs
Q fam1 ind1 rs
Not all genotypes need be in this file. Rather than have a very large
file, one could only list genotype scores that are below some
threshold, for example, assuming most genotypes are of very good quality. Genotypes
not in the this file will be untouched.
This format is designed to accept wildcards, as follows.
Every item should start with a Q character, to allow PLINK
to check the correctness of the file format. Consider this example file,
that lists two genotypes for people with FID/IID A/1 and B/1 for SNPs
rs1234 and rs5678. If a score if below threshold, it is set
to missing in the data.
The order of th not all
individuals/SNPs need appear.
PLINK accepts wildcards in this file, to allow for different
data formats to be specified. With a person wild-card, PLINK
expects all quality scores for that SNP, in order as in the FAM or PED
file, e.g.
Q * rs 0.923
Q * rs 0.97
With a SNP wildcard, PLINK exects all SNPs for a given person:
Q A 1 * 0.986 0.323
Q B 1 * 0.923 0.97
All these formats can be mixed together in a single file. These can be combined (in which case, PLINK expects all individuals for the first SNP, all for the second SNP, etc)
Q * * 0.986 0.923 0.323 0.97
WARNING This option is recently added in beta-stage of development.
Currently, a wild card looks to the current data to get the list of individuals
and SNPs to loop over. This could cause a problem if the file has been filtered, etc.
The next release will include commands to specify the order of individuals and SNPs,
--qual-people-list mysamples.lst
where mysamples.lst is a file with 2 columns (FID/IID), and
--qual-geno-snp-list mysnp.lst
where mysnp.lst is list of SNPs.
This way if somebody is in the quality score file but they have been
removed from the actual genotype dataset (or added), then this can be
handled properly without needing to change the whole quality score file.
This document last modified Saturday, 10-Oct-:11 EDT

我要回帖

更多关于 计算机科学期刊 的文章

 

随机推荐