Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For loops don't seem to work with soupX #145

Open
Kenneth-new-user opened this issue Nov 14, 2023 · 0 comments
Open

For loops don't seem to work with soupX #145

Kenneth-new-user opened this issue Nov 14, 2023 · 0 comments

Comments

@Kenneth-new-user
Copy link

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)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant