14
$\begingroup$

I'm using "glmnet" for lasso regression in GWAS. Some variants and individuals have missing values and it seems that glmnet cannot handle missing values.

Is there any solution for this? or is there other package which can handle missing values in lasso regression?

Here are my scripts.

> library(glmnet)
> geno6<-read.table("c6sigCnt.geno")
> geno6[1:10,1:10] #genotype file (0,1,2 for minor allele counts)

   V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
1   1  1  1  1  1  1  1  1  1   0
2   NA NA 1  1  1  1  1  1  1   1
3   0  0  0  0  0  0  0  0  0   2
4   0  1  0  0  0  0  0  0  0   1
5   1  0  1  1  1  1  1  1  1   1
6   0  2  0  0  0  0  0  0  0   0
7   0  0  0  0  0  0  0  0  0   2
8   0 NA  0  0  0  0  0  0  0   0
9   1  0  1  1  1  1  1  1  1   1
10  1  1  1  1  1  1  1  1  1   0

> pheno6<-read.table("c6sigCnt.pheno")
> head(pheno6) #case-control (1,2 for affection status)

  V1
1  2
2  2
3  2
4  2
5  2

> geno61<-as.matrix(geno6) 
> pheno61<-pheno6[,1] 
> fit_lasso <- glmnet(geno61,pheno61,family="binomial",alpha=1,nlambda=100) 

**Error in lognet(x, is.sparse, ix, jx, y, weights, offset, alpha, nobs,  : 
  NA/NaN/Inf in foreign function call (arg 5)**
$\endgroup$

3 Answers 3

13
$\begingroup$

Omitting cases with NA values could lead to bias. An alternative would be to perform multiple imputations of the missing data, for example with mice, and then do lasso on each of the imputations. Lasso will probably return different sets of selected variables for the imputations, but you could examine how frequently each variable is selected, among the imputed data sets, to identify your best candidate variables.

Imputation, of course, is inapplicable if the probability of a data point being missing is related to its true value. So before doing imputation make sure at least that is unlikely to be the case, based on knowledge of the subject matter.

$\endgroup$
3
$\begingroup$

Use complete.cases and/or na.omit to identify those rows that don't have NAs.

cc <- complete.cases(geno6) & complete.cases(pheno6)
geno61 <- as.matrix(geno6[cc, ])
pheno61 <- pheno6[cc, 1]

glmnet(geno61, pheno61, ...)    
$\endgroup$
1
$\begingroup$

I know this is an old question - but I wanted to add, beyond imputation with mice, to get a more reliable list of covariates, lasso could be performed after stacking all the imputed datasets (as if it were 1 dataset) but weight the records by the the fraction of missing variables. See: Wood et. al. 2008

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.