Skip to content

Commit

Permalink
tweak process_seurat [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
bschilder committed Apr 8, 2024
1 parent 5ea8b7e commit 3ba75d8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions R/process_seurat.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
process_seurat <- function(obj = NULL,
meta.data = NULL,
nfeatures = 2000,
reduction="pca",
dims = seq(100),
add_specificity = FALSE,
default_assay = NULL,
Expand Down Expand Up @@ -95,24 +96,27 @@ process_seurat <- function(obj = NULL,
}

#### Dimensionality reduction ####
obj2 <- Seurat::RunPCA(obj2,
npcs = max(dims))
if(reduction=="pca"){
obj2 <- Seurat::RunPCA(obj2,
npcs = max(dims))
}
obj2 <- Seurat::FindNeighbors(obj2,
reduction = reduction,
dims = dims)
obj2 <- Seurat::RunUMAP(obj2,
reduction=reduction,
dims = dims,
n.components = n.components,
return.model = TRUE)
#### Clustering ####
if(!isFALSE(cluster_reduction)){
## Recompute neighbours graph based on UMAP
## FindNeighbors doesn't take reduction or dims as args
obj2 <- Seurat::FindNeighbors(obj2,
reduction = cluster_reduction,
dims = seq_len(n.components))
obj2 <- Seurat::FindClusters(obj2,
reduction = cluster_reduction)
} else {
obj2 <- Seurat::FindClusters(obj2)
}
obj2 <- Seurat::FindClusters(obj2)
#### Return ####
return(obj2)
}

0 comments on commit 3ba75d8

Please sign in to comment.