'error when reading multiple samples in Seurat

I'm trying to read multiple samples using Read10X function from the Seurat package.

seurat_list <- lapply(samples, function(sample){
  • seurat_data <- Read10X(paste0(gsub("MNX.*", "", in.list), sample, '/filtered_feature_bc_matrix'))
    
  • return(seurat_data)
    
  • })

I'm getting this error:

Error in Read10X(paste0(gsub("MNX.*", "", in.list), sample, "/filtered_feature_bc_matrix")) : 

Directory provided does not exist

But when It works when I use this :

lapply(paste0(gsub("MNX.*", "", in.list), samples, '/filtered_feature_bc_matrix'),Read10X)

I don't understand what's the issue.

Thanks a lot.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source