X'X matrix is singular.

738 views
Skip to first unread message

Sarah

unread,
Jan 5, 2012, 7:43:39 PM1/5/12
to R/qtl discussion
I am trying to do a QTL analysis in a cross of ~200 individuals with
~80 markers. They relationships between the individuals are not as
simple as parent/child, however they were sampled from discrete
populations, A B and C. Further, each population had a subset of
sampling, A1 A2 and A3 for example. I am trying to use this
designation as a covariate in my QTL mapping, however the error is
always X'X matrix is singular. No other errors appear, but this error
occurs 12-50 times. I read that this meant the model was
overdetermined, so I tried to reduce the model by using A B and C, but
I get the same result. Likewise, if I create a matrix with each a
separate column so that it is binary (instead of 1-9 since it must be
numeric, column A1 with 1's for A1's and 0's for everything else, etc
for each possible population) but the same thing happens. For
example:

cross<-as.numeric(pull.pheno(x2, "fam"))

A<-as.numeric(cross<4)

C<-as.numeric(cross>6)

B<-as.numeric(cross==4 | cross==6 | cross==5)

x2$pheno$A<-A

x2$pheno$B<-B

x2$pheno$C<-C

crossX<-cbind(A, B, C)

out.cov<-scanone(x2, pheno.col=2, addcovar=crossX)

There were 50 or more warnings (use warnings() to see the first 50)
> warnings()
Warning messages:
1: In checkcovar(cross, pheno.col, addcovar, intcovar,
perm.strata, ... :
addcovar appears to be over-specified; consider dropping columns.

2: X'X matrix is singular.

I am clearly missing something fundamental, but if anyone as any
advice as to how to solve this problem I would appreciate it.

Thank you, Sarah

Karl Broman

unread,
Jan 6, 2012, 9:58:11 PM1/6/12
to rqtl...@googlegroups.com, Sarah
The "X'X is singular" means the genotype/covariate matrix is overdetermined, but it's hard to figure out why without looking at the data. (You could send it to me privately, and I'll keep it confidential.)

karl
-----------
Karl Broman
kbr...@biostat.wisc.edu
http://www.biostat.wisc.edu/~kbroman

> --
> You received this message because you are subscribed to the Google Groups "R/qtl discussion" group.
> To post to this group, send email to rqtl...@googlegroups.com.
> To unsubscribe from this group, send email to rqtl-disc+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rqtl-disc?hl=en.
>

Karl Broman

unread,
Jan 9, 2012, 9:34:24 AM1/9/12
to R/qtl discussion
The problem appears to be caused by a series of monomorphic markers.

A plot of the LOD curves showed a huge spike at the tip of one of the
chromosomes; this is probably where those "X'X is singular" warnings
are coming from.

I used geno.table() to view the genotype counts for the markers on
that chromosome (I've anonymized the marker names and chromosome
name). See below.

karl

> geno.table(x2, chr="1")
chr missing AA AB BB not.BB not.AA P.value
mar1 1 5 360 0 0 0 0 3.026772e-235
mar2 1 3 139 184 39 0 0 9.578999e-13
mar3 1 1 142 182 40 0 0 3.862013e-13
mar4 1 5 141 182 37 0 0 8.754122e-14
mar5 1 5 140 183 37 0 0 1.513102e-13
mar6 1 5 147 174 39 0 0 6.950241e-15
mar7 1 4 148 173 40 0 0 6.799797e-15
mar8 1 2 150 174 39 0 0 1.332038e-15
mar9 1 1 172 162 30 0 0 9.716309e-26
mar10 1 1 172 161 31 0 0 1.687788e-25
mar11 1 1 363 0 1 0 0 4.051523e-236
mar12 1 1 364 0 0 0 0 7.502619e-238
mar13 1 5 360 0 0 0 0 3.026772e-235
mar14 1 1 364 0 0 0 0 7.502619e-238
mar15 1 0 365 0 0 0 0 1.674061e-238
mar16 1 0 365 0 0 0 0 1.674061e-238
mar17 1 0 365 0 0 0 0 1.674061e-238
mar18 1 0 365 0 0 0 0 1.674061e-238
mar19 1 0 365 0 0 0 0 1.674061e-238
mar20 1 1 364 0 0 0 0 7.502619e-238
mar21 1 0 365 0 0 0 0 1.674061e-238
mar22 1 1 364 0 0 0 0 7.502619e-238

Sarah

unread,
Jan 9, 2012, 5:14:21 PM1/9/12
to R/qtl discussion
Thank you!! Here is the code karl sent me to fix the problem, if that
helps anyone else.

out.cov[out.cov$chr=="1",] # problem is at the end of chr
1geno.table(x2, chr="1") # a bunch of monomorphic markers
# drop the monomorphic markersmn <- markernames(x, chr="1")mn2drop <-
mn[grep("1", mn)]x <- drop.markers(x, mn2drop)
# need to treat the family covariate as a set of 0/1 factorslev <-
levels(x$pheno$fam)X <- matrix(0, nrow=nind(x),
ncol=length(lev)-1)for(i in 2:length(lev))  X[x$pheno$fam==lev[i],i-1]
<- 1
out.cov2<-scanone(x, pheno.col=2, addcovar=X)

jay.k...@gmail.com

unread,
Nov 23, 2013, 7:10:51 PM11/23/13
to rqtl...@googlegroups.com
I'm getting the same error when I use method="ehk", however when I use the imputation method I don't get the same error. Could markers with significant segregation distortion also cause this error?

Thanks, Jay

Karl Broman

unread,
Nov 25, 2013, 11:28:39 AM11/25/13
to rqtl...@googlegroups.com
> I'm getting the same error when I use method="ehk", however when I use the imputation method I don't get the same error. Could markers with significant segregation distortion also cause this error?

The 'X'X is singular' message is a warning rather than an error. Segregation distortion could be the cause: it means the fitted regression is over-parameterized, which would happen if one of the possible genotypes at a locus were not observed.

karl
Reply all
Reply to author
Forward
0 new messages