How to perform lasso on a wide matrix? I have a Matrix with almost 1000 samples (rows) and for each of this I have gene expression data for more than 16000 genes. I was trying to perform lasso with the glmnet algorithm but I always get the "cannot allocate vector of size ...Mb" error when I use the function model.matrix to prepare the data. I already tried to increase memory limit, cleaning the environment, deleting useless data and so on. I'm asking if there is another method instead of model.matrix and if this problem is due to RAM problems or something else. Thank you!

The error message indeed suggests that you don't have enough RAM.
However, this answer suggests that glmnet should be able to handle this amount of data, and suggests h2o for situations where glmnet does give up.
Anyway, if, even after reading this linked answer, you can't make glmnet do the job, maybe speedglm will help.
And yet another powerful library being able to handle large amounts of data would be the python module scanpy.
