15
$\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

15
$\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.

Multiple imputation can be reliable if data are "missing at random" (MAR) in a technical sense: that is, the probability of data being missing varies among cases only based on information present in the observed data. Before doing imputation consider whether that's likely to be the case, based on knowledge of the subject matter. If the probability of data being missing varies among cases for unknown reasons, data are "missing not at random" (MNAR) and further precautions are necessary. See Section 1.2 of Flexible Imputation of Missing Data.

$\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
  • 2
    $\begingroup$ This is not an answer because you are addressing a separate, programming-focused question - how to identify rows with missing data. $\endgroup$
    – AdamO
    Commented Jul 12 at 15:32
2
$\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 you have read our privacy policy.

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