Skip to content

Commit

Permalink
version 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre BUREAU authored and gaborcsardi committed Oct 16, 2014
1 parent 2404912 commit 8796f04
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 133 deletions.
13 changes: 6 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
Package: fat2Lpoly
Type: Package
Title: Two-locus Family-based Association Test with Polytomic Outcome
Version: 1.0.2
Date: 2014-04-02
Title: Two-locus Family-based Association Test with Polytomous Outcome
Version: 1.1.1
Date: 2014-10-16
Author: Alexandre BUREAU <alexandre.bureau@msp.ulaval.ca> and Jordie Croteau
<jordie.croteau@crulrg.ulaval.ca>
Maintainer: Alexandre BUREAU <alexandre.bureau@msp.ulaval.ca>
Depends: R (>= 2.10), kinship2, multgee
Description: Performs family-based association tests with a polytomous outcome under 2-locus and 1-locus models
defined by some design matrix.
Description: Performs family-based association tests with a polytomous outcome under 2-locus and 1-locus models defined by some design matrix.
License: GPL
LazyLoad: yes
URL: http://www.crulrg.ulaval.ca/pages_perso_chercheurs/bureau_a/
Packaged: 2014-04-02 18:25:36 UTC; alexandrebureau
Packaged: 2014-10-17 00:41:41 UTC; alexandrebureau
NeedsCompilation: no
Repository: CRAN
Date/Publication: 2014-04-02 20:46:07
Date/Publication: 2014-10-17 13:10:17
25 changes: 13 additions & 12 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
d4b5a135cf4a518b35946094ac8f72bc *DESCRIPTION
9b52386444c161cc811b7a0b4ab89b52 *NAMESPACE
443cc0cef835840085316f1a50a7fb6a *DESCRIPTION
32ca724baeb737f5e6bed3e344111d86 *NAMESPACE
3592877233d6560d023308dd0a3fd8d8 *R/alleles2sums.R
1d2bad87649bf425fa1a041928da6bda *R/calcule.poids.r
976d4c5fd03218c65931cc496164a174 *R/calcule.poids.Chen.R
77dc979b3fe15e339e943262bfb20c34 *R/calcule.poids.alphafixe.r
67e94eddd29101ea32fd2b411c3d829b *R/converti.terme.R
0752fb5f9b072e2b79b907704097026f *R/cov.score.interfunction.R
d101ce58abc1a65d1be2081ccbc5d654 *R/cov.score.poly.R
Expand All @@ -10,16 +11,16 @@ d101ce58abc1a65d1be2081ccbc5d654 *R/cov.score.poly.R
daaf5e8ca90c2471e5fd7a8ebaf110c3 *R/design.endo2disease.R
3f0295e3c3e5160a88e2196a983ef433 *R/design.full.R
c059ba713e7ff77846ca63a7a7254514 *R/design.polytomous.R
7b7685ed365f885a88a80596885bebf0 *R/fat2Lpoly.R
6cd60083b431e9a9516309ad062d2e4c *R/fat2Lpoly.withinR.R
d775dc9bb6f8c8186ae12b52377699d5 *R/fat2Lpoly.R
7a47c83bd3b96eba25435c06caa75972 *R/fat2Lpoly.withinR.R
37908df38c6a500601115baedc7b90cd *R/get.scores.pvalues.R
f0cec50fe70bfe2165f3d6e407b45698 *R/ibd.terms.R
5fb64df61e924d1d65cf7bb34d7c8693 *R/ibd.terms.w.r
490de2563d13e3c5a434b6b06561bdd8 *R/produits.paires.R
94ae3b0fbfa194052069c8631639efb0 *R/read.merlin.files.R
e5f1e13fd76701a3b2f1fdeae1815546 *R/score.poly.R
1c7d0fba4236e03ebcb36ff1f0e7944d *R/score.poly.w.r
6e42ce6c59252441332300a3039accba *R/scores.covs.R
39d98afae74499bfeb983c8426924cf4 *R/scores.covs.R
7e9e225b6f8ce9502c18dbbcb7e034b1 *data/fat2Lpoly.allSNPs.rda
2f74f4750902b07f284d4597868c6fb7 *data/ped.x.all.rda
f94acb3141c835660962f00d10d6c446 *inst/extdata/loc1.dat
Expand All @@ -32,13 +33,13 @@ c4980b56ecadd8761bc0bb225ba7a53b *inst/extdata/loc2.ibd
e0809510af61b6e71ce94a53f2b8f950 *inst/extdata/loc2.ped
2cbec943a544e46a5c82e33bf6a642cc *man/design.1locus.Rd
4fcd74f42b5576708a1d2ae5cab92e7d *man/design.dichotomous.Rd
0c267d525689f9a8461f6d5d505db427 *man/design.endo2disease.Rd
d42ea40ebecaead89a54451f8aef4d8a *man/design.full.Rd
7586671f01979b130cb4ac70059af627 *man/fat2Lpoly-internal.Rd
a55393e0ed486a0dae623914a508a948 *man/design.endo2disease.Rd
ad364d529b6848a450b3a66f8745db7f *man/design.full.Rd
9a3c501647b366e2abab8da19223eb66 *man/fat2Lpoly-internal.Rd
6c473cca57c3db5e5c6e1ccc2a02f26c *man/fat2Lpoly-package.Rd
31b53cd4ae76d41878593b56f118107f *man/fat2Lpoly.Rd
6ec2c1a056a1787acc7ee1effb9c41ae *man/fat2Lpoly.Rd
36a9184e890e2417fcbba6ea906f9b7f *man/fat2Lpoly.allSNPs.Rd
68d34011d81783f5cae1a07a1a3a470d *man/fat2Lpoly.withinR.Rd
97737caa04fc260e6de829bebe256824 *man/fat2Lpoly.withinR.Rd
6d4e6d2b961025ab859113cbfee882b9 *man/get.scores.pvalues.Rd
62a125af9f639621bad4cf2980e4f202 *man/ped.x.all.Rd
0feca94afbe1108dd496b2571d342b3c *man/read.merlin.files.Rd
30473cb92a6f2e43bc6bdf877110ca70 *man/read.merlin.files.Rd
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import(multgee,kinship2)
export(design.1locus,design.dichotomous,design.endo2disease,design.full,fat2Lpoly,fat2Lpoly.withinR,get.scores.pvalues,read.merlin.files)
export(design.1locus,design.dichotomous,design.endo2disease,design.full,fat2Lpoly,fat2Lpoly.withinR,get.scores.pvalues,read.merlin.files,calcule.poids.Chen,calcule.poids.alphafixe)
36 changes: 36 additions & 0 deletions R/calcule.poids.Chen.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
calcule.poids.Chen = function(xl,y,ind.par,rep.par,alpha,lc,klc=1)
# Fonction pour calculer le poids de chaque paire de sujet pour les tests du score conditionnels à un locus
# d'après l'équation 7 de Bureau et al. (2014) inspiré de l'équation 2 de Chen et al. (2009)
###################### Définition des arguments #####################################################################################
# xl : matrice de design pour une famille pour le calcul des covariances
# ind.par : donne les indices des locus pour la catégorie à laquelle chaque terme appartient
# lc : locus sur lequel on conditionne le test du score
# alpha.vec : vecteur de log rapports de cote entre phénotype et compte d'allèle au locus précisé par lc
#####################################################################################################################################
{
ni = dim(xl)[1]
w = array(0,c(ni,ni,dim(xl)[3]))
kk = 1
# Ajout d'un coefficient = 0 pour la catégorie de référence
alpha = c(alpha,0)
# print(y)
# print(alpha)
alpha.y = alpha[y]
if (klc > 1)
{
for (k in 1:(klc-1))
{
kk = kk + rep.par[k]
}
}
# Obtenir l'élément qui contient l'indice du locus lc dans ind.par
# Ce locus doit être inclus dans au moins une fonction logistique
ilc = ind.par[[kk]][lc]
plc = outer(xl[,ilc,klc],xl[,ilc,klc],"-")*outer(alpha.y,alpha.y,"-")
wk = 8/ni * exp(plc)/(1+exp(plc))^3
# On copie les mêmes poids pour toutes les catégories de réponse
for (k in 1:dim(xl)[3])
w[,,k] = wk
w
}

6 changes: 3 additions & 3 deletions R/calcule.poids.r → R/calcule.poids.alphafixe.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
calcule.poids = function(xl,y,ind.par,rep.par,alpha,lc,klc=1)
calcule.poids.alphafixe = function(xl,y,ind.par,rep.par,alpha,lc,klc=1)
# Fonction pour calculer le poids de chaque paire de sujet pour les tests du score conditionnels à un locus
# d'après l'équation 2 de Chen et al. (2009)
# d'après l'équation 6 de Bureau et al. (2014)
###################### Définition des arguments #####################################################################################
# xl : matrice de design pour une famille pour le calcul des covariances
# ind.par : donne les indices des locus pour la catégorie à laquelle chaque terme appartient
Expand All @@ -27,7 +27,7 @@ calcule.poids = function(xl,y,ind.par,rep.par,alpha,lc,klc=1)
# Ce locus doit être inclus dans au moins une fonction logistique
ilc = ind.par[[kk]][lc]
plc = outer(xl[,ilc,klc],xl[,ilc,klc],"-")*outer(alpha.y,alpha.y,"-")
wk = 8/ni * exp(plc)/(1+exp(plc))^3
wk = 2/(ni*(1+exp(plc)))
# On copie les mêmes poids pour toutes les catégories de réponse
for (k in 1:dim(xl)[3])
w[,,k] = wk
Expand Down
6 changes: 2 additions & 4 deletions R/fat2Lpoly.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# 4 avril 2013: valeur par défaut des arguments ibdfilenames et ibd.loci fixée à NULL.
# Si un de ces 2 arguments prend la valeur NULL, alors la fonction fat2Lpoly.withinR fait le calcul des coefficients de kinship (a priori) au lieu des IBD.

fat2Lpoly=function(pedfilenames,datfilenames,freq.data,ibdfilenames=NULL,snp.names.mat,ibd.loci=NULL,joint.tests=NULL,contingency.file=FALSE,design.constraint,par.constrained,constraints,lc=NULL,alpha=NULL)
fat2Lpoly=function(pedfilenames,datfilenames,freq.data,ibdfilenames=NULL,snp.names.mat,ibd.loci=NULL,joint.tests=NULL,contingency.file=FALSE,design.constraint,par.constrained,constraints,pairweights=calcule.poids.alphafixe,lc=NULL,alpha=NULL)
{
###################### Définition des arguments #####################################################################################
# pedfilenames : vecteur des noms de fichiers ped (un fichier par locus). Les sujets inclus peuvent être un sous-ensemble de ceux
Expand Down Expand Up @@ -49,12 +49,10 @@ if(is.null(ibd.loci)|is.null(ibdfilenames)) cat("\n","Warning: Either the argume
ped.x.all=read.merlin.files(pedfilenames,datfilenames,freq.data,ibdfilenames)

# exécution des tests pour les SNPs ou paires de SNPs
tests.loop=fat2Lpoly.withinR(ped.x.all,snp.names.mat,ibd.loci,contingency.file,design.constraint,par.constrained,constraints,lc,alpha)
tests.loop=fat2Lpoly.withinR(ped.x.all,snp.names.mat,ibd.loci,contingency.file,design.constraint,par.constrained,constraints,pairweights=pairweights,lc=lc,alpha=alpha)

# calcul des scores et valeur-p des différents tests pour tous les SNPs testés
p.values.scores=get.scores.pvalues(tests.loop,joint.tests)

cat("It was a pleasure working for you !\n")

return(list(scores.covs.all.SNPs=tests.loop$scores.covs.all.SNPs,p.values.scores=p.values.scores,MA.table=ped.x.all$MA.table,y1=ped.x.all$y1.name,y2=ped.x.all$y2.name))
}
4 changes: 2 additions & 2 deletions R/fat2Lpoly.withinR.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# 4 avril 2013: ajout du calcul des coefficients de kinship (a priori) au lieu des IBD, dans le cas où cette dernière information n'est pas fournie.

fat2Lpoly.withinR=function(ped.x.all,snp.names.mat,ibd.loci=NULL,contingency.file=FALSE,design.constraint,par.constrained,constraints,lc=NULL,alpha=NULL)
fat2Lpoly.withinR=function(ped.x.all,snp.names.mat,ibd.loci=NULL,contingency.file=FALSE,design.constraint,par.constrained,constraints,pairweights=calcule.poids.alphafixe,lc=NULL,alpha=NULL)
{
ped=ped.x.all$ped
x.all=ped.x.all$x.all
Expand Down Expand Up @@ -268,7 +268,7 @@ ind.par = tmp2$ind.par
ind.catl = rep(1:(n.levels-1),lapply(unique(ind.par),length))
ind.cat = rep(1:(n.levels-1),rep.par)

res[[s]]=scores.covs(subject.ids,fam.id,y,n.levels,ibd.dat,n.loc,xp,xp.loc,xl,il,xibd.loc,ind.par,rep.par,ind.catl,ind.cat,contingency.file,descrip.file,lc=lc,alpha.vec=alpha)
res[[s]]=scores.covs(subject.ids,fam.id,y,n.levels,ibd.dat,n.loc,xp,xp.loc,xl,il,xibd.loc,ind.par,rep.par,ind.catl,ind.cat,contingency.file,descrip.file,calculpoids=pairweights,lc=lc,alpha.vec=alpha)
}

list(scores.covs.all.SNPs=res,snp.names.mat=snp.names.mat)
Expand Down
4 changes: 2 additions & 2 deletions R/scores.covs.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

# modifié par Jordie le 22 août pour enlever des arguments superflus.

scores.covs=function(subject.ids,fam.id,y,n.levels,ibd.dat,n.loc,xp,xp.loc,xl,il,xibd.loc,ind.par,rep.par,ind.catl,ind.cat,contingency.file,descrip.file,lc=NULL,alpha.vec=rep(0,n.levels-1))
scores.covs=function(subject.ids,fam.id,y,n.levels,ibd.dat,n.loc,xp,xp.loc,xl,il,xibd.loc,ind.par,rep.par,ind.catl,ind.cat,contingency.file,descrip.file,calculpoids=calcule.poids.alphafixe,lc=NULL,alpha.vec=rep(0,n.levels-1))
{
###################### Définition des arguments #####################################################################################
# subject.ids: vecteur des id de chaque sujet
Expand Down Expand Up @@ -172,7 +172,7 @@ for(i in 1:nb.fam)
if (length(alpha.vec)!=dim(xl)[3]) stop("The number of alpha coefficients for the computation of weights does not equal the 3rd dimension of xl (",dim(xl)[3],")")
# Calcul des poids pour la famille
# On suppose que la matrice de design pour le niveau 1 contient le locus lc
w = calcule.poids(array(xl[indices.y,,],c(ni,dim(xl)[2],dim(xl)[3])),y[indices.y],ind.par,rep.par,alpha.vec,lc,klc=1)
w = calculpoids(array(xl[indices.y,,],c(ni,dim(xl)[2],dim(xl)[3])),y[indices.y],ind.par,rep.par,alpha.vec,lc,klc=1)
ibd.terms.mat[i,,,]=ibd.terms.w(y[indices.y],subject.ids[indices.y],l1[indices.ibd],l2[indices.ibd],array(pim[indices.ibd,],c(sum(indices.ibd),ncol(pim))),w)
scores.mat[i,]=score.poly.w(array(xp[indices.y,,],c(ni,dim(xp)[2],dim(xp)[3])),y[indices.y],w)
}
Expand Down
5 changes: 3 additions & 2 deletions man/design.endo2disease.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Setting-up design matrices for the endophenotype-to-disease model.
}
\description{
This function sets up two lists of three design matrices, one for each linear predictor of the logit of the three outcome levels defined by the combination of two dichotomous traits against the reference level (0,0) under the endophenotype-to-disease model of Bureau et al. The design matrices in the first list contain all terms forming the model, and those in the second list contain all main effect and product terms appearing in the model.
This function sets up two lists of three design matrices, one for each linear predictor of the logit of the three outcome levels defined by the combination of two dichotomous traits against the reference level (0,0) under the endophenotype-to-disease model of Bureau et al (2014). The design matrices in the first list contain all terms forming the model, and those in the second list contain all main effect and product terms appearing in the model.
}
\usage{
design.endo2disease(x, par.constrained, constraints)
Expand Down Expand Up @@ -40,7 +40,8 @@ The design matrices for the above model are constructed by this function.
\item{x.l }{List of 3 design matrices containing the terms \eqn{X_{1}}{X[1]}, \eqn{X_{2}}{X[2]} and \eqn{X_{1} X_{2}}{X[1] X[2]} appearing in the endophenotype-to-disease model.}
\item{x.loc.l }{list of character strings containing the indices of the variables in \code{x} involved in each term in the list \code{x.l}}
}

\references{
Bureau A., Croteau J., Chagnon, Y.C., Roy, M.-A. and Maziade, M. Extension of the Generalized Disequilibrium Test to polytomous phenotypes and two locus models. Frontiers in Genetics, 5: Article 258. }
\author{
Alexandre Bureau <alexandre.bureau@msp.ulaval.ca>
}
Expand Down
2 changes: 2 additions & 0 deletions man/design.full.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ The design matrices for the above model are constructed by this function.
\item{x.l }{identical to \code{x.e}}
\item{x.loc.l }{identical to \code{x.l}}
}
\references{
Bureau A., Croteau J., Chagnon, Y.C., Roy, M.-A. and Maziade, M. Extension of the Generalized Disequilibrium Test to polytomous phenotypes and two locus models. Frontiers in Genetics, 5: Article 258. }
\author{
Alexandre Bureau <alexandre.bureau@msp.ulaval.ca>
}
Expand Down
3 changes: 3 additions & 0 deletions man/fat2Lpoly-internal.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
\alias{scores.covs}
\alias{design.polytomous}
\alias{ibd.terms}
\alias{ibd.terms.w}
\alias{score.poly}
\alias{produits.paires}
\alias{converti.terme}
\alias{calcule.poids.Chen}
\alias{calcule.poids.alphafixe}
%% </LIST>

\title{Internal fat2Lpoly Functions}
Expand Down
15 changes: 10 additions & 5 deletions man/fat2Lpoly.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
Two-locus Family-based Association Test with Polytomous Outcome
}
\description{
For a list of SNP pairs, performs family-based association tests with a polytomous outcome under 2-locus and 1-locus models as described in [1]. Various functions \code{design.constraint} to create design matrices are provided in this package. The tested SNP is the second one of each pair, while the first one is considered the conditioning SNP. The function may also perform one-locus tests if individual SNPs are specified instead of SNP pairs.
Performs family-based association tests with a polytomous outcome under 2-locus and 1-locus models as described in reference [1]. Various functions \code{design.constraint} to create design matrices are provided in this package. When SNP pairs are specified, the tested SNP is the second one of each pair, while the first one is considered the conditioning SNP. The function may also perform one-locus tests if individual SNPs are specified instead of SNP pairs.
}
\usage{
fat2Lpoly(pedfilenames, datfilenames, freq.data, ibdfilenames = NULL,
snp.names.mat, ibd.loci = NULL, joint.tests = NULL,
contingency.file = FALSE, design.constraint,
par.constrained, constraints, lc = NULL, alpha = NULL)
par.constrained, constraints, pairweights=calcule.poids.alphafixe,
lc = NULL, alpha = NULL)
}
\arguments{
\item{pedfilenames}{
Expand Down Expand Up @@ -50,6 +51,9 @@ function building the design matrices WITHIN each category, for constraints spec
\item{constraints}{
Optional matrix of dimensions (\code{n.levels}-1) x nc specifying the nc linear constraints BETWEEN the logistic models for different levels of the response variable, involving the parameters specified in \code{par.constrained}, one constraint per column. A 0 means that the corresponding parameter is not involved in the constraint.
This functionality is not yet implemented.
}
\item{pairweights}{
function calculating the weights of the observation pair differences when conditioning on the first SNP in the test of the second SNP in a SNP pair. Default is calcule.poids.alphafixe, implementing the weighting function of equation (6) of reference [1]. An alternative is calcule.poids.Chen, implementing the weighting function of equation (7) of reference [1].
}
\item{lc}{
numerical identifier of the SNP (locus) on which to condition when testing model terms. Defaults to NULL, or no conditioning.
Expand All @@ -65,6 +69,8 @@ All fields in the pedigree files must be numeric. No letters allowed, even for

Families whose genotyped subjects are all in the same category (phenotype combination), are uninformative and will be excluded.

Conditioning on the first SNP in a SNP pair is implemented by weighting the observation pair differences according to a model of the polytomous outcome as a function of the first SNP genotypes. The function converting the coefficients of this regression model into weights is specified by the argument \code{pairweights}. The default function \code{calcule.poids.alphafixe} provided satisfactory power in simulations described in reference [1].

File "descriptive_statistics'date_and_time'.txt" (will be created if contingency.file='TRUE'): For each tested SNP, it shows contingency tables of the subjects in the 2 or 4 different categories, first for all families together and then for each individual family.

If one or both of the arguments ibd.loci and ibdfilenames are left unspecified (or NULL, their default), then we use the kinship coefficients multiplied by two, instead of the expectation of the IBD probabilities, in the computation of the score statistics. The kinship coefficients are obtained using the function \code{\link{kinship}} from the package \code{kinship2}.
Expand All @@ -88,8 +94,7 @@ affection name extracted from second line of the data file(s)
}
}
\references{
1. Bureau A., Croteau J., Chagnon, Y.C., Roy, M.-A. and Maziade, M. Extension of the Generalized Disequilibrium Test to polytomous phenotypes and two locus models.

1. Bureau A., Croteau J., Chagnon, Y.C., Roy, M.-A. and Maziade, M. Extension of the Generalized Disequilibrium Test to polytomous phenotypes and two locus models. Frontiers in Genetics, 5: Article 258.
2. http://www.sph.umich.edu/csg/abecasis/Merlin/tour/input_files.html
}
\author{
Expand Down Expand Up @@ -120,7 +125,7 @@ test=fat2Lpoly(pedfilenames=paste(path.data,c("loc1.ped","loc2.ped"),sep=""),
design.constraint=design.endo2disease,lc=1)

test$p.values.scores
}
}
###############################################################################

################### design.endo2disease without conditioning ##################
Expand Down

0 comments on commit 8796f04

Please sign in to comment.