kbroman / qtl

R/qtl: A QTL mapping environment
https://rqtl.org
GNU General Public License v3.0
77 stars 45 forks source link

addint bug when X chr QTL and missing phenotypes #101

Closed kbroman closed 1 year ago

kbroman commented 1 year ago

Problem reported on the R/qtl discussion group where addint() halts with an error if there's a QTL on the X chromosome and there are missing phenotypes.

qtl<- makeqtl(cross, chr=c(6,11,19,'X',8,5,1,3), pos=c(19.2, 474,68.7,344,268,538,1123,438))
formula_col_23_1 <- y~q1:q2+q1:q3+q1:q4+q1:q5+q1:q6+q1:q7+q1:q8
out.fq_col_23_1 <- fitqtl(cross, pheno.col = 23, qtl, formula=formula_col_23_1)
summary(out.fq_col_23_1)

addint(cross, pheno.col = 23, qtl = qtl, formula=formula_col_23_1, covar = Covariate)

Error in model.frame.default(formula = pheno ~ Xadjustment$sexpgmcovar,  :
  variable lengths differ (found for 'Xadjustment$sexpgmcovar')
In addition: Warning message:
In addint(cross, pheno.col = 23, qtl = qtl, formula = formula_col_23_1,  :
  Dropping 31 individuals with missing phenotypes.

I was able to reproduce the problem with the fake.f2 dataset:

data(fake.f2)
fake.f2 <- calc.genoprob(fake.f2, step=2.5)
out <- scanone(fake.f2, method="hk")
qtl <- summary(out, 3)
qtl <- makeqtl(fake.f2, chr=qtl$chr, pos=qtl$pos, what="prob")

fake.f2$pheno[c(5,15),1] <- NA

addint(fake.f2, qtl=qtl, method="hk")

It goes away if you pre-subset the cross and qtl object:

fake.f2_subset <- subset(fake.f2, ind = !is.na(fake.f2$pheno[,1]))

qtl <- makeqtl(fake.f2_subset, chr=qtl$chr, pos=qtl$pos, what="prob")
kbroman commented 1 year ago

Should note that the problem doesn't occur without the X chromosome QTL.

addint(fake.f2, qtl=qtl, method="hk", formula=y~q1+q2)
kbroman commented 1 year ago

This is also a problem for addcovarint().