Browse code

Fix directory not found issue in exportSCEtoAnndata.R

rz2333 authored on 21/04/2020 15:28:15
Showing 1 changed files

... ...
@@ -51,14 +51,15 @@ exportSCEtoAnnData <- function(sce,
51 51
   if (!is(SummarizedExperiment::assay(sce), 'dgCMatrix')) {
52 52
     SummarizedExperiment::assay(sce) <- .convertToMatrix(SummarizedExperiment::assay(sce))
53 53
   }
54
-
54
+  
55
+  dir.create(outputDir, showWarnings = FALSE, recursive = TRUE)
55 56
   annData <- .sce2adata(sce,useAssay)
56 57
   fileName <- paste0(sample,".h5ad")
57 58
   filePath <- file.path(outputDir,fileName)
58
-  
59
+
59 60
   if (file.exists(filePath) && !isTRUE(overwrite)) {
60 61
     stop(paste0(path, " already exists. Change 'outputDir' or set 'overwrite' to TRUE."))
61
-    }
62
+  }
62 63
 
63 64
   annData$write_h5ad(filePath,
64 65
                      compression = compression,