An introduction to adegenet 2.0.0
|
|
|
- Robert Augustus Neal
- 10 years ago
- Views:
Transcription
1 An introduction to adegenet Thibaut Jombart Imperial College London MRC Centre for Outbreak Analysis and Modelling July 29, 2015 Abstract This vignette provides an introductory tutorial to the adegenet package [4] for the R software [12]. This package implements tools to handle, analyse and simulate genetic data. Originally developped for multiallelic, codominant markers such as microsatellites, adegenet now also handles dominant markers, allows for any ploidy in the data, handles SNPs and sequence data, and implements a memory-efficient storage for genome-wide SNP data. This tutorial provides an overview of adegenet s basic functionalities. Since adegenet 1.4-0, this tutorial is no longer distributed as a package vignette. Also note that adegenet has undergone substantial changes with version 2.0.0, including a reform of the data structure and new accessors, all documented in this tutorial. [email protected] 1
2 Contents 1 Introduction 3 2 Getting started Installing the package - stable version Installing the package - devel version Getting help in R Asking help on a forum Bug report, feature requests, contributions: we are all one! Object classes genind objects genpop objects Using accessors Importing/exporting data Importing data from GENETIX, STRUCTURE, FSTAT, Genepop Importing data from other software Handling presence/absence data SNPs data Extracting polymorphism from DNA sequences Extracting polymorphism from proteic sequences Using genind/genpop constructors Exporting data Basics of data analysis Manipulating the data Using summaries Testing for Hardy-Weinberg equilibrium Measuring and testing population structure (a.k.a F statistics) Estimating inbreeding Multivariate analysis General overview Performing a Principal Component Analysis on genind objects Performing a Correspondance Analysis on genpop objects Spatial analysis Isolation by distance Testing isolation by distance Cline or distant patches? Using Monmonier s algorithm to define genetic boundaries Simulating hybridization 77 2
3 1 Introduction This tutorial introduces some basic functionalities of the adegenet package for R [12]. The purpose of this package is to provide tools for handling, analysing and simulating genetic data, with an emphasis on multivariate approaches and exploratory methods. Standard multivariate analyses are implemented in the ade4 package [2], of which adegenet was originally an extension. However, the package has since grown methods of its own such as the Discriminant Analysis of Principal Components (DAPC, [8]), the spatial Principal Components Analysis (spca, [5]), or the SeqTrack algorithm [6]. In this tutorial, we introduce the main data structures, show how to import data into adegenet, and cover some basic population genetics and multivariate analysis. Other tutorials are available via the command adegenettutorial: adegenettutorial("spca"): tutorial on the spca adegenettutorial("dapc"): tutorial on the DAPC adegenettutorial("genomics"): genlight objects tutorial on handling large SNP datasets using 3
4 2 Getting started 2.1 Installing the package - stable version Before going further, we shall make sure that adegenet is well installed on the computer. The current version of the package is Make sure you have a recent version of R ( 3.2.1) by typing: R.version.string [1] "R Under development (unstable) ( r68542)" Then, install adegenet with dependencies using: install.packages("adegenet", dep=true) We can now load the package alongside other useful packages: library("ape") library("pegas") library("seqinr") library("ggplot2") library("adegenet") If at some point you are unsure about the version of the package, you can check it using: packagedescription("adegenet", fields = "Version") [1] "2.0.0" adegenet version should read Installing the package - devel version The development of adegenet is hosted on github: You can install this version using the package devtools and the following commands: library("devtools") install_github("thibautjombart/adegenet") library("adegenet") The development version may implement new features and fix known issues. However, it may also occasionally be broken, as this is our working copy of the project. Usual disclaimers apply here: this package is provided with no warranty, etc. If unsure, use the stable version. 4
5 2.3 Getting help in R There are several ways of getting information about R in general, and about adegenet in particular. The function help.search is used to look for help on a given topic. For instance: help.search("hardy-weinberg") replies that there is a function HWE.test.genind in the adegenet package, and other similar functions in genetics and pegas. To get help for a given function, use?foo where foo is the function of interest. For instance (quotes and parentheses can be removed):?spca will open up the manpage of the spatial principal component analysis [5]. At the end of a manpage, an example section often shows how to use a function. This can be copied and pasted to the console, or directly executed from the console using example. For further questions concerning R, the function RSiteSearch is a powerful tool for making online researches using keywords in R s archives (mailing lists and manpages). adegenet has a few extra documentation sources. Information can be found from the website ( in the documents section, including several tutorials and a manual which compiles all manpages of the package, and a dedicated mailing list with searchable archives. To open the website from R, use: adegenetweb() The same can be done for tutorials, using adegenettutorial (see manpage to choose the tutorial to open). You will also find an overview of the main functionalities of the package typing:?adegenet Note that you can also browse help pages as html pages, using: help.start() To go to the adegenet page, click packages, adegenet, and adegenet-package. 2.4 Asking help on a forum Several mailing lists are available to find different kinds of information on R. adegenet has its own dedicated forum/mailing list: [email protected] To avoid spam, this list is filtered; subscription is recommended, and can be done at: 5
6 Posting questions on R forums can sometimes be a traumatic experience, and we are trying to avoid this as much as possible on the adegenet forum. To this end, the following points are worth keeping in mind: read the doc first: manpages and tutorials take an awful long time to write and maintain; make sure your answer is not in an obvious place before asking a question; pretending to have read all the available doc while you have not even looked at the basics tutorial is a clever, yet often unsuccessful strategy. search the archives: adegenet forum has searchable archives (see the adegenet website); your answer may be there already, so it is worth checking. give us info: you tried something, it is not working.. give us some information: what version of adegenet are you using, what commands did you enter and what was the output, etc. avoid personal messages: the adegenet forum has plenty of advantages: several people are likely to reply and participate in the conversation, answers are generally faster, and all of this is archived and searchable. Please do not the developers directly, unless you need to discuss confidential matters. short answers are okay: some answers will be short. Do not take them as rude, or think people are upset: answering questions on a forum is a time-consuming activity and the reward for it is low. Sometimes the best answer will be pointing to relevant documentation, e.g. Please check?xvaldapc. If you get this, we (most likely) still like you. The adegenet forum is not the only forum that might be relevant. Others include: R-sig-genetics: genetics in R. R-sig-phylo: phylogenetics in R. R-help: general questions about R. Please avoid double-posting (it is often considered to be rude). 2.5 Bug report, feature requests, contributions: we are all one! Free software evolves through interactions between communities of developers and users. This is especially true in R, where these two communities are very much intermingled. In short: we are all contributors! These contributions include: asking a question: see section above 6
7 asking for a new feature: something useful is missing, and you think it will be useful to others? Say it! Post a feature request using github s issues: reporting a possible bug: bugs are rare, but if you think you found one, post it as an issue on github: contributions: github makes contributions very easy; fork the project, make the changes you want, and when you are happy and the package passes the checks, send a pull request; for more on this go to the github page: And please, remember to add yourself as a contributor in the DESCRIPTION and relevant manpages! 7
8 3 Object classes Two main classes of objects are used for storing genetic marker data, depending on the level at which the genetic information is considered: genind is used for individual genotypes, whereas genpop is used for alleles numbers counted by populations. Note that the term population, here and later, is employed in a broad sense: it simply refers to any grouping of individuals. The specific class genlight is used for storing large genome-wide SNPs data. See the genomics tutorial for more information on this topic. 3.1 genind objects These objects store genetic data at an individual level, plus various meta-data (e.g. group membership). genind objects can be obtained by reading data files from other software, from a data.frame of genotypes, by conversion from a table of allele counts, or even from aligned DNA or proteic sequences (see importing data ). Here, we introduce this class using the dataset nancycats, which is already stored as a genind object: data(nancycats) is.genind(nancycats) [1] TRUE nancycats /// GENIND OBJECT ///////// // 237 individuals; 9 loci; 108 alleles; size: Kb // Basic 237 x 108 matrix of allele number of alleles per locus (range: locus factor for the 108 list of allele names for each ploidy of each individual (range: genind(tab = truenames(nancycats)$tab, pop = truenames(nancycats)$pop) // Optional population of each individual (group size range: a list containing: xy A genind object is formal S4 object with several slots, accessed using operator (see class?genind). Note that the $ is also implemented for adegenet objects, so that slots can be accessed as if they were components of a list. genind objects possess the following slots: 8
9 tab: a matrix of alleles counts (individuals in rows, alleles in columns). loc.n.all: the number of alleles in each marker. loc.fac: a factor indicating which columns correspond to which marker. all.names: a list of allele names for each locus. ploidy: a vector of integer indicating the ploidy of each individual; constant ploidy is assumed across different loci of a single individual, but different individuals can have different ploidy. type: a character string indicating whether the marker is codominant (codom) or presence/absence (PA). call: the matched call, i.e. command used to create the object. pop: (optional) a factor storing group membership of the individuals; when present, method needing a population information will automatically use this if nothing else is provided. strata: (optional) a data.frame storing hierarchical structure of individuals (see dedicated tutorial). hierarchy: (optional) a formula defining the hierarchical structure of individuals (see dedicated tutorial). other: (optional) a list storing optional information. Slots can be accessed or $, although it is recommended to use accessors to retrieve and change slot values (see section Using accessors ). The main slot of a genind is the table of allelic with individuals in rows and alleles in columns. For instance: nancycats[10:18, loc="fca8"]@tab fca8.117 fca8.119 fca8.121 fca8.123 fca8.127 fca8.129 fca8.131 N N N N N N N N N fca8.133 fca8.135 fca8.137 fca8.139 fca8.141 fca8.143 fca
10 N N N N N N N N N fca8.147 fca8.149 N N7 0 0 N N N N N N N Individual N224 is an homozygote for the allele 135 at the locus fca8, while N141 is an heterozygote with alleles 129/133. Note that as of adegenet 2.0.0, this table is no storing data as relative frequencies. These can still be obtained using the accessor tab. The particular case of presence/absence data is described in a dedicated section (see Handling presence/absence data ). As of version of adegenet, the implement hierarchical population structures. See dedicated tutorial for more on this topic. Note that objects can be regenerated using the matched call stored in genind objects, i.e. the instruction that created it. For instance: obj <- read.genetix(system.file("files/nancycats.gtx",package="adegenet")) Converting data from GENETIX to a genind object......done. obj$call read.genetix(file = system.file("files/nancycats.gtx", package = "adegenet")) toto <- eval(obj$call) Converting data from GENETIX to a genind object......done. 10
11 identical(obj,toto) [1] TRUE 3.2 genpop objects These objects store genetic data at a population level, plus various meta-data. Their struture is nearly identical to genind objects, only simpler as they no longer store group membership for individuals. genpop objects are created from genind objects using genind2genpop: data(nancycats) catpop <- genind2genpop(nancycats) Converting data from a genind to a genpop object......done. catpop /// GENPOP OBJECT ///////// // 17 populations; 9 loci; 108 alleles; size: 28.5 Kb // Basic 17 x 108 matrix of allele number of alleles per locus (range: locus factor for the 108 list of allele names for each ploidy of each individual (range: genind2genpop(x = nancycats) // Optional a list containing: xy As in genind objects, data are stored as numbers of alleles, but this time for populations (here, cat colonies): catpop$tab[1:5,1:10] fca8.117 fca8.119 fca8.121 fca8.123 fca8.127 fca8.129 fca8.131 P P
12 P P P fca8.133 fca8.135 fca8.137 P P P P P Using accessors One advantage of formal (S4) classes is that they allow for interacting simply with possibly complex objects. This is made possible by using accessors, i.e. functions that extract information from an object, rather than accessing the slots directly. Another advantage of this approach is that as long as accessors remain identical on the user s side, the internal structure of an object may change from one release to another without generating errors in old scripts. Although genind and genpop objects are fairly simple, we recommend using accessors whenever possible to access or modify their content. Available accessors are: nind: returns the number of individuals in the object; only for genind. nloc: returns the number of loci. nall: returns the number of alleles for each locus. npop: returns the number of populations. tab: returns a table of allele numbers, or frequencies (if requested), with optional replacement of missing values; replaces the former accessor truenames. indnames : returns/sets labels for individuals; only for genind. locnames : returns/sets labels for loci. alleles : returns/sets alleles. ploidy : returns/sets ploidy of the individuals; when setting values, a single value can be provided, in which case constant ploidy is assumed. pop : returns/sets a factor grouping individuals; only for genind. strata : returns/sets data defining strata of individuals; only for genind. hier : returns/sets hierarchical groups of individuals; only for genind. 12
13 other : returns/sets misc information stored as a list. where indicates that a replacement method is available using <-; for instance: head(indnames(nancycats),10) "N215" "N216" "N217" "N218" "N219" "N220" "N221" "N222" "N223" "N224" indnames(nancycats) <- paste("cat", 1:nInd(nancycats),sep=".") head(indnames(nancycats),10) [1] "cat.1" "cat.2" "cat.3" "cat.4" "cat.5" "cat.6" "cat.7" [8] "cat.8" "cat.9" "cat.10" Some accessors such as locnames may have specific options; for instance: locnames(nancycats) [1] "fca8" "fca23" "fca43" "fca45" "fca77" "fca78" "fca90" "fca96" "fca37" returns the names of the loci, while: temp <- locnames(nancycats, withalleles=true) head(temp, 10) [1] "fca8.117" "fca8.119" "fca8.121" "fca8.123" "fca8.127" "fca8.129" [7] "fca8.131" "fca8.133" "fca8.135" "fca8.137" returns the names of the alleles in the form loci.allele. The slot pop can be retrieved and set using pop: obj <- nancycats[sample(1:50,10)] pop(obj) [1] P02 P03 P02 P01 P04 P02 P02 P01 P02 P04 Levels: P01 P02 P03 P04 pop(obj) <- rep("newpop",10) pop(obj) [1] newpop newpop newpop newpop newpop newpop newpop newpop newpop newpop Levels: newpop Accessors make things easier. For instance, when setting new names for loci, the columns are renamed automatically: 13
14 head(colnames(tab(obj)),20) [1] "fca8.117" "fca8.119" "fca8.121" "fca8.123" "fca8.127" [6] "fca8.129" "fca8.131" "fca8.133" "fca8.135" "fca8.137" [11] "fca8.139" "fca8.141" "fca8.143" "fca8.145" "fca8.147" [16] "fca8.149" "fca23.128" "fca23.130" "fca23.132" "fca23.136" locnames(obj) [1] "fca8" "fca23" "fca43" "fca45" "fca77" "fca78" "fca90" "fca96" "fca37" locnames(obj)[1] <- "newlocusname" locnames(obj) [1] "newlocusname" "fca23" "fca43" "fca45" [5] "fca77" "fca78" "fca90" "fca96" [9] "fca37" head(colnames(tab(obj)),20) [1] "newlocusname.117" "newlocusname.119" "newlocusname.121" [4] "newlocusname.123" "newlocusname.127" "newlocusname.129" [7] "newlocusname.131" "newlocusname.133" "newlocusname.135" [10] "newlocusname.137" "newlocusname.139" "newlocusname.141" [13] "newlocusname.143" "newlocusname.145" "newlocusname.147" [16] "newlocusname.149" "fca23.128" "fca23.130" [19] "fca23.132" "fca23.136" An additional advantage of using accessors is they are most of the time safer to use. For instance, pop<- will check the length of the new group membership vector against the data, and complain if there is a mismatch. It also converts the provided replacement to a factor, while the command: obj@pop <- rep("newpop",10) Error in checkatassignment("genind", "pop", "character"): assignment of an object of class "character" is not valid pop in an object of class "genind"; is(value, "factorornull") is not TRUE generates an error (since replacement is not a factor). 14
15 4 Importing/exporting data 4.1 Importing data from GENETIX, STRUCTURE, FSTAT, Genepop Data can be read from the software GENETIX (extension.gtx), STRUCTURE (.str or.stru), FSTAT (.dat) and Genepop (.gen) files, using the corresponding read function: read.genetix, read.structure, read.fstat, and read.genepop. These functions take as main argument the path (as a string of characters) to an input file, and produce a genind object. Alternatively, one can use the function import2genind which detects a file format from its extension and uses the appropriate routine. For instance: obj1 <- read.genetix(system.file("files/nancycats.gtx",package="adegenet")) Converting data from GENETIX to a genind object......done. obj2 <- import2genind(system.file("files/nancycats.gtx", package="adegenet")) Converting data from GENETIX to a genind object......done. all.equal(obj1,obj2) [1] "Attributes: < Component \"call\": target, current do not match when deparsed >" The only difference between obj1 and obj2 is their call (which is normal as they were obtained from different command lines). 4.2 Importing data from other software Raw genetic markers data are often stored as tables with individuals in row and markers in column, where each entry is a character string coding the alleles possessed at one locus. Such data are easily imported into R as a data.frame, using for instance read.table for text files or read.csv for comma-separated text files. Then, the obtained data.frame can be converted into a genind object using df2genind. There are only a few pre-requisite the data should meet for this conversion to be possible. The easiest and clearest way of coding data is using a separator between alleles. For instance, 80/78, 80 78, or 80,78 are different ways of coding a genotype at a microsatellite locus with alleles 80 and 78. Note that for haploid data, no separator shall be used. The only contraint when using a separator is that the same separator is used in all 15
16 the dataset. There are no contraints as to i) the type of separator used or ii) the ploidy of the data. These parameters can be set in df2genind through arguments sep and ploidy, respectively. Alternatively, no separator may be used provided a fixed number of characters is used to code each allele. For instance, in a diploid organism, 0101 is an homozygote 1/1 while 1209 is a heterozygote 12/09 in a two-character per allele coding scheme. In a tetraploid system with one character per allele, 1209 will be understood as 1/2/0/9. Here, we provide an example using randomly generated tetraploid data and no separator. temp <- lapply(1:30, function(i) sample(1:9, 4, replace=true)) temp <- sapply(temp, paste, collapse="") temp <- matrix(temp, nrow=10, dimnames=list(paste("ind",1:10), paste("loc",1:3))) temp loc 1 loc 2 loc 3 ind 1 "3195" "2245" "6674" ind 2 "6249" "5976" "1577" ind 3 "9349" "2689" "9783" ind 4 "7932" "3889" "9515" ind 5 "8612" "7751" "5345" ind 6 "4234" "8759" "6391" ind 7 "4375" "6338" "3132" ind 8 "5397" "9385" "6558" ind 9 "5612" "5538" "1925" ind 10 "5168" "8568" "8349" obj <- df2genind(temp, ploidy=4, sep="") obj /// GENIND OBJECT ///////// // 10 individuals; 3 loci; 27 alleles; size: 9.5 Kb // Basic 10 x 27 matrix of allele number of alleles per locus (range: locus factor for the 27 list of allele names for each ploidy of each individual (range: df2genind(x = temp, sep = "", ploidy = 4) // Optional content - empty - 16
17 obj is a genind containing the same information, but recoded as a matrix of allele numbers ($tab slot). We can check that the conversion was exact by converting back the object into a table of character strings (function genind2df): genind2df(obj, sep=" ") loc 1 loc 2 loc 3 ind ind ind ind ind ind ind ind ind ind Handling presence/absence data adegenet was primarly designed to handle codominant, multiallelic markers like microsatellites. However, dominant markers like AFLP can be used as well. In such a case, only presence/absence of alleles can be deduced accurately from the genotypes. This has several consequences, like the unability to compute allele frequencies. Hence, some functionalities in adegenet won t be available for dominant markers. From version of adegenet, the distinction between both types of markers is made by the of genind or genpop objects, which equals codom for codominant markers, and PA for presence/absence data. In the latter case, the tab slot of a genind object no longer contains allele frequencies, but only presence/absence of alleles in a genotype. Similarly, the tab slot of a genpop object not longer contains counts of alleles in the populations; instead, it contains the number of genotypes in each population possessing at least one copy of the concerned alleles. Moreover, in the case of presence/absence, the slots loc.n.all, loc.fac, and all.names become useless, and are thus all set to NULL. Objects of type PA are otherwise handled like usual (type codom ) objects. Operations that are not available for PA type will issue an appropriate error message. Here is an example using a toy dataset AFLP.txt that can be downloaded from the adegenet website, section Documentation : dat <- read.table(system.file("files/aflp.txt",package="adegenet"), header=true) dat loc1 loc2 loc3 loc4 inda
18 indb indc indd 0 NA 1 NA inde indf indg The function df2genind is used to obtain a genind object: obj <- df2genind(dat, ploidy=1, type="pa") obj /// GENIND OBJECT ///////// // 7 individuals; 4 loci; 4 alleles; size: 4 Kb // Basic 7 x 4 matrix of allele number of alleles per locus (range: ploidy of each individual (range: df2genind(x = dat, ploidy = 1, type = "PA") // Optional content - empty - tab(obj) loc1 loc2 loc3 loc4 inda indb indc indd 0 NA 1 NA inde indf indg One can see that for instance, the summary of this object is more simple (no numbers of alleles per locus, no heterozygosity): pop(obj) <- rep(c('a','b'),4:3) summary(obj) # Total number of genotypes: 7 18
19 # Population sample sizes: a b 4 3 # Percentage of missing data: [1] But we can still perform basic manipulation, like converting our object into a genpop: obj2 <- genind2genpop(obj) Converting data from a genind to a genpop object......done. obj2 /// GENPOP OBJECT ///////// // 2 populations; 4 loci; 4 alleles; size: 2.8 Kb // Basic 2 x 4 matrix of allele number of alleles per locus (range: ploidy of each individual (range: genind2genpop(x = obj) // Optional content - empty - tab(obj2) loc1 loc2 loc3 loc4 a b To continue with the toy example, we can perform a simple PCA. Allele presence absence data are extracted and NAs replaced using tab: X <- tab(obj, NA.method="mean") Now the PCA is performed and plotted: 19
20 make PCA pca1 <- dudi.pca(x,scannf=false,scale=false) temp <- as.integer(pop(obj)) mycol <- transp(c("blue","red"),.7)[temp] mypch <- c(15,17)[temp] basic plot plot(pca1$li, col=mycol, cex=3, pch=mypch) use wordcloud for non-overlapping labels library(wordcloud) textplot(pca1$li[,1], pca1$li[,2], words=rownames(x), cex=1.4, new=false) legend the axes by adding loadings abline(h=0,v=0,col="grey",lty=2) s.arrow(pca1$c1*.5, add.plot=true) legend("topright", pch=c(15,17), col=transp(c("blue","red"),.7), leg=c("group A","Group B"), pt.cex=2) Axis inda indf loc1 loc4 indc loc3 inde loc2 indb indd Group A Group B indg Axis1 20
21 More generally, multivariate analyses from ade4, spca (spca), DAPC (dapc), the global and local tests (global.rtest, local.rtest), or the Monmonier s algorithm (monmonier) will work just fine with presence/absence data. However, it is clear that the usual Euclidean distance (used in PCA and spca), as well as many other distances, is not as accurate to measure genetic dissimilarity using presence/absence data as it is when using allele frequencies. The reason for this is that in presence/absence data, a part of the information is simply hidden. For instance, two individuals possessing the same allele will be considered at the same distance, whether they possess one or more copies of the allele. This might be especially problematic in organisms having a high degree of ploidy. 4.4 SNPs data In adegenet, SNP data can be handled in two different ways. For relatively small datasets (up to a few thousand SNPs) SNPs can be handled as usual codominant markers such as microsatellites using genind objects. In the case of genome-wide SNP data (from hundreds of thousands to millions of SNPs), genind objects are no longer efficient representation of the data. In this case, we use genlight objects to store and handle information with maximum efficiency and minimum memory requirements. See the tutorial genomics for more information. Below, we introduce only the case of SNPs handled using genind objects. The most convenient way to convert SNPs into a genind is using df2genind, which is described in the previous section. Let dat be an input matrix, as can be read into R using read.table or read.csv, with genotypes in row and SNP loci in columns. dat <- matrix(sample(c("a","t","g","c"), 15, replace=true),nrow=3) rownames(dat) <- paste("genot.", 1:3) colnames(dat) <- 1:5 dat genot. 1 "a" "a" "c" "g" "a" genot. 2 "g" "c" "c" "a" "t" genot. 3 "g" "g" "a" "a" "a" obj <- df2genind(dat, ploidy=1) tab(obj) 1.a 1.g 2.a 2.c 2.g 3.c 3.a 4.g 4.a 5.a 5.t genot genot genot obj is a genind containing the SNPs information, which can be used for further analysis in adegenet. 21
22 4.5 Extracting polymorphism from DNA sequences This section only covers the cases of relatively small datasets which can be handled efficiently using genind objects. For bigger (near full-genomes) datasets, SNPs can be extracted from fasta files into a genlight object using fasta2genlight. See the tutorial on genomics for more information. DNA sequences can be read into R using ape s read.dna (fasta and clustal formats), or adegenet s fasta2dnabin for a RAM-greedy implementation (fasta alignments only). Other options include reading data directly from GenBank using read.genbank, or from other public databases using the seqinr package and transforming the alignment object into a DNAbin using as.dnabin. Here, we illustrate this approach by re-using the example of read.genbank. A connection to the internet is required, as sequences are read directly from a distant database. library(ape) ref <- c("u15717", "U15718", "U15719", "U15720", "U15721", "U15722", "U15723", "U15724") mydna <- read.genbank(ref) mydna 8 DNA sequences in binary format stored in a list. All sequences of same length: 1045 Labels: U15717 U15718 U15719 U15720 U15721 U Base composition: a c g t class(mydna) [1] "DNAbin" mydna <- as.matrix(mydna) Polymorphism can be characterized using snpposi.plot and snpposi.test: the first plots SNP density along the alignment, the second tests whether these SNPs are randomly distributed. For instance: snpposi.plot(mydna,codon=false) 22
23 Distribution of SNPs in the genome density Nucleotide position By default, the function differentiates nucleotide positions: snpposi.plot(mydna) 23
24 Distribution of SNPs in the genome density Codon position Nucleotide position In adegenet, only polymorphic loci are conserved to form a genind object. This conversion is achieved by DNAbin2genind. This function allows one to specify a threshold for polymorphism; for instance, one could retain only SNPs for which the second largest allele frequency is greater than 1% (using the polythres argument). This is achieved using: obj <- DNAbin2genind(myDNA, polythres=0.01) obj /// GENIND OBJECT ///////// // 8 individuals; 155 loci; 318 alleles; size: 83.4 Kb // Basic 8 x 318 matrix of allele number of alleles per locus (range: locus factor for the 318 list of allele names for each ploidy of each individual (range: codom 24
25 @call: DNAbin2genind(x = mydna, polythres = 0.01) // Optional content - empty - Here, out of the 1,045 nucleotides of the sequences, 318 SNPs where extracted and stored as a genind object. Positions of the SNPs are stored as names of the loci: head(locnames(obj)) [1] "11" "13" "26" "31" "34" "39" 4.6 Extracting polymorphism from proteic sequences Alignments of proteic sequences can be exploited in adegenet in the same way as DNA sequences (see section above). Alignments are scanned for polymorphic sites, and only those are retained to form a genind object. Loci correspond to the position of the residue in the alignment, and alleles correspond to the different amino-acids (AA). Aligned proteic sequences are stored as objects of class alignment in the seqinr package [1]. See?as.alignment for a description of this class. The function extracting polymorphic sites from alignment objects is alignment2genind. Its use is fairly simple. It is here illustrated using a small dataset of aligned proteic sequences: library(seqinr) mase.res <- read.alignment(file=system.file("sequences/test.mase", package="seqinr"), format = "mase") mase.res $nb [1] 6 $nam [1] "Langur" "Baboon" "Human" "Rat" "Cow" "Horse" $seq $seq[[1]] $seq[[2]] $seq[[3]] 25
26 [1] "-ktyercefartlkrngmsgyygvsladwvclaqhesnyntqarnydpgdqstdygifqinsrywcndgkpraknacgip [1] "-kvfercelartlkklgldgykgvslanwlcltkwessyntkatnynpssestdygifqinskwwcndgkpnavdgchvs [1] "-kvfskcelahklkaqemdgfggyslanwvcmaeyesnfntrafngknangssdyglfqlnnkwwckdnkrsssnacnim $seq[[4]] $seq[[5]] $seq[[6]] $com [1] ";empty description\n" ";\n" ";\n" [4] ";\n" ";\n" ";\n" attr(,"class") [1] "alignment" x <- alignment2genind(mase.res) x /// GENIND OBJECT ///////// // 6 individuals; 82 loci; 212 alleles; size: 51.1 Kb // Basic 6 x 212 matrix of allele number of alleles per locus (range: locus factor for the 212 list of allele names for each ploidy of each individual (range: alignment2genind(x = mase.res) // Optional a list containing: com The six aligned protein sequences (mase.res) have been scanned for polymorphic sites, and these have been extracted to form the genind object x. Note that several settings such as the characters corresponding to missing values (i.e., gaps) and the polymorphism threshold for a site to be retained can be specified through the function s arguments (see?alignment2genind). The names of the loci directly provides the indices of polymorphic sites: 26
27 head(locnames(x)) [1] "3" "4" "5" "6" "9" "11" The table of polymorphic sites can be reconstructed easily by: tabaa <- genind2df(x) dim(tabaa) [1] 6 82 tabaa[, 1:20] Langur i f e r l r t k l g l d y k v n v l a k Baboon i f e r l r t r l g l d y r i n v l a k Human v f e r l r t r l g m d y r i n m l a k Rat t y e r f r t r n g m s y y v d v l a q Cow v f e r l r t k l g l d y k v n l l t k Horse v f s k l h k a q e m d f g y n v m a e The global AA composition of the polymorphic sites is given by: table(unlist(tabaa)) a d e f g h i k l m n p q r s t v w y Now that polymorphic sites have been converted into a genind object, simple distances can be computed between the sequences. Note that adegenet does not implement specific distances for protein sequences, we only use the simple Euclidean distance. Fancier protein distances are implemented in R; see for instance dist.alignment in the seqinr package, and dist.ml in the phangorn package. D <- dist(tab(x)) D Langur Baboon Human Rat Cow Baboon Human Rat Cow Horse
28 This matrix of distances is small enough for one to interprete the raw numbers. However, it is also very straightforward to represent these distances as a tree or in a reduced space. We first build a Neighbor-Joining tree using the ape package: library(ape) tre <- nj(d) par(xpd=true) plot(tre, type="unrooted", edge.w=2) edgelabels(tex=round(tre$edge.length,1), bg=rgb(.8,.8,1,.8)) Baboon Human Cow Langur Horse Rat The best possible planar representation of these Euclidean distances is achieved by Principal Coordinate Analyses (PCoA), which in this case will give identical results to PCA of the original (centred, non-scaled) data: pco1 <- dudi.pco(d, scannf=false,nf=2) s.label(pco1$li*1.1, clab=0, pch="") textplot(pco1$li[,1], pco1$li[,2], words=rownames(pco1$li), cex=1.4, new=false, xpd=true) title("principal Coordinate Analysis\n-based on proteic distances-") 28
29 Principal Coordinate Analysis based on proteic distances d = 2 Rat Baboon Human Langur Horse Cow 4.7 Using genind/genpop constructors genind or genpop objects are best obtained using the procedures described above. However, one can also build new genind or genpop objects using the constructor new(). In this case, the function must be given as main input an object corresponding to slot: a matrix of integers with individuals in row and alleles in columns, with columns being named as [marker].[allele]. Here is an example for genpop using a dataset from ade4 : data(microsatt) microsatt$tab[10:15,12:15] INRA INRA INRA INRA Mtbeliard NDama Normand Parthenais Somba Vosgienne
30 microsatt$tab contains alleles counts per populations, and can therefore be used to make a genpop object. Moreover, column names are set as required, and row names are unique. It is therefore safe to convert these data into a genpop using the constructor: toto <- new("genpop", tab=microsatt$tab) toto /// GENPOP OBJECT ///////// // 18 populations; 9 loci; 112 alleles; size: 28 Kb // Basic 18 x 112 matrix of allele number of alleles per locus (range: locus factor for the 112 list of allele names for each ploidy of each individual (range: =.Object, tab =..1) // Optional content - empty - summary(toto) # Number of populations: 18 # Number of alleles per locus: INRA5 INRA32 INRA35 INRA63 INRA72 ETH152 ETH225 INRA16 INRAK # Number of alleles per population: Baoule Borgou BPN Charolais Holstein Jersey Lagunaire Limousin MaineAnjou Mtbeliard NDama Normand Parthenais Somba Vosgienne ZChoa ZMbororo Zpeul # Percentage of missing data: [1] 0 30
31 4.8 Exporting data The genind class tends to become a standard in population genetics packages. As of adegenet 2.0.0, export functions towards hierfstat have been removed, as the package now uses genind objects as a native class. Similarly, export towards the package genetics have been removed, as adegenet now relies on pegas for basic population genetics. A generic way to export data is to produce a data.frame of genotypes coded by character strings. This is done by genind2df: obj <- genind2df(nancycats) obj[1:5,1:5] pop fca8 fca23 fca43 fca45 cat.1 P01 <NA> cat.2 P01 <NA> cat.3 P cat.4 P cat.5 P This function is flexible; for instance, one can separate alleles by any character string: genind2df(nancycats,sep=" ")[1:5,1:5] pop fca8 fca23 fca43 fca45 cat.1 P01 <NA> cat.2 P01 <NA> cat.3 P cat.4 P cat.5 P Note that tabulations can be obtained as follows using \t character. 31
32 5 Basics of data analysis 5.1 Manipulating the data Data manipulation is meant to be particularly flexible in adegenet. First, as genind and genpop objects are basically formed by a data matrix slot), it is natural to subset these objects like it is done with a matrix. The [ operator does this, forming a new object with the retained genotypes/populations and alleles: data(microbov) toto <- genind2genpop(microbov) Converting data from a genind to a genpop object......done. toto /// GENPOP OBJECT ///////// // 15 populations; 30 loci; 373 alleles; size: 88.9 Kb // Basic 15 x 373 matrix of allele number of alleles per locus (range: locus factor for the 373 list of allele names for each ploidy of each individual (range: genind2genpop(x = microbov) // Optional a list containing: coun breed spe popnames(toto) [1] "Borgou" "Zebu" "Lagunaire" [4] "NDama" "Somba" "Aubrac" [7] "Bazadais" "BlondeAquitaine" "BretPieNoire" [10] "Charolais" "Gascon" "Limousin" [13] "MaineAnjou" "Montbeliard" "Salers" titi <- toto[1:3,] popnames(titi) [1] "Borgou" "Zebu" "Lagunaire" 32
33 The object toto has been subsetted, keeping only the first three populations. Of course, any subsetting available for a matrix can be used with genind and genpop objects. In addition, we can subset loci directly using indices or logicals, in which case they refer to the output of locnames: nall(titi) INRA63 INRA5 ETH225 ILSTS5 HEL5 HEL1 INRA35 ETH152 INRA ETH10 HEL9 CSSM66 INRA32 ETH3 BM2113 BM1824 HEL13 INRA BM1818 ILSTS6 MM12 CSRM60 ETH185 HAUT24 HAUT27 TGLA227 TGLA TGLA122 TGLA53 SPS tata <- titi[,loc=c(1,3)] tata /// GENPOP OBJECT ///////// // 3 populations; 2 loci; 21 alleles; size: 18.1 Kb // Basic 3 x 21 matrix of allele number of alleles per locus (range: locus factor for the 21 list of allele names for each ploidy of each individual (range: = x, i = i, j = j, loc =..1, drop = drop) // Optional a list containing: coun breed spe nall(tata) INRA63 ETH Alternatively, one can subset loci using their explicit name: locnames(titi) [1] "INRA63" "INRA5" "ETH225" "ILSTS5" "HEL5" "HEL1" "INRA35" [8] "ETH152" "INRA23" "ETH10" "HEL9" "CSSM66" "INRA32" "ETH3" 33
34 [15] "BM2113" "BM1824" "HEL13" "INRA37" "BM1818" "ILSTS6" "MM12" [22] "CSRM60" "ETH185" "HAUT24" "HAUT27" "TGLA227" "TGLA126" "TGLA122" [29] "TGLA53" "SPS115" hel5 <- titi[,loc="hel5"] hel5 /// GENPOP OBJECT ///////// // 3 populations; 1 locus; 11 alleles; size: 16.5 Kb // Basic 3 x 11 matrix of allele number of alleles per locus (range: locus factor for the 11 list of allele names for each ploidy of each individual (range: = x, i = i, j = j, loc = "HEL5", drop = drop) // Optional a list containing: coun breed spe locnames(hel5) [1] "HEL5" To simplify the task of separating data by marker systematically, the function seploc can be used. It returns a list of objects (optionnaly, of data matrices), each corresponding to a marker: data(nancycats) sepcats <- seploc(nancycats) class(sepcats) [1] "list" names(sepcats) [1] "fca8" "fca23" "fca43" "fca45" "fca77" "fca78" "fca90" "fca96" "fca37" sepcats$fca45 /// GENIND OBJECT ///////// // 237 individuals; 1 locus; 9 alleles; size: 31.3 Kb 34
35 // Basic 237 x 9 matrix of allele number of alleles per locus (range: locus factor for the 9 list of allele names for each ploidy of each individual (range: = x) // Optional population of each individual (group size range: a list containing: xy identical(tab(sepcats$fca45), tab(nancycats[,loc="fca45"])) [1] TRUE The object sepcats$fca45 only contains data of the marker fca45. Following the same idea, seppop allows one to separate genotypes in a genind object by population. For instance, we can separate genotype of cattles in the dataset microbov by breed: data(microbov) obj <- seppop(microbov) class(obj) [1] "list" names(obj) [1] "Borgou" "Zebu" "Lagunaire" [4] "NDama" "Somba" "Aubrac" [7] "Bazadais" "BlondeAquitaine" "BretPieNoire" [10] "Charolais" "Gascon" "Limousin" [13] "MaineAnjou" "Montbeliard" "Salers" obj$borgou /// GENIND OBJECT ///////// // 50 individuals; 30 loci; 373 alleles; size: Kb // Basic content 35
36 @tab: 50 x 373 matrix of allele number of alleles per locus (range: locus factor for the 373 list of allele names for each ploidy of each individual (range: = x, i = i, j = j, treatother =..1, quiet =..2, drop = drop) // Optional population of each individual (group size range: a list containing: coun breed spe The returned object obj is a list of genind objects each containing genotypes of a given breed. A last, rather vicious trick is to separate data by population and by marker. This is easy using lapply; one can first separate population then markers, or the contrary. Here, we separate markers inside each breed in obj: obj <- lapply(obj,seploc) names(obj) [1] "Borgou" "Zebu" "Lagunaire" [4] "NDama" "Somba" "Aubrac" [7] "Bazadais" "BlondeAquitaine" "BretPieNoire" [10] "Charolais" "Gascon" "Limousin" [13] "MaineAnjou" "Montbeliard" "Salers" class(obj$borgou) [1] "list" names(obj$borgou) [1] "INRA63" "INRA5" "ETH225" "ILSTS5" "HEL5" "HEL1" "INRA35" [8] "ETH152" "INRA23" "ETH10" "HEL9" "CSSM66" "INRA32" "ETH3" [15] "BM2113" "BM1824" "HEL13" "INRA37" "BM1818" "ILSTS6" "MM12" [22] "CSRM60" "ETH185" "HAUT24" "HAUT27" "TGLA227" "TGLA126" "TGLA122" [29] "TGLA53" "SPS115" obj$borgou$inra63 /// GENIND OBJECT ///////// // 50 individuals; 1 locus; 9 alleles; size: 12.9 Kb // Basic content 36
37 @tab: 50 x 9 matrix of allele number of alleles per locus (range: locus factor for the 9 list of allele names for each ploidy of each individual (range: = x) // Optional population of each individual (group size range: a list containing: coun breed spe For instance, obj$borgou$inra63 contains genotypes of the breed Borgou for the marker INRA63. Lastly, one may want to pool genotypes in different datasets, but having the same markers, into a single dataset. This is more than just merging components of all datasets, because alleles can differ (they almost always do) and markers are not necessarily sorted the same way. The function repool is designed to avoid these problems. It can merge any genind provided as arguments as soon as the same markers are used. For instance, it can be used after a seppop to retain only some populations: obj <- seppop(microbov) names(obj) [1] "Borgou" "Zebu" "Lagunaire" [4] "NDama" "Somba" "Aubrac" [7] "Bazadais" "BlondeAquitaine" "BretPieNoire" [10] "Charolais" "Gascon" "Limousin" [13] "MaineAnjou" "Montbeliard" "Salers" newobj <- repool(obj$borgou, obj$charolais) newobj /// GENIND OBJECT ///////// // 105 individuals; 30 loci; 295 alleles; size: Kb // Basic 105 x 295 matrix of allele number of alleles per locus (range: locus factor for the 295 list of allele names for each ploidy of each individual (range: codom 37
38 @call: repool(obj$borgou, obj$charolais) // Optional population of each individual (group size range: 50-55) popnames(newobj) [1] "Borgou" "Charolais" Done! Note that the content can be processed during the conversion from genind to genpop if the argument process.other is set to TRUE. Only vectors of a length, or matrices with a number of rows matching the number individuals will be processed. The way they are processed is defined by a function passed as the argument other.action (defaulting to mean ). Let us illustrate this using sim2pop: data(sim2pop) sim2pop /// GENIND OBJECT ///////// // 130 individuals; 20 loci; 241 alleles; size: Kb // Basic 130 x 241 matrix of allele number of alleles per locus (range: locus factor for the 241 list of allele names for each ploidy of each individual (range: old2new(object = sim2pop) // Optional population of each individual (group size range: a list containing: xy nind(sim2pop) [1] 130 head(other(sim2pop)$xy) x y [1,]
39 [2,] [3,] [4,] [5,] [6,] dim(other(sim2pop)$xy) [1] The component sim2pop@other$xy contains spatial coordinates of individuals from 2 populations. other(genind2genpop(sim2pop, process.other=true)) Converting data from a genind to a genpop object......done. $xy x y P P In this case, numeric vectors with a length corresponding to the number of individuals will we averaged per groups; note that any other function than mean can be used by providing any function to the argument other.action. Matrices with a number of rows corresponding to the number of individuals are processed similarly. 5.2 Using summaries Both genind and genpop objects have a summary providing basic information about data. Informations are both printed and invisibly returned as a list. toto <- summary(nancycats) # Total number of genotypes: 237 # Population sample sizes: P01 P02 P03 P04 P05 P06 P07 P08 P09 P10 P11 P12 P13 P14 P15 P16 P # Number of alleles per locus: 39
40 fca8 fca23 fca43 fca45 fca77 fca78 fca90 fca96 fca # Number of alleles per population: P01 P02 P03 P04 P05 P06 P07 P08 P09 P10 P11 P12 P13 P14 P15 P16 P # Percentage of missing data: [1] # Observed heterozygosity: fca8 fca23 fca43 fca45 fca77 fca78 fca fca96 fca # Expected heterozygosity: fca8 fca23 fca43 fca45 fca77 fca78 fca fca96 fca names(toto) [1] "N" "pop.eff" "loc.n.all" "pop.nall" "NA.perc" "Hobs" [7] "Hexp" par(mfrow=c(2,2)) plot(toto$pop.eff, toto$pop.nall, xlab="colonies sample size", ylab="number of alleles",main="alleles numbers and sample sizes", type="n") text(toto$pop.eff,toto$pop.nall,lab=names(toto$pop.eff)) barplot(toto$loc.n.all, ylab="number of alleles", main="number of alleles per locus") barplot(toto$hexp-toto$hobs, main="heterozygosity: expected-observed", ylab="hexp - Hobs") barplot(toto$pop.eff, main="sample sizes per population", ylab="number of genotypes",las=3) 40
41 Alleles numbers and sample sizes Number of alleles per locus Number of alleles P06 P08 P12 P03 P05 P10 P09 P13 P15 P07 P16 P01 P17 P14 P11 P02 P04 Number of alleles fca8 fca43 fca77 fca90 fca37 Colonies sample size Heterozygosity: expected observed Sample sizes per population Hexp Hobs Number of genotypes fca8 fca43 fca77 fca90 fca37 P01 P02 P03 P04 P05 P06 P07 P08 P09 P10 P11 P12 P13 P14 P15 P16 P17 Is mean observed H significantly lower than mean expected H? bartlett.test(list(toto$hexp,toto$hobs)) Bartlett test of homogeneity of variances data: list(toto$hexp, toto$hobs) Bartlett's K-squared = , df = 1, p-value = t.test(toto$hexp,toto$hobs,pair=t,var.equal=true,alter="greater") Paired t-test data: toto$hexp and toto$hobs t = , df = 8, p-value = 1.631e-05 alternative hypothesis: true difference in means is greater than 0 95 percent confidence interval: 41
42 Inf sample estimates: mean of the differences Yes, it is. 5.3 Testing for Hardy-Weinberg equilibrium As of version 2.0.0, adegenet is designed to work alongside a number of other packages, especially pegas and hierfstat for a number of classical population genetics methods. The former function HWE.test.genind has consequently been removed, and replaced by pegas s hw.test, which performs one test per locus: library(pegas) data(nancycats) cats.hwt <- hw.test(nancycats, B=0) cats.hwt chi^2 df Pr(chi^2 >) fca e+00 fca e+00 fca e+00 fca e-03 fca e+00 fca e+00 fca e+00 fca e-14 fca e-10 Note that B=0 is used for the parametric version; larger numbers will indicate the number of permutations to use for a Monte-Carlo version. 5.4 Measuring and testing population structure (a.k.a F statistics) Population structure is traditionally measured and tested using F statistics, in particular F st. As of version 2.0.0, adegenet relies on hierfstat and pegas for most F statistics. Note that some of these features might be part of the current devel version of hierfstat, which can be installed by: library(devtools) install_github("jgx65/hierfstat") Can we find any population structure in the cat colonies from Nancy? statistics are provided by: The basic F 42
43 library("hierfstat") fstat(nancycats) pop Ind Total pop This table provides the three F statistics F st (pop/total), F it (Ind/total), and F is (ind/pop). These are overall measures which take into account all genotypes and all loci. For more detail, pegas provides estimates by locus: library(pegas) Fst(as.loci(nancycats)) Fit Fst Fis fca fca fca fca fca fca fca fca fca Are these values significant? This question can be addressed using the G-statistic test [3]; it is implemented for genind objects and produces a randtest object (package ade4). Gtest <- gstat.randtest(nancycats,nsim=99) Gtest Monte-Carlo test Call: gstat.randtest(x = nancycats, nsim = 99) Observation: Based on 99 replicates Simulated p-value: 0.01 Alternative hypothesis: greater Std.Obs Expectation Variance plot(gtest) 43
44 Histogram of sim Frequency Finally, pairwise F st is frequently used as a measure of distance between populations. The function pairwise.fst computes Nei s estimator [11] of pairwise F st, defined as: F st(a, B) = H t (n A H s (A) + n B H s (B))/(n A + n B ) Ht where A and B refer to the two populations of sample size n A and n B and respective expected heterozygosity H s (A) and H s (B), and H t is the expected heterozygosity in the whole dataset. For a given locus, expected heterozygosity is computed as 1 p 2 i, where p i is the frequency of the ith allele, and the represents summation over all alleles. For multilocus data, the heterozygosity is simply averaged over all loci. These computations are achieved for all pairs of populations by the function pairwise.fst; we illustrate this on a subset of individuals of nancycats (computations for the whole dataset would take a few tens of seconds): matfst <- pairwise.fst(nancycats[1:50,]) matfst sim
45 The resulting matrix is Euclidean when there are no missing values: is.euclid(matfst) [1] TRUE It can therefore be used in a Principal Coordinate Analysis (which requires Euclideanity), used to build trees, etc. 5.5 Estimating inbreeding Inbreeding refers to an excess of homozygosity in a given individual due to the mating of genetically related parents. This excess of homozygosity is due to the fact that there are non-negligible chances of inheriting two identical alleles from a recent common ancestor. Inbreeding can be associated to a loss of fitness leading to inbreeding depression. Typically, loss of fitness is caused by recessive deleterious alleles which have usually low frequency in the population, but for which inbred individuals are more likely to be homozygotes. The inbreeding coefficient F is defined as the probability that at a given locus, two identical alleles have been inherited from a common ancestor. In the absence of inbreeding, the probability of being homozygote at one loci is (for diploid individuals) simply i p2 i where i indexes the alleles and p i is the frequency of allele i. This can be generalized incorporating F as: p(homozygote) = F + (1 F ) i p 2 i and even more generally, for any ploidy π: p(homozygote) = F + (1 F ) i p π i This therefore allows for computing the likelihood of a given state (homozygote/heterozygote) in a given genotype (log-likelihood are summed across loci for more than one marker). This estimation is achieved by inbreeding. Depending on the value of the argument res.type, the function returns a sample from the likelihood function (res.type= sample ) or the likelihood function itself, as a R function (res.type= function ). While likelihood functions are quickly obtained and easy to display graphically, sampling from the distributions is more computer intensive but useful to derive summary statistics of the distributions. Here, we illustrate inbreeding using the microbov dataset, which contains cattle breeds genotypes for 30 microsatellites; to focus on breed Salers only, we use seppop: data(microbov) sal <- seppop(microbov)$salers sal 45
46 /// GENIND OBJECT ///////// // 50 individuals; 30 loci; 373 alleles; size: Kb // Basic 50 x 373 matrix of allele number of alleles per locus (range: locus factor for the 373 list of allele names for each ploidy of each individual (range: = x, i = i, j = j, treatother =..1, quiet =..2, drop = drop) // Optional population of each individual (group size range: a list containing: coun breed spe We first compute the mean inbreeding for each individual, and plot the resulting distribution: temp <- inbreeding(sal, N=100) class(temp) [1] "list" head(names(temp)) [1] "FRBTSAL9087" "FRBTSAL9088" "FRBTSAL9089" "FRBTSAL9090" "FRBTSAL9091" [6] "FRBTSAL9093" head(temp[[1]],20) [1] [7] [13] [19] temp is a list of values sampled from the likelihood distribution of each individual; means values are obtained for all individuals using sapply: Fbar <- sapply(temp, mean) 46
47 hist(fbar, col="firebrick", main="average inbreeding in Salers cattles") Average inbreeding in Salers cattles Frequency We can see that some individuals (actually, a single one) have higher inbreeding (>0.4). We can recompute inbreeding for this individual, asking for the likelihood function to be returned: which(fbar>0.4) FRBTSAL Fbar F <- inbreeding(sal, res.type="function")[which(fbar>0.4)] F $FRBTSAL9266 function (F) { args <- lapply(as.list(match.call())[-1l], eval, parent.frame()) names <- if (is.null(names(args))) 47
48 character(length(args)) else names(args) dovec <- names %in% vectorize.args do.call("mapply", c(fun = FUN, args[dovec], MoreArgs = list(args[!dovec]), SIMPLIFY = SIMPLIFY, USE.NAMES = USE.NAMES)) } <environment: 0x901de80> The output object F can seem a bit cryptic: it is an function embedded within a hidden environment. This does not matter, however, since it is easily represented: plot(f$frbtsal9266, main=paste("inbreeding of individual",names(f)), xlab="inbreeding (F)", ylab="probability density") Inbreeding of individual FRBTSAL9266 Probability density 0e+00 2e 09 4e 09 6e 09 8e Inbreeding (F) Indeed, this individual shows subsequent inbreeding, with about 50% chances of being homozygote through inheritance from a common ancestor of its parents. 48
49 6 Multivariate analysis 6.1 General overview Multivariate analysis consists in summarising a strongly multivariate information into a few synthetic variables. In genetics, such approaches are useful to get a simplified picture of the genetic diversity obersved amongst individuals or populations. A review of multivariate analysis in population genetics can be found in [7]. Here, we aim at providing an overview of some applications using methods implemented in ade4 and adegenet. Useful functions include: scalegen (adegenet): centre/scale allele frequencies and replaces missing data; useful, among other things, before running a principal component analysis (PCA). dudi.pca (ade4 ): implements PCA; can be used on transformed allele frequencies of individuals or populations. dudi.ca (ade4 ): implements Correspondance Analysis (CA); can be used on raw allele counts of populations (@tab slot in genpop objects). dist.genpop (adegenet): implements 5 pairwise genetic distances between populations pairwise.fst (adegenet): implements pairwise F ST, which is also a Euclidean distance between populations. dist (stats): computes pairwise distances between multivariate observations; can be used on raw or transformed allele frequencies. dudi.pco (ade4 ): implements Principal Coordinates Analysis (PCoA); this methods finds synthetic variables which summarize a Euclidean distance matrix as best as possible; can be used on outputs of dist, dist.genpop, and pairwise.fst. is.euclid (ade4 ): tests whether a distance matrix is Euclidean, which is a pre-requisite of PCoA. cailliez (ade4 ): renders a non-euclidean distance matrix Euclidean by adding a constant to all entries. dapc (adegenet): implements the Discriminant Analysis of Principal Components (DAPC [8]), a powerful method for the analysis of population genetic structures; see dedicated tutorial (dapc). spca (adegenet): implements the spatial Principal Component Analysis (spca [5]), a method for the analysis of spatial genetic structures; see dedicated tutorial (dapc). glpca (adegenet): implements PCA for genome-wide SNP data stored as genlight objects; see dedicated tutorial (genomics). 49
50 Besides the procedures themselves, graphic functions are also often of the utmost importance; these include: scatter (ade4,adegenet): generic function to display multivariate analyses; in practice, the most useful application for genetic data is the one implemented in adegenet for DAPC results. s.label (ade4 ): function used for basic display of principal components. loadingplot (adegenet): function used to display the loadings (i.e., contribution to a given structure) of alleles for a given principal component; annotates and returns the most contributing alleles. s.class (ade4 ): displays two quantitative variables with known groups of observations, using inertia ellipses for the groups; useful to represent principal components when groups are known. s.chull (ade4 ): same as s.class, except convex polygons are used rather than ellipses. s.value (ade4 ): graphical display of a quantitative variable distributed over a twodimensional space; useful to map principal components or allele frequencies over a geographic area. colorplot (adegenet): graphical display of 1 to 3 quantitative variables distributed over a two-dimensional space; useful for combined representations of principal components over a geographic area. Can also be used to produce color versions of traditional scatterplots. transp (adegenet): auxiliary function making colors transparent. num2col (adegenet): auxiliary function transforming a quantitative variable into colors using a given palette. assignplot (adegenet): specific plot of group membership probabilities for DAPC; see dedicated tutorial (dapc). compoplot (adegenet): specific STRUCTURE-like plot of group membership probabilities for DAPC; see dedicated tutorial (dapc). add.scatter (ade4 ): add inset plots to an existing figure. add.scatter.eig (ade4 ): specific application of add.scatter to add barplots of eigenvalues to an existing figure. In the sections below, we briefly illustrate how these tools can be combined to extract information from genetic data. 50
51 6.2 Performing a Principal Component Analysis on genind objects The tables contained in genind objects can be submitted to a Principal Component Analysis (PCA) to seek a summary of the genetic diversity among the sampled individuals. Such analysis is straightforward using adegenet to prepare data and ade4 for the analysis per se. One has first to replace missing data (NAs) and transform the allele frequencies in an appropriate way. These operations are achieved by scalegen. NAs are replaced by the mean allele frequency; different scaling options are available (argument method), but in general centring is sufficient since allele frequencies have inherently comparable variances. data(microbov) sum(is.na(microbov$tab)) [1] 6325 There are 6325 missing data. They will all be replaced by scalegen: X <- scalegen(microbov, NA.method="mean") class(x) [1] "matrix" dim(x) [1] X[1:5,1:5] INRA INRA INRA INRA INRA AFBIBOR AFBIBOR AFBIBOR AFBIBOR AFBIBOR Note that alternatively, we could have used na.replace to replace missing data, and then left the centring/scaling to dudi.pca. The analysis can now be performed. We disable the scaling in dudi.pca, which would erase the scaling choice made earlier in scalegen. Note: in practice, retained axes can be chosen interactively by removing the arguments scannf=false,nf=3. pca1 <- dudi.pca(x,cent=false,scale=false,scannf=false,nf=3) barplot(pca1$eig[1:50],main="pca eigenvalues", col=heat.colors(50)) 51
52 PCA eigenvalues pca1 Duality diagramm class: pca dudi $call: dudi.pca(df = X, center = FALSE, scale = FALSE, scannf = FALSE, nf = 3) $nf: 3 axis-components saved $rank: 343 eigen values: vector length mode content 1 $cw 373 numeric column weights 2 $lw 704 numeric row weights 3 $eig 343 numeric eigen values data.frame nrow ncol content 1 $tab modified array 2 $li row coordinates 52
53 3 $l row normed scores 4 $co column coordinates 5 $c column normed scores other elements: cent norm The output object pca1 is a list containing various information; of particular interest are: $eig: the eigenvalues of the analysis, indicating the amount of variance represented by each principal component (PC). $li: the principal components of the analysis; these are the synthetic variables summarizing the genetic diversity, usually visualized using scatterplots. $c1: the allele loadings, used to compute linear combinations forming the PCs; squared, they represent the contribution to each PCs. The basic scatterplot for this analysis can be obtained by: s.label(pca1$li) title("pca of microbov dataset\naxes 1-2") add.scatter.eig(pca1$eig[1:20], 3,1,2) PCA of microbov dataset axes 1 2 AFBTLAG9421 AFBTLAG9443 AFBTLAG9446 AFBTLAG9402 AFBTLAG9451 AFBTLAG9437 AFBTLAG9412 AFBTLAG9413 AFBTLAG9426 AFBTLAG9407 AFBTLAG9432 AFBTLAG9435 AFBTLAG9416 AFBTLAG9417 AFBTLAG9431 AFBTLAG9442 AFBTLAG9405 AFBTLAG9425 AFBTLAG9427 AFBTLAG9436 AFBTLAG9406 AFBTLAG9414 AFBTLAG9411 AFBTLAG9430 AFBTLAG9410 AFBTLAG9439 AFBTLAG9448 AFBTLAG9444 AFBTLAG9424 AFBTLAG9447 AFBTLAG9408 AFBTLAG9428 AFBTLAG9433 AFBTLAG9419 AFBTLAG9423 AFBTLAG9403 AFBTLAG9434 AFBTLAG9418 AFBTLAG9449 AFBTLAG9438 AFBTLAG9452 AFBTLAG9450 AFBTLAG9404 AFBTLAG9445 AFBTND215 AFBTSOM9385 AFBTLAG9409 AFBTLAG9420 AFBTLAG9429 AFBTLAG9440 AFBTLAG9441 AFBTSOM9388 AFBTLAG9422 AFBTLAG9415 AFBTND253 AFBTSOM9361 AFBTND211 AFBTND221 AFBTSOM9400 AFBTSOM9377 AFBTSOM9374 AFBTSOM9356 AFBTSOM9371 AFBTND216 AFBTND222 AFBTSOM9352 AFBTSOM9389 AFBTSOM9353 AFBTSOM9362 AFBTSOM9372 AFBTND258 AFBTND207 AFBTSOM9358 AFBTSOM9379 AFBTSOM9381 AFBTSOM9391 AFBTND242 AFBTND255 AFBTSOM9363 AFBTSOM9368 AFBTSOM9366 AFBTSOM9365 AFBTND213 AFBTND248 AFBTND202 AFBTND217 AFBTND205 AFBTND241 AFBTSOM9376 AFBTSOM9398 AFBTSOM9399 AFBTSOM9396 AFBTSOM9384 AFBTSOM9392 AFBTSOM9397 AFBTND292 AFBTND285 AFBTSOM9354 AFBTND214 AFBTND257 AFBTSOM9360 AFBTSOM9390 AFBTSOM9373 AFBTSOM9395 AFBTSOM9355 AFBTND223 AFBTND212 AFBTSOM9364 AFBTSOM9394 AFBTSOM9370 AFBTND244 AFBTSOM9367 AFBTND254 AFBTND209 AFBTSOM9375 AFBTSOM9393 AFBTSOM9382 AFBTSOM9380 AFBTSOM9359 AFBTSOM9386 AFBTND233 AFBTND259 AFBTND206 AFBTND284 AFBTSOM9387 FRBTBAZ26469 FRBTMBE1503 AFBTSOM9378 AFBTSOM9401 AFBTSOM9369 AFBTSOM9383 AFBIBOR9508 AFBIBOR9505 FRBTBAZ29246 FRBTBPN1937 FRBTAUB9213 FRBTGAS9057 AFBTSOM9357 FRBTMA25282 FRBTMA25614 FRBTBDA29877 FRBTMBE1514 FRBTBAZ30420 FRBTBAZ26401 FRBTBAZ26078 FRBTBAZ29253 AFBIBOR9511 AFBTND208 AFBIBOR9509 AFBIBOR9541 FRBTBAZ25957 FRBTBAZ26352 FRBTBAZ29259 FRBTBAZ30418 FRBTBAZ26112 FRBTBAZ15654 FRBTBAZ25576 AFBIBOR9542 FRBTAUB9076 FRBTBAZ25578 FRBTAUB9220 FRBTAUB9230 FRBTAUB9231 FRBTAUB9287 FRBTBAZ25950 FRBTBAZ26110 FRBTBAZ26092 FRBTBAZ26354 FRBTBAZ26439 FRBTBAZ29281 FRBTBAZ29598 FRBTBAZ26388 FRBTBAZ29244 FRBTBAZ29254 FRBTBAZ29262 FRBTBAZ29261 FRBTBAZ30429 FRBTBAZ30440 FRBTBDA29860 FRBTBDA29852 FRBTBDA35281 FRBTBDA36120 FRBTBPN1898 FRBTGAS9193 FRBTMBE1532 FRBTBDA29866 FRBTBDA35268 FRBTBPN1915 FRBTBAZ30531 FRBTBAZ30540 FRBTBDA29859 FRBTBDA35278 FRBTBPN1876 FRBTBPN1894 FRBTBPN1907 FRBTBPN1913 FRBTBPN1896 FRBTBPN25810 FRBTCHA25326 FRBTMA25433 FRBTCHA15994 FRBTLIM5133 FRBTCHA26798 FRBTMA25409 FRBTBPN1914 FRBTBDA35955 FRBTBPN1895 FRBTBDA35941 FRBTBDA29863 FRBTCHA30893 FRBTCHA30353 FRBTCHA26199 FRBTBDA35248 FRBTCHA15946 FRBTBPN1904 FRBTCHA25654 FRBTBDA35269 FRBTBDA35255 FRBTBPN1932 FRBTCHA25009 FRBTCHA25543 FRBTCHA25018 FRBTBDA29856 FRBTCHA25024 FRBTBDA29882 FRBTBAZ25954 FRBTBAZ26375 FRBTBAZ29272 FRBTBAZ30421 FRBTBDA29880 FRBTBPN1906 FRBTBAZ25956 FRBTBAZ26400 FRBTBAZ26097 FRBTBAZ26386 FRBTBAZ26396 AFBIBOR9517 FRBTBAZ30533 FRBTBAZ26463 FRBTBAZ26457 FRBTBAZ30539 FRBTBDA35262 FRBTBDA29854 FRBTBAZ30436 FRBTBDA29879 FRBTBDA35283 FRBTBDA35259 FRBTBDA29868 FRBTBDA35274 FRBTBPN1870 FRBTBDA35864 FRBTBDA35267 FRBTBPN1927 FRBTCHA25069 FRBTBDA35286 FRBTBPN1930 FRBTCHA15957 FRBTBPN1873 FRBTCHA25295 FRBTCHA26074 FRBTCHA30356 FRBTCHA26246 FRBTGAS14184 FRBTGAS9176 FRBTMA25522 FRBTGAS9177 FRBTGAS9178 FRBTGAS9058 FRBTGAS9197 FRBTLIM30818 FRBTLIM30821 FRBTLIM30825 FRBTLIM30820 FRBTGAS14187 FRBTCHA26040 FRBTCHA26011 FRBTCHA26800 FRBTCHA26792 FRBTCHA30896 FRBTCHA30884 FRBTGAS9170 FRBTLIM30816 FRBTLIM30826 FRBTLIM30833 FRBTCHA30878 FRBTLIM30832 FRBTLIM30831 FRBTBPN1928 FRBTBDA29855 FRBTAUB9288 FRBTAUB9226 FRBTBDA29858 FRBTAUB9232 FRBTAUB9235 FRBTAUB9074 FRBTAUB9070 FRBTAUB9210 FRBTAUB9064 AFBIBOR9510 AFBIBOR9521 FRBTAUB9079 FRBTBAZ15655 FRBTBAZ29247 FRBTAUB9286 FRBTAUB9228 FRBTAUB9290 FRBTBDA29857 FRBTBDA29870 FRBTBDA35243 FRBTBDA35877 FRBTBPN1897 FRBTBPN1899 FRBTBPN1911 FRBTBDA29864 FRBTBDA29862 FRBTBDA29881 FRBTBDA35446 FRBTBPN1934 FRBTCHA15985 FRBTCHA25322 FRBTBDA29865 FRBTBDA29853 FRBTBDA29872 FRBTBDA35245 FRBTBDA35284 FRBTBDA35256 FRBTBDA29869 AFBIBOR9519 AFBIBOR9533 AFBIBOR9512 AFBIBOR9548 FRBTAUB9067 FRBTAUB9061 FRBTAUB9069 FRBTAUB9078 FRBTAUB9212 FRBTAUB9222 FRBTAUB9227 FRBTAUB9237 FRBTBAZ26403 FRBTBDA29851 FRBTBDA35260 FRBTBDA35899 FRBTBDA35916 FRBTCHA25015 FRBTBDA35379 FRBTBDA29875 FRBTAUB9216 FRBTAUB9075 FRBTBDA35244 FRBTAUB9221 FRBTBDA35258 FRBTBDA35931 FRBTBPN1872 FRBTBPN1902 FRBTBPN1910 FRBTCHA25995 FRBTCHA26014 FRBTCHA26789 FRBTGAS9175 FRBTGAS9179 FRBTGAS9051 FRBTGAS9053 FRBTGAS9059 FRBTCHA30344 FRBTLIM30829 FRBTCHA26793 FRBTLIM30830 FRBTGAS9190 FRBTCHA25513 FRBTCHA26054 FRBTCHA26193 FRBTCHA26784 FRBTCHA26196 FRBTBPN1935 FRBTCHA26202 FRBTCHA26783 FRBTCHA26285 FRBTBPN25811 FRBTCHA26205 FRBTCHA26274 FRBTCHA25390 FRBTCHA26785 FRBTGAS9205 FRBTGAS9055 FRBTCHA26786 FRBTCHA30879 FRBTCHA30373 FRBTCHA30335 FRBTGAS14188 FRBTCHA30391 FRBTGAS9174 FRBTGAS9195 FRBTLIM30835 FRBTLIM30841 FRBTLIM30850 FRBTLIM30842 FRBTLIM30843 FRBTLIM30846 FRBTLIM30847 FRBTLIM30845 FRBTLIM30853 FRBTLIM30844 FRBTLIM30849 FRBTLIM30859 FRBTMA25588 FRBTLIM5137 FRBTMA29945 FRBTMBE1516 FRBTMA25917 FRBTMA25922 FRBTMA26280 FRBTMA29572 FRBTMBE1536 FRBTMA26035 FRBTMA25896 FRBTMA25982 FRBTLIM30858 FRBTMA25273 FRBTMA26321 FRBTMA25436 FRBTMA29561 FRBTMA26168 FRBTMA25530 FRBTMA25387 FRBTMA25820 FRBTCHA30382 FRBTLIM5135 FRBTCHA30886 FRBTLIM30819 FRBTGAS9181 FRBTLIM30827 FRBTGAS9052 FRBTGAS9204 FRBTLIM3001 FRBTLIM30828 FRBTLIM30836 FRBTLIM30860 FRBTMA25423 FRBTMA25488 FRBTLIM30848 FRBTMA25684 FRBTMA25439 FRBTMA26019 FRBTMA26022 FRBTMA29806 FRBTMA29950 FRBTMA29952 FRBTMBE1529 FRBTMA29819 FRBTMA29812 FRBTMA29571 FRBTGAS14185 FRBTGAS9172 FRBTGAS9180 FRBTCHA26790 FRBTCHA30341 FRBTGAS9056 FRBTGAS9183 FRBTLIM30817 FRBTLIM30857 FRBTMA25612 FRBTMA29943 FRBTMBE1507 FRBTMA26491 FRBTMBE1497 FRBTMBE1510 FRBTMBE1520 FRBTMBE1538 FRBTSAL9266 FRBTMBE1534 FRBTMBE1513 FRBTMBE1531 FRBTMBE1519 FRBTSAL9089 FRBTMBE1535 FRBTMA25978 FRBTSAL9246 FRBTSAL9268 FRBTSAL9280 FRBTGAS9050 FRBTGAS14183 FRBTGAS9184 FRBTBDA36124 FRBTGAS14180 FRBTAUB9229 FRBTCHA26797 FRBTBDA35485 FRBTBPN1875 FRBTGAS14186 FRBTAUB9081 FRBTBPN1877 FRBTGAS9049 FRBTGAS9182 FRBTGAS9198 FRBTGAS9185 FRBTGAS9189 FRBTLIM30824 FRBTLIM30834 FRBTMA25298 FRBTMA25412 FRBTMA26232 FRBTMBE1547 FRBTMBE1540 FRBTMA29948 FRBTMBE1502 FRBTMBE1505 FRBTMBE1549 FRBTSAL9248 FRBTMBE1508 FRBTSAL9253 FRBTSAL9242 FRBTSAL9272 FRBTLIM30840 FRBTGAS9202 FRBTLIM30851 FRBTMA25594 FRBTMBE1496 FRBTMBE1506 FRBTSAL9093 FRBTSAL9247 FRBTSAL9090 FRBTMA25428 FRBTGAS9054 FRBTGAS9060 FRBTGAS9171 AFBIBOR9528 AFBIBOR9549 FRBTAUB9077 FRBTBPN1901 FRBTAUB9066 FRBTAUB9073 FRBTAUB9068 FRBTGAS9173 FRBTGAS9186 FRBTGAS9199 FRBTGAS9200 FRBTLIM30822 FRBTLIM30823 FRBTGAS9201 FRBTLIM30838 FRBTLIM30839 FRBTLIM30854 FRBTMA25902 FRBTMBE1511 FRBTMBE1541 FRBTSAL9250 FRBTSAL9273 FRBTSAL9285 FRBTSAL9276 FRBTMBE1548 FRBTMA25278 FRBTLIM30852 FRBTMBE1517 FRBTSAL9100 FRBTSAL9094 FRBTSAL9249 FRBTLIM30855 FRBTMBE1523 FRBTMBE1544 FRBTSAL9101 FRBTSAL9261 FRBTSAL9256 FRBTSAL9260 FRBTSAL9277 FRBTAUB9211 FRBTAUB9234 FRBTBDA29861 FRBTBDA29873 FRBTBDA35280 FRBTMA25382 FRBTSAL9091 FRBTLIM30856 FRBTSAL9257 FRBTSAL9284 FRBTSAL9283 FRBTSAL9259 FRBTSAL9262 FRBTMA29809 FRBTAUB9223 FRBTGAS9188 FRBTGAS9203 FRBTAUB9208 FRBTAUB9219 FRBTAUB9062 FRBTAUB9225 FRBTLIM5136 AFBIBOR9543 AFBIBOR9536 AFBIBOR9540 AFBIBOR9507 AFBIBOR9529 FRBTLIM30837 FRBTSAL9099 FRBTMA25418 FRBTSAL9275 FRBTSAL9095 FRBTSAL9088 FRBTSAL9096 FRBTSAL9243 FRBTSAL9271 FRBTSAL9252 FRBTSAL9097 FRBTSAL9265 FRBTBDA29878 FRBTAUB9238 FRBTAUB9072 FRBTSAL9270 FRBTSAL9258 FRBTSAL9267 AFBIBOR9532 AFBIBOR9530 FRBTAUB9063 AFBIZEB9465 AFBIBOR9545 AFBIBOR9531 FRBTAUB9224 FRBTAUB9218 FRBTSAL9087 FRBTSAL9102 FRBTSAL9103 FRBTSAL9241 FRBTBDA29874 FRBTSAL9245 FRBTSAL9251 FRBTSAL9255 FRBTAUB9289 FRBTAUB9071 FRBTAUB9065 AFBIBOR9513 AFBIBOR9514 AFBIBOR9524 AFBIBOR9518 AFBIBOR9515 AFBIBOR9539 AFBIBOR9527 AFBIBOR9535 AFBIBOR9537 AFBIZEB9468 AFBIZEB9489 AFBIBOR9522 AFBIBOR9516 AFBIZEB9478 AFBIBOR9538 AFBIBOR9520 AFBIBOR9525 AFBIBOR9504 AFBIBOR9547 AFBIBOR9506 AFBIBOR9544 AFBIZEB9485 AFBIBOR9546 AFBIBOR9552 AFBIBOR9534 AFBIBOR9526 AFBIZEB9463 AFBIZEB9458 AFBIZEB9491 AFBIBOR9523 AFBIZEB9467 AFBIZEB9480 AFBIBOR9551 AFBIZEB9464 AFBIZEB9470 AFBIZEB9473 AFBIZEB9475 AFBIZEB9481 AFBIZEB9486 AFBIZEB9497 AFBIZEB9482 AFBIZEB9476 AFBIZEB9490 AFBIZEB9461 Eigenvalues AFBIZEB9471 AFBIZEB9479 AFBIBOR9503 AFBIZEB9500 AFBIZEB9495 AFBIZEB9487 AFBIZEB9457 AFBIBOR9550 AFBIZEB9484 AFBIZEB9488 AFBIZEB9498 AFBIZEB9462 AFBIZEB9453 AFBIZEB9456 AFBIZEB9466 AFBIZEB9493 AFBIZEB9483 AFBIZEB9492 AFBIZEB9472 AFBIZEB9494 AFBIZEB9477 AFBIZEB9502 AFBIZEB9469 AFBIZEB9501 AFBIZEB9474 AFBIZEB9459 AFBIZEB9455 AFBIZEB9499 AFBIZEB9460 AFBIZEB9454 AFBIZEB9496 d = 5 53
54 However, this figure can largely be improved. First, we can use s.class to represent both the genotypes and inertia ellipses for populations. s.class(pca1$li, pop(microbov)) title("pca of microbov dataset\naxes 1-2") add.scatter.eig(pca1$eig[1:20], 3,1,2) d = 5 Borgou Zebu Lagunaire NDama Somba Aubrac Bazadais BlondeAquitaine BretPieNoire Charolais Gascon Limousin MaineAnjou Montbeliard Salers PCA of microbov dataset axes 1 2 Eigenvalues This plane shows that the main structuring is between African an French breeds, the second structure reflecting genetic diversity among African breeds. The third axis reflects the diversity among French breeds: s.class(pca1$li,pop(microbov),xax=1,yax=3,sub="pca 1-3",csub=2) title("pca of microbov dataset\naxes 1-3") add.scatter.eig(pca1$eig[1:20],nf=3,xax=1,yax=3) 54
55 d = 5 PCA 1 3 Borgou Zebu Lagunaire NDama Somba Aubrac Bazadais BlondeAquitaine BretPieNoire Charolais Gascon Limousin MaineAnjou Montbeliard Salers PCA of microbov dataset axes 1 3 Eigenvalues Overall, all breeds seem well differentiated. However, we can yet improve these scatterplots, which are fortunately easy to customize. For instance, we can remove the grid, choose different colors for the groups, use larger dots and transparency to better assess the density of points, and remove internal segments of the ellipses: col <- funky(15) s.class(pca1$li, pop(microbov),xax=1,yax=3, col=transp(col,.6), axesell=false, cstar=0, cpoint=3, grid=false) 55
56 MaineAnjou Charolais BretPieNoire Montbeliard BlondeAquitaine Salers Gascon Limousin Aubrac Bazadais Lagunaire NDama Somba Zebu Borgou Let us now assume that we ignore the group memberships. We can still use color in an informative way. For instance, we can recode the principal components represented in the scatterplot on the RGB scale: colorplot(pca1$li, pca1$li, transp=true, cex=3, xlab="pc 1", ylab="pc 2") title("pca of microbov dataset\naxes 1-2") abline(v=0,h=0,col="grey", lty=2) 56
57 PCA of microbov dataset axes 1 2 PC Colors are based on the first three PCs of the PCA, recoded respectively on the red, green, and blue channel. In this figure, the genetic diversity is represented in two complementary ways: by the distances (further away = more genetically different), and by the colors (more different colors = more genetically different). PC 1 We can represent the diversity on the third axis similarly: colorplot(pca1$li[c(1,3)], pca1$li, transp=true, cex=3, xlab="pc 1", ylab="pc 3") title("pca of microbov dataset\naxes 1-3") abline(v=0,h=0,col="grey", lty=2) 57
58 PCA of microbov dataset axes 1 3 PC PC Performing a Correspondance Analysis on genpop objects Being contingency tables, slot in genpop objects can be submitted to a Correspondance Analysis (CA) to seek a typology of populations. The approach is very similar to the previous one for PCA. data(microbov) obj <- genind2genpop(microbov) Converting data from a genind to a genpop object......done. ca1 <- dudi.coa(tab(obj),scannf=false,nf=3) barplot(ca1$eig,main="correspondance Analysis eigenvalues", col=heat.colors(length(ca1$eig))) 58
59 Correspondance Analysis eigenvalues Now we display the resulting typology using a basic scatterplot: s.label(ca1$li, sub="ca 1-2",csub=2) add.scatter.eig(ca1$eig,nf=3,xax=1,yax=2,posi="bottomright") 59
60 d = 0.5 Zebu Borgou Aubrac Salers BlondeAquitaine Gascon BretPieNoire Charolais Limousin MaineAnjou Montbeliard Bazadais NDama Somba Eigenvalues CA 1 2 Lagunaire The same graph is derived for the axes 2-3: s.label(ca1$li,xax=2,yax=3,lab=popnames(obj),sub="ca 1-3",csub=2) add.scatter.eig(ca1$eig,nf=3,xax=2,yax=3,posi="topleft") 60
61 Eigenvalues d = 0.5 MaineAnjou Charolais BretPieNoire Lagunaire NDama Somba Borgou Montbeliard BlondeAquitaine Gascon Limousin Aubrac Salers Zebu Bazadais CA 1 3 As in the PCA above, axes are to be interpreted separately in terms of continental differentiation, and between-breeds diversity. Importantly, as in any analysis carried out at a population level, all information about the diversity within populations is lost in this analysis. See the tutorial on DAPC for an individual-based approach which is nontheless optimal in terms of group separation (dapc). Note that as an alternative, wordcloud can be used to avoid overlaps in labels: library(wordcloud) set.seed(1) s.label(ca1$li*1.2, sub="ca 1-2",csub=2, clab=0, cpoint="") textplot(ca1$li[,1], ca1$li[,2], words=popnames(obj), cex=1.4, new=false, xpd=true) add.scatter.eig(ca1$eig,nf=3,xax=1,yax=2,posi="bottomright") 61
62 d = 0.5 Zebu Borgou Salers Gascon Aubrac MaineAnjou BlondeAquitaine Bazadais BretPieNoire CharolaisLimousin Montbeliard NDama Somba Eigenvalues Lagunaire CA 1 2 However, only general trends can be interpreted: labels positions are randomised to avoid overlap, so they no longer accurately position populations on the factorial axes. 62
63 7 Spatial analysis The R software probably offers the largest collection of spatial methods among statistical software. Here, we briefly illustrate two methods commonly used in population genetics. Spatial multivariate analysis is covered in a dedicated tutorial; see spca tutorial for more information. 7.1 Isolation by distance Testing isolation by distance Isolation by distance (IBD) is tested using Mantel test between a matrix of genetic distances and a matrix of geographic distances. It can be tested using individuals as well as populations. This example uses cat colonies from the city of Nancy. We test the correlation between Edwards distances and Euclidean geographic distances between colonies. data(nancycats) toto <- genind2genpop(nancycats) Converting data from a genind to a genpop object......done. Dgen <- dist.genpop(toto,method=2) Dgeo <- dist(nancycats$other$xy) ibd <- mantel.randtest(dgen,dgeo) ibd Monte-Carlo test Call: mantel.randtest(m1 = Dgen, m2 = Dgeo) Observation: Based on 999 replicates Simulated p-value: Alternative hypothesis: greater Std.Obs Expectation Variance plot(ibd) 63
64 Histogram of sim Frequency The original value of the correlation between the distance matrices is represented by the dot, while histograms represent permuted values (i.e., under the absence of spatial structure). Significant spatial structure would therefore result in the original value being out of the reference distribution. Here, isolation by distance is clearly not significant. Let us provide another example using a dataset of individuals simulated under an IBD model: data(spcaillus) x <- spcaillus$dat2b Dgen <- dist(x$tab) Dgeo <- dist(other(x)$xy) ibd <- mantel.randtest(dgen,dgeo) ibd Monte-Carlo test Call: mantel.randtest(m1 = Dgen, m2 = Dgeo) Observation: sim 64
65 Based on 999 replicates Simulated p-value: Alternative hypothesis: greater Std.Obs Expectation Variance plot(ibd) Histogram of sim Frequency This time there is a clear isolation by distance pattern Cline or distant patches? The correlation between genetic and geographic distances can occur under a range of different biological scenarios. Classical IBD would result in continuous clines of genetic differentiation and cause such correlation. However, distant and differentiated populations would also result in such a pattern. These are slightly different processes and we would like to be able to disentangle them. A very simple first approach is simply plotting both distances: 65 sim
66 plot(dgeo, Dgen) abline(lm(dgen~dgeo), col="red",lty=2) Dgeo Dgen Most of the time, simple scatterplots fail to provide a good picture of the data as the density of points in the scatterplot is badly displayed. Colors can be used to provide better (and prettier) plots. Local density is measured using a 2-dimensional kernel density estimation (kde2d), and the results are displayed using image; colorramppalette is used to generate a customized color palette: library(mass) dens <- kde2d(dgeo,dgen, n=300) mypal <- colorramppalette(c("white","blue","gold", "orange", "red")) plot(dgeo, Dgen, pch=20,cex=.5) image(dens, col=transp(mypal(300),.7), add=true) abline(lm(dgen~dgeo)) title("isolation by distance plot") 66
67 Dgeo Dgen Isolation by distance plot The scatterplot clearly shows one single consistent cloud of point, without discontinuities which would have indicated patches. This is reassuring, since the data were actually simulated under an IBD (continuous) model. 7.2 Using Monmonier s algorithm to define genetic boundaries Monmonier s algorithm [10] was originally designed to find boundaries of maximum differences between contiguous polygons of a tesselation. As such, the method was basically used in geographical analysis. More recently, [9] suggested that this algorithm could be employed to detect genetic boundaries among georeferecend genotypes (or populations). This algorithm is implemented using a more general approach than the initial one in adegenet. Instead of using Voronoi tesselation as in the original version, the functions monmonier and optimize.monmonier can handle various neighbouring graphs such as Delaunay triangulation, Gabriel s graph, Relative Neighbours graph, etc. These graphs define spatial connectivity among locations (of genotypes or populations), with couple of locations being neighbours (if connected) or not. Another information is given by a set of markers which define genetic distances among these points. The aim of Monmonier s algorithm is to find the path through the strongest genetic distances between neighbours. A more complete description of the principle of this algorithm will be found in the documentation of 67
68 monmonier. Indeed, the very purpose of this tutorial is simply to show how it can be used on genetic data. Let s take the example from the function s manpage and detail it. The dataset used is sim2pop. data(sim2pop) sim2pop /// GENIND OBJECT ///////// // 130 individuals; 20 loci; 241 alleles; size: Kb // Basic 130 x 241 matrix of allele number of alleles per locus (range: locus factor for the 241 list of allele names for each ploidy of each individual (range: old2new(object = sim2pop) // Optional population of each individual (group size range: a list containing: xy summary(sim2pop$pop) P01 P temp <- sim2pop$pop levels(temp) <- c(3,5) temp <- as.numeric(as.character(temp)) plot(sim2pop$other$xy,pch=temp,cex=1.5,xlab='x',ylab='y') legend("topright",leg=c("pop A", "Pop B"),pch=c(3,5)) 68
69 y Pop A Pop B x There are two sampled populations in this dataset, with inequal sample sizes (100 and 30). Twenty microsatellite-like loci are available for all genotypes (no missing data). monmonier requires several arguments to be specified: args(monmonier) function (xy, dist, cn, threshold = NULL, bd.length = NULL, nrun = 1, skip.local.diff = rep(0, nrun), scanthres = is.null(threshold), allowloop = TRUE) NULL The first argument (xy) is a matrix of geographic coordinates, already stored in sim2pop. Next argument is an object of class dist, which is the matrix of pairwise genetic distances. For now, we will use the classical Euclidean distance between allelic profiles of the individuals. This is obtained by: D <- dist(sim2pop$tab) The next argument (cn) is a connection network. Routines for building such networks are scattered over several packages, but all made available through the function choosecn. Here, 69
70 we disable the interactivity of the function (ask=false) and select the second type of graph which is the graph of Gabriel (type=2). gab <- choosecn(sim2pop$other$xy,ask=false,type=2) The obtained network is automatically plotted by the function. It seems we are now ready to proceed to the algorithm. mon1 <- monmonier(sim2pop$other$xy,d,gab) 70
71 This plot shows all local differences sorted in decreasing order. The idea behind this is that a significant boundary would cause local differences to decrease abruptly after the boundary. This should be used to choose the threshold difference for the algorithm to stop extending the boundary. Here, there is no indication af an actual boundary. Why do the algorithm fail to find a boundary? Either because there is no genetic differentiation to be found, or because the signal differentiating both populations is too weak to overcome the random noise in genetic distances. What is the F st between the two samples? pairwise.fst(sim2pop) This value would be considered as very weak differentiation (F ST = 0.023). Is it significant? We can easily ellaborate a permutation test of this F ST value; to save computational time, we use only a small number of replicates to generate F ST values in absence of population structure: replicate(10, pairwise.fst(sim2pop, pop=sample(pop(sim2pop)))) [1] [6] F ST values in absence of population structure would be one order of magnitude lower (more replicate would give a very low p-value just replace 10 by 200 in the above command). In fact, the two samples are indeed genetically differentiated. 71
72 Can Monmonier s algorithm find a boundary between the two populations? Yes, if we get rid of the random noise. This can be achieved using a simple ordination method such as Principal Coordinates Analysis. pco1 <- dudi.pco(d,scannf=false,nf=1) barplot(pco1$eig,main="eigenvalues") Eigenvalues We retain only the first eigenvalue. The corresponding coordinates are used to redefine the genetic distances among genotypes. The algorithm is then re-run. D <- dist(pco1$li) mon1 <- monmonier(sim2pop$other$xy,d,gab) 72
73 # # List of paths of maximum differences between neighbours # # Using a Monmonier based algorithm # # $call:monmonier(xy = sim2pop$other$xy, dist = D, cn = gab, scanthres = FALSE) # Object content # Class: monmonier $nrun (number of successive runs): 1 $run1: run of the algorithm $threshold (minimum difference between neighbours): $xy: spatial coordinates $cn: connection network # Runs content # # Run 1 # First direction Class: list $path: x y Point_ $values: # Second direction 73
74 Class: list $path: x y Point_ Point_ Point_ $values: This may take some time... but never more than five minutes on an ordinary personnal computer. The object mon1 contains the whole information about the boundaries found. As several boundaries can be seeked at the same time (argument nrun), you have to specify about which run and which direction you want to get informations (values of differences or path coordinates). For instance: names(mon1) [1] "run1" "nrun" "threshold" "xy" "cn" "call" names(mon1$run1) [1] "dir1" "dir2" mon1$run1$dir1 $path x y Point_ $values [1] It can also be useful to identify which points are crossed by the barrier; this can be done using coords.monmonier: coords.monmonier(mon1) $run1 $run1$dir1 x.hw y.hw first second Point_ $run1$dir2 74
75 x.hw y.hw first second Point_ Point_ Point_ Point_ Point_ Point_ Point_ Point_ Point_ Point_ Point_ Point_ Point_ Point_ Point_ Point_ Point_ Point_ Point_ Point_ Point_ The returned dataframe contains, in this order, the x and y coordinates of the points of the barrier, and the identifiers of the two parent points, that is, the points whose barycenter is the point of the barrier. Finally, you can plot very simply the obtained boundary using the method plot: plot(mon1) 75
76 see arguments in?plot.monmonier to customize this representation. Last, we can compare the infered boundary with the actual distribution of populations: plot(mon1,add.arrows=false,bwd=10,col="black") points(sim2pop$other$xy, cex=2, pch=20, col=fac2col(pop(sim2pop), col.pal=spectral)) legend("topright",leg=c("pop A", "Pop B"), pch=c(20), col=spectral(2), pt.cex=2) 76
77 Pop A Pop B Not too bad... 8 Simulating hybridization The function hybridize allows to simulate hybridization between individuals from two distinct genetic pools, or more broadly between two genind objects. Here, we use the example from the manpage of the function, to go a little further. Please have a look at the documentation, especially at the different possible outputs (outputs for the software STRUCTURE is notably available). temp <- seppop(microbov) names(temp) [1] "Borgou" "Zebu" "Lagunaire" [4] "NDama" "Somba" "Aubrac" [7] "Bazadais" "BlondeAquitaine" "BretPieNoire" [10] "Charolais" "Gascon" "Limousin" [13] "MaineAnjou" "Montbeliard" "Salers" 77
78 salers <- temp$salers zebu <- temp$zebu zebler <- hybridize(salers, zebu, n=40, pop="zebler") A first generation (F1) of hybrids zebler is obtained. Is it possible to perform a backcross, say, with salers population? Yes, here it is: F2 <- hybridize(salers, zebler, n=40) F3 <- hybridize(salers, F2, n=40) F4 <- hybridize(salers, F3, n=40) Finally, note that despite this example shows hybridization between diploid organisms, hybridize is not restrained to this case. In fact, organisms with any even level of ploidy can be used, in which case half of the genes is taken from each reference population. Ultimately, more complex mating schemes could be implemented... suggestion or (better) contributions are welcome! 78
79 References [1] D. Charif and J.R. Lobry. SeqinR 1.0-2: a contributed package to the R project for statistical computing devoted to biological sequences retrieval and analysis. In H.E. Roman U. Bastolla, M. Porto and M. Vendruscolo, editors, Structural approaches to sequence evolution: Molecules, networks, populations, Biological and Medical Physics, Biomedical Engineering, pages Springer Verlag, New York, ISBN : [2] S. Dray and A.-B. Dufour. The ade4 package: implementing the duality diagram for ecologists. Journal of Statistical Software, 22(4):1 20, [3] J. Goudet, M. Raymond, T. Meeüs, and F. Rousset. Testing differentiation in diploid populations. Genetics, 144: , [4] T. Jombart. adegenet: a R package for the multivariate analysis of genetic markers. Bioinformatics, 24: , [5] T. Jombart, S. Devillard, A.-B. Dufour, and D. Pontier. Revealing cryptic spatial patterns in genetic variability by a new multivariate method. Heredity, 101:92 103, [6] T. Jombart, R. M. Eggo, P. J. Dodd, and F. Balloux. Reconstructing disease outbreaks from genetic data: a graph approach. Heredity, 106: , [7] T. Jombart, D. Pontier, and A-B. Dufour. Genetic markers in the playground of multivariate analysis. Heredity, 102: , [8] Thibaut Jombart, Sebastien Devillard, and Francois Balloux. Discriminant analysis of principal components: a new method for the analysis of genetically structured populations. BMC Genetics, 11(1):94, [9] F. Manni, E. Guérard, and E. Heyer. Geographic patterns of (genetic, morphologic, linguistic) variation: how barriers can be detected by Monmonier s algorithm. Human Biology, 76: , [10] M. Monmonier. Maximum-difference barriers: an alternative numerical regionalization method. Geographical Analysis, 3: , [11] M. Nei. Analysis of gene diversity in subdivided populations. Proc Natl Acad Sci U S A, 70(12): , Dec [12] R Development Core Team. R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing, Vienna, Austria, ISBN
Reading Genetic Data Files Into R with adegenet and pegas
Reading Genetic Data Files Into R with adegenet and pegas Emmanuel Paradis June 24, 2015 adegenet [2] and pegas [4] are two packages that complement each other for population genetic analyses in R. Since
BAPS: Bayesian Analysis of Population Structure
BAPS: Bayesian Analysis of Population Structure Manual v. 6.0 NOTE: ANY INQUIRIES CONCERNING THE PROGRAM SHOULD BE SENT TO JUKKA CORANDER (first.last at helsinki.fi). http://www.helsinki.fi/bsg/software/baps/
SeattleSNPs Interactive Tutorial: Web Tools for Site Selection, Linkage Disequilibrium and Haplotype Analysis
SeattleSNPs Interactive Tutorial: Web Tools for Site Selection, Linkage Disequilibrium and Haplotype Analysis Goal: This tutorial introduces several websites and tools useful for determining linkage disequilibrium
http://biology.anu.edu.au/genalex/
!"##$%&'%"#("!"# Written by Michaela D.J. Blyton and Nicola S. Flanagan http://biology.anu.edu.au/genalex/ A Guide to GenAlEx 6.5 2 of 131 Table of contents Table of contents... 2! Introduction... 5! GenAlEx
Bioinformatics Resources at a Glance
Bioinformatics Resources at a Glance A Note about FASTA Format There are MANY free bioinformatics tools available online. Bioinformaticists have developed a standard format for nucleotide and protein sequences
OECD.Stat Web Browser User Guide
OECD.Stat Web Browser User Guide May 2013 May 2013 1 p.10 Search by keyword across themes and datasets p.31 View and save combined queries p.11 Customise dimensions: select variables, change table layout;
SeqScape Software Version 2.5 Comprehensive Analysis Solution for Resequencing Applications
Product Bulletin Sequencing Software SeqScape Software Version 2.5 Comprehensive Analysis Solution for Resequencing Applications Comprehensive reference sequence handling Helps interpret the role of each
BayeScan v2.1 User Manual
BayeScan v2.1 User Manual Matthieu Foll January, 2012 1. Introduction This program, BayeScan aims at identifying candidate loci under natural selection from genetic data, using differences in allele frequencies
GenBank, Entrez, & FASTA
GenBank, Entrez, & FASTA Nucleotide Sequence Databases First generation GenBank is a representative example started as sort of a museum to preserve knowledge of a sequence from first discovery great repositories,
Version 5.0 Release Notes
Version 5.0 Release Notes 2011 Gene Codes Corporation Gene Codes Corporation 775 Technology Drive, Ann Arbor, MI 48108 USA 1.800.497.4939 (USA) +1.734.769.7249 (elsewhere) +1.734.769.7074 (fax) www.genecodes.com
DataPA OpenAnalytics End User Training
DataPA OpenAnalytics End User Training DataPA End User Training Lesson 1 Course Overview DataPA Chapter 1 Course Overview Introduction This course covers the skills required to use DataPA OpenAnalytics
When you install Mascot, it includes a copy of the Swiss-Prot protein database. However, it is almost certain that you and your colleagues will want
1 When you install Mascot, it includes a copy of the Swiss-Prot protein database. However, it is almost certain that you and your colleagues will want to search other databases as well. There are very
UKB_WCSGAX: UK Biobank 500K Samples Genotyping Data Generation by the Affymetrix Research Services Laboratory. April, 2015
UKB_WCSGAX: UK Biobank 500K Samples Genotyping Data Generation by the Affymetrix Research Services Laboratory April, 2015 1 Contents Overview... 3 Rare Variants... 3 Observation... 3 Approach... 3 ApoE
Reading and writing files
Reading and writing files Importing data in R Data contained in external text files can be imported in R using one of the following functions: scan() read.table() read.csv() read.csv2() read.delim() read.delim2()
Didacticiel Études de cas. Association Rules mining with Tanagra, R (arules package), Orange, RapidMiner, Knime and Weka.
1 Subject Association Rules mining with Tanagra, R (arules package), Orange, RapidMiner, Knime and Weka. This document extends a previous tutorial dedicated to the comparison of various implementations
PaRFR : Parallel Random Forest Regression on Hadoop for Multivariate Quantitative Trait Loci Mapping. Version 1.0, Oct 2012
PaRFR : Parallel Random Forest Regression on Hadoop for Multivariate Quantitative Trait Loci Mapping Version 1.0, Oct 2012 This document describes PaRFR, a Java package that implements a parallel random
org.rn.eg.db December 16, 2015 org.rn.egaccnum is an R object that contains mappings between Entrez Gene identifiers and GenBank accession numbers.
org.rn.eg.db December 16, 2015 org.rn.egaccnum Map Entrez Gene identifiers to GenBank Accession Numbers org.rn.egaccnum is an R object that contains mappings between Entrez Gene identifiers and GenBank
The Scientific Data Mining Process
Chapter 4 The Scientific Data Mining Process When I use a word, Humpty Dumpty said, in rather a scornful tone, it means just what I choose it to mean neither more nor less. Lewis Carroll [87, p. 214] In
PGR Computing Programming Skills
PGR Computing Programming Skills Dr. I. Hawke 2008 1 Introduction The purpose of computing is to do something faster, more efficiently and more reliably than you could as a human do it. One obvious point
Microsoft Excel 2010 Pivot Tables
Microsoft Excel 2010 Pivot Tables Email: [email protected] Web Page: http://training.health.ufl.edu Microsoft Excel 2010: Pivot Tables 1.5 hours Topics include data groupings, pivot tables, pivot
Tutorial 2: Reading and Manipulating Files Jason Pienaar and Tom Miller
Tutorial 2: Reading and Manipulating Files Jason Pienaar and Tom Miller Most of you want to use R to analyze data. However, while R does have a data editor, other programs such as excel are often better
Consumption of OData Services of Open Items Analytics Dashboard using SAP Predictive Analysis
Consumption of OData Services of Open Items Analytics Dashboard using SAP Predictive Analysis (Version 1.17) For validation Document version 0.1 7/7/2014 Contents What is SAP Predictive Analytics?... 3
Chapter 1: The Cochrane Library Search Tour
Chapter : The Cochrane Library Search Tour Chapter : The Cochrane Library Search Tour This chapter will provide an overview of The Cochrane Library Search: Learn how The Cochrane Library new search feature
Step-by-Step Guide to Bi-Parental Linkage Mapping WHITE PAPER
Step-by-Step Guide to Bi-Parental Linkage Mapping WHITE PAPER JMP Genomics Step-by-Step Guide to Bi-Parental Linkage Mapping Introduction JMP Genomics offers several tools for the creation of linkage maps
Homework 4 Statistics W4240: Data Mining Columbia University Due Tuesday, October 29 in Class
Problem 1. (10 Points) James 6.1 Problem 2. (10 Points) James 6.3 Problem 3. (10 Points) James 6.5 Problem 4. (15 Points) James 6.7 Problem 5. (15 Points) James 6.10 Homework 4 Statistics W4240: Data Mining
GWAS Data Cleaning. GENEVA Coordinating Center Department of Biostatistics University of Washington. January 13, 2016.
GWAS Data Cleaning GENEVA Coordinating Center Department of Biostatistics University of Washington January 13, 2016 Contents 1 Overview 2 2 Preparing Data 3 2.1 Data formats used in GWASTools............................
Dataframes. Lecture 8. Nicholas Christian BIOST 2094 Spring 2011
Dataframes Lecture 8 Nicholas Christian BIOST 2094 Spring 2011 Outline 1. Importing and exporting data 2. Tools for preparing and cleaning datasets Sorting Duplicates First entry Merging Reshaping Missing
Introduction to Bioinformatics AS 250.265 Laboratory Assignment 6
Introduction to Bioinformatics AS 250.265 Laboratory Assignment 6 In the last lab, you learned how to perform basic multiple sequence alignments. While useful in themselves for determining conserved residues
Step by Step Guide to Importing Genetic Data into JMP Genomics
Step by Step Guide to Importing Genetic Data into JMP Genomics Page 1 Introduction Data for genetic analyses can exist in a variety of formats. Before this data can be analyzed it must imported into one
IBM SPSS Direct Marketing 23
IBM SPSS Direct Marketing 23 Note Before using this information and the product it supports, read the information in Notices on page 25. Product Information This edition applies to version 23, release
Matthew McClure October 18, 2013
Matthew McClure October 18, 2013 Microsatellite Imputation Infer MS from SNP Haplotype Genotyped ONCE Initial Study 347 cattle -ISAG bovine MS parentage panel -Illumina HDSNP -Phased using BEAGLE Brown
Data processing goes big
Test report: Integration Big Data Edition Data processing goes big Dr. Götz Güttich Integration is a powerful set of tools to access, transform, move and synchronize data. With more than 450 connectors,
IBM SPSS Direct Marketing 22
IBM SPSS Direct Marketing 22 Note Before using this information and the product it supports, read the information in Notices on page 25. Product Information This edition applies to version 22, release
REVIEWS. Computer programs for population genetics data analysis: a survival guide FOCUS ON STATISTICAL ANALYSIS
FOCUS ON STATISTICAL ANALYSIS REVIEWS Computer programs for population genetics data analysis: a survival guide Laurent Excoffier and Gerald Heckel Abstract The analysis of genetic diversity within species
COGNOS Query Studio Ad Hoc Reporting
COGNOS Query Studio Ad Hoc Reporting Copyright 2008, the California Institute of Technology. All rights reserved. This documentation contains proprietary information of the California Institute of Technology
ASSIsT: An Automatic SNP ScorIng Tool for in and out-breeding species Reference Manual
ASSIsT: An Automatic SNP ScorIng Tool for in and out-breeding species Reference Manual Di Guardo M, Micheletti D, Bianco L, Koehorst-van Putten HJJ, Longhi S, Costa F, Aranzana MJ, Velasco R, Arús P, Troggio
Tutorial on gplink. http://pngu.mgh.harvard.edu/~purcell/plink/gplink.shtml. PLINK tutorial, December 2006; Shaun Purcell, [email protected].
Tutorial on gplink http://pngu.mgh.harvard.edu/~purcell/plink/gplink.shtml Basic gplink analyses Data management Summary statistics Association analysis Population stratification IBD-based analysis gplink
Visualization of Phylogenetic Trees and Metadata
Visualization of Phylogenetic Trees and Metadata November 27, 2015 Sample to Insight CLC bio, a QIAGEN Company Silkeborgvej 2 Prismet 8000 Aarhus C Denmark Telephone: +45 70 22 32 44 www.clcbio.com [email protected]
HP Quality Center. Upgrade Preparation Guide
HP Quality Center Upgrade Preparation Guide Document Release Date: November 2008 Software Release Date: November 2008 Legal Notices Warranty The only warranties for HP products and services are set forth
Hypercosm. Studio. www.hypercosm.com
Hypercosm Studio www.hypercosm.com Hypercosm Studio Guide 3 Revision: November 2005 Copyright 2005 Hypercosm LLC All rights reserved. Hypercosm, OMAR, Hypercosm 3D Player, and Hypercosm Studio are trademarks
Exploratory Data Analysis and Plotting
Exploratory Data Analysis and Plotting The purpose of this handout is to introduce you to working with and manipulating data in R, as well as how you can begin to create figures from the ground up. 1 Importing
CS 2112 Spring 2014. 0 Instructions. Assignment 3 Data Structures and Web Filtering. 0.1 Grading. 0.2 Partners. 0.3 Restrictions
CS 2112 Spring 2014 Assignment 3 Data Structures and Web Filtering Due: March 4, 2014 11:59 PM Implementing spam blacklists and web filters requires matching candidate domain names and URLs very rapidly
Microsoft Word 2010 Mail Merge (Level 3)
IT Services Microsoft Word 2010 Mail Merge (Level 3) Contents Introduction...1 Creating a Data Set...2 Creating the Merge Document...2 The Mailings Tab...2 Modifying the List of Recipients...3 The Address
Molecular typing of VTEC: from PFGE to NGS-based phylogeny
Molecular typing of VTEC: from PFGE to NGS-based phylogeny Valeria Michelacci 10th Annual Workshop of the National Reference Laboratories for E. coli in the EU Rome, November 5 th 2015 Molecular typing
Documentation for structure software: Version 2.3
Documentation for structure software: Version 2.3 Jonathan K. Pritchard a Xiaoquan Wen a Daniel Falush b 1 2 3 a Department of Human Genetics University of Chicago b Department of Statistics University
Psychology 205: Research Methods in Psychology
Psychology 205: Research Methods in Psychology Using R to analyze the data for study 2 Department of Psychology Northwestern University Evanston, Illinois USA November, 2012 1 / 38 Outline 1 Getting ready
Importing Data into R
1 R is an open source programming language focused on statistical computing. R supports many types of files as input and the following tutorial will cover some of the most popular. Importing from text
Vector HelpDesk - Administrator s Guide
Vector HelpDesk - Administrator s Guide Vector HelpDesk - Administrator s Guide Configuring and Maintaining Vector HelpDesk version 5.6 Vector HelpDesk - Administrator s Guide Copyright Vector Networks
MATLAB DFS. Interface Library. User Guide
MATLAB DFS Interface Library User Guide DHI Water Environment Health Agern Allé 5 DK-2970 Hørsholm Denmark Tel: +45 4516 9200 Fax: +45 4516 9292 E-mail: [email protected] Web: www.dhigroup.com 2007-03-07/MATLABDFS_INTERFACELIBRARY_USERGUIDE.DOC/JGR/HKH/2007Manuals/lsm
A Tutorial in Genetic Sequence Classification Tools and Techniques
A Tutorial in Genetic Sequence Classification Tools and Techniques Jake Drew Data Mining CSE 8331 Southern Methodist University [email protected] www.jakemdrew.com Sequence Characters IUPAC nucleotide
Clone Manager. Getting Started
Clone Manager for Windows Professional Edition Volume 2 Alignment, Primer Operations Version 9.5 Getting Started Copyright 1994-2015 Scientific & Educational Software. All rights reserved. The software
Intro to Mail Merge. Contents: David Diskin for the University of the Pacific Center for Professional and Continuing Education. Word Mail Merge Wizard
Intro to Mail Merge David Diskin for the University of the Pacific Center for Professional and Continuing Education Contents: Word Mail Merge Wizard Mail Merge Possibilities Labels Form Letters Directory
Tutorial for proteome data analysis using the Perseus software platform
Tutorial for proteome data analysis using the Perseus software platform Laboratory of Mass Spectrometry, LNBio, CNPEM Tutorial version 1.0, January 2014. Note: This tutorial was written based on the information
App Building Guidelines
App Building Guidelines App Building Guidelines Table of Contents Definition of Apps... 2 Most Recent Vintage Dataset... 2 Meta Info tab... 2 Extension yxwz not yxmd... 3 Map Input... 3 Report Output...
A Demonstration of Hierarchical Clustering
Recitation Supplement: Hierarchical Clustering and Principal Component Analysis in SAS November 18, 2002 The Methods In addition to K-means clustering, SAS provides several other types of unsupervised
A QUICK OVERVIEW OF THE OMNeT++ IDE
Introduction A QUICK OVERVIEW OF THE OMNeT++ IDE The OMNeT++ 4.x Integrated Development Environment is based on the Eclipse platform, and extends it with new editors, views, wizards, and additional functionality.
Comparing Methods for Identifying Transcription Factor Target Genes
Comparing Methods for Identifying Transcription Factor Target Genes Alena van Bömmel (R 3.3.73) Matthew Huska (R 3.3.18) Max Planck Institute for Molecular Genetics Folie 1 Transcriptional Regulation TF
Package hoarder. June 30, 2015
Type Package Title Information Retrieval for Genetic Datasets Version 0.1 Date 2015-06-29 Author [aut, cre], Anu Sironen [aut] Package hoarder June 30, 2015 Maintainer Depends
Scicos is a Scilab toolbox included in the Scilab package. The Scicos editor can be opened by the scicos command
7 Getting Started 7.1 Construction of a Simple Diagram Scicos contains a graphical editor that can be used to construct block diagram models of dynamical systems. The blocks can come from various palettes
NASA Workflow Tool. User Guide. September 29, 2010
NASA Workflow Tool User Guide September 29, 2010 NASA Workflow Tool User Guide 1. Overview 2. Getting Started Preparing the Environment 3. Using the NED Client Common Terminology Workflow Configuration
Journal of Statistical Software
JSS Journal of Statistical Software October 2006, Volume 16, Code Snippet 3. http://www.jstatsoft.org/ LDheatmap: An R Function for Graphical Display of Pairwise Linkage Disequilibria between Single Nucleotide
ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)
ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology) Subject Description: This subject deals with discrete structures like set theory, mathematical
A guide to the analysis of KASP genotyping data using cluster plots
extraction sequencing genotyping extraction sequencing genotyping extraction sequencing genotyping extraction sequencing A guide to the analysis of KASP genotyping data using cluster plots Contents of
Data Storage STAT 133. Gaston Sanchez. Department of Statistics, UC Berkeley
Data Storage STAT 133 Gaston Sanchez Department of Statistics, UC Berkeley gastonsanchez.com github.com/gastonstat Course web: gastonsanchez.com/stat133 Data Storage 2 Awesome Resource Introduction to
SPSS: Getting Started. For Windows
For Windows Updated: August 2012 Table of Contents Section 1: Overview... 3 1.1 Introduction to SPSS Tutorials... 3 1.2 Introduction to SPSS... 3 1.3 Overview of SPSS for Windows... 3 Section 2: Entering
Novell ZENworks Asset Management 7.5
Novell ZENworks Asset Management 7.5 w w w. n o v e l l. c o m October 2006 USING THE WEB CONSOLE Table Of Contents Getting Started with ZENworks Asset Management Web Console... 1 How to Get Started...
HydroDesktop Overview
HydroDesktop Overview 1. Initial Objectives HydroDesktop (formerly referred to as HIS Desktop) is a new component of the HIS project intended to address the problem of how to obtain, organize and manage
standarich_v1.00: an R package to estimate population allelic richness using standardized sample size
standarich_v1.00: an R package to estimate population allelic richness using standardized sample size Author: Filipe Alberto, CCMAR, University of the Algarve, Portugal Date: 3-2006 What it does The package
Coveo Platform 7.0. Microsoft Dynamics CRM Connector Guide
Coveo Platform 7.0 Microsoft Dynamics CRM Connector Guide Notice The content in this document represents the current view of Coveo as of the date of publication. Because Coveo continually responds to changing
User Guide to the Content Analysis Tool
User Guide to the Content Analysis Tool User Guide To The Content Analysis Tool 1 Contents Introduction... 3 Setting Up a New Job... 3 The Dashboard... 7 Job Queue... 8 Completed Jobs List... 8 Job Details
Genome Explorer For Comparative Genome Analysis
Genome Explorer For Comparative Genome Analysis Jenn Conn 1, Jo L. Dicks 1 and Ian N. Roberts 2 Abstract Genome Explorer brings together the tools required to build and compare phylogenies from both sequence
RETRIEVING SEQUENCE INFORMATION. Nucleotide sequence databases. Database search. Sequence alignment and comparison
RETRIEVING SEQUENCE INFORMATION Nucleotide sequence databases Database search Sequence alignment and comparison Biological sequence databases Originally just a storage place for sequences. Currently the
Using Edit-Distance Functions to Identify Similar E-Mail Addresses Howard Schreier, U.S. Dept. of Commerce, Washington DC
Paper 073-29 Using Edit-Distance Functions to Identify Similar E-Mail Addresses Howard Schreier, U.S. Dept. of Commerce, Washington DC ABSTRACT Version 9 of SAS software has added functions which can efficiently
G563 Quantitative Paleontology. SQL databases. An introduction. Department of Geological Sciences Indiana University. (c) 2012, P.
SQL databases An introduction AMP: Apache, mysql, PHP This installations installs the Apache webserver, the PHP scripting language, and the mysql database on your computer: Apache: runs in the background
0 Introduction to Data Analysis Using an Excel Spreadsheet
Experiment 0 Introduction to Data Analysis Using an Excel Spreadsheet I. Purpose The purpose of this introductory lab is to teach you a few basic things about how to use an EXCEL 2010 spreadsheet to do
SNPbrowser Software v3.5
Product Bulletin SNP Genotyping SNPbrowser Software v3.5 A Free Software Tool for the Knowledge-Driven Selection of SNP Genotyping Assays Easily visualize SNPs integrated with a physical map, linkage disequilibrium
Optimization of sampling strata with the SamplingStrata package
Optimization of sampling strata with the SamplingStrata package Package version 1.1 Giulio Barcaroli January 12, 2016 Abstract In stratified random sampling the problem of determining the optimal size
Installing R and the psych package
Installing R and the psych package William Revelle Department of Psychology Northwestern University August 17, 2014 Contents 1 Overview of this and related documents 2 2 Install R and relevant packages
Appendix 2.1 Tabular and Graphical Methods Using Excel
Appendix 2.1 Tabular and Graphical Methods Using Excel 1 Appendix 2.1 Tabular and Graphical Methods Using Excel The instructions in this section begin by describing the entry of data into an Excel spreadsheet.
Programming Exercise 3: Multi-class Classification and Neural Networks
Programming Exercise 3: Multi-class Classification and Neural Networks Machine Learning November 4, 2011 Introduction In this exercise, you will implement one-vs-all logistic regression and neural networks
LRmix tutorial, version 4.1
LRmix tutorial, version 4.1 Hinda Haned Netherlands Forensic Institute, The Hague, The Netherlands May 2013 Contents 1 What is LRmix? 1 2 Installation 1 2.1 Install the R software...........................
MATLAB @ Work. MATLAB Source Control Using Git
MATLAB @ Work MATLAB Source Control Using Git Richard Johnson Using source control is a key practice for professional programmers. If you have ever broken a program with a lot of editing changes, you can
Innovative Techniques and Tools to Detect Data Quality Problems
Paper DM05 Innovative Techniques and Tools to Detect Data Quality Problems Hong Qi and Allan Glaser Merck & Co., Inc., Upper Gwynnedd, PA ABSTRACT High quality data are essential for accurate and meaningful
SAP Business Objects Business Intelligence platform Document Version: 4.1 Support Package 7 2015-11-24. Data Federation Administration Tool Guide
SAP Business Objects Business Intelligence platform Document Version: 4.1 Support Package 7 2015-11-24 Data Federation Administration Tool Guide Content 1 What's new in the.... 5 2 Introduction to administration
Topographic Change Detection Using CloudCompare Version 1.0
Topographic Change Detection Using CloudCompare Version 1.0 Emily Kleber, Arizona State University Edwin Nissen, Colorado School of Mines J Ramón Arrowsmith, Arizona State University Introduction CloudCompare
JMulTi/JStatCom - A Data Analysis Toolkit for End-users and Developers
JMulTi/JStatCom - A Data Analysis Toolkit for End-users and Developers Technology White Paper JStatCom Engineering, www.jstatcom.com by Markus Krätzig, June 4, 2007 Abstract JStatCom is a software framework
TIBCO Spotfire Business Author Essentials Quick Reference Guide. Table of contents:
Table of contents: Access Data for Analysis Data file types Format assumptions Data from Excel Information links Add multiple data tables Create & Interpret Visualizations Table Pie Chart Cross Table Treemap
Introduction to the data.table package in R
Introduction to the data.table package in R Revised: September 18, 2015 (A later revision may be available on the homepage) Introduction This vignette is aimed at those who are already familiar with creating
Kyubit Business Intelligence OLAP analysis - User Manual
Using OLAP analysis features of Kyubit Business Intelligence www.kyubit.com Kyubit Business Intelligence OLAP analysis - User Manual Using OLAP analysis features of Kyubit Business Intelligence 2016, All
How to Use a Data Spreadsheet: Excel
How to Use a Data Spreadsheet: Excel One does not necessarily have special statistical software to perform statistical analyses. Microsoft Office Excel can be used to run statistical procedures. Although
Tips and Tricks SAGE ACCPAC INTELLIGENCE
Tips and Tricks SAGE ACCPAC INTELLIGENCE 1 Table of Contents Auto e-mailing reports... 4 Automatically Running Macros... 7 Creating new Macros from Excel... 8 Compact Metadata Functionality... 9 Copying,
Presentation by: Ahmad Alsahaf. Research collaborator at the Hydroinformatics lab - Politecnico di Milano MSc in Automation and Control Engineering
Johann Bernoulli Institute for Mathematics and Computer Science, University of Groningen 9-October 2015 Presentation by: Ahmad Alsahaf Research collaborator at the Hydroinformatics lab - Politecnico di
Logging In From your Web browser, enter the GLOBE URL: https://bms.activemediaonline.net/bms/
About GLOBE Global Library of Brand Elements GLOBE is a digital asset and content management system. GLOBE serves as the central repository for all brand-related marketing materials. What is an asset?
Audit TM. The Security Auditing Component of. Out-of-the-Box
Audit TM The Security Auditing Component of Out-of-the-Box This guide is intended to provide a quick reference and tutorial to the principal features of Audit. Please refer to the User Manual for more
Cal Answers Analysis Training Part I. Creating Analyses in OBIEE
Cal Answers Analysis Training Part I Creating Analyses in OBIEE University of California, Berkeley March 2012 Table of Contents Table of Contents... 1 Overview... 2 Getting Around OBIEE... 2 Cal Answers
Chemotaxis and Migration Tool 2.0
Chemotaxis and Migration Tool 2.0 Visualization and Data Analysis of Chemotaxis and Migration Processes Chemotaxis and Migration Tool 2.0 is a program for analyzing chemotaxis and migration data. Quick
Getting your data into R
1 Getting your data into R How to load and export data Dr Simon R. White MRC Biostatistics Unit, Cambridge 2012 2 Part I Case study: Reading data into R and getting output from R 3 Data formats Not just
Forensic Statistics. From the ground up. 15 th International Symposium on Human Identification
Forensic Statistics 15 th International Symposium on Human Identification From the ground up UNTHSC John V. Planz, Ph.D. UNT Health Science Center at Fort Worth Why so much attention to statistics? Exclusions
Statistical Data Mining. Practical Assignment 3 Discriminant Analysis and Decision Trees
Statistical Data Mining Practical Assignment 3 Discriminant Analysis and Decision Trees In this practical we discuss linear and quadratic discriminant analysis and tree-based classification techniques.
