I have multiple matrix files that I would like to run through with SoupX but the following code stops after the first iteration.
Ideally I would want to read through the files in data/Matrices and then save the outputs in data/Matrices/soupX.
library(Seurat)
library(SoupX)
Files = c("file1", "file2", "file3", "file4")
for(f in Files) {
data.dir = paste("~/data/Matrices//", f, "/filtered_feature_bc_matrix",sep="")
InPath = paste("~/data/Matrices/", f, sep="")
OutFile = paste("~/data/Matrices/soupx/", f, sep="")
data <- Read10X(data.dir = data.dir)
data = CreateSeuratObject(counts = data)
data <- NormalizeData(data)
data <- FindVariableFeatures(data, selection.method = "vst", nfeatures = 2000)
all.genes <- rownames(data)
data <- ScaleData(data, features = all.genes)
data <- RunPCA(data, features = VariableFeatures(object = data))
data <- FindNeighbors(data, dims = 1:10)
data <- FindClusters(data, resolution = 0.5)
sc = load10X(InPath)
sc = setClusters(sc, setNames(data$seurat_clusters, colnames(data)))
sc = autoEstCont(sc)
out = adjustCounts(sc, roundToInt=TRUE)
DropletUtils:::write10xCounts(OutFile, out)
}
I have multiple matrix files that I would like to run through with SoupX but the following code stops after the first iteration. Ideally I would want to read through the files in data/Matrices and then save the outputs in data/Matrices/soupX.