Skip to content

Commit

Permalink
Merge pull request #925 from allyhawkins/allyhawkins/threads-cluster-…
Browse files Browse the repository at this point in the history
…stability

Specify number of threads used when calculating cluster stability
  • Loading branch information
allyhawkins authored Dec 3, 2024
2 parents cdb9cef + b78801e commit 0e826e7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion analyses/cell-type-ewings/evaluate-clusters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ for sample_id in $sample_ids; do
output_file = '${library_id}_cluster-summary-report.html', \
params = list(library_id = '$library_id', \
sce_file = '$sce_file', \
cluster_results_file = '$cluster_results'), \
cluster_results_file = '$cluster_results',
threads = $threads), \
envir = new.env()) \
"
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ get_cluster_stats <- function(sce,
# get cluster stability for each unique combination of params used for clustering
# must have `cluster_params` column
get_cluster_stability <- function(sce,
all_cluster_results) {
all_cluster_results,
threads = 1) {
pcs <- reducedDim(sce, "PCA")

# split clustering results by param used
Expand All @@ -87,7 +88,8 @@ get_cluster_stability <- function(sce,
algorithm = unique(df$algorithm),
nn = unique(df$nn),
resolution = unique(df$resolution),
objective_function = objective_function)
objective_function = objective_function,
threads = threads)

}) |>
dplyr::bind_rows(.id = "cluster_params")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ params:
library_id: "SCPCL000822"
sce_file: "../../../../data/current/SCPCP000015/SCPCS000490/SCPCL000822_processed.rds"
cluster_results_file: "../../results/clustering/SCPCS000490/SCPCL000822_cluster-results.tsv"
threads: 1
---

This notebook summarizes clustering metrics for `r params$library_id`.
Expand Down Expand Up @@ -169,7 +170,7 @@ all_stats |>
```{r, warning=FALSE, message=FALSE}
# calculate cluster stability
stability_stats <- split_umap_df |>
purrr::map(\(df){ get_cluster_stability(sce, df)})
purrr::map(\(df){ get_cluster_stability(sce, df, params$threads)})
```


Expand Down

0 comments on commit 0e826e7

Please sign in to comment.